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

Side by Side Diff: chrome/browser/apps/ephemeral_app_launcher.h

Issue 339103002: Update the EphemeralAppLauncher for use by the webstorePrivate API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase again Created 6 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
« no previous file with comments | « no previous file | chrome/browser/apps/ephemeral_app_launcher.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 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 #include <vector>
9 10
10 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/callback.h"
11 #include "base/scoped_observer.h" 13 #include "base/scoped_observer.h"
12 #include "chrome/browser/extensions/webstore_standalone_installer.h" 14 #include "chrome/browser/extensions/webstore_standalone_installer.h"
13 #include "chrome/browser/ui/extensions/extension_enable_flow_delegate.h" 15 #include "chrome/browser/ui/extensions/extension_enable_flow_delegate.h"
14 #include "content/public/browser/web_contents_observer.h" 16 #include "content/public/browser/web_contents_observer.h"
15 17
16 class ExtensionEnableFlow; 18 class ExtensionEnableFlow;
17 class Profile; 19 class Profile;
18 20
19 namespace content { 21 namespace content {
20 class WebContents; 22 class WebContents;
21 } 23 }
22 24
23 namespace extensions { 25 namespace extensions {
24 class Extension; 26 class Extension;
27 class ExtensionInstallChecker;
25 class ExtensionRegistry; 28 class ExtensionRegistry;
26 } 29 }
27 30
28 // EphemeralAppLauncher manages the launching of ephemeral apps. It handles 31 // EphemeralAppLauncher manages the launching of ephemeral apps. It handles
29 // display of a prompt, initiates install of the app (if necessary) and finally 32 // display of a prompt, initiates install of the app (if necessary) and finally
30 // launches the app. 33 // launches the app.
31 class EphemeralAppLauncher : public extensions::WebstoreStandaloneInstaller, 34 class EphemeralAppLauncher : public extensions::WebstoreStandaloneInstaller,
32 public content::WebContentsObserver, 35 public content::WebContentsObserver,
33 public ExtensionEnableFlowDelegate { 36 public ExtensionEnableFlowDelegate {
34 public: 37 public:
35 typedef WebstoreStandaloneInstaller::Callback Callback; 38 typedef base::Callback<void(extensions::webstore_install::Result result,
39 const std::string& error)> LaunchCallback;
40
41 // Returns true if launching ephemeral apps is enabled.
42 static bool IsFeatureEnabled();
36 43
37 // Create for the app launcher. 44 // Create for the app launcher.
38 static scoped_refptr<EphemeralAppLauncher> CreateForLauncher( 45 static scoped_refptr<EphemeralAppLauncher> CreateForLauncher(
39 const std::string& webstore_item_id, 46 const std::string& webstore_item_id,
40 Profile* profile, 47 Profile* profile,
41 gfx::NativeWindow parent_window, 48 gfx::NativeWindow parent_window,
42 const Callback& callback); 49 const LaunchCallback& callback);
43 50
44 // Create for a link within a browser tab. 51 // Create for a web contents.
45 static scoped_refptr<EphemeralAppLauncher> CreateForLink( 52 static scoped_refptr<EphemeralAppLauncher> CreateForWebContents(
46 const std::string& webstore_item_id, 53 const std::string& webstore_item_id,
47 content::WebContents* web_contents); 54 content::WebContents* web_contents,
55 const LaunchCallback& callback);
48 56
49 // Initiate app launch. 57 // Initiate app launch.
50 void Start(); 58 void Start();
51 59
52 private: 60 protected:
53 friend class base::RefCountedThreadSafe<EphemeralAppLauncher>;
54
55 EphemeralAppLauncher(const std::string& webstore_item_id, 61 EphemeralAppLauncher(const std::string& webstore_item_id,
56 Profile* profile, 62 Profile* profile,
57 gfx::NativeWindow parent_window, 63 gfx::NativeWindow parent_window,
58 const Callback& callback); 64 const LaunchCallback& callback);
59 EphemeralAppLauncher(const std::string& webstore_item_id, 65 EphemeralAppLauncher(const std::string& webstore_item_id,
60 content::WebContents* web_contents, 66 content::WebContents* web_contents,
61 const Callback& callback); 67 const LaunchCallback& callback);
62 68
63 virtual ~EphemeralAppLauncher(); 69 virtual ~EphemeralAppLauncher();
64 70
71 // Returns true if an app that is already installed in extension system can
72 // be launched.
73 bool CanLaunchInstalledApp(const extensions::Extension* extension,
74 extensions::webstore_install::Result* reason,
75 std::string* error);
76
77 // Initiates the enable flow for an app before it can be launched.
78 void EnableInstalledApp(const extensions::Extension* extension);
79
80 // After the ephemeral installation or enable flow are complete, attempts to
81 // launch the app and notify the client of the outcome.
82 void MaybeLaunchApp();
83
84 // Launches an app. At this point, it is assumed that the app is enabled and
85 // can be launched.
65 void LaunchApp(const extensions::Extension* extension) const; 86 void LaunchApp(const extensions::Extension* extension) const;
66 87
88 // Notifies the client of the launch outcome.
89 void InvokeCallback(extensions::webstore_install::Result result,
90 const std::string& error);
91
92 // Aborts the ephemeral install and notifies the client of the outcome.
93 void AbortLaunch(extensions::webstore_install::Result result,
94 const std::string& error);
95
96 // Creates an install checker. Allows tests to mock the install checker.
97 virtual scoped_ptr<extensions::ExtensionInstallChecker>
98 CreateInstallChecker();
99
100 // Determines whether the app can be installed ephemerally.
101 void CheckEphemeralInstallPermitted();
102
103 // Install checker callback.
104 void OnInstallChecked(int check_failures);
105
67 // WebstoreStandaloneInstaller implementation. 106 // WebstoreStandaloneInstaller implementation.
68 virtual bool CheckRequestorAlive() const OVERRIDE; 107 virtual bool CheckRequestorAlive() const OVERRIDE;
69 virtual const GURL& GetRequestorURL() const OVERRIDE; 108 virtual const GURL& GetRequestorURL() const OVERRIDE;
70 virtual bool ShouldShowPostInstallUI() const OVERRIDE; 109 virtual bool ShouldShowPostInstallUI() const OVERRIDE;
71 virtual bool ShouldShowAppInstalledBubble() const OVERRIDE; 110 virtual bool ShouldShowAppInstalledBubble() const OVERRIDE;
72 virtual content::WebContents* GetWebContents() const OVERRIDE; 111 virtual content::WebContents* GetWebContents() const OVERRIDE;
73 virtual scoped_refptr<ExtensionInstallPrompt::Prompt> CreateInstallPrompt() 112 virtual scoped_refptr<ExtensionInstallPrompt::Prompt> CreateInstallPrompt()
74 const OVERRIDE; 113 const OVERRIDE;
75 virtual bool CheckInlineInstallPermitted( 114 virtual bool CheckInlineInstallPermitted(
76 const base::DictionaryValue& webstore_data, 115 const base::DictionaryValue& webstore_data,
77 std::string* error) const OVERRIDE; 116 std::string* error) const OVERRIDE;
78 virtual bool CheckRequestorPermitted( 117 virtual bool CheckRequestorPermitted(
79 const base::DictionaryValue& webstore_data, 118 const base::DictionaryValue& webstore_data,
80 std::string* error) const OVERRIDE; 119 std::string* error) const OVERRIDE;
81 virtual bool CheckInstallValid( 120 virtual void OnManifestParsed() OVERRIDE;
82 const base::DictionaryValue& manifest,
83 std::string* error) OVERRIDE;
84 virtual scoped_ptr<ExtensionInstallPrompt> CreateInstallUI() OVERRIDE; 121 virtual scoped_ptr<ExtensionInstallPrompt> CreateInstallUI() OVERRIDE;
85 virtual scoped_ptr<extensions::WebstoreInstaller::Approval> 122 virtual scoped_ptr<extensions::WebstoreInstaller::Approval>
86 CreateApproval() const OVERRIDE; 123 CreateApproval() const OVERRIDE;
87 virtual void CompleteInstall(const std::string& error) OVERRIDE; 124 virtual void CompleteInstall(extensions::webstore_install::Result result,
125 const std::string& error) OVERRIDE;
88 126
89 // content::WebContentsObserver implementation. 127 // content::WebContentsObserver implementation.
90 virtual void WebContentsDestroyed() OVERRIDE; 128 virtual void WebContentsDestroyed() OVERRIDE;
91 129
92 // ExtensionEnableFlowDelegate implementation. 130 // ExtensionEnableFlowDelegate implementation.
93 virtual void ExtensionEnableFlowFinished() OVERRIDE; 131 virtual void ExtensionEnableFlowFinished() OVERRIDE;
94 virtual void ExtensionEnableFlowAborted(bool user_initiated) OVERRIDE; 132 virtual void ExtensionEnableFlowAborted(bool user_initiated) OVERRIDE;
95 133
134 private:
135 friend class base::RefCountedThreadSafe<EphemeralAppLauncher>;
136 friend class EphemeralAppLauncherTest;
137
138 LaunchCallback launch_callback_;
139
96 gfx::NativeWindow parent_window_; 140 gfx::NativeWindow parent_window_;
97 scoped_ptr<content::WebContents> dummy_web_contents_; 141 scoped_ptr<content::WebContents> dummy_web_contents_;
98 142
99 // Created in CheckInstallValid(). 143 scoped_ptr<ExtensionEnableFlow> extension_enable_flow_;
100 scoped_refptr<extensions::Extension> extension_;
101 144
102 scoped_ptr<ExtensionEnableFlow> extension_enable_flow_; 145 scoped_ptr<extensions::ExtensionInstallChecker> install_checker_;
103 146
104 DISALLOW_COPY_AND_ASSIGN(EphemeralAppLauncher); 147 DISALLOW_COPY_AND_ASSIGN(EphemeralAppLauncher);
105 }; 148 };
106 149
107 #endif // CHROME_BROWSER_APPS_EPHEMERAL_APP_LAUNCHER_H_ 150 #endif // CHROME_BROWSER_APPS_EPHEMERAL_APP_LAUNCHER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/apps/ephemeral_app_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698