| 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_action_button.h" | 5 #import "chrome/browser/ui/cocoa/extensions/browser_action_button.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 class ExtensionActionIconFactoryBridge | 45 class ExtensionActionIconFactoryBridge |
| 46 : public content::NotificationObserver, | 46 : public content::NotificationObserver, |
| 47 public ExtensionActionIconFactory::Observer { | 47 public ExtensionActionIconFactory::Observer { |
| 48 public: | 48 public: |
| 49 ExtensionActionIconFactoryBridge(BrowserActionButton* owner, | 49 ExtensionActionIconFactoryBridge(BrowserActionButton* owner, |
| 50 Profile* profile, | 50 Profile* profile, |
| 51 const Extension* extension) | 51 const Extension* extension) |
| 52 : owner_(owner), | 52 : owner_(owner), |
| 53 browser_action_([[owner cell] extensionAction]), | 53 browser_action_([[owner cell] extensionAction]), |
| 54 icon_factory_(profile, extension, browser_action_, this) { | 54 icon_factory_(profile, extension, browser_action_, this) { |
| 55 registrar_.Add( | 55 registrar_.Add(this, |
| 56 this, chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED, | 56 extensions::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED, |
| 57 content::Source<ExtensionAction>(browser_action_)); | 57 content::Source<ExtensionAction>(browser_action_)); |
| 58 } | 58 } |
| 59 | 59 |
| 60 virtual ~ExtensionActionIconFactoryBridge() {} | 60 virtual ~ExtensionActionIconFactoryBridge() {} |
| 61 | 61 |
| 62 // ExtensionActionIconFactory::Observer implementation. | 62 // ExtensionActionIconFactory::Observer implementation. |
| 63 virtual void OnIconUpdated() OVERRIDE { | 63 virtual void OnIconUpdated() OVERRIDE { |
| 64 [owner_ updateState]; | 64 [owner_ updateState]; |
| 65 } | 65 } |
| 66 | 66 |
| 67 // Overridden from content::NotificationObserver. | 67 // Overridden from content::NotificationObserver. |
| 68 virtual void Observe( | 68 virtual void Observe( |
| 69 int type, | 69 int type, |
| 70 const content::NotificationSource& source, | 70 const content::NotificationSource& source, |
| 71 const content::NotificationDetails& details) OVERRIDE { | 71 const content::NotificationDetails& details) OVERRIDE { |
| 72 if (type == chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED) | 72 if (type == extensions::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED) |
| 73 [owner_ updateState]; | 73 [owner_ updateState]; |
| 74 else | 74 else |
| 75 NOTREACHED(); | 75 NOTREACHED(); |
| 76 } | 76 } |
| 77 | 77 |
| 78 gfx::Image GetIcon(int tabId) { | 78 gfx::Image GetIcon(int tabId) { |
| 79 return icon_factory_.GetIcon(tabId); | 79 return icon_factory_.GetIcon(tabId); |
| 80 } | 80 } |
| 81 | 81 |
| 82 private: | 82 private: |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 operation:NSCompositeSourceOver | 353 operation:NSCompositeSourceOver |
| 354 fraction:enabled ? 1.0 : 0.4 | 354 fraction:enabled ? 1.0 : 0.4 |
| 355 respectFlipped:YES | 355 respectFlipped:YES |
| 356 hints:nil]; | 356 hints:nil]; |
| 357 | 357 |
| 358 cellFrame.origin.y += kBrowserActionBadgeOriginYOffset; | 358 cellFrame.origin.y += kBrowserActionBadgeOriginYOffset; |
| 359 [self drawBadgeWithinFrame:cellFrame]; | 359 [self drawBadgeWithinFrame:cellFrame]; |
| 360 } | 360 } |
| 361 | 361 |
| 362 @end | 362 @end |
| OLD | NEW |