OLD | NEW |
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/extensions/extension.h" | 15 #include "chrome/common/extensions/extension.h" |
16 #include "chrome/common/extensions/extension_action.h" | 16 #include "chrome/common/extensions/extension_action.h" |
17 #include "chrome/common/extensions/extension_resource.h" | 17 #include "chrome/common/extensions/extension_resource.h" |
18 #include "content/common/notification_observer.h" | 18 #include "content/common/notification_observer.h" |
19 #include "content/common/notification_registrar.h" | 19 #include "content/common/notification_registrar.h" |
20 #include "content/common/notification_source.h" | 20 #include "content/common/notification_source.h" |
21 #include "content/common/notification_type.h" | 21 #include "content/common/notification_type.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/rect.h" | 25 #include "ui/gfx/rect.h" |
| 26 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
26 #include "ui/gfx/size.h" | 27 #include "ui/gfx/size.h" |
27 | 28 |
28 NSString* const kBrowserActionButtonUpdatedNotification = | 29 NSString* const kBrowserActionButtonUpdatedNotification = |
29 @"BrowserActionButtonUpdatedNotification"; | 30 @"BrowserActionButtonUpdatedNotification"; |
30 | 31 |
31 NSString* const kBrowserActionButtonDraggingNotification = | 32 NSString* const kBrowserActionButtonDraggingNotification = |
32 @"BrowserActionButtonDraggingNotification"; | 33 @"BrowserActionButtonDraggingNotification"; |
33 NSString* const kBrowserActionButtonDragEndNotification = | 34 NSString* const kBrowserActionButtonDragEndNotification = |
34 @"BrowserActionButtonDragEndNotification"; | 35 @"BrowserActionButtonDragEndNotification"; |
35 | 36 |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 @synthesize extensionAction = extensionAction_; | 303 @synthesize extensionAction = extensionAction_; |
303 | 304 |
304 - (void)drawBadgeWithinFrame:(NSRect)frame { | 305 - (void)drawBadgeWithinFrame:(NSRect)frame { |
305 gfx::CanvasSkiaPaint canvas(frame, false); | 306 gfx::CanvasSkiaPaint canvas(frame, false); |
306 canvas.set_composite_alpha(true); | 307 canvas.set_composite_alpha(true); |
307 gfx::Rect boundingRect(NSRectToCGRect(frame)); | 308 gfx::Rect boundingRect(NSRectToCGRect(frame)); |
308 extensionAction_->PaintBadge(&canvas, boundingRect, tabId_); | 309 extensionAction_->PaintBadge(&canvas, boundingRect, tabId_); |
309 } | 310 } |
310 | 311 |
311 - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { | 312 - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { |
312 [NSGraphicsContext saveGraphicsState]; | 313 gfx::ScopedNSGraphicsContextSaveGState scopedGState; |
313 [super drawInteriorWithFrame:cellFrame inView:controlView]; | 314 [super drawInteriorWithFrame:cellFrame inView:controlView]; |
314 cellFrame.origin.y += kBrowserActionBadgeOriginYOffset; | 315 cellFrame.origin.y += kBrowserActionBadgeOriginYOffset; |
315 [self drawBadgeWithinFrame:cellFrame]; | 316 [self drawBadgeWithinFrame:cellFrame]; |
316 [NSGraphicsContext restoreGraphicsState]; | |
317 } | 317 } |
318 | 318 |
319 @end | 319 @end |
OLD | NEW |