Chromium Code Reviews| 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/toolbar_action_view.h" | 5 #include "chrome/browser/ui/views/toolbar/toolbar_action_view.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
| 12 #include "chrome/browser/sessions/session_tab_helper.h" | 12 #include "chrome/browser/sessions/session_tab_helper.h" |
| 13 #include "chrome/browser/themes/theme_properties.h" | 13 #include "chrome/browser/themes/theme_properties.h" |
| 14 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" | 14 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" |
| 15 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" | 15 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" |
| 16 #include "chrome/browser/ui/view_ids.h" | 16 #include "chrome/browser/ui/view_ids.h" |
| 17 #include "content/public/browser/notification_source.h" | 17 #include "content/public/browser/notification_source.h" |
| 18 #include "ui/accessibility/ax_node_data.h" | 18 #include "ui/accessibility/ax_node_data.h" |
| 19 #include "ui/base/resource/resource_bundle.h" | 19 #include "ui/base/resource/resource_bundle.h" |
| 20 #include "ui/base/theme_provider.h" | 20 #include "ui/base/theme_provider.h" |
| 21 #include "ui/compositor/paint_recorder.h" | 21 #include "ui/compositor/paint_recorder.h" |
| 22 #include "ui/events/event.h" | 22 #include "ui/events/event.h" |
| 23 #include "ui/gfx/image/image_skia.h" | 23 #include "ui/gfx/image/image_skia.h" |
| 24 #include "ui/gfx/image/image_skia_operations.h" | 24 #include "ui/gfx/image/image_skia_operations.h" |
| 25 #include "ui/gfx/image/image_skia_source.h" | 25 #include "ui/gfx/image/image_skia_source.h" |
| 26 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" | |
| 26 #include "ui/views/animation/ink_drop_impl.h" | 27 #include "ui/views/animation/ink_drop_impl.h" |
| 27 #include "ui/views/controls/button/label_button_border.h" | 28 #include "ui/views/controls/button/label_button_border.h" |
| 28 #include "ui/views/controls/menu/menu_controller.h" | 29 #include "ui/views/controls/menu/menu_controller.h" |
| 29 #include "ui/views/controls/menu/menu_model_adapter.h" | 30 #include "ui/views/controls/menu/menu_model_adapter.h" |
| 30 #include "ui/views/controls/menu/menu_runner.h" | 31 #include "ui/views/controls/menu/menu_runner.h" |
| 31 #include "ui/views/mouse_constants.h" | 32 #include "ui/views/mouse_constants.h" |
| 32 | 33 |
| 33 using views::LabelButtonBorder; | 34 using views::LabelButtonBorder; |
| 34 | 35 |
| 35 namespace { | 36 namespace { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 } | 104 } |
| 104 | 105 |
| 105 return GetThemeProvider()->GetColor( | 106 return GetThemeProvider()->GetColor( |
| 106 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); | 107 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); |
| 107 } | 108 } |
| 108 | 109 |
| 109 std::unique_ptr<views::InkDrop> ToolbarActionView::CreateInkDrop() { | 110 std::unique_ptr<views::InkDrop> ToolbarActionView::CreateInkDrop() { |
| 110 std::unique_ptr<views::InkDropImpl> ink_drop = | 111 std::unique_ptr<views::InkDropImpl> ink_drop = |
| 111 CustomButton::CreateDefaultInkDropImpl(); | 112 CustomButton::CreateDefaultInkDropImpl(); |
| 112 ink_drop->SetShowHighlightOnHover(!delegate_->ShownInsideMenu()); | 113 ink_drop->SetShowHighlightOnHover(!delegate_->ShownInsideMenu()); |
| 114 ink_drop->SetShowHighlightOnFocus(true); | |
| 113 return std::move(ink_drop); | 115 return std::move(ink_drop); |
| 114 } | 116 } |
| 115 | 117 |
| 118 std::unique_ptr<views::InkDropRipple> ToolbarActionView::CreateInkDropRipple() | |
| 119 const { | |
| 120 if (delegate_->ShownInsideMenu()) { | |
| 121 // The ripple should not be visible when |this| is shown inside of a menu. | |
| 122 // TODO(bruthig): Use a lighter weight InkDropRipple type that doesn't | |
| 123 // consume as many the resources as the FloodFillInkDropRipple. See | |
| 124 // https://crbug.com/665214. | |
| 125 return base::MakeUnique<views::FloodFillInkDropRipple>( | |
| 126 gfx::Rect(), gfx::Point(), SK_ColorTRANSPARENT, 0.f); | |
|
Peter Kasting
2016/11/15 00:38:39
Can we just return null, and have the caller handl
bruthig
2016/11/15 01:25:12
Short answer, returning null is a possible long te
Peter Kasting
2016/11/15 01:47:36
I commented there about the overall route here. I
bruthig
2016/11/15 03:47:50
Done.
| |
| 127 } | |
| 128 | |
| 129 return MenuButton::CreateInkDropRipple(); | |
| 130 } | |
| 131 | |
| 116 content::WebContents* ToolbarActionView::GetCurrentWebContents() const { | 132 content::WebContents* ToolbarActionView::GetCurrentWebContents() const { |
| 117 return delegate_->GetCurrentWebContents(); | 133 return delegate_->GetCurrentWebContents(); |
| 118 } | 134 } |
| 119 | 135 |
| 120 void ToolbarActionView::UpdateState() { | 136 void ToolbarActionView::UpdateState() { |
| 121 content::WebContents* web_contents = GetCurrentWebContents(); | 137 content::WebContents* web_contents = GetCurrentWebContents(); |
| 122 if (SessionTabHelper::IdForTab(web_contents) < 0) | 138 if (SessionTabHelper::IdForTab(web_contents) < 0) |
| 123 return; | 139 return; |
| 124 | 140 |
| 125 if (!view_controller_->IsEnabled(web_contents) && | 141 if (!view_controller_->IsEnabled(web_contents) && |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 311 if (menu_controller->in_nested_run()) { | 327 if (menu_controller->in_nested_run()) { |
| 312 // There is another menu showing. Close the outermost menu (since we are | 328 // There is another menu showing. Close the outermost menu (since we are |
| 313 // shown in the same menu, we don't want to close the whole thing). | 329 // shown in the same menu, we don't want to close the whole thing). |
| 314 menu_controller->Cancel(views::MenuController::EXIT_OUTERMOST); | 330 menu_controller->Cancel(views::MenuController::EXIT_OUTERMOST); |
| 315 return true; | 331 return true; |
| 316 } | 332 } |
| 317 } | 333 } |
| 318 | 334 |
| 319 return false; | 335 return false; |
| 320 } | 336 } |
| OLD | NEW |