Index: chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.mm |
diff --git a/chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.mm b/chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.mm |
index 5176e9c5121fb06f08cbd6316ab78483bd79c5e4..cde85afbe2282ed25eac54f5e4f851afcc88ac7b 100644 |
--- a/chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.mm |
+++ b/chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.mm |
@@ -10,13 +10,20 @@ |
#include "chrome/app/chrome_command_ids.h" |
#include "chrome/browser/apps/app_shim/extension_app_shim_handler_mac.h" |
#include "chrome/browser/apps/app_window_registry_util.h" |
+#include "chrome/browser/profiles/profile.h" |
#import "chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h" |
+#include "chrome/browser/ui/browser.h" |
+#include "chrome/browser/ui/browser_finder.h" |
+#include "chrome/browser/web_applications/web_app_mac.h" |
#include "chrome/grit/generated_resources.h" |
#include "extensions/browser/app_window/app_window.h" |
+#include "extensions/browser/extension_registry.h" |
#include "extensions/common/extension.h" |
#include "ui/base/l10n/l10n_util.h" |
#include "ui/base/l10n/l10n_util_mac.h" |
+using extensions::ExtensionRegistry; |
+ |
namespace { |
// Gets an item from the main menu given the tag of the top level item |
@@ -295,8 +302,22 @@ void AddDuplicateItem(NSMenuItem* top_level_item, |
window); |
const extensions::Extension* extension = NULL; |
+ // Try and look if there is a relevant app window. Otherwise, look at the |
jackhou1
2014/12/11 02:43:18
Maybe something like:
// If there is no correspon
mitchellj
2014/12/12 00:03:45
Acknowledged.
|
+ // browser window |
if (appWindow) |
extension = appWindow->GetExtension(); |
+ else { |
+ Browser* browser = chrome::FindBrowserWithWindow(window); |
+ if (browser && browser->is_app()) { |
+ ExtensionRegistry* registry = |
+ ExtensionRegistry::Get(browser->profile()); |
+ const extensions::Extension* temp = registry->GetExtensionById( |
+ web_app::GetExtensionIdFromApplicationName(browser->app_name()), |
+ ExtensionRegistry::ENABLED); |
+ if (temp->is_hosted_app()) |
+ extension = temp; |
+ } |
+ } |
if (extension) |
[self addMenuItems:extension]; |
@@ -374,16 +395,40 @@ void AddDuplicateItem(NSMenuItem* top_level_item, |
extensions::AppWindow* appWindow = |
AppWindowRegistryUtil::GetAppWindowForNativeWindowAnyProfile( |
[NSApp keyWindow]); |
- if (appWindow) |
+ if (appWindow) { |
apps::ExtensionAppShimHandler::QuitAppForWindow(appWindow); |
+ } else { |
+ Browser* browser = chrome::FindBrowserWithWindow([NSApp keyWindow]); |
+ if (browser && browser->is_app()) { |
+ ExtensionRegistry* registry = ExtensionRegistry::Get(browser->profile()); |
+ const extensions::Extension* extension = registry->GetExtensionById( |
+ web_app::GetExtensionIdFromApplicationName(browser->app_name()), |
+ ExtensionRegistry::ENABLED); |
+ if (extension->is_hosted_app()) |
+ apps::ExtensionAppShimHandler::QuitHostedAppForWindow(browser, |
+ extension); |
+ } |
+ } |
} |
- (void)hideCurrentPlatformApp { |
extensions::AppWindow* appWindow = |
AppWindowRegistryUtil::GetAppWindowForNativeWindowAnyProfile( |
[NSApp keyWindow]); |
- if (appWindow) |
+ if (appWindow) { |
apps::ExtensionAppShimHandler::HideAppForWindow(appWindow); |
+ } else { |
+ Browser* browser = chrome::FindBrowserWithWindow([NSApp keyWindow]); |
+ if (browser && browser->is_app()) { |
jackhou1
2014/12/11 02:43:18
This logic of "browser->is_app() && extension->is_
mitchellj
2014/12/12 00:03:45
Done.
|
+ ExtensionRegistry* registry = ExtensionRegistry::Get(browser->profile()); |
+ const extensions::Extension* extension = registry->GetExtensionById( |
+ web_app::GetExtensionIdFromApplicationName(browser->app_name()), |
+ ExtensionRegistry::ENABLED); |
+ if (extension->is_hosted_app()) |
+ apps::ExtensionAppShimHandler::HideHostedApp(browser->profile(), |
+ extension->id()); |
+ } |
+ } |
} |
- (void)focusCurrentPlatformApp { |