| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 forButtonState:image_button_cell::kHoverState]; | 142 forButtonState:image_button_cell::kHoverState]; |
| 143 [cell setImageID:IDR_BROWSER_ACTION_P | 143 [cell setImageID:IDR_BROWSER_ACTION_P |
| 144 forButtonState:image_button_cell::kPressedState]; | 144 forButtonState:image_button_cell::kPressedState]; |
| 145 [cell setImageID:IDR_BROWSER_ACTION | 145 [cell setImageID:IDR_BROWSER_ACTION |
| 146 forButtonState:image_button_cell::kDisabledState]; | 146 forButtonState:image_button_cell::kDisabledState]; |
| 147 | 147 |
| 148 [self setTitle:@""]; | 148 [self setTitle:@""]; |
| 149 [self setButtonType:NSMomentaryChangeButton]; | 149 [self setButtonType:NSMomentaryChangeButton]; |
| 150 [self setShowsBorderOnlyWhileMouseInside:YES]; | 150 [self setShowsBorderOnlyWhileMouseInside:YES]; |
| 151 | 151 |
| 152 if (extension->ShowConfigureContextMenus()) { | 152 contextMenuController_.reset([[ExtensionActionContextMenuController alloc] |
| 153 contextMenuController_.reset([[ExtensionActionContextMenuController alloc] | 153 initWithExtension:extension |
| 154 initWithExtension:extension | 154 browser:browser |
| 155 browser:browser | 155 extensionAction:browser_action]); |
| 156 extensionAction:browser_action]); | 156 base::scoped_nsobject<NSMenu> contextMenu( |
| 157 base::scoped_nsobject<NSMenu> contextMenu( | 157 [[NSMenu alloc] initWithTitle:@""]); |
| 158 [[NSMenu alloc] initWithTitle:@""]); | 158 [contextMenu setDelegate:self]; |
| 159 [contextMenu setDelegate:self]; | 159 [self setMenu:contextMenu]; |
| 160 [self setMenu:contextMenu]; | |
| 161 } | |
| 162 | 160 |
| 163 tabId_ = tabId; | 161 tabId_ = tabId; |
| 164 extension_ = extension; | 162 extension_ = extension; |
| 165 iconFactoryBridge_.reset(new ExtensionActionIconFactoryBridge( | 163 iconFactoryBridge_.reset(new ExtensionActionIconFactoryBridge( |
| 166 self, browser->profile(), extension)); | 164 self, browser->profile(), extension)); |
| 167 | 165 |
| 168 moveAnimation_.reset([[NSViewAnimation alloc] init]); | 166 moveAnimation_.reset([[NSViewAnimation alloc] init]); |
| 169 [moveAnimation_ gtm_setDuration:kAnimationDuration | 167 [moveAnimation_ gtm_setDuration:kAnimationDuration |
| 170 eventMask:NSLeftMouseUpMask]; | 168 eventMask:NSLeftMouseUpMask]; |
| 171 [moveAnimation_ setAnimationBlockingMode:NSAnimationNonblocking]; | 169 [moveAnimation_ setAnimationBlockingMode:NSAnimationNonblocking]; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 operation:NSCompositeSourceOver | 346 operation:NSCompositeSourceOver |
| 349 fraction:enabled ? 1.0 : 0.4 | 347 fraction:enabled ? 1.0 : 0.4 |
| 350 respectFlipped:YES | 348 respectFlipped:YES |
| 351 hints:nil]; | 349 hints:nil]; |
| 352 | 350 |
| 353 cellFrame.origin.y += kBrowserActionBadgeOriginYOffset; | 351 cellFrame.origin.y += kBrowserActionBadgeOriginYOffset; |
| 354 [self drawBadgeWithinFrame:cellFrame]; | 352 [self drawBadgeWithinFrame:cellFrame]; |
| 355 } | 353 } |
| 356 | 354 |
| 357 @end | 355 @end |
| OLD | NEW |