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

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: 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
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* GetExtension(
51 Profile* profile, const std::string& extension_id);
52 virtual content::WebContents* LaunchApp(
53 Profile* profile,
54 const extensions::Extension* extension);
55 virtual void LaunchShim(Profile* profile,
56 const extensions::Extension* extension);
57
40 }; 58 };
41 59
42 ExtensionAppShimHandler(); 60 ExtensionAppShimHandler();
43 virtual ~ExtensionAppShimHandler(); 61 virtual ~ExtensionAppShimHandler();
44 62
45 // AppShimHandler overrides: 63 // AppShimHandler overrides:
46 virtual bool OnShimLaunch(Host* host, AppShimLaunchType launch_type) OVERRIDE; 64 virtual bool OnShimLaunch(Host* host, AppShimLaunchType launch_type) OVERRIDE;
47 virtual void OnShimClose(Host* host) OVERRIDE; 65 virtual void OnShimClose(Host* host) OVERRIDE;
48 virtual void OnShimFocus(Host* host) OVERRIDE; 66 virtual void OnShimFocus(Host* host) OVERRIDE;
49 virtual void OnShimQuit(Host* host) OVERRIDE; 67 virtual void OnShimQuit(Host* host) OVERRIDE;
50 68
51 // AppLifetimeMonitor::Observer overrides: 69 // AppLifetimeMonitor::Observer overrides:
52 virtual void OnAppStart(Profile* profile, const std::string& app_id) OVERRIDE; 70 virtual void OnAppStart(Profile* profile, const std::string& app_id) OVERRIDE;
53 virtual void OnAppActivated(Profile* profile, 71 virtual void OnAppActivated(Profile* profile,
54 const std::string& app_id) OVERRIDE; 72 const std::string& app_id) OVERRIDE;
55 virtual void OnAppDeactivated(Profile* profile, 73 virtual void OnAppDeactivated(Profile* profile,
56 const std::string& app_id) OVERRIDE; 74 const std::string& app_id) OVERRIDE;
57 virtual void OnAppStop(Profile* profile, const std::string& app_id) OVERRIDE; 75 virtual void OnAppStop(Profile* profile, const std::string& app_id) OVERRIDE;
58 virtual void OnChromeTerminating() OVERRIDE; 76 virtual void OnChromeTerminating() OVERRIDE;
59 77
60 protected: 78 protected:
61 typedef std::map<std::pair<Profile*, std::string>, AppShimHandler::Host*> 79 typedef std::map<std::pair<Profile*, std::string>, AppShimHandler::Host*>
62 HostMap; 80 HostMap;
63 81
64 // Exposed for testing. 82 // Exposed for testing.
65 void set_profile_manager_facade(ProfileManagerFacade* profile_manager_facade); 83 void set_dependency_facade(Delegate* dependency_facade);
tapted 2013/06/21 04:30:47 dependency_facade -> delegate
jackhou1 2013/06/21 05:46:27 Done.
66 HostMap& hosts() { return hosts_; } 84 HostMap& hosts() { return hosts_; }
67 content::NotificationRegistrar& registrar() { return registrar_; } 85 content::NotificationRegistrar& registrar() { return registrar_; }
68 86
69 private: 87 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 88 // Listen to the NOTIFICATION_EXTENSION_HOST_DESTROYED message to detect when
75 // an app closes. When that happens, call OnAppClosed on the relevant 89 // an app closes. When that happens, call OnAppClosed on the relevant
76 // AppShimHandler::Host which causes the app shim process to quit. 90 // AppShimHandler::Host which causes the app shim process to quit.
77 // The host will call OnShimClose on this. 91 // The host will call OnShimClose on this.
78 virtual void Observe(int type, 92 virtual void Observe(int type,
79 const content::NotificationSource& source, 93 const content::NotificationSource& source,
80 const content::NotificationDetails& details) OVERRIDE; 94 const content::NotificationDetails& details) OVERRIDE;
81 95
82 scoped_ptr<ProfileManagerFacade> profile_manager_facade_; 96 scoped_ptr<Delegate> delegate_;
83 97
84 HostMap hosts_; 98 HostMap hosts_;
85 99
86 content::NotificationRegistrar registrar_; 100 content::NotificationRegistrar registrar_;
87 }; 101 };
88 102
89 } // namespace apps 103 } // namespace apps
90 104
91 #endif // APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_H_ 105 #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') | apps/app_shim/extension_app_shim_handler_mac.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698