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 #import "browser_actions_controller.h" | 5 #import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
11 #include "base/strings/sys_string_conversions.h" | 11 #include "base/strings/sys_string_conversions.h" |
12 #include "chrome/browser/extensions/extension_action.h" | 12 #include "chrome/browser/extensions/extension_action.h" |
13 #include "chrome/browser/extensions/extension_action_manager.h" | 13 #include "chrome/browser/extensions/extension_action_manager.h" |
14 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
15 #include "chrome/browser/extensions/extension_system.h" | 15 #include "chrome/browser/extensions/extension_system.h" |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 DCHECK(browser && container); | 264 DCHECK(browser && container); |
265 | 265 |
266 if ((self = [super init])) { | 266 if ((self = [super init])) { |
267 browser_ = browser; | 267 browser_ = browser; |
268 profile_ = browser->profile(); | 268 profile_ = browser->profile(); |
269 | 269 |
270 // TODO(joi): Do all registrations up front. | 270 // TODO(joi): Do all registrations up front. |
271 if (!profile_->GetPrefs()->FindPreference( | 271 if (!profile_->GetPrefs()->FindPreference( |
272 prefs::kBrowserActionContainerWidth)) | 272 prefs::kBrowserActionContainerWidth)) |
273 [BrowserActionsController registerUserPrefs:( | 273 [BrowserActionsController registerUserPrefs:( |
274 (PrefRegistrySyncable*) | 274 (user_prefs::PrefRegistrySyncable*) |
275 profile_->GetPrefs()->DeprecatedGetPrefRegistry())]; | 275 profile_->GetPrefs()->DeprecatedGetPrefRegistry())]; |
276 | 276 |
277 observer_.reset(new ExtensionServiceObserverBridge(self, browser_)); | 277 observer_.reset(new ExtensionServiceObserverBridge(self, browser_)); |
278 ExtensionService* extensionService = | 278 ExtensionService* extensionService = |
279 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 279 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
280 // |extensionService| can be NULL in Incognito. | 280 // |extensionService| can be NULL in Incognito. |
281 if (extensionService) { | 281 if (extensionService) { |
282 toolbarModel_ = extensionService->toolbar_model(); | 282 toolbarModel_ = extensionService->toolbar_model(); |
283 toolbarModel_->AddObserver(observer_.get()); | 283 toolbarModel_->AddObserver(observer_.get()); |
284 } | 284 } |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 if (effect == NSViewAnimationFadeInEffect) { | 440 if (effect == NSViewAnimationFadeInEffect) { |
441 return NO; | 441 return NO; |
442 } else if (effect == NSViewAnimationFadeOutEffect) { | 442 } else if (effect == NSViewAnimationFadeOutEffect) { |
443 return YES; | 443 return YES; |
444 } | 444 } |
445 | 445 |
446 NOTREACHED(); | 446 NOTREACHED(); |
447 return YES; | 447 return YES; |
448 } | 448 } |
449 | 449 |
450 + (void)registerUserPrefs:(PrefRegistrySyncable*)registry { | 450 + (void)registerUserPrefs:(user_prefs::PrefRegistrySyncable*)registry { |
451 registry->RegisterDoublePref(prefs::kBrowserActionContainerWidth, | 451 registry->RegisterDoublePref( |
452 0, | 452 prefs::kBrowserActionContainerWidth, |
453 PrefRegistrySyncable::UNSYNCABLE_PREF); | 453 0, |
| 454 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
454 } | 455 } |
455 | 456 |
456 #pragma mark - | 457 #pragma mark - |
457 #pragma mark NSMenuDelegate | 458 #pragma mark NSMenuDelegate |
458 | 459 |
459 - (void)menuNeedsUpdate:(NSMenu*)menu { | 460 - (void)menuNeedsUpdate:(NSMenu*)menu { |
460 [menu removeAllItems]; | 461 [menu removeAllItems]; |
461 | 462 |
462 // See menu_button.h for documentation on why this is needed. | 463 // See menu_button.h for documentation on why this is needed. |
463 [menu addItemWithTitle:@"" action:nil keyEquivalent:@""]; | 464 [menu addItemWithTitle:@"" action:nil keyEquivalent:@""]; |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 const extensions::ExtensionList& toolbar_items = | 878 const extensions::ExtensionList& toolbar_items = |
878 toolbarModel_->toolbar_items(); | 879 toolbarModel_->toolbar_items(); |
879 if (index < toolbar_items.size()) { | 880 if (index < toolbar_items.size()) { |
880 const Extension* extension = toolbar_items[index]; | 881 const Extension* extension = toolbar_items[index]; |
881 return [buttons_ objectForKey:base::SysUTF8ToNSString(extension->id())]; | 882 return [buttons_ objectForKey:base::SysUTF8ToNSString(extension->id())]; |
882 } | 883 } |
883 return nil; | 884 return nil; |
884 } | 885 } |
885 | 886 |
886 @end | 887 @end |
OLD | NEW |