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

Unified Diff: chrome/browser/apps/app_shim/extension_app_shim_handler_mac.h

Issue 790043002: Hosted apps on OS X now act more like a native app. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@creating-app-shims-2
Patch Set: Added comments and refactored app_controller_mac Created 6 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/apps/app_shim/extension_app_shim_handler_mac.h
diff --git a/chrome/browser/apps/app_shim/extension_app_shim_handler_mac.h b/chrome/browser/apps/app_shim/extension_app_shim_handler_mac.h
index 8ac49432086d84b5748090b73365b6e842bbeaa2..32cebc13aba3741b5b655e3d7ada31ccc3fff181 100644
--- a/chrome/browser/apps/app_shim/extension_app_shim_handler_mac.h
+++ b/chrome/browser/apps/app_shim/extension_app_shim_handler_mac.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_MAC_H_
#include <map>
+#include <set>
#include <string>
#include <vector>
@@ -13,6 +14,8 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/apps/app_shim/app_shim_handler_mac.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_list_observer.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "extensions/browser/app_window/app_window_registry.h"
@@ -38,7 +41,8 @@ namespace apps {
// extension.
class ExtensionAppShimHandler : public AppShimHandler,
public content::NotificationObserver,
- public AppLifetimeMonitor::Observer {
+ public AppLifetimeMonitor::Observer,
+ public chrome::BrowserListObserver {
public:
class Delegate {
public:
@@ -72,10 +76,25 @@ class ExtensionAppShimHandler : public AppShimHandler,
AppShimHandler::Host* FindHost(Profile* profile, const std::string& app_id);
+ void SetHostedAppHidden(Profile* profile,
+ const std::string& app_id,
+ bool hidden);
+
+ static const extensions::Extension* GetAppExtension(
+ Profile* profile,
+ const std::string& extension_id);
+
+ static const extensions::Extension* GetAppForBrowser(Browser* browser);
+
static void QuitAppForWindow(extensions::AppWindow* app_window);
+ static void QuitHostedAppForWindow(Profile* profile,
+ const std::string& app_id);
+
static void HideAppForWindow(extensions::AppWindow* app_window);
+ static void HideHostedApp(Profile* profile, const std::string& app_id);
+
static void FocusAppForWindow(extensions::AppWindow* app_window);
// Brings the window to the front without showing it and instructs the shim to
@@ -115,9 +134,15 @@ class ExtensionAppShimHandler : public AppShimHandler,
const content::NotificationSource& source,
const content::NotificationDetails& details) override;
+ // chrome::BrowserListObserver overrides;
+ void OnBrowserAdded(Browser* browser) override;
+ void OnBrowserRemoved(Browser* browser) override;
+
protected:
typedef std::map<std::pair<Profile*, std::string>, AppShimHandler::Host*>
HostMap;
+ typedef std::set<Browser*> BrowserSet;
+ typedef std::map<std::string, BrowserSet> AppBrowserMap;
// Exposed for testing.
void set_delegate(Delegate* delegate);
@@ -128,6 +153,9 @@ class ExtensionAppShimHandler : public AppShimHandler,
// Helper function to get the instance on the browser process.
static ExtensionAppShimHandler* GetInstance();
+ // Closes all browsers associated with an app.
+ void CloseBrowsersForApp(const std::string& app_id);
+
// This is passed to Delegate::LoadProfileAsync for shim-initiated launches
// where the profile was not yet loaded.
void OnProfileLoaded(Host* host,
@@ -145,6 +173,9 @@ class ExtensionAppShimHandler : public AppShimHandler,
HostMap hosts_;
+ // A map of app ids to associated browser windows.
+ AppBrowserMap app_browser_windows_;
+
content::NotificationRegistrar registrar_;
base::WeakPtrFactory<ExtensionAppShimHandler> weak_factory_;
« no previous file with comments | « chrome/browser/app_controller_mac.mm ('k') | chrome/browser/apps/app_shim/extension_app_shim_handler_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698