OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/toolbar/toolbar_actions_bar.h" | 5 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/profiler/scoped_tracker.h" | 9 #include "base/profiler/scoped_tracker.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "chrome/browser/ui/toolbar/toolbar_actions_bar_observer.h" | 25 #include "chrome/browser/ui/toolbar/toolbar_actions_bar_observer.h" |
26 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
27 #include "components/crx_file/id_util.h" | 27 #include "components/crx_file/id_util.h" |
28 #include "components/pref_registry/pref_registry_syncable.h" | 28 #include "components/pref_registry/pref_registry_syncable.h" |
29 #include "extensions/browser/extension_registry.h" | 29 #include "extensions/browser/extension_registry.h" |
30 #include "extensions/browser/extension_system.h" | 30 #include "extensions/browser/extension_system.h" |
31 #include "extensions/browser/runtime_data.h" | 31 #include "extensions/browser/runtime_data.h" |
32 #include "extensions/common/extension.h" | 32 #include "extensions/common/extension.h" |
33 #include "extensions/common/feature_switch.h" | 33 #include "extensions/common/feature_switch.h" |
34 #include "grit/theme_resources.h" | 34 #include "grit/theme_resources.h" |
| 35 #include "ui/base/resource/material_design/material_design_controller.h" |
35 #include "ui/base/resource/resource_bundle.h" | 36 #include "ui/base/resource/resource_bundle.h" |
36 #include "ui/gfx/image/image_skia.h" | 37 #include "ui/gfx/image/image_skia.h" |
37 | 38 |
38 namespace { | 39 namespace { |
39 | 40 |
40 using WeakToolbarActions = std::vector<ToolbarActionViewController*>; | 41 using WeakToolbarActions = std::vector<ToolbarActionViewController*>; |
41 | 42 |
42 // Matches ToolbarView::kStandardSpacing; | 43 // Matches ToolbarView::kStandardSpacing; |
43 const int kLeftPadding = 3; | 44 const int kLeftPadding = 3; |
44 const int kRightPadding = kLeftPadding; | 45 const int kRightPadding = kLeftPadding; |
45 const int kItemSpacing = kLeftPadding; | 46 const int kItemSpacing = kLeftPadding; |
46 const int kOverflowLeftPadding = kItemSpacing; | 47 const int kOverflowLeftPadding = kItemSpacing; |
47 const int kOverflowRightPadding = kItemSpacing; | 48 const int kOverflowRightPadding = kItemSpacing; |
48 | 49 |
49 enum DimensionType { WIDTH, HEIGHT }; | 50 enum DimensionType { WIDTH, HEIGHT }; |
50 | 51 |
51 // Returns the width or height of the toolbar action icon size. | 52 // Returns the width or height of the toolbar action icon size. |
52 int GetIconDimension(DimensionType type) { | 53 int GetIconDimension(DimensionType type) { |
| 54 if (ui::MaterialDesignController::IsModeMaterial()) |
| 55 return 28; |
| 56 |
53 static bool initialized = false; | 57 static bool initialized = false; |
54 static int icon_height = 0; | 58 static int icon_height = 0; |
55 static int icon_width = 0; | 59 static int icon_width = 0; |
56 if (!initialized) { | 60 if (!initialized) { |
57 initialized = true; | 61 initialized = true; |
58 gfx::ImageSkia* skia = | 62 gfx::ImageSkia* skia = |
59 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 63 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
60 IDR_BROWSER_ACTION); | 64 IDR_BROWSER_ACTION); |
61 icon_height = skia->height(); | 65 icon_height = skia->height(); |
62 icon_width = skia->width(); | 66 icon_width = skia->width(); |
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 for (ToolbarActionViewController* action : toolbar_actions_) { | 798 for (ToolbarActionViewController* action : toolbar_actions_) { |
795 if (action->GetId() == action_id) | 799 if (action->GetId() == action_id) |
796 return action; | 800 return action; |
797 } | 801 } |
798 return nullptr; | 802 return nullptr; |
799 } | 803 } |
800 | 804 |
801 content::WebContents* ToolbarActionsBar::GetCurrentWebContents() { | 805 content::WebContents* ToolbarActionsBar::GetCurrentWebContents() { |
802 return browser_->tab_strip_model()->GetActiveWebContents(); | 806 return browser_->tab_strip_model()->GetActiveWebContents(); |
803 } | 807 } |
OLD | NEW |