| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #import "browser_actions_controller.h" | 5 #import "browser_actions_controller.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "app/mac/nsimage_cache.h" | 10 #include "app/mac/nsimage_cache.h" |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 return nil; | 353 return nil; |
| 354 } | 354 } |
| 355 | 355 |
| 356 - (CGFloat)savedWidth { | 356 - (CGFloat)savedWidth { |
| 357 if (!toolbarModel_) | 357 if (!toolbarModel_) |
| 358 return 0; | 358 return 0; |
| 359 if (!profile_->GetPrefs()->HasPrefPath(prefs::kExtensionToolbarSize)) { | 359 if (!profile_->GetPrefs()->HasPrefPath(prefs::kExtensionToolbarSize)) { |
| 360 // Migration code to the new VisibleIconCount pref. | 360 // Migration code to the new VisibleIconCount pref. |
| 361 // TODO(mpcomplete): remove this at some point. | 361 // TODO(mpcomplete): remove this at some point. |
| 362 double predefinedWidth = | 362 double predefinedWidth = |
| 363 profile_->GetPrefs()->GetReal(prefs::kBrowserActionContainerWidth); | 363 profile_->GetPrefs()->GetDouble(prefs::kBrowserActionContainerWidth); |
| 364 if (predefinedWidth != 0) { | 364 if (predefinedWidth != 0) { |
| 365 int iconWidth = kBrowserActionWidth + kBrowserActionButtonPadding; | 365 int iconWidth = kBrowserActionWidth + kBrowserActionButtonPadding; |
| 366 int extraWidth = kChevronWidth; | 366 int extraWidth = kChevronWidth; |
| 367 toolbarModel_->SetVisibleIconCount( | 367 toolbarModel_->SetVisibleIconCount( |
| 368 (predefinedWidth - extraWidth) / iconWidth); | 368 (predefinedWidth - extraWidth) / iconWidth); |
| 369 } | 369 } |
| 370 } | 370 } |
| 371 | 371 |
| 372 int savedButtonCount = toolbarModel_->GetVisibleIconCount(); | 372 int savedButtonCount = toolbarModel_->GetVisibleIconCount(); |
| 373 if (savedButtonCount < 0 || // all icons are visible | 373 if (savedButtonCount < 0 || // all icons are visible |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 return NO; | 412 return NO; |
| 413 } else if (effect == NSViewAnimationFadeOutEffect) { | 413 } else if (effect == NSViewAnimationFadeOutEffect) { |
| 414 return YES; | 414 return YES; |
| 415 } | 415 } |
| 416 | 416 |
| 417 NOTREACHED(); | 417 NOTREACHED(); |
| 418 return YES; | 418 return YES; |
| 419 } | 419 } |
| 420 | 420 |
| 421 + (void)registerUserPrefs:(PrefService*)prefs { | 421 + (void)registerUserPrefs:(PrefService*)prefs { |
| 422 prefs->RegisterRealPref(prefs::kBrowserActionContainerWidth, 0); | 422 prefs->RegisterDoublePref(prefs::kBrowserActionContainerWidth, 0); |
| 423 } | 423 } |
| 424 | 424 |
| 425 #pragma mark - | 425 #pragma mark - |
| 426 #pragma mark Private Methods | 426 #pragma mark Private Methods |
| 427 | 427 |
| 428 - (void)createButtons { | 428 - (void)createButtons { |
| 429 if (!toolbarModel_) | 429 if (!toolbarModel_) |
| 430 return; | 430 return; |
| 431 | 431 |
| 432 NSUInteger i = 0; | 432 NSUInteger i = 0; |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 858 if (profile_->IsOffTheRecord()) | 858 if (profile_->IsOffTheRecord()) |
| 859 index = toolbarModel_->IncognitoIndexToOriginal(index); | 859 index = toolbarModel_->IncognitoIndexToOriginal(index); |
| 860 if (index < toolbarModel_->size()) { | 860 if (index < toolbarModel_->size()) { |
| 861 const Extension* extension = toolbarModel_->GetExtensionByIndex(index); | 861 const Extension* extension = toolbarModel_->GetExtensionByIndex(index); |
| 862 return [buttons_ objectForKey:base::SysUTF8ToNSString(extension->id())]; | 862 return [buttons_ objectForKey:base::SysUTF8ToNSString(extension->id())]; |
| 863 } | 863 } |
| 864 return nil; | 864 return nil; |
| 865 } | 865 } |
| 866 | 866 |
| 867 @end | 867 @end |
| OLD | NEW |