Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(718)

Side by Side Diff: chrome/browser/ui/views/browser_actions_container.cc

Issue 10387047: views: Refactor the way we register BrowserActionsContainer prefs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/views/browser_actions_container.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/bind.h" 7 #include "base/bind.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "ui/base/resource/resource_bundle.h" 48 #include "ui/base/resource/resource_bundle.h"
49 #include "ui/base/theme_provider.h" 49 #include "ui/base/theme_provider.h"
50 #include "ui/gfx/canvas.h" 50 #include "ui/gfx/canvas.h"
51 #include "ui/views/controls/button/text_button.h" 51 #include "ui/views/controls/button/text_button.h"
52 #include "ui/views/controls/menu/menu_item_view.h" 52 #include "ui/views/controls/menu/menu_item_view.h"
53 #include "ui/views/controls/menu/menu_model_adapter.h" 53 #include "ui/views/controls/menu/menu_model_adapter.h"
54 #include "ui/views/controls/menu/menu_runner.h" 54 #include "ui/views/controls/menu/menu_runner.h"
55 #include "ui/views/controls/resize_area.h" 55 #include "ui/views/controls/resize_area.h"
56 #include "ui/views/metrics.h" 56 #include "ui/views/metrics.h"
57 57
58 namespace {
59
58 // Horizontal spacing between most items in the container, as well as after the 60 // Horizontal spacing between most items in the container, as well as after the
59 // last item or chevron (if visible). 61 // last item or chevron (if visible).
60 static const int kItemSpacing = ToolbarView::kStandardSpacing; 62 const int kItemSpacing = ToolbarView::kStandardSpacing;
63
61 // Horizontal spacing before the chevron (if visible). 64 // Horizontal spacing before the chevron (if visible).
62 static const int kChevronSpacing = kItemSpacing - 2; 65 const int kChevronSpacing = kItemSpacing - 2;
66
67 void RegisterUserPrefs(PrefService* prefs) {
68 prefs->RegisterIntegerPref(prefs::kBrowserActionContainerWidth,
69 0,
70 PrefService::UNSYNCABLE_PREF);
71 }
72
73 } // namespace
63 74
64 // static 75 // static
65 bool BrowserActionsContainer::disable_animations_during_testing_ = false; 76 bool BrowserActionsContainer::disable_animations_during_testing_ = false;
66 77
67 //////////////////////////////////////////////////////////////////////////////// 78 ////////////////////////////////////////////////////////////////////////////////
68 // BrowserActionButton 79 // BrowserActionButton
69 80
70 BrowserActionButton::BrowserActionButton(const Extension* extension, 81 BrowserActionButton::BrowserActionButton(const Extension* extension,
71 BrowserActionsContainer* panel) 82 BrowserActionsContainer* panel)
72 : ALLOW_THIS_IN_INITIALIZER_LIST( 83 : ALLOW_THIS_IN_INITIALIZER_LIST(
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 BrowserActionsContainer::~BrowserActionsContainer() { 429 BrowserActionsContainer::~BrowserActionsContainer() {
419 if (model_) 430 if (model_)
420 model_->RemoveObserver(this); 431 model_->RemoveObserver(this);
421 StopShowFolderDropMenuTimer(); 432 StopShowFolderDropMenuTimer();
422 if (popup_) 433 if (popup_)
423 popup_->GetWidget()->RemoveObserver(this); 434 popup_->GetWidget()->RemoveObserver(this);
424 HidePopup(); 435 HidePopup();
425 DeleteBrowserActionViews(); 436 DeleteBrowserActionViews();
426 } 437 }
427 438
428 // Static.
429 void BrowserActionsContainer::RegisterUserPrefs(PrefService* prefs) {
430 prefs->RegisterIntegerPref(prefs::kBrowserActionContainerWidth,
431 0,
432 PrefService::UNSYNCABLE_PREF);
433 }
434
435 void BrowserActionsContainer::Init() { 439 void BrowserActionsContainer::Init() {
436 LoadImages(); 440 LoadImages();
437 441
442 if (!profile_->GetPrefs()->FindPreference(
443 prefs::kBrowserActionContainerWidth))
444 RegisterUserPrefs(profile_->GetPrefs());
445
438 // We wait to set the container width until now so that the chevron images 446 // We wait to set the container width until now so that the chevron images
439 // will be loaded. The width calculation needs to know the chevron size. 447 // will be loaded. The width calculation needs to know the chevron size.
440 if (model_ && 448 if (model_ &&
441 !profile_->GetPrefs()->HasPrefPath(prefs::kExtensionToolbarSize)) { 449 !profile_->GetPrefs()->HasPrefPath(prefs::kExtensionToolbarSize)) {
442 // Migration code to the new VisibleIconCount pref. 450 // Migration code to the new VisibleIconCount pref.
443 // TODO(mpcomplete): remove this after users are upgraded to 5.0. 451 // TODO(mpcomplete): remove this after users are upgraded to 5.0.
444 int predefined_width = 452 int predefined_width =
445 profile_->GetPrefs()->GetInteger(prefs::kBrowserActionContainerWidth); 453 profile_->GetPrefs()->GetInteger(prefs::kBrowserActionContainerWidth);
446 if (predefined_width != 0) 454 if (predefined_width != 0)
447 model_->SetVisibleIconCount(WidthToIconCount(predefined_width)); 455 model_->SetVisibleIconCount(WidthToIconCount(predefined_width));
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
1124 } 1132 }
1125 } 1133 }
1126 1134
1127 bool BrowserActionsContainer::ShouldDisplayBrowserAction( 1135 bool BrowserActionsContainer::ShouldDisplayBrowserAction(
1128 const Extension* extension) { 1136 const Extension* extension) {
1129 // Only display incognito-enabled extensions while in incognito mode. 1137 // Only display incognito-enabled extensions while in incognito mode.
1130 return 1138 return
1131 (!profile_->IsOffTheRecord() || 1139 (!profile_->IsOffTheRecord() ||
1132 profile_->GetExtensionService()->IsIncognitoEnabled(extension->id())); 1140 profile_->GetExtensionService()->IsIncognitoEnabled(extension->id()));
1133 } 1141 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/browser_actions_container.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698