Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/dropdown_bar_host.h" | 5 #include "chrome/browser/ui/views/dropdown_bar_host.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "chrome/browser/ui/view_ids.h" | 9 #include "chrome/browser/ui/view_ids.h" |
| 10 #include "chrome/browser/ui/views/dropdown_bar_host_delegate.h" | 10 #include "chrome/browser/ui/views/dropdown_bar_host_delegate.h" |
| 11 #include "chrome/browser/ui/views/dropdown_bar_view.h" | 11 #include "chrome/browser/ui/views/dropdown_bar_view.h" |
| 12 #include "chrome/browser/ui/views/frame/browser_view.h" | 12 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 13 #include "ui/events/keycodes/keyboard_codes.h" | 13 #include "ui/events/keycodes/keyboard_codes.h" |
| 14 #include "ui/gfx/animation/slide_animation.h" | 14 #include "ui/gfx/animation/slide_animation.h" |
| 15 #include "ui/gfx/scrollbar_size.h" | 15 #include "ui/gfx/scrollbar_size.h" |
| 16 #include "ui/views/focus/external_focus_tracker.h" | 16 #include "ui/views/focus/external_focus_tracker.h" |
| 17 #include "ui/views/focus/view_storage.h" | 17 #include "ui/views/focus/view_storage.h" |
| 18 #include "ui/views/widget/widget.h" | 18 #include "ui/views/widget/widget.h" |
| 19 | 19 |
| 20 namespace { | |
| 21 | |
| 22 // TODO(estade): move this to its own file and reuse for | |
|
Evan Stade
2016/01/27 00:44:18
I would complete this TODO before landing, but onl
| |
| 23 // OmniboxPopupContentsView::popup_. | |
| 24 class ThemeCopyingWidget : public views::Widget { | |
| 25 public: | |
| 26 explicit ThemeCopyingWidget(views::Widget* role_model) | |
| 27 : role_model_(role_model) {} | |
| 28 ~ThemeCopyingWidget() override {} | |
| 29 | |
| 30 const ui::NativeTheme* GetNativeTheme() const override { | |
| 31 return role_model_->GetNativeTheme(); | |
| 32 } | |
| 33 | |
| 34 private: | |
| 35 // The widget we'll copy our theme from. | |
| 36 views::Widget* role_model_; | |
| 37 | |
| 38 DISALLOW_COPY_AND_ASSIGN(ThemeCopyingWidget); | |
| 39 }; | |
| 40 | |
| 41 } // namespace | |
| 42 | |
| 20 // static | 43 // static |
| 21 bool DropdownBarHost::disable_animations_during_testing_ = false; | 44 bool DropdownBarHost::disable_animations_during_testing_ = false; |
| 22 | 45 |
| 23 //////////////////////////////////////////////////////////////////////////////// | 46 //////////////////////////////////////////////////////////////////////////////// |
| 24 // DropdownBarHost, public: | 47 // DropdownBarHost, public: |
| 25 | 48 |
| 26 DropdownBarHost::DropdownBarHost(BrowserView* browser_view) | 49 DropdownBarHost::DropdownBarHost(BrowserView* browser_view) |
| 27 : browser_view_(browser_view), | 50 : browser_view_(browser_view), |
| 28 clip_view_(new views::View()), | 51 clip_view_(new views::View()), |
| 29 view_(NULL), | 52 view_(NULL), |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 41 void DropdownBarHost::Init(views::View* host_view, | 64 void DropdownBarHost::Init(views::View* host_view, |
| 42 views::View* view, | 65 views::View* view, |
| 43 DropdownBarHostDelegate* delegate) { | 66 DropdownBarHostDelegate* delegate) { |
| 44 DCHECK(view); | 67 DCHECK(view); |
| 45 DCHECK(delegate); | 68 DCHECK(delegate); |
| 46 | 69 |
| 47 view_ = view; | 70 view_ = view; |
| 48 delegate_ = delegate; | 71 delegate_ = delegate; |
| 49 | 72 |
| 50 // Initialize the host. | 73 // Initialize the host. |
| 51 host_.reset(new views::Widget); | 74 host_.reset(new ThemeCopyingWidget(browser_view_->GetWidget())); |
| 52 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL); | 75 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL); |
| 53 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 76 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 54 params.parent = browser_view_->GetWidget()->GetNativeView(); | 77 params.parent = browser_view_->GetWidget()->GetNativeView(); |
| 55 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 78 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
| 56 host_->Init(params); | 79 host_->Init(params); |
| 57 host_->SetContentsView(clip_view_); | 80 host_->SetContentsView(clip_view_); |
| 58 clip_view_->AddChildView(view_); | 81 clip_view_->AddChildView(view_); |
| 59 | 82 |
| 60 SetHostViewNative(host_view); | 83 SetHostViewNative(host_view); |
| 61 | 84 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 228 escape, ui::AcceleratorManager::kNormalPriority, this); | 251 escape, ui::AcceleratorManager::kNormalPriority, this); |
| 229 esc_accel_target_registered_ = true; | 252 esc_accel_target_registered_ = true; |
| 230 } | 253 } |
| 231 | 254 |
| 232 void DropdownBarHost::UnregisterAccelerators() { | 255 void DropdownBarHost::UnregisterAccelerators() { |
| 233 DCHECK(esc_accel_target_registered_); | 256 DCHECK(esc_accel_target_registered_); |
| 234 ui::Accelerator escape(ui::VKEY_ESCAPE, ui::EF_NONE); | 257 ui::Accelerator escape(ui::VKEY_ESCAPE, ui::EF_NONE); |
| 235 focus_manager_->UnregisterAccelerator(escape, this); | 258 focus_manager_->UnregisterAccelerator(escape, this); |
| 236 esc_accel_target_registered_ = false; | 259 esc_accel_target_registered_ = false; |
| 237 } | 260 } |
| OLD | NEW |