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

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

Issue 9586018: Add support for multiple icon sizes for Mac platform apps (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix build Created 8 years, 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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"
11 #include "base/sys_string_conversions.h" 11 #include "base/sys_string_conversions.h"
12 #include "chrome/browser/extensions/image_loading_tracker.h" 12 #include "chrome/browser/extensions/image_loading_tracker.h"
13 #include "chrome/browser/ui/cocoa/extensions/extension_action_context_menu.h" 13 #include "chrome/browser/ui/cocoa/extensions/extension_action_context_menu.h"
14 #import "chrome/browser/ui/cocoa/image_utils.h" 14 #import "chrome/browser/ui/cocoa/image_utils.h"
15 #include "chrome/common/chrome_notification_types.h" 15 #include "chrome/common/chrome_notification_types.h"
16 #include "chrome/common/extensions/extension.h" 16 #include "chrome/common/extensions/extension.h"
17 #include "chrome/common/extensions/extension_action.h" 17 #include "chrome/common/extensions/extension_action.h"
18 #include "chrome/common/extensions/extension_resource.h" 18 #include "chrome/common/extensions/extension_resource.h"
19 #include "content/public/browser/notification_observer.h" 19 #include "content/public/browser/notification_observer.h"
20 #include "content/public/browser/notification_registrar.h" 20 #include "content/public/browser/notification_registrar.h"
21 #include "content/public/browser/notification_source.h" 21 #include "content/public/browser/notification_source.h"
22 #include "skia/ext/skia_utils_mac.h" 22 #include "skia/ext/skia_utils_mac.h"
23 #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h" 23 #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h"
24 #include "ui/gfx/canvas_skia_paint.h" 24 #include "ui/gfx/canvas_skia_paint.h"
25 #include "ui/gfx/image/image.h"
25 #include "ui/gfx/rect.h" 26 #include "ui/gfx/rect.h"
26 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" 27 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
27 #include "ui/gfx/size.h" 28 #include "ui/gfx/size.h"
28 29
29 NSString* const kBrowserActionButtonUpdatedNotification = 30 NSString* const kBrowserActionButtonUpdatedNotification =
30 @"BrowserActionButtonUpdatedNotification"; 31 @"BrowserActionButtonUpdatedNotification";
31 32
32 NSString* const kBrowserActionButtonDraggingNotification = 33 NSString* const kBrowserActionButtonDraggingNotification =
33 @"BrowserActionButtonDraggingNotification"; 34 @"BrowserActionButtonDraggingNotification";
34 NSString* const kBrowserActionButtonDragEndNotification = 35 NSString* const kBrowserActionButtonDragEndNotification =
(...skipping 24 matching lines...) Expand all
59 ImageLoadingTracker::DONT_CACHE); 60 ImageLoadingTracker::DONT_CACHE);
60 } 61 }
61 registrar_.Add( 62 registrar_.Add(
62 this, chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED, 63 this, chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED,
63 content::Source<ExtensionAction>(extension->browser_action())); 64 content::Source<ExtensionAction>(extension->browser_action()));
64 } 65 }
65 66
66 ~ExtensionImageTrackerBridge() {} 67 ~ExtensionImageTrackerBridge() {}
67 68
68 // ImageLoadingTracker::Observer implementation. 69 // ImageLoadingTracker::Observer implementation.
69 void OnImageLoaded(SkBitmap* image, const ExtensionResource& resource, 70 void OnImageLoaded(const gfx::Image& image,
70 int index) { 71 const std::string& extension_id,
71 if (image) 72 int index) OVERRIDE {
72 [owner_ setDefaultIcon:gfx::SkBitmapToNSImage(*image)]; 73 if (!image.IsEmpty())
74 [owner_ setDefaultIcon:image.ToNSImage()];
73 [owner_ updateState]; 75 [owner_ updateState];
74 } 76 }
75 77
76 // Overridden from content::NotificationObserver. 78 // Overridden from content::NotificationObserver.
77 void Observe(int type, 79 void Observe(int type,
78 const content::NotificationSource& source, 80 const content::NotificationSource& source,
79 const content::NotificationDetails& details) { 81 const content::NotificationDetails& details) {
80 if (type == chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED) 82 if (type == chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED)
81 [owner_ updateState]; 83 [owner_ updateState];
82 else 84 else
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 } 316 }
315 317
316 - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { 318 - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView {
317 gfx::ScopedNSGraphicsContextSaveGState scopedGState; 319 gfx::ScopedNSGraphicsContextSaveGState scopedGState;
318 [super drawInteriorWithFrame:cellFrame inView:controlView]; 320 [super drawInteriorWithFrame:cellFrame inView:controlView];
319 cellFrame.origin.y += kBrowserActionBadgeOriginYOffset; 321 cellFrame.origin.y += kBrowserActionBadgeOriginYOffset;
320 [self drawBadgeWithinFrame:cellFrame]; 322 [self drawBadgeWithinFrame:cellFrame];
321 } 323 }
322 324
323 @end 325 @end
OLDNEW
« no previous file with comments | « chrome/browser/shell_integration_linux.cc ('k') | chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698