OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/toolbar/app_menu_button.h" | 5 #include "chrome/browser/ui/views/toolbar/app_menu_button.h" |
6 | 6 |
7 #include "base/location.h" | 7 #include "base/location.h" |
8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
11 #include "chrome/browser/themes/theme_properties.h" | 11 #include "chrome/browser/themes/theme_properties.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" | 13 #include "chrome/browser/ui/toolbar/app_menu_model.h" |
14 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h" | 14 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h" |
15 #include "chrome/browser/ui/views/layout_constants.h" | 15 #include "chrome/browser/ui/views/layout_constants.h" |
16 #include "chrome/browser/ui/views/toolbar/app_menu.h" | 16 #include "chrome/browser/ui/views/toolbar/app_menu.h" |
17 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" | 17 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
18 #include "extensions/common/feature_switch.h" | 18 #include "extensions/common/feature_switch.h" |
19 #include "grit/theme_resources.h" | 19 #include "grit/theme_resources.h" |
20 #include "ui/base/resource/material_design/material_design_controller.h" | 20 #include "ui/base/resource/material_design/material_design_controller.h" |
21 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
22 #include "ui/base/theme_provider.h" | 22 #include "ui/base/theme_provider.h" |
23 #include "ui/gfx/color_palette.h" | 23 #include "ui/gfx/color_palette.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 keyboard::KeyboardController::GetInstance(); | 87 keyboard::KeyboardController::GetInstance(); |
88 if (keyboard_controller && keyboard_controller->keyboard_visible()) { | 88 if (keyboard_controller && keyboard_controller->keyboard_visible()) { |
89 keyboard_controller->HideKeyboard( | 89 keyboard_controller->HideKeyboard( |
90 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); | 90 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); |
91 } | 91 } |
92 #endif | 92 #endif |
93 | 93 |
94 Browser* browser = toolbar_view_->browser(); | 94 Browser* browser = toolbar_view_->browser(); |
95 | 95 |
96 menu_.reset(new AppMenu(browser, for_drop ? AppMenu::FOR_DROP : 0)); | 96 menu_.reset(new AppMenu(browser, for_drop ? AppMenu::FOR_DROP : 0)); |
97 menu_model_.reset(new WrenchMenuModel(toolbar_view_, browser)); | 97 menu_model_.reset(new AppMenuModel(toolbar_view_, browser)); |
98 menu_->Init(menu_model_.get()); | 98 menu_->Init(menu_model_.get()); |
99 | 99 |
100 FOR_EACH_OBSERVER(views::MenuListener, menu_listeners_, OnMenuOpened()); | 100 FOR_EACH_OBSERVER(views::MenuListener, menu_listeners_, OnMenuOpened()); |
101 | 101 |
102 // Because running the menu below spins a nested message loop, |this| can be | 102 // Because running the menu below spins a nested message loop, |this| can be |
103 // deleted by the time RunMenu() returns. To detect this, we set |destroyed_| | 103 // deleted by the time RunMenu() returns. To detect this, we set |destroyed_| |
104 // (which is normally null) to point to a local. If our destructor runs during | 104 // (which is normally null) to point to a local. If our destructor runs during |
105 // RunMenu(), then this local will be set to true on return, and we'll know | 105 // RunMenu(), then this local will be set to true on return, and we'll know |
106 // it's not safe to access any member variables. | 106 // it's not safe to access any member variables. |
107 bool destroyed = false; | 107 bool destroyed = false; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 | 263 |
264 void AppMenuButton::OnPaint(gfx::Canvas* canvas) { | 264 void AppMenuButton::OnPaint(gfx::Canvas* canvas) { |
265 views::MenuButton::OnPaint(canvas); | 265 views::MenuButton::OnPaint(canvas); |
266 if (ui::MaterialDesignController::IsModeMaterial()) | 266 if (ui::MaterialDesignController::IsModeMaterial()) |
267 return; | 267 return; |
268 wrench_icon_painter_->Paint(canvas, | 268 wrench_icon_painter_->Paint(canvas, |
269 GetThemeProvider(), | 269 GetThemeProvider(), |
270 gfx::Rect(size()), | 270 gfx::Rect(size()), |
271 WrenchIconPainter::BEZEL_NONE); | 271 WrenchIconPainter::BEZEL_NONE); |
272 } | 272 } |
OLD | NEW |