| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef CHROME_BROWSER_APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_MAC_H_ | 5 #ifndef CHROME_BROWSER_APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_MAC_H_ |
| 6 #define CHROME_BROWSER_APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_MAC_H_ | 6 #define CHROME_BROWSER_APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_MAC_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "apps/app_lifetime_monitor.h" | 14 #include "apps/app_lifetime_monitor.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "chrome/browser/apps/app_shim/app_shim_handler_mac.h" | 17 #include "chrome/browser/apps/app_shim/app_shim_handler_mac.h" |
| 18 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
| 19 #include "chrome/browser/ui/browser_list_observer.h" | 19 #include "chrome/browser/ui/browser_list_observer.h" |
| 20 #include "content/public/browser/notification_observer.h" | 20 #include "content/public/browser/notification_observer.h" |
| 21 #include "content/public/browser/notification_registrar.h" | 21 #include "content/public/browser/notification_registrar.h" |
| 22 #include "extensions/browser/app_window/app_window_registry.h" | 22 #include "extensions/browser/app_window/app_window_registry.h" |
| 23 | 23 |
| 24 class Profile; | 24 class Profile; |
| 25 | 25 |
| 26 namespace base { | 26 namespace base { |
| 27 class FilePath; | 27 class FilePath; |
| 28 } | 28 } |
| 29 | 29 |
| 30 namespace content { |
| 31 class BrowserContext; |
| 32 } |
| 33 |
| 30 namespace extensions { | 34 namespace extensions { |
| 31 class AppWindow; | 35 class AppWindow; |
| 32 class Extension; | 36 class Extension; |
| 33 } | 37 } |
| 34 | 38 |
| 35 namespace apps { | 39 namespace apps { |
| 36 | 40 |
| 37 // This app shim handler that handles events for app shims that correspond to an | 41 // This app shim handler that handles events for app shims that correspond to an |
| 38 // extension. | 42 // extension. |
| 39 class ExtensionAppShimHandler : public AppShimHandler, | 43 class ExtensionAppShimHandler : public AppShimHandler, |
| 40 public content::NotificationObserver, | 44 public content::NotificationObserver, |
| 41 public AppLifetimeMonitor::Observer, | 45 public AppLifetimeMonitor::Observer, |
| 42 public chrome::BrowserListObserver { | 46 public chrome::BrowserListObserver { |
| 43 public: | 47 public: |
| 44 class Delegate { | 48 class Delegate { |
| 45 public: | 49 public: |
| 46 virtual ~Delegate() {} | 50 virtual ~Delegate() {} |
| 47 | 51 |
| 48 virtual bool ProfileExistsForPath(const base::FilePath& path); | 52 virtual bool ProfileExistsForPath(const base::FilePath& path); |
| 49 virtual Profile* ProfileForPath(const base::FilePath& path); | 53 virtual Profile* ProfileForPath(const base::FilePath& path); |
| 50 virtual void LoadProfileAsync(const base::FilePath& path, | 54 virtual void LoadProfileAsync(const base::FilePath& path, |
| 51 base::Callback<void(Profile*)> callback); | 55 base::Callback<void(Profile*)> callback); |
| 52 virtual bool IsProfileLockedForPath(const base::FilePath& path); | 56 virtual bool IsProfileLockedForPath(const base::FilePath& path); |
| 53 | 57 |
| 54 virtual extensions::AppWindowRegistry::AppWindowList GetWindows( | 58 virtual extensions::AppWindowRegistry::AppWindowList GetWindows( |
| 55 Profile* profile, | 59 Profile* profile, |
| 56 const std::string& extension_id); | 60 const std::string& extension_id); |
| 57 | 61 |
| 58 virtual const extensions::Extension* MaybeGetAppExtension( | 62 virtual const extensions::Extension* MaybeGetAppExtension( |
| 59 Profile* profile, | 63 content::BrowserContext* context, |
| 60 const std::string& extension_id); | 64 const std::string& extension_id); |
| 61 virtual void EnableExtension(Profile* profile, | 65 virtual void EnableExtension(Profile* profile, |
| 62 const std::string& extension_id, | 66 const std::string& extension_id, |
| 63 const base::Callback<void()>& callback); | 67 const base::Callback<void()>& callback); |
| 64 virtual void LaunchApp(Profile* profile, | 68 virtual void LaunchApp(Profile* profile, |
| 65 const extensions::Extension* extension, | 69 const extensions::Extension* extension, |
| 66 const std::vector<base::FilePath>& files); | 70 const std::vector<base::FilePath>& files); |
| 67 virtual void LaunchShim(Profile* profile, | 71 virtual void LaunchShim(Profile* profile, |
| 68 const extensions::Extension* extension); | 72 const extensions::Extension* extension); |
| 69 virtual void LaunchUserManager(); | 73 virtual void LaunchUserManager(); |
| 70 | 74 |
| 71 virtual void MaybeTerminate(); | 75 virtual void MaybeTerminate(); |
| 72 }; | 76 }; |
| 73 | 77 |
| 74 ExtensionAppShimHandler(); | 78 ExtensionAppShimHandler(); |
| 75 ~ExtensionAppShimHandler() override; | 79 ~ExtensionAppShimHandler() override; |
| 76 | 80 |
| 77 // Get the host corresponding to a profile and app id, or null if there is | 81 // Get the host corresponding to a profile and app id, or null if there is |
| 78 // none. Virtual for tests. | 82 // none. Virtual for tests. |
| 79 virtual AppShimHandler::Host* FindHost(Profile* profile, | 83 virtual AppShimHandler::Host* FindHost(Profile* profile, |
| 80 const std::string& app_id); | 84 const std::string& app_id); |
| 81 | 85 |
| 82 void SetHostedAppHidden(Profile* profile, | 86 void SetHostedAppHidden(Profile* profile, |
| 83 const std::string& app_id, | 87 const std::string& app_id, |
| 84 bool hidden); | 88 bool hidden); |
| 85 | 89 |
| 86 static const extensions::Extension* MaybeGetAppExtension( | 90 static const extensions::Extension* MaybeGetAppExtension( |
| 87 Profile* profile, | 91 content::BrowserContext* context, |
| 88 const std::string& extension_id); | 92 const std::string& extension_id); |
| 89 | 93 |
| 90 static const extensions::Extension* MaybeGetAppForBrowser(Browser* browser); | 94 static const extensions::Extension* MaybeGetAppForBrowser(Browser* browser); |
| 91 | 95 |
| 92 static void QuitAppForWindow(extensions::AppWindow* app_window); | 96 static void QuitAppForWindow(extensions::AppWindow* app_window); |
| 93 | 97 |
| 94 static void QuitHostedAppForWindow(Profile* profile, | 98 static void QuitHostedAppForWindow(Profile* profile, |
| 95 const std::string& app_id); | 99 const std::string& app_id); |
| 96 | 100 |
| 97 static void HideAppForWindow(extensions::AppWindow* app_window); | 101 static void HideAppForWindow(extensions::AppWindow* app_window); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 118 AppShimLaunchType launch_type, | 122 AppShimLaunchType launch_type, |
| 119 const std::vector<base::FilePath>& files) override; | 123 const std::vector<base::FilePath>& files) override; |
| 120 void OnShimClose(Host* host) override; | 124 void OnShimClose(Host* host) override; |
| 121 void OnShimFocus(Host* host, | 125 void OnShimFocus(Host* host, |
| 122 AppShimFocusType focus_type, | 126 AppShimFocusType focus_type, |
| 123 const std::vector<base::FilePath>& files) override; | 127 const std::vector<base::FilePath>& files) override; |
| 124 void OnShimSetHidden(Host* host, bool hidden) override; | 128 void OnShimSetHidden(Host* host, bool hidden) override; |
| 125 void OnShimQuit(Host* host) override; | 129 void OnShimQuit(Host* host) override; |
| 126 | 130 |
| 127 // AppLifetimeMonitor::Observer overrides: | 131 // AppLifetimeMonitor::Observer overrides: |
| 128 void OnAppStart(Profile* profile, const std::string& app_id) override; | 132 void OnAppStart(content::BrowserContext* context, |
| 129 void OnAppActivated(Profile* profile, const std::string& app_id) override; | 133 const std::string& app_id) override; |
| 130 void OnAppDeactivated(Profile* profile, const std::string& app_id) override; | 134 void OnAppActivated(content::BrowserContext* context, |
| 131 void OnAppStop(Profile* profile, const std::string& app_id) override; | 135 const std::string& app_id) override; |
| 136 void OnAppDeactivated(content::BrowserContext* context, |
| 137 const std::string& app_id) override; |
| 138 void OnAppStop(content::BrowserContext* context, |
| 139 const std::string& app_id) override; |
| 132 | 140 |
| 133 // content::NotificationObserver overrides: | 141 // content::NotificationObserver overrides: |
| 134 void Observe(int type, | 142 void Observe(int type, |
| 135 const content::NotificationSource& source, | 143 const content::NotificationSource& source, |
| 136 const content::NotificationDetails& details) override; | 144 const content::NotificationDetails& details) override; |
| 137 | 145 |
| 138 // chrome::BrowserListObserver overrides; | 146 // chrome::BrowserListObserver overrides; |
| 139 void OnBrowserAdded(Browser* browser) override; | 147 void OnBrowserAdded(Browser* browser) override; |
| 140 void OnBrowserRemoved(Browser* browser) override; | 148 void OnBrowserRemoved(Browser* browser) override; |
| 141 | 149 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 content::NotificationRegistrar registrar_; | 196 content::NotificationRegistrar registrar_; |
| 189 | 197 |
| 190 base::WeakPtrFactory<ExtensionAppShimHandler> weak_factory_; | 198 base::WeakPtrFactory<ExtensionAppShimHandler> weak_factory_; |
| 191 | 199 |
| 192 DISALLOW_COPY_AND_ASSIGN(ExtensionAppShimHandler); | 200 DISALLOW_COPY_AND_ASSIGN(ExtensionAppShimHandler); |
| 193 }; | 201 }; |
| 194 | 202 |
| 195 } // namespace apps | 203 } // namespace apps |
| 196 | 204 |
| 197 #endif // CHROME_BROWSER_APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_MAC_H_ | 205 #endif // CHROME_BROWSER_APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_MAC_H_ |
| OLD | NEW |