| 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 "chrome/browser/ui/cocoa/extensions/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" |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 | 275 |
| 276 - (id)initWithBrowser:(Browser*)browser | 276 - (id)initWithBrowser:(Browser*)browser |
| 277 containerView:(BrowserActionsContainerView*)container { | 277 containerView:(BrowserActionsContainerView*)container { |
| 278 DCHECK(browser && container); | 278 DCHECK(browser && container); |
| 279 | 279 |
| 280 if ((self = [super init])) { | 280 if ((self = [super init])) { |
| 281 browser_ = browser; | 281 browser_ = browser; |
| 282 profile_ = browser->profile(); | 282 profile_ = browser->profile(); |
| 283 | 283 |
| 284 observer_.reset(new ExtensionServiceObserverBridge(self, browser_)); | 284 observer_.reset(new ExtensionServiceObserverBridge(self, browser_)); |
| 285 ExtensionService* extensionService = | 285 toolbarModel_ = ExtensionToolbarModel::Get(profile_); |
| 286 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 286 if (toolbarModel_) |
| 287 // |extensionService| can be NULL in Incognito. | |
| 288 if (extensionService) { | |
| 289 toolbarModel_ = extensionService->toolbar_model(); | |
| 290 toolbarModel_->AddObserver(observer_.get()); | 287 toolbarModel_->AddObserver(observer_.get()); |
| 291 } | |
| 292 | 288 |
| 293 containerView_ = container; | 289 containerView_ = container; |
| 294 [containerView_ setPostsFrameChangedNotifications:YES]; | 290 [containerView_ setPostsFrameChangedNotifications:YES]; |
| 295 [[NSNotificationCenter defaultCenter] | 291 [[NSNotificationCenter defaultCenter] |
| 296 addObserver:self | 292 addObserver:self |
| 297 selector:@selector(containerFrameChanged:) | 293 selector:@selector(containerFrameChanged:) |
| 298 name:NSViewFrameDidChangeNotification | 294 name:NSViewFrameDidChangeNotification |
| 299 object:containerView_]; | 295 object:containerView_]; |
| 300 [[NSNotificationCenter defaultCenter] | 296 [[NSNotificationCenter defaultCenter] |
| 301 addObserver:self | 297 addObserver:self |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 887 const extensions::ExtensionList& toolbar_items = | 883 const extensions::ExtensionList& toolbar_items = |
| 888 toolbarModel_->toolbar_items(); | 884 toolbarModel_->toolbar_items(); |
| 889 if (index < toolbar_items.size()) { | 885 if (index < toolbar_items.size()) { |
| 890 const Extension* extension = toolbar_items[index].get(); | 886 const Extension* extension = toolbar_items[index].get(); |
| 891 return [buttons_ objectForKey:base::SysUTF8ToNSString(extension->id())]; | 887 return [buttons_ objectForKey:base::SysUTF8ToNSString(extension->id())]; |
| 892 } | 888 } |
| 893 return nil; | 889 return nil; |
| 894 } | 890 } |
| 895 | 891 |
| 896 @end | 892 @end |
| OLD | NEW |