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

Side by Side Diff: chrome/browser/extensions/webstore_inline_installer.h

Issue 10907104: Support an --install-from-webstore command line switch (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: updated comment Created 8 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_EXTENSIONS_WEBSTORE_INLINE_INSTALLER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_WEBSTORE_INLINE_INSTALLER_H_
6 #define CHROME_BROWSER_EXTENSIONS_WEBSTORE_INLINE_INSTALLER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_WEBSTORE_INLINE_INSTALLER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 15 matching lines...) Expand all
26 namespace extensions { 26 namespace extensions {
27 class Extension; 27 class Extension;
28 class SafeWebstoreResponseParser; 28 class SafeWebstoreResponseParser;
29 29
30 // Manages inline installs requested by a page (downloads and parses metadata 30 // Manages inline installs requested by a page (downloads and parses metadata
31 // from the webstore, shows the install UI, starts the download once the user 31 // from the webstore, shows the install UI, starts the download once the user
32 // confirms). Clients must implement the WebstoreInlineInstaller::Delegate 32 // confirms). Clients must implement the WebstoreInlineInstaller::Delegate
33 // interface to be notified when the inline install completes (successfully or 33 // interface to be notified when the inline install completes (successfully or
34 // not). The client will not be notified if the WebContents that this install 34 // not). The client will not be notified if the WebContents that this install
35 // request is attached to goes away. 35 // request is attached to goes away.
36 class WebstoreInlineInstaller 36 class WebstoreInlineInstaller
Mihai Parparita -not on Chrome 2012/09/07 22:01:36 Add a TODO about renaming this class, since it's n
asargent_no_longer_on_chrome 2012/09/14 23:24:35 Done.
37 : public base::RefCountedThreadSafe<WebstoreInlineInstaller>, 37 : public base::RefCountedThreadSafe<WebstoreInlineInstaller>,
38 public ExtensionInstallPrompt::Delegate, 38 public ExtensionInstallPrompt::Delegate,
39 public content::WebContentsObserver, 39 public content::WebContentsObserver,
40 public net::URLFetcherDelegate, 40 public net::URLFetcherDelegate,
41 public WebstoreInstaller::Delegate, 41 public WebstoreInstaller::Delegate,
42 public WebstoreInstallHelper::Delegate { 42 public WebstoreInstallHelper::Delegate {
43 public: 43 public:
44 class Delegate { 44 // A callback for when the install process completes successfully or not. If
45 public: 45 // there was a failure, |success| will be false and |error| may contain a
46 virtual void OnInlineInstallSuccess(int install_id, 46 // developer-readable error message about why it failed.
47 int return_route_id) = 0; 47 typedef base::Callback<void(bool success, const std::string& error)> Callback;
Mihai Parparita -not on Chrome 2012/09/07 22:01:36 This needs a base/callback.h #include.
asargent_no_longer_on_chrome 2012/09/14 23:24:35 Done.
48 virtual void OnInlineInstallFailure(int install_id,
49 int return_route_id,
50 const std::string& error) = 0;
51 };
52 48
53 WebstoreInlineInstaller(content::WebContents* web_contents, 49 WebstoreInlineInstaller(content::WebContents* web_contents,
54 int install_id,
55 int return_route_id,
56 std::string webstore_item_id, 50 std::string webstore_item_id,
51 bool require_verified_site,
Mihai Parparita -not on Chrome 2012/09/07 22:01:36 An enum param would be more readable.
asargent_no_longer_on_chrome 2012/09/14 23:24:35 Done.
57 GURL requestor_url, 52 GURL requestor_url,
58 Delegate* d); 53 Callback callback);
59 void BeginInstall(); 54 void BeginInstall();
60 55
61 private: 56 private:
62 friend class base::RefCountedThreadSafe<WebstoreInlineInstaller>; 57 friend class base::RefCountedThreadSafe<WebstoreInlineInstaller>;
63 friend class SafeWebstoreResponseParser; 58 friend class SafeWebstoreResponseParser;
64 FRIEND_TEST_ALL_PREFIXES(WebstoreInlineInstallerTest, DomainVerification); 59 FRIEND_TEST_ALL_PREFIXES(WebstoreInlineInstallerTest, DomainVerification);
65 60
66 virtual ~WebstoreInlineInstaller(); 61 virtual ~WebstoreInlineInstaller();
67 62
68 // Several delegate/client inteface implementations follow. The normal flow 63 // Several delegate/client inteface implementations follow. The normal flow
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 virtual void OnExtensionInstallFailure(const std::string& id, 103 virtual void OnExtensionInstallFailure(const std::string& id,
109 const std::string& error) OVERRIDE; 104 const std::string& error) OVERRIDE;
110 105
111 void CompleteInstall(const std::string& error); 106 void CompleteInstall(const std::string& error);
112 107
113 // Checks whether the install is initiated by a page in the verified site 108 // Checks whether the install is initiated by a page in the verified site
114 // (which is at least a domain, but can also have a port or a path). 109 // (which is at least a domain, but can also have a port or a path).
115 static bool IsRequestorURLInVerifiedSite(const GURL& requestor_url, 110 static bool IsRequestorURLInVerifiedSite(const GURL& requestor_url,
116 const std::string& verified_site); 111 const std::string& verified_site);
117 112
118 int install_id_;
119 int return_route_id_;
120 std::string id_; 113 std::string id_;
114 bool require_verified_site_;
121 GURL requestor_url_; 115 GURL requestor_url_;
122 Delegate* delegate_; 116 Callback callback_;
123 scoped_ptr<ExtensionInstallPrompt> install_ui_; 117 scoped_ptr<ExtensionInstallPrompt> install_ui_;
124 118
125 // For fetching webstore JSON data. 119 // For fetching webstore JSON data.
126 scoped_ptr<net::URLFetcher> webstore_data_url_fetcher_; 120 scoped_ptr<net::URLFetcher> webstore_data_url_fetcher_;
127 121
128 // Extracted from the webstore JSON data response. 122 // Extracted from the webstore JSON data response.
129 std::string localized_name_; 123 std::string localized_name_;
130 std::string localized_description_; 124 std::string localized_description_;
131 std::string localized_user_count_; 125 std::string localized_user_count_;
132 double average_rating_; 126 double average_rating_;
133 int rating_count_; 127 int rating_count_;
134 scoped_ptr<DictionaryValue> webstore_data_; 128 scoped_ptr<DictionaryValue> webstore_data_;
135 scoped_ptr<DictionaryValue> manifest_; 129 scoped_ptr<DictionaryValue> manifest_;
136 scoped_refptr<Extension> dummy_extension_; 130 scoped_refptr<Extension> dummy_extension_;
137 SkBitmap icon_; 131 SkBitmap icon_;
138 132
139 DISALLOW_IMPLICIT_CONSTRUCTORS(WebstoreInlineInstaller); 133 DISALLOW_IMPLICIT_CONSTRUCTORS(WebstoreInlineInstaller);
140 }; 134 };
141 135
142 } // namespace extensions 136 } // namespace extensions
143 137
144 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INLINE_INSTALLER_H_ 138 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INLINE_INSTALLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698