| 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/ui/toolbar/toolbar_action_view_controller.h" | 14 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" |
| 14 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" | 15 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" |
| 15 #include "chrome/browser/ui/view_ids.h" | 16 #include "chrome/browser/ui/view_ids.h" |
| 16 #include "chrome/grit/generated_resources.h" | 17 #include "chrome/grit/generated_resources.h" |
| 17 #include "content/public/browser/notification_source.h" | 18 #include "content/public/browser/notification_source.h" |
| 18 #include "grit/theme_resources.h" | 19 #include "grit/theme_resources.h" |
| 19 #include "ui/accessibility/ax_view_state.h" | 20 #include "ui/accessibility/ax_view_state.h" |
| 20 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
| 22 #include "ui/base/theme_provider.h" |
| 21 #include "ui/compositor/paint_recorder.h" | 23 #include "ui/compositor/paint_recorder.h" |
| 22 #include "ui/events/event.h" | 24 #include "ui/events/event.h" |
| 23 #include "ui/gfx/image/image_skia.h" | 25 #include "ui/gfx/image/image_skia.h" |
| 24 #include "ui/gfx/image/image_skia_operations.h" | 26 #include "ui/gfx/image/image_skia_operations.h" |
| 25 #include "ui/gfx/image/image_skia_source.h" | 27 #include "ui/gfx/image/image_skia_source.h" |
| 26 #include "ui/resources/grit/ui_resources.h" | 28 #include "ui/resources/grit/ui_resources.h" |
| 27 #include "ui/views/animation/button_ink_drop_delegate.h" | 29 #include "ui/views/animation/button_ink_drop_delegate.h" |
| 28 #include "ui/views/controls/button/label_button_border.h" | 30 #include "ui/views/controls/button/label_button_border.h" |
| 29 #include "ui/views/controls/menu/menu_controller.h" | 31 #include "ui/views/controls/menu/menu_controller.h" |
| 30 #include "ui/views/controls/menu/menu_model_adapter.h" | 32 #include "ui/views/controls/menu/menu_model_adapter.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 } | 111 } |
| 110 | 112 |
| 111 void ToolbarActionView::AddInkDropLayer(ui::Layer* ink_drop_layer) { | 113 void ToolbarActionView::AddInkDropLayer(ui::Layer* ink_drop_layer) { |
| 112 image()->SetPaintToLayer(true); | 114 image()->SetPaintToLayer(true); |
| 113 image()->SetFillsBoundsOpaquely(false); | 115 image()->SetFillsBoundsOpaquely(false); |
| 114 views::MenuButton::AddInkDropLayer(ink_drop_layer); | 116 views::MenuButton::AddInkDropLayer(ink_drop_layer); |
| 115 } | 117 } |
| 116 | 118 |
| 117 void ToolbarActionView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { | 119 void ToolbarActionView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { |
| 118 views::MenuButton::RemoveInkDropLayer(ink_drop_layer); | 120 views::MenuButton::RemoveInkDropLayer(ink_drop_layer); |
| 119 image()->SetFillsBoundsOpaquely(true); | |
| 120 image()->SetPaintToLayer(false); | 121 image()->SetPaintToLayer(false); |
| 121 } | 122 } |
| 122 | 123 |
| 124 SkColor ToolbarActionView::GetInkDropBaseColor() const { |
| 125 return GetThemeProvider()->GetColor( |
| 126 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); |
| 127 } |
| 128 |
| 123 content::WebContents* ToolbarActionView::GetCurrentWebContents() const { | 129 content::WebContents* ToolbarActionView::GetCurrentWebContents() const { |
| 124 return delegate_->GetCurrentWebContents(); | 130 return delegate_->GetCurrentWebContents(); |
| 125 } | 131 } |
| 126 | 132 |
| 127 void ToolbarActionView::UpdateState() { | 133 void ToolbarActionView::UpdateState() { |
| 128 content::WebContents* web_contents = GetCurrentWebContents(); | 134 content::WebContents* web_contents = GetCurrentWebContents(); |
| 129 if (SessionTabHelper::IdForTab(web_contents) < 0) | 135 if (SessionTabHelper::IdForTab(web_contents) < 0) |
| 130 return; | 136 return; |
| 131 | 137 |
| 132 if (!view_controller_->IsEnabled(web_contents) && | 138 if (!view_controller_->IsEnabled(web_contents) && |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 if (menu_controller->in_nested_run()) { | 329 if (menu_controller->in_nested_run()) { |
| 324 // There is another menu showing. Close the outermost menu (since we are | 330 // There is another menu showing. Close the outermost menu (since we are |
| 325 // shown in the same menu, we don't want to close the whole thing). | 331 // shown in the same menu, we don't want to close the whole thing). |
| 326 menu_controller->Cancel(views::MenuController::EXIT_OUTERMOST); | 332 menu_controller->Cancel(views::MenuController::EXIT_OUTERMOST); |
| 327 return true; | 333 return true; |
| 328 } | 334 } |
| 329 } | 335 } |
| 330 | 336 |
| 331 return false; | 337 return false; |
| 332 } | 338 } |
| OLD | NEW |