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_EPHEMERAL_APP_LAUNCHER_H_ | 5 #ifndef CHROME_BROWSER_APPS_EPHEMERAL_APP_LAUNCHER_H_ |
6 #define CHROME_BROWSER_APPS_EPHEMERAL_APP_LAUNCHER_H_ | 6 #define CHROME_BROWSER_APPS_EPHEMERAL_APP_LAUNCHER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/scoped_observer.h" | 11 #include "base/scoped_observer.h" |
12 #include "chrome/browser/extensions/webstore_standalone_installer.h" | 12 #include "chrome/browser/extensions/webstore_standalone_installer.h" |
13 #include "chrome/browser/ui/extensions/extension_enable_flow_delegate.h" | 13 #include "chrome/browser/ui/extensions/extension_enable_flow_delegate.h" |
14 #include "content/public/browser/web_contents_observer.h" | 14 #include "content/public/browser/web_contents_observer.h" |
15 #include "extensions/browser/extension_registry_observer.h" | |
16 | 15 |
17 class ExtensionEnableFlow; | 16 class ExtensionEnableFlow; |
18 class Profile; | 17 class Profile; |
19 | 18 |
20 namespace content { | 19 namespace content { |
21 class WebContents; | 20 class WebContents; |
22 } | 21 } |
23 | 22 |
24 namespace extensions { | 23 namespace extensions { |
25 class Extension; | 24 class Extension; |
26 class ExtensionRegistry; | 25 class ExtensionRegistry; |
27 } | 26 } |
28 | 27 |
29 // EphemeralAppLauncher manages the launching of ephemeral apps. It handles | 28 // EphemeralAppLauncher manages the launching of ephemeral apps. It handles |
30 // display of a prompt, initiates install of the app (if necessary) and finally | 29 // display of a prompt, initiates install of the app (if necessary) and finally |
31 // launches the app. | 30 // launches the app. |
32 class EphemeralAppLauncher : public extensions::WebstoreStandaloneInstaller, | 31 class EphemeralAppLauncher : public extensions::WebstoreStandaloneInstaller, |
33 public content::WebContentsObserver, | 32 public content::WebContentsObserver, |
34 public extensions::ExtensionRegistryObserver, | |
35 public ExtensionEnableFlowDelegate { | 33 public ExtensionEnableFlowDelegate { |
36 public: | 34 public: |
37 typedef WebstoreStandaloneInstaller::Callback Callback; | 35 typedef WebstoreStandaloneInstaller::Callback Callback; |
38 | 36 |
39 // Create for the app launcher. | 37 // Create for the app launcher. |
40 static scoped_refptr<EphemeralAppLauncher> CreateForLauncher( | 38 static scoped_refptr<EphemeralAppLauncher> CreateForLauncher( |
41 const std::string& webstore_item_id, | 39 const std::string& webstore_item_id, |
42 Profile* profile, | 40 Profile* profile, |
43 gfx::NativeWindow parent_window, | 41 gfx::NativeWindow parent_window, |
44 const Callback& callback); | 42 const Callback& callback); |
(...skipping 12 matching lines...) Expand all Loading... |
57 EphemeralAppLauncher(const std::string& webstore_item_id, | 55 EphemeralAppLauncher(const std::string& webstore_item_id, |
58 Profile* profile, | 56 Profile* profile, |
59 gfx::NativeWindow parent_window, | 57 gfx::NativeWindow parent_window, |
60 const Callback& callback); | 58 const Callback& callback); |
61 EphemeralAppLauncher(const std::string& webstore_item_id, | 59 EphemeralAppLauncher(const std::string& webstore_item_id, |
62 content::WebContents* web_contents, | 60 content::WebContents* web_contents, |
63 const Callback& callback); | 61 const Callback& callback); |
64 | 62 |
65 virtual ~EphemeralAppLauncher(); | 63 virtual ~EphemeralAppLauncher(); |
66 | 64 |
67 void StartObserving(); | |
68 void LaunchApp(const extensions::Extension* extension) const; | 65 void LaunchApp(const extensions::Extension* extension) const; |
69 | 66 |
70 // WebstoreStandaloneInstaller implementation. | 67 // WebstoreStandaloneInstaller implementation. |
71 virtual bool CheckRequestorAlive() const OVERRIDE; | 68 virtual bool CheckRequestorAlive() const OVERRIDE; |
72 virtual const GURL& GetRequestorURL() const OVERRIDE; | 69 virtual const GURL& GetRequestorURL() const OVERRIDE; |
73 virtual bool ShouldShowPostInstallUI() const OVERRIDE; | 70 virtual bool ShouldShowPostInstallUI() const OVERRIDE; |
74 virtual bool ShouldShowAppInstalledBubble() const OVERRIDE; | 71 virtual bool ShouldShowAppInstalledBubble() const OVERRIDE; |
75 virtual content::WebContents* GetWebContents() const OVERRIDE; | 72 virtual content::WebContents* GetWebContents() const OVERRIDE; |
76 virtual scoped_ptr<ExtensionInstallPrompt::Prompt> | 73 virtual scoped_ptr<ExtensionInstallPrompt::Prompt> |
77 CreateInstallPrompt() const OVERRIDE; | 74 CreateInstallPrompt() const OVERRIDE; |
78 virtual bool CheckInlineInstallPermitted( | 75 virtual bool CheckInlineInstallPermitted( |
79 const base::DictionaryValue& webstore_data, | 76 const base::DictionaryValue& webstore_data, |
80 std::string* error) const OVERRIDE; | 77 std::string* error) const OVERRIDE; |
81 virtual bool CheckRequestorPermitted( | 78 virtual bool CheckRequestorPermitted( |
82 const base::DictionaryValue& webstore_data, | 79 const base::DictionaryValue& webstore_data, |
83 std::string* error) const OVERRIDE; | 80 std::string* error) const OVERRIDE; |
84 virtual bool CheckInstallValid( | 81 virtual bool CheckInstallValid( |
85 const base::DictionaryValue& manifest, | 82 const base::DictionaryValue& manifest, |
86 std::string* error) OVERRIDE; | 83 std::string* error) OVERRIDE; |
87 virtual scoped_ptr<ExtensionInstallPrompt> CreateInstallUI() OVERRIDE; | 84 virtual scoped_ptr<ExtensionInstallPrompt> CreateInstallUI() OVERRIDE; |
88 virtual scoped_ptr<extensions::WebstoreInstaller::Approval> | 85 virtual scoped_ptr<extensions::WebstoreInstaller::Approval> |
89 CreateApproval() const OVERRIDE; | 86 CreateApproval() const OVERRIDE; |
90 virtual void CompleteInstall(const std::string& error) OVERRIDE; | 87 virtual void CompleteInstall(const std::string& error) OVERRIDE; |
91 | 88 |
92 // content::WebContentsObserver implementation. | 89 // content::WebContentsObserver implementation. |
93 virtual void WebContentsDestroyed() OVERRIDE; | 90 virtual void WebContentsDestroyed() OVERRIDE; |
94 | 91 |
95 // ExtensionRegistryObserver implementation. | |
96 virtual void OnExtensionLoaded( | |
97 content::BrowserContext* browser_context, | |
98 const extensions::Extension* extension) OVERRIDE; | |
99 | |
100 // ExtensionEnableFlowDelegate implementation. | 92 // ExtensionEnableFlowDelegate implementation. |
101 virtual void ExtensionEnableFlowFinished() OVERRIDE; | 93 virtual void ExtensionEnableFlowFinished() OVERRIDE; |
102 virtual void ExtensionEnableFlowAborted(bool user_initiated) OVERRIDE; | 94 virtual void ExtensionEnableFlowAborted(bool user_initiated) OVERRIDE; |
103 | 95 |
104 // Listen to extension unloaded notifications. | |
105 ScopedObserver<extensions::ExtensionRegistry, | |
106 extensions::ExtensionRegistryObserver> | |
107 extension_registry_observer_; | |
108 | |
109 gfx::NativeWindow parent_window_; | 96 gfx::NativeWindow parent_window_; |
110 scoped_ptr<content::WebContents> dummy_web_contents_; | 97 scoped_ptr<content::WebContents> dummy_web_contents_; |
111 | 98 |
112 // Created in CheckInstallValid(). | 99 // Created in CheckInstallValid(). |
113 scoped_refptr<extensions::Extension> extension_; | 100 scoped_refptr<extensions::Extension> extension_; |
114 | 101 |
115 scoped_ptr<ExtensionEnableFlow> extension_enable_flow_; | 102 scoped_ptr<ExtensionEnableFlow> extension_enable_flow_; |
116 | 103 |
117 DISALLOW_COPY_AND_ASSIGN(EphemeralAppLauncher); | 104 DISALLOW_COPY_AND_ASSIGN(EphemeralAppLauncher); |
118 }; | 105 }; |
119 | 106 |
120 #endif // CHROME_BROWSER_APPS_EPHEMERAL_APP_LAUNCHER_H_ | 107 #endif // CHROME_BROWSER_APPS_EPHEMERAL_APP_LAUNCHER_H_ |
OLD | NEW |