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

Side by Side Diff: chrome/browser/ui/views/toolbar/browser_action_view.cc

Issue 148143004: Add notification mechanism when BrowserActionButton's icon has been updated. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "chrome/browser/ui/views/toolbar/browser_action_view.h" 5 #include "chrome/browser/ui/views/toolbar/browser_action_view.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/chrome_notification_types.h" 8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/extensions/api/commands/command_service.h" 9 #include "chrome/browser/extensions/api/commands/command_service.h"
10 #include "chrome/browser/extensions/dev_mode_bubble_controller.h" 10 #include "chrome/browser/extensions/dev_mode_bubble_controller.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 } 108 }
109 109
110 //////////////////////////////////////////////////////////////////////////////// 110 ////////////////////////////////////////////////////////////////////////////////
111 // BrowserActionButton 111 // BrowserActionButton
112 112
113 BrowserActionButton::BrowserActionButton(const Extension* extension, 113 BrowserActionButton::BrowserActionButton(const Extension* extension,
114 Browser* browser, 114 Browser* browser,
115 BrowserActionView::Delegate* delegate) 115 BrowserActionView::Delegate* delegate)
116 : MenuButton(this, base::string16(), NULL, false), 116 : MenuButton(this, base::string16(), NULL, false),
117 browser_(browser), 117 browser_(browser),
118 icon_observer_(NULL),
Finnur 2014/02/10 11:20:57 Move this line down one to avoid compile error see
118 browser_action_( 119 browser_action_(
119 extensions::ExtensionActionManager::Get(browser->profile())-> 120 extensions::ExtensionActionManager::Get(browser->profile())->
120 GetBrowserAction(*extension)), 121 GetBrowserAction(*extension)),
121 extension_(extension), 122 extension_(extension),
122 icon_factory_(browser->profile(), extension, browser_action_, this), 123 icon_factory_(browser->profile(), extension, browser_action_, this),
123 delegate_(delegate), 124 delegate_(delegate),
124 context_menu_(NULL), 125 context_menu_(NULL),
125 called_registered_extension_command_(false) { 126 called_registered_extension_command_(false) {
126 SetBorder(views::Border::NullBorder()); 127 SetBorder(views::Border::NullBorder());
127 set_alignment(TextButton::ALIGN_CENTER); 128 set_alignment(TextButton::ALIGN_CENTER);
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 UpdateState(); 305 UpdateState();
305 break; 306 break;
306 default: 307 default:
307 NOTREACHED(); 308 NOTREACHED();
308 break; 309 break;
309 } 310 }
310 } 311 }
311 312
312 void BrowserActionButton::OnIconUpdated() { 313 void BrowserActionButton::OnIconUpdated() {
313 UpdateState(); 314 UpdateState();
315 if (icon_observer_) {
316 int tab_id = delegate_->GetCurrentTabId();
317 gfx::Size spacing(0, ToolbarView::kVertSpacing);
318 gfx::ImageSkia icon = *icon_factory_.GetIcon(tab_id).ToImageSkia();
319 if (!IsEnabled(tab_id))
320 icon = gfx::ImageSkiaOperations::CreateTransparentImage(icon, .25);
Finnur 2014/02/10 10:41:41 This is copied almost verbatim from GetIconWithBad
321 icon_observer_->OnIconUpdated(
322 browser_action_->GetIconWithBadge(icon, tab_id, spacing));
323 }
314 } 324 }
315 325
316 bool BrowserActionButton::Activate() { 326 bool BrowserActionButton::Activate() {
317 if (!IsPopup()) 327 if (!IsPopup())
318 return true; 328 return true;
319 329
320 delegate_->OnBrowserActionExecuted(this); 330 delegate_->OnBrowserActionExecuted(this);
321 331
322 // TODO(erikkay): Run a nested modal loop while the mouse is down to 332 // TODO(erikkay): Run a nested modal loop while the mouse is down to
323 // enable menu-like drag-select behavior. 333 // enable menu-like drag-select behavior.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 extensions::Command browser_action_command; 436 extensions::Command browser_action_command;
427 if (!only_if_active || !command_service->GetBrowserActionCommand( 437 if (!only_if_active || !command_service->GetBrowserActionCommand(
428 extension_->id(), 438 extension_->id(),
429 extensions::CommandService::ACTIVE_ONLY, 439 extensions::CommandService::ACTIVE_ONLY,
430 &browser_action_command, 440 &browser_action_command,
431 NULL)) { 441 NULL)) {
432 GetFocusManager()->UnregisterAccelerator(*keybinding_.get(), this); 442 GetFocusManager()->UnregisterAccelerator(*keybinding_.get(), this);
433 keybinding_.reset(NULL); 443 keybinding_.reset(NULL);
434 } 444 }
435 } 445 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698