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/browser_actions_container.h" | 5 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
11 #include "chrome/browser/extensions/extension_system.h" | 11 #include "chrome/browser/extensions/extension_system.h" |
12 #include "chrome/browser/extensions/extension_util.h" | 12 #include "chrome/browser/extensions/extension_util.h" |
13 #include "chrome/browser/extensions/extension_view_host.h" | 13 #include "chrome/browser/extensions/extension_view_host.h" |
14 #include "chrome/browser/extensions/tab_helper.h" | 14 #include "chrome/browser/extensions/tab_helper.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/sessions/session_tab_helper.h" | 16 #include "chrome/browser/sessions/session_tab_helper.h" |
17 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
18 #include "chrome/browser/ui/browser_window.h" | 18 #include "chrome/browser/ui/browser_window.h" |
19 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
20 #include "chrome/browser/ui/view_ids.h" | 20 #include "chrome/browser/ui/view_ids.h" |
21 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h" | 21 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h" |
22 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views
.h" | 22 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views
.h" |
23 #include "chrome/browser/ui/views/extensions/extension_popup.h" | 23 #include "chrome/browser/ui/views/extensions/extension_popup.h" |
24 #include "chrome/browser/ui/views/toolbar/browser_action_view.h" | 24 #include "chrome/browser/ui/views/toolbar/browser_action_view.h" |
25 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" | 25 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
26 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
| 27 #include "extensions/browser/pref_names.h" |
27 #include "grit/generated_resources.h" | 28 #include "grit/generated_resources.h" |
28 #include "grit/theme_resources.h" | 29 #include "grit/theme_resources.h" |
29 #include "grit/ui_resources.h" | 30 #include "grit/ui_resources.h" |
30 #include "ui/base/accessibility/accessible_view_state.h" | 31 #include "ui/base/accessibility/accessible_view_state.h" |
31 #include "ui/base/dragdrop/drag_utils.h" | 32 #include "ui/base/dragdrop/drag_utils.h" |
32 #include "ui/base/l10n/l10n_util.h" | 33 #include "ui/base/l10n/l10n_util.h" |
33 #include "ui/base/resource/resource_bundle.h" | 34 #include "ui/base/resource/resource_bundle.h" |
34 #include "ui/base/theme_provider.h" | 35 #include "ui/base/theme_provider.h" |
35 #include "ui/gfx/animation/slide_animation.h" | 36 #include "ui/gfx/animation/slide_animation.h" |
36 #include "ui/gfx/canvas.h" | 37 #include "ui/gfx/canvas.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 HidePopup(); | 111 HidePopup(); |
111 DeleteBrowserActionViews(); | 112 DeleteBrowserActionViews(); |
112 } | 113 } |
113 | 114 |
114 void BrowserActionsContainer::Init() { | 115 void BrowserActionsContainer::Init() { |
115 LoadImages(); | 116 LoadImages(); |
116 | 117 |
117 // We wait to set the container width until now so that the chevron images | 118 // We wait to set the container width until now so that the chevron images |
118 // will be loaded. The width calculation needs to know the chevron size. | 119 // will be loaded. The width calculation needs to know the chevron size. |
119 if (model_ && | 120 if (model_ && |
120 !profile_->GetPrefs()->HasPrefPath(prefs::kExtensionToolbarSize)) { | 121 !profile_->GetPrefs()->HasPrefPath( |
| 122 extensions::pref_names::kToolbarSize)) { |
121 // Migration code to the new VisibleIconCount pref. | 123 // Migration code to the new VisibleIconCount pref. |
122 // TODO(mpcomplete): remove this after users are upgraded to 5.0. | 124 // TODO(mpcomplete): remove this after users are upgraded to 5.0. |
123 int predefined_width = | 125 int predefined_width = profile_->GetPrefs()->GetInteger( |
124 profile_->GetPrefs()->GetInteger(prefs::kBrowserActionContainerWidth); | 126 extensions::pref_names::kBrowserActionContainerWidth); |
125 if (predefined_width != 0) | 127 if (predefined_width != 0) |
126 model_->SetVisibleIconCount(WidthToIconCount(predefined_width)); | 128 model_->SetVisibleIconCount(WidthToIconCount(predefined_width)); |
127 } | 129 } |
128 if (model_ && model_->extensions_initialized()) | 130 if (model_ && model_->extensions_initialized()) |
129 SetContainerWidth(); | 131 SetContainerWidth(); |
130 } | 132 } |
131 | 133 |
132 BrowserActionView* BrowserActionsContainer::GetBrowserActionView( | 134 BrowserActionView* BrowserActionsContainer::GetBrowserActionView( |
133 ExtensionAction* action) { | 135 ExtensionAction* action) { |
134 for (BrowserActionViews::iterator i(browser_action_views_.begin()); | 136 for (BrowserActionViews::iterator i(browser_action_views_.begin()); |
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
868 arrow, | 870 arrow, |
869 show_action); | 871 show_action); |
870 popup_->GetWidget()->AddObserver(this); | 872 popup_->GetWidget()->AddObserver(this); |
871 popup_button_ = button; | 873 popup_button_ = button; |
872 | 874 |
873 // Only set button as pushed if it was triggered by a user click. | 875 // Only set button as pushed if it was triggered by a user click. |
874 if (should_grant) | 876 if (should_grant) |
875 popup_button_->SetButtonPushed(); | 877 popup_button_->SetButtonPushed(); |
876 return true; | 878 return true; |
877 } | 879 } |
OLD | NEW |