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

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

Issue 10412052: Pull browser action click logic into ToolbarModelController, so that when I (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: views changes Created 8 years, 7 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) 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 "browser_actions_controller.h" 5 #import "browser_actions_controller.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <string> 8 #include <string>
9 9
10 #include "base/sys_string_conversions.h" 10 #include "base/sys_string_conversions.h"
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 } 714 }
715 } else if (![hiddenButtons_ containsObject:button]) { 715 } else if (![hiddenButtons_ containsObject:button]) {
716 [hiddenButtons_ addObject:button]; 716 [hiddenButtons_ addObject:button];
717 [button removeFromSuperview]; 717 [button removeFromSuperview];
718 [button setAlphaValue:0.0]; 718 [button setAlphaValue:0.0];
719 [self updateOverflowMenu]; 719 [self updateOverflowMenu];
720 } 720 }
721 } 721 }
722 722
723 - (void)browserActionClicked:(BrowserActionButton*)button { 723 - (void)browserActionClicked:(BrowserActionButton*)button {
724 int tabId = [self currentTabId]; 724 const Extension* extension = [button extension];
725 if (tabId < 0) { 725 GURL popupUrl;
726 NOTREACHED() << "No current tab."; 726 switch (toolbarModel_->ExecuteBrowserAction(extension, browser_, &popupUrl)) {
727 return; 727 case ExtensionToolbarModel::ACTION_NONE:
728 } 728 break;
729 // If an extension popup is already open, it will get closed when it 729 case ExtensionToolbarModel::ACTION_SHOW_POPUP: {
730 // loses focus. 730 NSPoint arrowPoint = [self popupPointForBrowserAction:extension];
731 731 [ExtensionPopupController showURL:popupUrl
732 ExtensionAction* action = [button extension]->browser_action(); 732 inBrowser:browser_
733 if (action->HasPopup(tabId)) { 733 anchoredAt:arrowPoint
734 GURL popupUrl = action->GetPopupUrl(tabId); 734 arrowLocation:info_bubble::kTopRight
735 NSPoint arrowPoint = [self popupPointForBrowserAction:[button extension]]; 735 devMode:NO];
736 [ExtensionPopupController showURL:popupUrl 736 break;
737 inBrowser:browser_ 737 }
738 anchoredAt:arrowPoint
739 arrowLocation:info_bubble::kTopRight
740 devMode:NO];
741 } else {
742 toolbarModel_->ExecuteBrowserAction(action->extension_id(), browser_);
743 } 738 }
744 } 739 }
745 740
746 - (BOOL)shouldDisplayBrowserAction:(const Extension*)extension { 741 - (BOOL)shouldDisplayBrowserAction:(const Extension*)extension {
747 // Only display incognito-enabled extensions while in incognito mode. 742 // Only display incognito-enabled extensions while in incognito mode.
748 return 743 return
749 (!profile_->IsOffTheRecord() || 744 (!profile_->IsOffTheRecord() ||
750 profile_->GetExtensionService()->IsIncognitoEnabled(extension->id())); 745 profile_->GetExtensionService()->IsIncognitoEnabled(extension->id()));
751 } 746 }
752 747
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 if (profile_->IsOffTheRecord()) 855 if (profile_->IsOffTheRecord())
861 index = toolbarModel_->IncognitoIndexToOriginal(index); 856 index = toolbarModel_->IncognitoIndexToOriginal(index);
862 if (index < toolbarModel_->size()) { 857 if (index < toolbarModel_->size()) {
863 const Extension* extension = toolbarModel_->GetExtensionByIndex(index); 858 const Extension* extension = toolbarModel_->GetExtensionByIndex(index);
864 return [buttons_ objectForKey:base::SysUTF8ToNSString(extension->id())]; 859 return [buttons_ objectForKey:base::SysUTF8ToNSString(extension->id())];
865 } 860 }
866 return nil; 861 return nil;
867 } 862 }
868 863
869 @end 864 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698