1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/views/location_bar/location_bar_container.h"
7 #include "chrome/browser/ui/omnibox/omnibox_view.h"
8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
9 #include "ui/gfx/color_utils.h"
10 #include "ui/views/controls/native/native_view_host.h"
11 #include "ui/views/layout/fill_layout.h"
12 #include "ui/views/widget/widget.h"
14 void LocationBarContainer::SetInToolbar(bool in_toolbar
) {
15 if (animator_
.IsAnimating())
19 void LocationBarContainer::OnFocus() {
20 // Reenable when convert back to widget.
22 // TODO(sky): verify if this is necessary.
23 GetWidget()->NotifyAccessibilityEvent(
24 this, ui::AccessibilityTypes::EVENT_FOCUS, false);
26 location_bar_view_
->GetLocationEntry()->SetFocus();
29 void LocationBarContainer::PlatformInit() {
31 // TODO: this is right way to go about this on windows, but it leads to ugly
32 // coordinate conversions. Need to straighten those out before reeabling.
34 views::Widget* widget = new views::Widget();
35 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL);
36 params.can_activate = false;
37 params.parent_widget = GetWidget();
40 native_view_host_ = new views::NativeViewHost;
41 AddChildView(native_view_host_);
42 native_view_host_->Attach(widget->GetNativeView());
43 widget->SetContentsView(new views::View);
44 view_parent_ = widget->GetContentsView();
45 view_parent_->SetLayoutManager(new views::FillLayout);
47 widget->ShowInactive(); // Do not allow this widget to gain focus.
51 void LocationBarContainer::StackAtTop() {
52 // TODO: reenable when PlatformInit() code is reenabled.
54 view_parent_->GetWidget()->StackAtTop();