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

Side by Side Diff: chrome/browser/cocoa/extensions/browser_actions_controller.mm

Issue 567037: Initial work on making extensions work in incognito mode. (Closed)
Patch Set: added experimental requirement Created 10 years, 10 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
« no previous file with comments | « no previous file | chrome/browser/extensions/browser_action_apitest.cc » ('j') | 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) 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 <string> 7 #include <string>
8 8
9 #include "base/sys_string_conversions.h" 9 #include "base/sys_string_conversions.h"
10 #include "chrome/browser/browser.h" 10 #include "chrome/browser/browser.h"
(...skipping 12 matching lines...) Expand all
23 extern const CGFloat kBrowserActionButtonPadding = 3; 23 extern const CGFloat kBrowserActionButtonPadding = 3;
24 24
25 NSString* const kBrowserActionsChangedNotification = @"BrowserActionsChanged"; 25 NSString* const kBrowserActionsChangedNotification = @"BrowserActionsChanged";
26 26
27 @interface BrowserActionsController(Private) 27 @interface BrowserActionsController(Private)
28 - (void)createActionButtonForExtension:(Extension*)extension 28 - (void)createActionButtonForExtension:(Extension*)extension
29 withIndex:(int)index; 29 withIndex:(int)index;
30 - (void)removeActionButtonForExtension:(Extension*)extension; 30 - (void)removeActionButtonForExtension:(Extension*)extension;
31 - (void)repositionActionButtons; 31 - (void)repositionActionButtons;
32 - (int)currentTabId; 32 - (int)currentTabId;
33 - (bool)shouldDisplayBrowserAction:(Extension*)extension;
33 @end 34 @end
34 35
35 // A helper class to proxy extension notifications to the view controller's 36 // A helper class to proxy extension notifications to the view controller's
36 // appropriate methods. 37 // appropriate methods.
37 class ExtensionsServiceObserverBridge : public NotificationObserver, 38 class ExtensionsServiceObserverBridge : public NotificationObserver,
38 public ExtensionToolbarModel::Observer { 39 public ExtensionToolbarModel::Observer {
39 public: 40 public:
40 ExtensionsServiceObserverBridge(BrowserActionsController* owner, 41 ExtensionsServiceObserverBridge(BrowserActionsController* owner,
41 Profile* profile) : owner_(owner) { 42 Profile* profile) : owner_(owner) {
42 registrar_.Add(this, NotificationType::EXTENSION_HOST_VIEW_SHOULD_CLOSE, 43 registrar_.Add(this, NotificationType::EXTENSION_HOST_VIEW_SHOULD_CLOSE,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 iter != toolbarModel_->end(); ++iter) { 133 iter != toolbarModel_->end(); ++iter) {
133 [self createActionButtonForExtension:*iter withIndex:i++]; 134 [self createActionButtonForExtension:*iter withIndex:i++];
134 } 135 }
135 } 136 }
136 137
137 - (void)createActionButtonForExtension:(Extension*)extension 138 - (void)createActionButtonForExtension:(Extension*)extension
138 withIndex:(int)index { 139 withIndex:(int)index {
139 if (!extension->browser_action()) 140 if (!extension->browser_action())
140 return; 141 return;
141 142
143 if (![self shouldDisplayBrowserAction:extension])
144 return;
145
142 // Show the container if it's the first button. Otherwise it will be shown 146 // Show the container if it's the first button. Otherwise it will be shown
143 // already. 147 // already.
144 if ([buttons_ count] == 0) 148 if ([buttons_ count] == 0)
145 [containerView_ setHidden:NO]; 149 [containerView_ setHidden:NO];
146 150
147 BrowserActionButton* newButton = [[[BrowserActionButton alloc] 151 BrowserActionButton* newButton = [[[BrowserActionButton alloc]
148 initWithExtension:extension 152 initWithExtension:extension
149 profile:profile_ 153 profile:profile_
150 tabId:[self currentTabId]] autorelease]; 154 tabId:[self currentTabId]] autorelease];
151 [newButton setTarget:self]; 155 [newButton setTarget:self];
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 return button; 263 return button;
260 } 264 }
261 NOTREACHED(); 265 NOTREACHED();
262 return nil; 266 return nil;
263 } 267 }
264 268
265 - (NSButton*)buttonWithIndex:(int)index { 269 - (NSButton*)buttonWithIndex:(int)index {
266 return [buttonOrder_ objectAtIndex:(NSUInteger)index]; 270 return [buttonOrder_ objectAtIndex:(NSUInteger)index];
267 } 271 }
268 272
273 - (bool)shouldDisplayBrowserAction:(Extension*)extension {
274 return (!profile_->IsOffTheRecord() ||
275 profile_->GetExtensionsService()->
276 IsIncognitoEnabled(extension->id()));
277 }
278
269 @end 279 @end
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/browser_action_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698