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_H_ | 5 #ifndef APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_H_ |
6 #define APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_H_ | 6 #define APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_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/shell_window_registry.h" | 14 #include "apps/app_window_registry.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
18 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.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 Extension; | 31 class Extension; |
32 } | 32 } |
33 | 33 |
34 namespace apps { | 34 namespace apps { |
35 | 35 |
36 class ShellWindow; | 36 class AppWindow; |
37 | 37 |
38 // This app shim handler that handles events for app shims that correspond to an | 38 // This app shim handler that handles events for app shims that correspond to an |
39 // extension. | 39 // extension. |
40 class ExtensionAppShimHandler : public AppShimHandler, | 40 class ExtensionAppShimHandler : public AppShimHandler, |
41 public content::NotificationObserver, | 41 public content::NotificationObserver, |
42 public AppLifetimeMonitor::Observer { | 42 public AppLifetimeMonitor::Observer { |
43 public: | 43 public: |
44 class Delegate { | 44 class Delegate { |
45 public: | 45 public: |
46 virtual ~Delegate() {} | 46 virtual ~Delegate() {} |
47 | 47 |
48 virtual bool ProfileExistsForPath(const base::FilePath& path); | 48 virtual bool ProfileExistsForPath(const base::FilePath& path); |
49 virtual Profile* ProfileForPath(const base::FilePath& path); | 49 virtual Profile* ProfileForPath(const base::FilePath& path); |
50 virtual void LoadProfileAsync(const base::FilePath& path, | 50 virtual void LoadProfileAsync(const base::FilePath& path, |
51 base::Callback<void(Profile*)> callback); | 51 base::Callback<void(Profile*)> callback); |
52 | 52 |
53 virtual ShellWindowRegistry::ShellWindowList GetWindows( | 53 virtual AppWindowRegistry::AppWindowList GetWindows( |
54 Profile* profile, const std::string& extension_id); | 54 Profile* profile, |
| 55 const std::string& extension_id); |
55 | 56 |
56 virtual const extensions::Extension* GetAppExtension( | 57 virtual const extensions::Extension* GetAppExtension( |
57 Profile* profile, const std::string& extension_id); | 58 Profile* profile, const std::string& extension_id); |
58 virtual void EnableExtension(Profile* profile, | 59 virtual void EnableExtension(Profile* profile, |
59 const std::string& extension_id, | 60 const std::string& extension_id, |
60 const base::Callback<void()>& callback); | 61 const base::Callback<void()>& callback); |
61 virtual void LaunchApp(Profile* profile, | 62 virtual void LaunchApp(Profile* profile, |
62 const extensions::Extension* extension, | 63 const extensions::Extension* extension, |
63 const std::vector<base::FilePath>& files); | 64 const std::vector<base::FilePath>& files); |
64 virtual void LaunchShim(Profile* profile, | 65 virtual void LaunchShim(Profile* profile, |
65 const extensions::Extension* extension); | 66 const extensions::Extension* extension); |
66 | 67 |
67 virtual void MaybeTerminate(); | 68 virtual void MaybeTerminate(); |
68 }; | 69 }; |
69 | 70 |
70 ExtensionAppShimHandler(); | 71 ExtensionAppShimHandler(); |
71 virtual ~ExtensionAppShimHandler(); | 72 virtual ~ExtensionAppShimHandler(); |
72 | 73 |
73 AppShimHandler::Host* FindHost(Profile* profile, const std::string& app_id); | 74 AppShimHandler::Host* FindHost(Profile* profile, const std::string& app_id); |
74 | 75 |
75 static void QuitAppForWindow(ShellWindow* shell_window); | 76 static void QuitAppForWindow(AppWindow* app_window); |
76 | 77 |
77 static void HideAppForWindow(ShellWindow* shell_window); | 78 static void HideAppForWindow(AppWindow* app_window); |
78 | 79 |
79 static void FocusAppForWindow(ShellWindow* shell_window); | 80 static void FocusAppForWindow(AppWindow* app_window); |
80 | 81 |
81 // Brings the window to the front without showing it and instructs the shim to | 82 // Brings the window to the front without showing it and instructs the shim to |
82 // request user attention. Returns false if there is no shim for this window. | 83 // request user attention. Returns false if there is no shim for this window. |
83 static bool RequestUserAttentionForWindow(ShellWindow* shell_window); | 84 static bool RequestUserAttentionForWindow(AppWindow* app_window); |
84 | 85 |
85 // AppShimHandler overrides: | 86 // AppShimHandler overrides: |
86 virtual void OnShimLaunch(Host* host, | 87 virtual void OnShimLaunch(Host* host, |
87 AppShimLaunchType launch_type, | 88 AppShimLaunchType launch_type, |
88 const std::vector<base::FilePath>& files) OVERRIDE; | 89 const std::vector<base::FilePath>& files) OVERRIDE; |
89 virtual void OnShimClose(Host* host) OVERRIDE; | 90 virtual void OnShimClose(Host* host) OVERRIDE; |
90 virtual void OnShimFocus(Host* host, | 91 virtual void OnShimFocus(Host* host, |
91 AppShimFocusType focus_type, | 92 AppShimFocusType focus_type, |
92 const std::vector<base::FilePath>& files) OVERRIDE; | 93 const std::vector<base::FilePath>& files) OVERRIDE; |
93 virtual void OnShimSetHidden(Host* host, bool hidden) OVERRIDE; | 94 virtual void OnShimSetHidden(Host* host, bool hidden) OVERRIDE; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 content::NotificationRegistrar registrar_; | 138 content::NotificationRegistrar registrar_; |
138 | 139 |
139 base::WeakPtrFactory<ExtensionAppShimHandler> weak_factory_; | 140 base::WeakPtrFactory<ExtensionAppShimHandler> weak_factory_; |
140 | 141 |
141 DISALLOW_COPY_AND_ASSIGN(ExtensionAppShimHandler); | 142 DISALLOW_COPY_AND_ASSIGN(ExtensionAppShimHandler); |
142 }; | 143 }; |
143 | 144 |
144 } // namespace apps | 145 } // namespace apps |
145 | 146 |
146 #endif // APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_H_ | 147 #endif // APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_H_ |
OLD | NEW |