| 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 APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_MAC_H_ | 5 #ifndef APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_MAC_H_ |
| 6 #define APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_MAC_H_ | 6 #define APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_MAC_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "apps/app_lifetime_monitor.h" | 12 #include "apps/app_lifetime_monitor.h" |
| 13 #include "apps/app_shim/app_shim_handler_mac.h" | 13 #include "apps/app_shim/app_shim_handler_mac.h" |
| 14 #include "apps/app_window_registry.h" | |
| 15 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 17 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
| 18 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
| 18 #include "extensions/browser/app_window/app_window_registry.h" |
| 19 | 19 |
| 20 class Profile; | 20 class Profile; |
| 21 | 21 |
| 22 namespace base { | 22 namespace base { |
| 23 class FilePath; | 23 class FilePath; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace content { | 26 namespace content { |
| 27 class WebContents; | 27 class WebContents; |
| 28 } | 28 } |
| 29 | 29 |
| 30 namespace extensions { | 30 namespace extensions { |
| 31 class AppWindow; |
| 31 class Extension; | 32 class Extension; |
| 32 } | 33 } |
| 33 | 34 |
| 34 namespace apps { | 35 namespace apps { |
| 35 | 36 |
| 36 class AppWindow; | |
| 37 | |
| 38 // This app shim handler that handles events for app shims that correspond to an | 37 // This app shim handler that handles events for app shims that correspond to an |
| 39 // extension. | 38 // extension. |
| 40 class ExtensionAppShimHandler : public AppShimHandler, | 39 class ExtensionAppShimHandler : public AppShimHandler, |
| 41 public content::NotificationObserver, | 40 public content::NotificationObserver, |
| 42 public AppLifetimeMonitor::Observer { | 41 public AppLifetimeMonitor::Observer { |
| 43 public: | 42 public: |
| 44 class Delegate { | 43 class Delegate { |
| 45 public: | 44 public: |
| 46 virtual ~Delegate() {} | 45 virtual ~Delegate() {} |
| 47 | 46 |
| 48 virtual bool ProfileExistsForPath(const base::FilePath& path); | 47 virtual bool ProfileExistsForPath(const base::FilePath& path); |
| 49 virtual Profile* ProfileForPath(const base::FilePath& path); | 48 virtual Profile* ProfileForPath(const base::FilePath& path); |
| 50 virtual void LoadProfileAsync(const base::FilePath& path, | 49 virtual void LoadProfileAsync(const base::FilePath& path, |
| 51 base::Callback<void(Profile*)> callback); | 50 base::Callback<void(Profile*)> callback); |
| 52 | 51 |
| 53 virtual AppWindowRegistry::AppWindowList GetWindows( | 52 virtual extensions::AppWindowRegistry::AppWindowList GetWindows( |
| 54 Profile* profile, | 53 Profile* profile, |
| 55 const std::string& extension_id); | 54 const std::string& extension_id); |
| 56 | 55 |
| 57 virtual const extensions::Extension* GetAppExtension( | 56 virtual const extensions::Extension* GetAppExtension( |
| 58 Profile* profile, const std::string& extension_id); | 57 Profile* profile, const std::string& extension_id); |
| 59 virtual void EnableExtension(Profile* profile, | 58 virtual void EnableExtension(Profile* profile, |
| 60 const std::string& extension_id, | 59 const std::string& extension_id, |
| 61 const base::Callback<void()>& callback); | 60 const base::Callback<void()>& callback); |
| 62 virtual void LaunchApp(Profile* profile, | 61 virtual void LaunchApp(Profile* profile, |
| 63 const extensions::Extension* extension, | 62 const extensions::Extension* extension, |
| 64 const std::vector<base::FilePath>& files); | 63 const std::vector<base::FilePath>& files); |
| 65 virtual void LaunchShim(Profile* profile, | 64 virtual void LaunchShim(Profile* profile, |
| 66 const extensions::Extension* extension); | 65 const extensions::Extension* extension); |
| 67 | 66 |
| 68 virtual void MaybeTerminate(); | 67 virtual void MaybeTerminate(); |
| 69 }; | 68 }; |
| 70 | 69 |
| 71 ExtensionAppShimHandler(); | 70 ExtensionAppShimHandler(); |
| 72 virtual ~ExtensionAppShimHandler(); | 71 virtual ~ExtensionAppShimHandler(); |
| 73 | 72 |
| 74 AppShimHandler::Host* FindHost(Profile* profile, const std::string& app_id); | 73 AppShimHandler::Host* FindHost(Profile* profile, const std::string& app_id); |
| 75 | 74 |
| 76 static void QuitAppForWindow(AppWindow* app_window); | 75 static void QuitAppForWindow(extensions::AppWindow* app_window); |
| 77 | 76 |
| 78 static void HideAppForWindow(AppWindow* app_window); | 77 static void HideAppForWindow(extensions::AppWindow* app_window); |
| 79 | 78 |
| 80 static void FocusAppForWindow(AppWindow* app_window); | 79 static void FocusAppForWindow(extensions::AppWindow* app_window); |
| 81 | 80 |
| 82 // Brings the window to the front without showing it and instructs the shim to | 81 // Brings the window to the front without showing it and instructs the shim to |
| 83 // request user attention. If there is no shim, show the app and return false. | 82 // request user attention. If there is no shim, show the app and return false. |
| 84 static bool ActivateAndRequestUserAttentionForWindow(AppWindow* app_window); | 83 static bool ActivateAndRequestUserAttentionForWindow( |
| 84 extensions::AppWindow* app_window); |
| 85 | 85 |
| 86 // Instructs the shim to request user attention. Returns false if there is no | 86 // Instructs the shim to request user attention. Returns false if there is no |
| 87 // shim for this window. | 87 // shim for this window. |
| 88 static void RequestUserAttentionForWindow( | 88 static void RequestUserAttentionForWindow( |
| 89 AppWindow* app_window, | 89 extensions::AppWindow* app_window, |
| 90 AppShimAttentionType attention_type); | 90 AppShimAttentionType attention_type); |
| 91 | 91 |
| 92 // Called by AppControllerMac when Chrome hides. | 92 // Called by AppControllerMac when Chrome hides. |
| 93 static void OnChromeWillHide(); | 93 static void OnChromeWillHide(); |
| 94 | 94 |
| 95 // AppShimHandler overrides: | 95 // AppShimHandler overrides: |
| 96 virtual void OnShimLaunch(Host* host, | 96 virtual void OnShimLaunch(Host* host, |
| 97 AppShimLaunchType launch_type, | 97 AppShimLaunchType launch_type, |
| 98 const std::vector<base::FilePath>& files) OVERRIDE; | 98 const std::vector<base::FilePath>& files) OVERRIDE; |
| 99 virtual void OnShimClose(Host* host) OVERRIDE; | 99 virtual void OnShimClose(Host* host) OVERRIDE; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 content::NotificationRegistrar registrar_; | 150 content::NotificationRegistrar registrar_; |
| 151 | 151 |
| 152 base::WeakPtrFactory<ExtensionAppShimHandler> weak_factory_; | 152 base::WeakPtrFactory<ExtensionAppShimHandler> weak_factory_; |
| 153 | 153 |
| 154 DISALLOW_COPY_AND_ASSIGN(ExtensionAppShimHandler); | 154 DISALLOW_COPY_AND_ASSIGN(ExtensionAppShimHandler); |
| 155 }; | 155 }; |
| 156 | 156 |
| 157 } // namespace apps | 157 } // namespace apps |
| 158 | 158 |
| 159 #endif // APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_MAC_H_ | 159 #endif // APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_MAC_H_ |
| OLD | NEW |