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

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

Issue 595017: [Mac] Use the ExtensionToolbarModel for ordering of the Browser Actions. Prep... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Remove redundant profile object. 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 | Annotate | Revision Log
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 "chrome/browser/cocoa/extensions/browser_action_button.h" 5 #import "chrome/browser/cocoa/extensions/browser_action_button.h"
6 6
7 #include "app/gfx/canvas_paint.h" 7 #include "app/gfx/canvas_paint.h"
8 #include "base/gfx/rect.h" 8 #include "base/gfx/rect.h"
9 #include "base/gfx/size.h" 9 #include "base/gfx/size.h"
10 #include "base/sys_string_conversions.h" 10 #include "base/sys_string_conversions.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 DISALLOW_COPY_AND_ASSIGN(ExtensionImageTrackerBridge); 85 DISALLOW_COPY_AND_ASSIGN(ExtensionImageTrackerBridge);
86 }; 86 };
87 87
88 @implementation BrowserActionButton 88 @implementation BrowserActionButton
89 89
90 + (Class)cellClass { 90 + (Class)cellClass {
91 return [BrowserActionCell class]; 91 return [BrowserActionCell class];
92 } 92 }
93 93
94 - (id)initWithExtension:(Extension*)extension 94 - (id)initWithExtension:(Extension*)extension
95 tabId:(int)tabId 95 profile:(Profile*)profile
96 xOffset:(int)xOffset { 96 tabId:(int)tabId {
97 NSRect frame = NSMakeRect(xOffset, 97 NSRect frame = NSMakeRect(0.0,
98 kBrowserActionOriginYOffset, 98 kBrowserActionOriginYOffset,
99 kBrowserActionWidth, 99 kBrowserActionWidth,
100 kBrowserActionHeight); 100 kBrowserActionHeight);
101 if ((self = [super initWithFrame:frame])) { 101 if ((self = [super initWithFrame:frame])) {
102 BrowserActionCell* cell = [[[BrowserActionCell alloc] init] autorelease]; 102 BrowserActionCell* cell = [[[BrowserActionCell alloc] init] autorelease];
103 // [NSButton setCell:] warns to NOT use setCell: other than in the 103 // [NSButton setCell:] warns to NOT use setCell: other than in the
104 // initializer of a control. However, we are using a basic 104 // initializer of a control. However, we are using a basic
105 // NSButton whose initializer does not take an NSCell as an 105 // NSButton whose initializer does not take an NSCell as an
106 // object. To honor the assumed semantics, we do nothing with 106 // object. To honor the assumed semantics, we do nothing with
107 // NSButton between alloc/init and setCell:. 107 // NSButton between alloc/init and setCell:.
108 [self setCell:cell]; 108 [self setCell:cell];
109 [cell setTabId:tabId]; 109 [cell setTabId:tabId];
110 [cell setExtensionAction:extension->browser_action()]; 110 [cell setExtensionAction:extension->browser_action()];
111 111
112 [self setTitle:@""]; 112 [self setTitle:@""];
113 [self setButtonType:NSMomentaryChangeButton]; 113 [self setButtonType:NSMomentaryChangeButton];
114 [self setShowsBorderOnlyWhileMouseInside:YES]; 114 [self setShowsBorderOnlyWhileMouseInside:YES];
115 115
116 [self setMenu:[[[ExtensionActionContextMenu alloc] 116 [self setMenu:[[[ExtensionActionContextMenu alloc]
117 initWithExtension:extension] autorelease]]; 117 initWithExtension:extension profile:profile] autorelease]];
118 118
119 tabId_ = tabId; 119 tabId_ = tabId;
120 extension_ = extension; 120 extension_ = extension;
121 imageLoadingBridge_.reset(new ExtensionImageTrackerBridge(self, extension)); 121 imageLoadingBridge_.reset(new ExtensionImageTrackerBridge(self, extension));
122 122
123 [self updateState]; 123 [self updateState];
124 } 124 }
125 125
126 return self; 126 return self;
127 } 127 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 extensionAction_->PaintBadge(&canvas, boundingRect, tabId_); 187 extensionAction_->PaintBadge(&canvas, boundingRect, tabId_);
188 } 188 }
189 189
190 [NSGraphicsContext restoreGraphicsState]; 190 [NSGraphicsContext restoreGraphicsState];
191 } 191 }
192 192
193 @synthesize tabId = tabId_; 193 @synthesize tabId = tabId_;
194 @synthesize extensionAction = extensionAction_; 194 @synthesize extensionAction = extensionAction_;
195 195
196 @end 196 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698