| 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/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/tab_helper.h" | 12 #include "chrome/browser/extensions/tab_helper.h" | 
| 13 #include "chrome/browser/prefs/pref_registry_syncable.h" |  | 
| 14 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" | 
| 15 #include "chrome/browser/sessions/session_tab_helper.h" | 14 #include "chrome/browser/sessions/session_tab_helper.h" | 
| 16 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" | 
| 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 16 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 
| 18 #include "chrome/browser/ui/view_ids.h" | 17 #include "chrome/browser/ui/view_ids.h" | 
| 19 #include "chrome/browser/ui/views/browser_action_view.h" | 18 #include "chrome/browser/ui/views/browser_action_view.h" | 
| 20 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h" | 19 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h" | 
| 21 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views
     .h" | 20 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views
     .h" | 
| 22 #include "chrome/browser/ui/views/extensions/extension_popup.h" | 21 #include "chrome/browser/ui/views/extensions/extension_popup.h" | 
| 23 #include "chrome/browser/ui/views/toolbar_view.h" | 22 #include "chrome/browser/ui/views/toolbar_view.h" | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
| 40 | 39 | 
| 41 namespace { | 40 namespace { | 
| 42 | 41 | 
| 43 // 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 | 
| 44 // last item or chevron (if visible). | 43 // last item or chevron (if visible). | 
| 45 const int kItemSpacing = ToolbarView::kStandardSpacing; | 44 const int kItemSpacing = ToolbarView::kStandardSpacing; | 
| 46 | 45 | 
| 47 // Horizontal spacing before the chevron (if visible). | 46 // Horizontal spacing before the chevron (if visible). | 
| 48 const int kChevronSpacing = kItemSpacing - 2; | 47 const int kChevronSpacing = kItemSpacing - 2; | 
| 49 | 48 | 
| 50 void RegisterUserPrefs(PrefRegistrySyncable* registry) { |  | 
| 51   registry->RegisterIntegerPref(prefs::kBrowserActionContainerWidth, |  | 
| 52                                 0, |  | 
| 53                                 PrefRegistrySyncable::UNSYNCABLE_PREF); |  | 
| 54 } |  | 
| 55 |  | 
| 56 }  // namespace | 49 }  // namespace | 
| 57 | 50 | 
| 58 // static | 51 // static | 
| 59 bool BrowserActionsContainer::disable_animations_during_testing_ = false; | 52 bool BrowserActionsContainer::disable_animations_during_testing_ = false; | 
| 60 | 53 | 
| 61 //////////////////////////////////////////////////////////////////////////////// | 54 //////////////////////////////////////////////////////////////////////////////// | 
| 62 // BrowserActionsContainer | 55 // BrowserActionsContainer | 
| 63 | 56 | 
| 64 BrowserActionsContainer::BrowserActionsContainer(Browser* browser, | 57 BrowserActionsContainer::BrowserActionsContainer(Browser* browser, | 
| 65                                                  View* owner_view) | 58                                                  View* owner_view) | 
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 112   StopShowFolderDropMenuTimer(); | 105   StopShowFolderDropMenuTimer(); | 
| 113   if (popup_) | 106   if (popup_) | 
| 114     popup_->GetWidget()->RemoveObserver(this); | 107     popup_->GetWidget()->RemoveObserver(this); | 
| 115   HidePopup(); | 108   HidePopup(); | 
| 116   DeleteBrowserActionViews(); | 109   DeleteBrowserActionViews(); | 
| 117 } | 110 } | 
| 118 | 111 | 
| 119 void BrowserActionsContainer::Init() { | 112 void BrowserActionsContainer::Init() { | 
| 120   LoadImages(); | 113   LoadImages(); | 
| 121 | 114 | 
| 122   // TODO(joi): Switch to official way of registering user prefs for |  | 
| 123   // this class, i.e. in a function called from |  | 
| 124   // browser_prefs::RegisterUserPrefs. |  | 
| 125   if (!profile_->GetPrefs()->FindPreference( |  | 
| 126           prefs::kBrowserActionContainerWidth)) |  | 
| 127     RegisterUserPrefs(static_cast<PrefRegistrySyncable*>( |  | 
| 128         profile_->GetPrefs()->DeprecatedGetPrefRegistry())); |  | 
| 129 |  | 
| 130   // We wait to set the container width until now so that the chevron images | 115   // We wait to set the container width until now so that the chevron images | 
| 131   // will be loaded.  The width calculation needs to know the chevron size. | 116   // will be loaded.  The width calculation needs to know the chevron size. | 
| 132   if (model_ && | 117   if (model_ && | 
| 133       !profile_->GetPrefs()->HasPrefPath(prefs::kExtensionToolbarSize)) { | 118       !profile_->GetPrefs()->HasPrefPath(prefs::kExtensionToolbarSize)) { | 
| 134     // Migration code to the new VisibleIconCount pref. | 119     // Migration code to the new VisibleIconCount pref. | 
| 135     // TODO(mpcomplete): remove this after users are upgraded to 5.0. | 120     // TODO(mpcomplete): remove this after users are upgraded to 5.0. | 
| 136     int predefined_width = | 121     int predefined_width = | 
| 137         profile_->GetPrefs()->GetInteger(prefs::kBrowserActionContainerWidth); | 122         profile_->GetPrefs()->GetInteger(prefs::kBrowserActionContainerWidth); | 
| 138     if (predefined_width != 0) | 123     if (predefined_width != 0) | 
| 139       model_->SetVisibleIconCount(WidthToIconCount(predefined_width)); | 124       model_->SetVisibleIconCount(WidthToIconCount(predefined_width)); | 
| (...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 854       views::BubbleBorder::TOP_LEFT : views::BubbleBorder::TOP_RIGHT; | 839       views::BubbleBorder::TOP_LEFT : views::BubbleBorder::TOP_RIGHT; | 
| 855   popup_ = ExtensionPopup::ShowPopup(popup_url, | 840   popup_ = ExtensionPopup::ShowPopup(popup_url, | 
| 856                                      browser_, | 841                                      browser_, | 
| 857                                      reference_view, | 842                                      reference_view, | 
| 858                                      arrow_location, | 843                                      arrow_location, | 
| 859                                      show_action); | 844                                      show_action); | 
| 860   popup_->GetWidget()->AddObserver(this); | 845   popup_->GetWidget()->AddObserver(this); | 
| 861   popup_button_ = button; | 846   popup_button_ = button; | 
| 862   popup_button_->SetButtonPushed(); | 847   popup_button_->SetButtonPushed(); | 
| 863 } | 848 } | 
| OLD | NEW | 
|---|