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

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

Issue 448004: Merge 32980 - o Updates the browser action buttons when a tab is changed. Thi... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/249/src/
Patch Set: Created 11 years 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "app/gfx/canvas_paint.h" 9 #include "app/gfx/canvas_paint.h"
10 #include "base/sys_string_conversions.h" 10 #include "base/sys_string_conversions.h"
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 - (void)setTabSpecificIcon:(NSImage*)image { 207 - (void)setTabSpecificIcon:(NSImage*)image {
208 tabSpecificIcon_.reset([image retain]); 208 tabSpecificIcon_.reset([image retain]);
209 } 209 }
210 210
211 - (void)updateState { 211 - (void)updateState {
212 int tabId = [controller_ currentTabId]; 212 int tabId = [controller_ currentTabId];
213 if (tabId < 0) 213 if (tabId < 0)
214 return; 214 return;
215 215
216 std::string tooltip = extension_->browser_action()->GetTitle(tabId); 216 std::string tooltip = extension_->browser_action()->GetTitle(tabId);
217 if (!tooltip.empty()) 217 if (tooltip.empty()) {
218 [self setToolTip:nil];
219 } else {
218 [self setToolTip:base::SysUTF8ToNSString(tooltip)]; 220 [self setToolTip:base::SysUTF8ToNSString(tooltip)];
221 }
219 222
220 SkBitmap image = extension_->browser_action()->GetIcon(tabId); 223 SkBitmap image = extension_->browser_action()->GetIcon(tabId);
221 if (!image.isNull()) { 224 if (!image.isNull()) {
222 [self setTabSpecificIcon:gfx::SkBitmapToNSImage(image)]; 225 [self setTabSpecificIcon:gfx::SkBitmapToNSImage(image)];
223 [self setImage:tabSpecificIcon_]; 226 [self setImage:tabSpecificIcon_];
224 } else if (defaultIcon_) { 227 } else if (defaultIcon_) {
225 [self setImage:defaultIcon_]; 228 [self setImage:defaultIcon_];
226 } 229 }
227 230
228 [badgeView_ setTabId:tabId]; 231 [badgeView_ setTabId:tabId];
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 containerView_ = container; 314 containerView_ = container;
312 [containerView_ setHidden:YES]; 315 [containerView_ setHidden:YES];
313 observer_.reset(new ExtensionsServiceObserverBridge(self, profile_)); 316 observer_.reset(new ExtensionsServiceObserverBridge(self, profile_));
314 buttons_.reset([[NSMutableDictionary alloc] init]); 317 buttons_.reset([[NSMutableDictionary alloc] init]);
315 buttonOrder_.reset([[NSMutableArray alloc] init]); 318 buttonOrder_.reset([[NSMutableArray alloc] init]);
316 } 319 }
317 320
318 return self; 321 return self;
319 } 322 }
320 323
324 - (void)update {
325 for (BrowserActionButton* button in [buttons_ allValues]) {
326 [button updateState];
327 }
328 }
329
321 - (void)hidePopup { 330 - (void)hidePopup {
322 [popupController_ close]; 331 [popupController_ close];
323 popupController_ = nil; 332 popupController_ = nil;
324 } 333 }
325 334
326 - (ExtensionPopupController*)popup { 335 - (ExtensionPopupController*)popup {
327 return popupController_; 336 return popupController_;
328 } 337 }
329 338
330 - (void)browserActionVisibilityHasChanged { 339 - (void)browserActionVisibilityHasChanged {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 454
446 - (int)currentTabId { 455 - (int)currentTabId {
447 TabContents* selected_tab = browser_->GetSelectedTabContents(); 456 TabContents* selected_tab = browser_->GetSelectedTabContents();
448 if (!selected_tab) 457 if (!selected_tab)
449 return -1; 458 return -1;
450 459
451 return selected_tab->controller().session_id().id(); 460 return selected_tab->controller().session_id().id();
452 } 461 }
453 462
454 @end 463 @end
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/extensions/browser_actions_controller.h ('k') | chrome/browser/cocoa/toolbar_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698