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" |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 namespace { | 40 namespace { |
41 | 41 |
42 // Horizontal spacing between most items in the container, as well as after the | 42 // Horizontal spacing between most items in the container, as well as after the |
43 // last item or chevron (if visible). | 43 // last item or chevron (if visible). |
44 const int kItemSpacing = ToolbarView::kStandardSpacing; | 44 const int kItemSpacing = ToolbarView::kStandardSpacing; |
45 | 45 |
46 // Horizontal spacing before the chevron (if visible). | 46 // Horizontal spacing before the chevron (if visible). |
47 const int kChevronSpacing = kItemSpacing - 2; | 47 const int kChevronSpacing = kItemSpacing - 2; |
48 | 48 |
49 void RegisterUserPrefs(PrefService* prefs) { | 49 void RegisterUserPrefs(PrefServiceSyncable* prefs) { |
50 prefs->RegisterIntegerPref(prefs::kBrowserActionContainerWidth, | 50 prefs->RegisterIntegerPref(prefs::kBrowserActionContainerWidth, |
51 0, | 51 0, |
52 PrefService::UNSYNCABLE_PREF); | 52 PrefServiceSyncable::UNSYNCABLE_PREF); |
53 } | 53 } |
54 | 54 |
55 } // namespace | 55 } // namespace |
56 | 56 |
57 // static | 57 // static |
58 bool BrowserActionsContainer::disable_animations_during_testing_ = false; | 58 bool BrowserActionsContainer::disable_animations_during_testing_ = false; |
59 | 59 |
60 //////////////////////////////////////////////////////////////////////////////// | 60 //////////////////////////////////////////////////////////////////////////////// |
61 // BrowserActionsContainer | 61 // BrowserActionsContainer |
62 | 62 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 StopShowFolderDropMenuTimer(); | 111 StopShowFolderDropMenuTimer(); |
112 if (popup_) | 112 if (popup_) |
113 popup_->GetWidget()->RemoveObserver(this); | 113 popup_->GetWidget()->RemoveObserver(this); |
114 HidePopup(); | 114 HidePopup(); |
115 DeleteBrowserActionViews(); | 115 DeleteBrowserActionViews(); |
116 } | 116 } |
117 | 117 |
118 void BrowserActionsContainer::Init() { | 118 void BrowserActionsContainer::Init() { |
119 LoadImages(); | 119 LoadImages(); |
120 | 120 |
| 121 // TODO(joi): Switch to official way of registering user prefs for |
| 122 // this class, i.e. in a function called from |
| 123 // browser_prefs::RegisterUserPrefs. |
121 if (!profile_->GetPrefs()->FindPreference( | 124 if (!profile_->GetPrefs()->FindPreference( |
122 prefs::kBrowserActionContainerWidth)) | 125 prefs::kBrowserActionContainerWidth)) |
123 RegisterUserPrefs(profile_->GetPrefs()); | 126 RegisterUserPrefs(profile_->GetPrefs()); |
124 | 127 |
125 // We wait to set the container width until now so that the chevron images | 128 // We wait to set the container width until now so that the chevron images |
126 // will be loaded. The width calculation needs to know the chevron size. | 129 // will be loaded. The width calculation needs to know the chevron size. |
127 if (model_ && | 130 if (model_ && |
128 !profile_->GetPrefs()->HasPrefPath(prefs::kExtensionToolbarSize)) { | 131 !profile_->GetPrefs()->HasPrefPath(prefs::kExtensionToolbarSize)) { |
129 // Migration code to the new VisibleIconCount pref. | 132 // Migration code to the new VisibleIconCount pref. |
130 // TODO(mpcomplete): remove this after users are upgraded to 5.0. | 133 // TODO(mpcomplete): remove this after users are upgraded to 5.0. |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 views::BubbleBorder::TOP_LEFT : views::BubbleBorder::TOP_RIGHT; | 850 views::BubbleBorder::TOP_LEFT : views::BubbleBorder::TOP_RIGHT; |
848 popup_ = ExtensionPopup::ShowPopup(popup_url, | 851 popup_ = ExtensionPopup::ShowPopup(popup_url, |
849 browser_, | 852 browser_, |
850 reference_view, | 853 reference_view, |
851 arrow_location, | 854 arrow_location, |
852 show_action); | 855 show_action); |
853 popup_->GetWidget()->AddObserver(this); | 856 popup_->GetWidget()->AddObserver(this); |
854 popup_button_ = button; | 857 popup_button_ = button; |
855 popup_button_->SetButtonPushed(); | 858 popup_button_->SetButtonPushed(); |
856 } | 859 } |
OLD | NEW |