Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / cocoa / extensions / browser_actions_controller.mm
index 504809d..10e1261 100644 (file)
@@ -220,19 +220,30 @@ class ExtensionServiceObserverBridge
   }
 
   // extensions::ExtensionToolbarModel::Observer implementation.
-  virtual void BrowserActionAdded(
+  virtual void ToolbarExtensionAdded(
       const Extension* extension,
       int index) OVERRIDE {
     [owner_ createActionButtonForExtension:extension withIndex:index];
     [owner_ resizeContainerAndAnimate:NO];
   }
 
-  virtual void BrowserActionRemoved(const Extension* extension) OVERRIDE {
+  virtual void ToolbarExtensionRemoved(const Extension* extension) OVERRIDE {
     [owner_ removeActionButtonForExtension:extension];
     [owner_ resizeContainerAndAnimate:NO];
   }
 
-  virtual bool BrowserActionShowPopup(const Extension* extension) OVERRIDE {
+  virtual void ToolbarExtensionMoved(const Extension* extension,
+                                     int index) OVERRIDE {
+  }
+
+  virtual void ToolbarExtensionUpdated(const Extension* extension) OVERRIDE {
+    BrowserActionButton* button = [owner_ buttonForExtension:extension];
+    if (button)
+      [button updateState];
+  }
+
+  virtual bool ShowExtensionActionPopup(const Extension* extension,
+                                        bool grant_active_tab) OVERRIDE {
     // Do not override other popups and only show in active window.
     ExtensionPopupController* popup = [ExtensionPopupController popup];
     if (popup || !browser_->window()->IsActive())
@@ -240,7 +251,17 @@ class ExtensionServiceObserverBridge
 
     BrowserActionButton* button = [owner_ buttonForExtension:extension];
     return button && [owner_ browserActionClicked:button
-                                      shouldGrant:NO];
+                                      shouldGrant:grant_active_tab];
+  }
+
+  virtual void ToolbarVisibleCountChanged() OVERRIDE {
+  }
+
+  virtual void ToolbarHighlightModeChanged(bool is_highlighting) OVERRIDE {
+  }
+
+  virtual Browser* GetBrowser() OVERRIDE {
+    return browser_;
   }
 
  private:
@@ -704,7 +725,7 @@ class ExtensionServiceObserverBridge
 
     if (intersectionWidth > dragThreshold && button != draggedButton &&
         ![button isAnimating] && index < [self visibleButtonCount]) {
-      toolbarModel_->MoveBrowserAction([draggedButton extension], index);
+      toolbarModel_->MoveExtensionIcon([draggedButton extension], index);
       [self positionActionButtonsAndAnimate:YES];
       return;
     }
@@ -743,12 +764,13 @@ class ExtensionServiceObserverBridge
 - (BOOL)browserActionClicked:(BrowserActionButton*)button
                  shouldGrant:(BOOL)shouldGrant {
   const Extension* extension = [button extension];
-  GURL popupUrl;
-  switch (toolbarModel_->ExecuteBrowserAction(extension, browser_, &popupUrl,
-                                              shouldGrant)) {
+  switch (extensions::ExtensionActionAPI::Get(profile_)->ExecuteExtensionAction(
+              extension, browser_, shouldGrant)) {
     case ExtensionAction::ACTION_NONE:
       break;
     case ExtensionAction::ACTION_SHOW_POPUP: {
+      GURL popupUrl = extensions::ExtensionActionManager::Get(profile_)->
+          GetBrowserAction(*extension)->GetPopupUrl([self currentTabId]);
       NSPoint arrowPoint = [self popupPointForBrowserAction:extension];
       [ExtensionPopupController showURL:popupUrl
                               inBrowser:browser_