| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "browser_actions_controller.h" | 5 #import "browser_actions_controller.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "app/gfx/canvas_paint.h" | 9 #include "app/gfx/canvas_paint.h" |
| 10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 BrowserActionButton* actionButton = [buttons_ objectForKey:extensionId]; | 436 BrowserActionButton* actionButton = [buttons_ objectForKey:extensionId]; |
| 437 NSRect relativeButtonBounds = [[[actionButton window] contentView] | 437 NSRect relativeButtonBounds = [[[actionButton window] contentView] |
| 438 convertRect:[actionButton bounds] | 438 convertRect:[actionButton bounds] |
| 439 fromView:actionButton]; | 439 fromView:actionButton]; |
| 440 NSPoint arrowPoint = [[actionButton window] convertBaseToScreen:NSMakePoint( | 440 NSPoint arrowPoint = [[actionButton window] convertBaseToScreen:NSMakePoint( |
| 441 NSMinX(relativeButtonBounds), | 441 NSMinX(relativeButtonBounds), |
| 442 NSMinY(relativeButtonBounds))]; | 442 NSMinY(relativeButtonBounds))]; |
| 443 // Adjust the anchor point to be at the center of the browser action button. | 443 // Adjust the anchor point to be at the center of the browser action button. |
| 444 arrowPoint.x += kBrowserActionWidth / 2; | 444 arrowPoint.x += kBrowserActionWidth / 2; |
| 445 | 445 |
| 446 // Close any existing (or loading) popup owned by this controller. |
| 447 if (popupController_) |
| 448 [self hidePopup]; |
| 449 |
| 446 popupController_ = [ExtensionPopupController showURL:action->popup_url() | 450 popupController_ = [ExtensionPopupController showURL:action->popup_url() |
| 447 inBrowser:browser_ | 451 inBrowser:browser_ |
| 448 anchoredAt:arrowPoint | 452 anchoredAt:arrowPoint |
| 449 arrowLocation:kTopRight]; | 453 arrowLocation:kTopRight]; |
| 450 } else { | 454 } else { |
| 451 ExtensionBrowserEventRouter::GetInstance()->BrowserActionExecuted( | 455 ExtensionBrowserEventRouter::GetInstance()->BrowserActionExecuted( |
| 452 profile_, action->extension_id(), browser_); | 456 profile_, action->extension_id(), browser_); |
| 453 } | 457 } |
| 454 } | 458 } |
| 455 | 459 |
| 456 - (int)currentTabId { | 460 - (int)currentTabId { |
| 457 TabContents* selected_tab = browser_->GetSelectedTabContents(); | 461 TabContents* selected_tab = browser_->GetSelectedTabContents(); |
| 458 if (!selected_tab) | 462 if (!selected_tab) |
| 459 return -1; | 463 return -1; |
| 460 | 464 |
| 461 return selected_tab->controller().session_id().id(); | 465 return selected_tab->controller().session_id().id(); |
| 462 } | 466 } |
| 463 | 467 |
| 464 - (NSButton*)buttonWithIndex:(int)index { | 468 - (NSButton*)buttonWithIndex:(int)index { |
| 465 return [buttonOrder_ objectAtIndex:(NSUInteger)index]; | 469 return [buttonOrder_ objectAtIndex:(NSUInteger)index]; |
| 466 } | 470 } |
| 467 | 471 |
| 468 @end | 472 @end |
| OLD | NEW |