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

Side by Side Diff: apps/app_shim/extension_app_shim_handler_mac.h

Issue 17481002: Restructure ExtensionAppShimHandler testing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 7 years, 6 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | apps/app_shim/extension_app_shim_handler_mac.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 10
11 #include "apps/app_lifetime_monitor.h" 11 #include "apps/app_lifetime_monitor.h"
12 #include "apps/app_shim/app_shim_handler_mac.h" 12 #include "apps/app_shim/app_shim_handler_mac.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "chrome/browser/extensions/shell_window_registry.h"
14 #include "content/public/browser/notification_observer.h" 15 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h" 16 #include "content/public/browser/notification_registrar.h"
16 17
17 class Profile; 18 class Profile;
18 19
19 namespace base { 20 namespace base {
20 class FilePath; 21 class FilePath;
21 } 22 }
22 23
24 namespace content {
25 class WebContents;
26 }
27
23 namespace extensions { 28 namespace extensions {
24 class Extension; 29 class Extension;
25 } 30 }
26 31
27 namespace apps { 32 namespace apps {
28 33
29 // This app shim handler that handles events for app shims that correspond to an 34 // This app shim handler that handles events for app shims that correspond to an
30 // extension. 35 // extension.
31 class ExtensionAppShimHandler : public AppShimHandler, 36 class ExtensionAppShimHandler : public AppShimHandler,
32 public content::NotificationObserver, 37 public content::NotificationObserver,
33 public AppLifetimeMonitor::Observer { 38 public AppLifetimeMonitor::Observer {
34 public: 39 public:
35 class ProfileManagerFacade { 40 class Delegate {
36 public: 41 public:
37 virtual ~ProfileManagerFacade() {} 42 virtual ~Delegate() {}
43
38 virtual bool ProfileExistsForPath(const base::FilePath& path); 44 virtual bool ProfileExistsForPath(const base::FilePath& path);
39 virtual Profile* ProfileForPath(const base::FilePath& path); 45 virtual Profile* ProfileForPath(const base::FilePath& path);
46
47 virtual extensions::ShellWindowRegistry::ShellWindowList GetWindows(
48 Profile* profile, const std::string& extension_id);
49
50 virtual const extensions::Extension* GetAppExtension(
51 Profile* profile, const std::string& extension_id);
52 virtual void LaunchApp(Profile* profile,
53 const extensions::Extension* extension);
54 virtual void LaunchShim(Profile* profile,
55 const extensions::Extension* extension);
56
40 }; 57 };
41 58
42 ExtensionAppShimHandler(); 59 ExtensionAppShimHandler();
43 virtual ~ExtensionAppShimHandler(); 60 virtual ~ExtensionAppShimHandler();
44 61
45 // AppShimHandler overrides: 62 // AppShimHandler overrides:
46 virtual bool OnShimLaunch(Host* host, AppShimLaunchType launch_type) OVERRIDE; 63 virtual bool OnShimLaunch(Host* host, AppShimLaunchType launch_type) OVERRIDE;
47 virtual void OnShimClose(Host* host) OVERRIDE; 64 virtual void OnShimClose(Host* host) OVERRIDE;
48 virtual void OnShimFocus(Host* host) OVERRIDE; 65 virtual void OnShimFocus(Host* host) OVERRIDE;
49 virtual void OnShimQuit(Host* host) OVERRIDE; 66 virtual void OnShimQuit(Host* host) OVERRIDE;
50 67
51 // AppLifetimeMonitor::Observer overrides: 68 // AppLifetimeMonitor::Observer overrides:
52 virtual void OnAppStart(Profile* profile, const std::string& app_id) OVERRIDE; 69 virtual void OnAppStart(Profile* profile, const std::string& app_id) OVERRIDE;
53 virtual void OnAppActivated(Profile* profile, 70 virtual void OnAppActivated(Profile* profile,
54 const std::string& app_id) OVERRIDE; 71 const std::string& app_id) OVERRIDE;
55 virtual void OnAppDeactivated(Profile* profile, 72 virtual void OnAppDeactivated(Profile* profile,
56 const std::string& app_id) OVERRIDE; 73 const std::string& app_id) OVERRIDE;
57 virtual void OnAppStop(Profile* profile, const std::string& app_id) OVERRIDE; 74 virtual void OnAppStop(Profile* profile, const std::string& app_id) OVERRIDE;
58 virtual void OnChromeTerminating() OVERRIDE; 75 virtual void OnChromeTerminating() OVERRIDE;
59 76
60 protected: 77 protected:
61 typedef std::map<std::pair<Profile*, std::string>, AppShimHandler::Host*> 78 typedef std::map<std::pair<Profile*, std::string>, AppShimHandler::Host*>
62 HostMap; 79 HostMap;
63 80
64 // Exposed for testing. 81 // Exposed for testing.
65 void set_profile_manager_facade(ProfileManagerFacade* profile_manager_facade); 82 void set_delegate(Delegate* delegate);
66 HostMap& hosts() { return hosts_; } 83 HostMap& hosts() { return hosts_; }
67 content::NotificationRegistrar& registrar() { return registrar_; } 84 content::NotificationRegistrar& registrar() { return registrar_; }
68 85
69 private: 86 private:
70 virtual bool LaunchApp(Profile* profile,
71 const std::string& app_id,
72 AppShimLaunchType launch_type);
73
74 // Listen to the NOTIFICATION_EXTENSION_HOST_DESTROYED message to detect when 87 // Listen to the NOTIFICATION_EXTENSION_HOST_DESTROYED message to detect when
75 // an app closes. When that happens, call OnAppClosed on the relevant 88 // an app closes. When that happens, call OnAppClosed on the relevant
76 // AppShimHandler::Host which causes the app shim process to quit. 89 // AppShimHandler::Host which causes the app shim process to quit.
77 // The host will call OnShimClose on this. 90 // The host will call OnShimClose on this.
78 virtual void Observe(int type, 91 virtual void Observe(int type,
79 const content::NotificationSource& source, 92 const content::NotificationSource& source,
80 const content::NotificationDetails& details) OVERRIDE; 93 const content::NotificationDetails& details) OVERRIDE;
81 94
82 scoped_ptr<ProfileManagerFacade> profile_manager_facade_; 95 scoped_ptr<Delegate> delegate_;
83 96
84 HostMap hosts_; 97 HostMap hosts_;
85 98
86 content::NotificationRegistrar registrar_; 99 content::NotificationRegistrar registrar_;
87 }; 100 };
88 101
89 } // namespace apps 102 } // namespace apps
90 103
91 #endif // APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_H_ 104 #endif // APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_H_
OLDNEW
« no previous file with comments | « no previous file | apps/app_shim/extension_app_shim_handler_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698