| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser_actions_container.h" | 5 #include "chrome/browser/ui/views/browser_actions_container.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/extensions/extension_system.h" | 10 #include "chrome/browser/extensions/extension_system.h" |
| 11 #include "chrome/browser/extensions/tab_helper.h" | 11 #include "chrome/browser/extensions/tab_helper.h" |
| 12 #include "chrome/browser/prefs/pref_registry_syncable.h" |
| 12 #include "chrome/browser/prefs/pref_service.h" | 13 #include "chrome/browser/prefs/pref_service.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/sessions/session_tab_helper.h" | 15 #include "chrome/browser/sessions/session_tab_helper.h" |
| 15 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 17 #include "chrome/browser/ui/view_ids.h" | 18 #include "chrome/browser/ui/view_ids.h" |
| 18 #include "chrome/browser/ui/views/browser_action_view.h" | 19 #include "chrome/browser/ui/views/browser_action_view.h" |
| 19 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h" | 20 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h" |
| 20 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views
.h" | 21 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views
.h" |
| 21 #include "chrome/browser/ui/views/extensions/extension_popup.h" | 22 #include "chrome/browser/ui/views/extensions/extension_popup.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 39 | 40 |
| 40 namespace { | 41 namespace { |
| 41 | 42 |
| 42 // Horizontal spacing between most items in the container, as well as after the | 43 // Horizontal spacing between most items in the container, as well as after the |
| 43 // last item or chevron (if visible). | 44 // last item or chevron (if visible). |
| 44 const int kItemSpacing = ToolbarView::kStandardSpacing; | 45 const int kItemSpacing = ToolbarView::kStandardSpacing; |
| 45 | 46 |
| 46 // Horizontal spacing before the chevron (if visible). | 47 // Horizontal spacing before the chevron (if visible). |
| 47 const int kChevronSpacing = kItemSpacing - 2; | 48 const int kChevronSpacing = kItemSpacing - 2; |
| 48 | 49 |
| 49 void RegisterUserPrefs(PrefServiceSyncable* prefs) { | 50 void RegisterUserPrefs(PrefRegistrySyncable* registry) { |
| 50 prefs->RegisterIntegerPref(prefs::kBrowserActionContainerWidth, | 51 registry->RegisterIntegerPref(prefs::kBrowserActionContainerWidth, |
| 51 0, | 52 0, |
| 52 PrefServiceSyncable::UNSYNCABLE_PREF); | 53 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 53 } | 54 } |
| 54 | 55 |
| 55 } // namespace | 56 } // namespace |
| 56 | 57 |
| 57 // static | 58 // static |
| 58 bool BrowserActionsContainer::disable_animations_during_testing_ = false; | 59 bool BrowserActionsContainer::disable_animations_during_testing_ = false; |
| 59 | 60 |
| 60 //////////////////////////////////////////////////////////////////////////////// | 61 //////////////////////////////////////////////////////////////////////////////// |
| 61 // BrowserActionsContainer | 62 // BrowserActionsContainer |
| 62 | 63 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 } | 117 } |
| 117 | 118 |
| 118 void BrowserActionsContainer::Init() { | 119 void BrowserActionsContainer::Init() { |
| 119 LoadImages(); | 120 LoadImages(); |
| 120 | 121 |
| 121 // TODO(joi): Switch to official way of registering user prefs for | 122 // TODO(joi): Switch to official way of registering user prefs for |
| 122 // this class, i.e. in a function called from | 123 // this class, i.e. in a function called from |
| 123 // browser_prefs::RegisterUserPrefs. | 124 // browser_prefs::RegisterUserPrefs. |
| 124 if (!profile_->GetPrefs()->FindPreference( | 125 if (!profile_->GetPrefs()->FindPreference( |
| 125 prefs::kBrowserActionContainerWidth)) | 126 prefs::kBrowserActionContainerWidth)) |
| 126 RegisterUserPrefs(profile_->GetPrefs()); | 127 RegisterUserPrefs(static_cast<PrefRegistrySyncable*>( |
| 128 profile_->GetPrefs()->DeprecatedGetPrefRegistry())); |
| 127 | 129 |
| 128 // We wait to set the container width until now so that the chevron images | 130 // We wait to set the container width until now so that the chevron images |
| 129 // will be loaded. The width calculation needs to know the chevron size. | 131 // will be loaded. The width calculation needs to know the chevron size. |
| 130 if (model_ && | 132 if (model_ && |
| 131 !profile_->GetPrefs()->HasPrefPath(prefs::kExtensionToolbarSize)) { | 133 !profile_->GetPrefs()->HasPrefPath(prefs::kExtensionToolbarSize)) { |
| 132 // Migration code to the new VisibleIconCount pref. | 134 // Migration code to the new VisibleIconCount pref. |
| 133 // TODO(mpcomplete): remove this after users are upgraded to 5.0. | 135 // TODO(mpcomplete): remove this after users are upgraded to 5.0. |
| 134 int predefined_width = | 136 int predefined_width = |
| 135 profile_->GetPrefs()->GetInteger(prefs::kBrowserActionContainerWidth); | 137 profile_->GetPrefs()->GetInteger(prefs::kBrowserActionContainerWidth); |
| 136 if (predefined_width != 0) | 138 if (predefined_width != 0) |
| (...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 views::BubbleBorder::TOP_LEFT : views::BubbleBorder::TOP_RIGHT; | 854 views::BubbleBorder::TOP_LEFT : views::BubbleBorder::TOP_RIGHT; |
| 853 popup_ = ExtensionPopup::ShowPopup(popup_url, | 855 popup_ = ExtensionPopup::ShowPopup(popup_url, |
| 854 browser_, | 856 browser_, |
| 855 reference_view, | 857 reference_view, |
| 856 arrow_location, | 858 arrow_location, |
| 857 show_action); | 859 show_action); |
| 858 popup_->GetWidget()->AddObserver(this); | 860 popup_->GetWidget()->AddObserver(this); |
| 859 popup_button_ = button; | 861 popup_button_ = button; |
| 860 popup_button_->SetButtonPushed(); | 862 popup_button_->SetButtonPushed(); |
| 861 } | 863 } |
| OLD | NEW |