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

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

Issue 12212076: Move web store data fetching and parsing out of WebstoreStandaloneInstaller. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 10 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_STANDALONE_INSTALLER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_WEBSTORE_STANDALONE_INSTALLER_H_
6 #define CHROME_BROWSER_EXTENSIONS_WEBSTORE_STANDALONE_INSTALLER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_WEBSTORE_STANDALONE_INSTALLER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/extensions/extension_install_prompt.h" 14 #include "chrome/browser/extensions/extension_install_prompt.h"
15 #include "chrome/browser/extensions/webstore_data_fetcher_delegate.h"
15 #include "chrome/browser/extensions/webstore_install_helper.h" 16 #include "chrome/browser/extensions/webstore_install_helper.h"
16 #include "chrome/browser/extensions/webstore_installer.h" 17 #include "chrome/browser/extensions/webstore_installer.h"
17 #include "content/public/browser/web_contents_observer.h" 18 #include "content/public/browser/web_contents_observer.h"
18 #include "googleurl/src/gurl.h" 19 #include "googleurl/src/gurl.h"
19 #include "net/url_request/url_fetcher_delegate.h" 20 #include "net/url_request/url_fetcher_delegate.h"
20 #include "third_party/skia/include/core/SkBitmap.h" 21 #include "third_party/skia/include/core/SkBitmap.h"
21 22
22 23
23 namespace net { 24 namespace net {
24 class URLFetcher; 25 class URLFetcher;
25 } 26 }
26 27
27 namespace extensions { 28 namespace extensions {
28 class Extension; 29 class Extension;
29 class SafeWebstoreResponseParser; 30 class WebstoreDataFetcher;
30 31
31 // Manages inline installs requested by a page (downloads and parses metadata 32 // Manages inline installs requested by a page (downloads and parses metadata
32 // from the webstore, shows the install UI, starts the download once the user 33 // from the webstore, shows the install UI, starts the download once the user
33 // confirms). Clients must implement the WebstoreStandaloneInstaller::Delegate 34 // confirms). Clients must implement the WebstoreStandaloneInstaller::Delegate
34 // interface to be notified when the inline install completes (successfully or 35 // interface to be notified when the inline install completes (successfully or
35 // not). The client will not be notified if the WebContents that this install 36 // not). The client will not be notified if the WebContents that this install
36 // request is attached to goes away. 37 // request is attached to goes away.
37 class WebstoreStandaloneInstaller 38 class WebstoreStandaloneInstaller
38 : public base::RefCountedThreadSafe<WebstoreStandaloneInstaller>, 39 : public base::RefCountedThreadSafe<WebstoreStandaloneInstaller>,
39 public ExtensionInstallPrompt::Delegate, 40 public ExtensionInstallPrompt::Delegate,
40 public content::WebContentsObserver, 41 public content::WebContentsObserver,
41 public net::URLFetcherDelegate, 42 public WebstoreDataFetcherDelegate,
42 public WebstoreInstaller::Delegate, 43 public WebstoreInstaller::Delegate,
43 public WebstoreInstallHelper::Delegate { 44 public WebstoreInstallHelper::Delegate {
44 public: 45 public:
45 enum VerifiedSiteRequired { 46 enum VerifiedSiteRequired {
46 REQUIRE_VERIFIED_SITE, 47 REQUIRE_VERIFIED_SITE,
47 DO_NOT_REQUIRE_VERIFIED_SITE 48 DO_NOT_REQUIRE_VERIFIED_SITE
48 }; 49 };
49 50
50 enum PromptType { 51 enum PromptType {
51 STANDARD_PROMPT, 52 STANDARD_PROMPT,
(...skipping 12 matching lines...) Expand all
64 PromptType prompt_type, 65 PromptType prompt_type,
65 GURL requestor_url, 66 GURL requestor_url,
66 Callback callback); 67 Callback callback);
67 68
68 void set_skip_post_install_ui(bool skip) { skip_post_install_ui_ = skip; } 69 void set_skip_post_install_ui(bool skip) { skip_post_install_ui_ = skip; }
69 70
70 void BeginInstall(); 71 void BeginInstall();
71 72
72 private: 73 private:
73 friend class base::RefCountedThreadSafe<WebstoreStandaloneInstaller>; 74 friend class base::RefCountedThreadSafe<WebstoreStandaloneInstaller>;
74 friend class SafeWebstoreResponseParser;
75 FRIEND_TEST_ALL_PREFIXES(WebstoreStandaloneInstallerTest, DomainVerification); 75 FRIEND_TEST_ALL_PREFIXES(WebstoreStandaloneInstallerTest, DomainVerification);
76 76
77 virtual ~WebstoreStandaloneInstaller(); 77 virtual ~WebstoreStandaloneInstaller();
78 78
79 // Several delegate/client inteface implementations follow. The normal flow 79 // Several delegate/client inteface implementations follow. The normal flow
80 // (for successful installs) is: 80 // (for successful installs) is:
81 // 81 //
82 // 1. BeginInstall: starts the fetch of data from the webstore 82 // 1. BeginInstall: starts the fetch of data from the webstore
83 // 2. OnURLFetchComplete: starts the parsing of data from the webstore 83 // 2. OnURLFetchComplete: starts the parsing of data from the webstore
84 // 3. OnWebstoreResponseParseSuccess: starts the parsing of the manifest and 84 // 3. OnWebstoreResponseParseSuccess: starts the parsing of the manifest and
85 // fetching of icon data. 85 // fetching of icon data.
86 // 4. OnWebstoreParseSuccess: shows the install UI 86 // 4. OnWebstoreParseSuccess: shows the install UI
87 // 5. InstallUIProceed: initiates the .crx download/install 87 // 5. InstallUIProceed: initiates the .crx download/install
88 // 88 //
89 // All flows (whether successful or not) end up in CompleteInstall, which 89 // All flows (whether successful or not) end up in CompleteInstall, which
90 // informs our delegate of success/failure. 90 // informs our delegate of success/failure.
91 91
92 // net::URLFetcherDelegate interface implementation. 92 // WebstoreDataFetcherDelegate interface implementation.
93 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; 93 virtual void OnWebstoreRequestFailure() OVERRIDE;
94 94 virtual void OnWebstoreResponseParseSuccess(
95 // Client callbacks for SafeWebstoreResponseParser when parsing is complete. 95 base::DictionaryValue* webstore_data) OVERRIDE;
96 void OnWebstoreResponseParseSuccess(DictionaryValue* webstore_data); 96 virtual void OnWebstoreResponseParseFailure(
97 void OnWebstoreResponseParseFailure(const std::string& error); 97 const std::string& error) OVERRIDE;
98 98
99 // WebstoreInstallHelper::Delegate interface implementation. 99 // WebstoreInstallHelper::Delegate interface implementation.
100 virtual void OnWebstoreParseSuccess( 100 virtual void OnWebstoreParseSuccess(
101 const std::string& id, 101 const std::string& id,
102 const SkBitmap& icon, 102 const SkBitmap& icon,
103 base::DictionaryValue* parsed_manifest) OVERRIDE; 103 base::DictionaryValue* parsed_manifest) OVERRIDE;
104 virtual void OnWebstoreParseFailure( 104 virtual void OnWebstoreParseFailure(
105 const std::string& id, 105 const std::string& id,
106 InstallHelperResultCode result_code, 106 InstallHelperResultCode result_code,
107 const std::string& error_message) OVERRIDE; 107 const std::string& error_message) OVERRIDE;
(...skipping 22 matching lines...) Expand all
130 130
131 std::string id_; 131 std::string id_;
132 bool require_verified_site_; 132 bool require_verified_site_;
133 PromptType prompt_type_; 133 PromptType prompt_type_;
134 GURL requestor_url_; 134 GURL requestor_url_;
135 Callback callback_; 135 Callback callback_;
136 scoped_ptr<ExtensionInstallPrompt> install_ui_; 136 scoped_ptr<ExtensionInstallPrompt> install_ui_;
137 bool skip_post_install_ui_; 137 bool skip_post_install_ui_;
138 138
139 // For fetching webstore JSON data. 139 // For fetching webstore JSON data.
140 scoped_ptr<net::URLFetcher> webstore_data_url_fetcher_; 140 scoped_ptr<WebstoreDataFetcher> webstore_data_fetcher_;
141 141
142 // Extracted from the webstore JSON data response. 142 // Extracted from the webstore JSON data response.
143 std::string localized_name_; 143 std::string localized_name_;
144 std::string localized_description_; 144 std::string localized_description_;
145 std::string localized_user_count_; 145 std::string localized_user_count_;
146 double average_rating_; 146 double average_rating_;
147 int rating_count_; 147 int rating_count_;
148 scoped_ptr<DictionaryValue> webstore_data_; 148 scoped_ptr<DictionaryValue> webstore_data_;
149 scoped_ptr<DictionaryValue> manifest_; 149 scoped_ptr<DictionaryValue> manifest_;
150 scoped_refptr<Extension> dummy_extension_; 150 scoped_refptr<Extension> dummy_extension_;
151 SkBitmap icon_; 151 SkBitmap icon_;
152 152
153 DISALLOW_IMPLICIT_CONSTRUCTORS(WebstoreStandaloneInstaller); 153 DISALLOW_IMPLICIT_CONSTRUCTORS(WebstoreStandaloneInstaller);
154 }; 154 };
155 155
156 } // namespace extensions 156 } // namespace extensions
157 157
158 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_STANDALONE_INSTALLER_H_ 158 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_STANDALONE_INSTALLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/webstore_data_fetcher_delegate.h ('k') | chrome/browser/extensions/webstore_standalone_installer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698