OLD | NEW |
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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
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_ui.h" | 14 #include "chrome/browser/extensions/extension_install_ui.h" |
15 #include "chrome/browser/extensions/webstore_install_helper.h" | 15 #include "chrome/browser/extensions/webstore_install_helper.h" |
16 #include "chrome/browser/extensions/webstore_installer.h" | 16 #include "chrome/browser/extensions/webstore_installer.h" |
17 #include "content/public/browser/web_contents_observer.h" | 17 #include "content/public/browser/web_contents_observer.h" |
18 #include "content/public/common/url_fetcher_delegate.h" | |
19 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
| 19 #include "net/url_request/url_fetcher_delegate.h" |
20 #include "third_party/skia/include/core/SkBitmap.h" | 20 #include "third_party/skia/include/core/SkBitmap.h" |
21 | 21 |
22 class SafeWebstoreResponseParser; | 22 class SafeWebstoreResponseParser; |
23 | 23 |
24 namespace extensions { | 24 namespace extensions { |
25 class Extension; | 25 class Extension; |
26 } | 26 } |
27 | 27 |
| 28 namespace net { |
| 29 class URLFetcher; |
| 30 } |
| 31 |
28 // Manages inline installs requested by a page (downloads and parses metadata | 32 // Manages inline installs requested by a page (downloads and parses metadata |
29 // 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 |
30 // confirms). Clients must implement the WebstoreInlineInstaller::Delegate | 34 // confirms). Clients must implement the WebstoreInlineInstaller::Delegate |
31 // interface to be notified when the inline install completes (successfully or | 35 // interface to be notified when the inline install completes (successfully or |
32 // 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 |
33 // request is attached to goes away. | 37 // request is attached to goes away. |
34 class WebstoreInlineInstaller | 38 class WebstoreInlineInstaller |
35 : public base::RefCountedThreadSafe<WebstoreInlineInstaller>, | 39 : public base::RefCountedThreadSafe<WebstoreInlineInstaller>, |
36 public ExtensionInstallUI::Delegate, | 40 public ExtensionInstallUI::Delegate, |
37 public content::WebContentsObserver, | 41 public content::WebContentsObserver, |
38 public content::URLFetcherDelegate, | 42 public net::URLFetcherDelegate, |
39 public WebstoreInstaller::Delegate, | 43 public WebstoreInstaller::Delegate, |
40 public WebstoreInstallHelper::Delegate { | 44 public WebstoreInstallHelper::Delegate { |
41 public: | 45 public: |
42 class Delegate { | 46 class Delegate { |
43 public: | 47 public: |
44 virtual void OnInlineInstallSuccess(int install_id, | 48 virtual void OnInlineInstallSuccess(int install_id, |
45 int return_route_id) = 0; | 49 int return_route_id) = 0; |
46 virtual void OnInlineInstallFailure(int install_id, | 50 virtual void OnInlineInstallFailure(int install_id, |
47 int return_route_id, | 51 int return_route_id, |
48 const std::string& error) = 0; | 52 const std::string& error) = 0; |
(...skipping 20 matching lines...) Expand all Loading... |
69 // 1. BeginInstall: starts the fetch of data from the webstore | 73 // 1. BeginInstall: starts the fetch of data from the webstore |
70 // 2. OnURLFetchComplete: starts the parsing of data from the webstore | 74 // 2. OnURLFetchComplete: starts the parsing of data from the webstore |
71 // 3. OnWebstoreResponseParseSuccess: starts the parsing of the manifest and | 75 // 3. OnWebstoreResponseParseSuccess: starts the parsing of the manifest and |
72 // fetching of icon data. | 76 // fetching of icon data. |
73 // 4. OnWebstoreParseSuccess: shows the install UI | 77 // 4. OnWebstoreParseSuccess: shows the install UI |
74 // 5. InstallUIProceed: initiates the .crx download/install | 78 // 5. InstallUIProceed: initiates the .crx download/install |
75 // | 79 // |
76 // All flows (whether successful or not) end up in CompleteInstall, which | 80 // All flows (whether successful or not) end up in CompleteInstall, which |
77 // informs our delegate of success/failure. | 81 // informs our delegate of success/failure. |
78 | 82 |
79 // content::URLFetcherDelegate interface implementation. | 83 // net::URLFetcherDelegate interface implementation. |
80 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 84 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
81 | 85 |
82 // Client callbacks for SafeWebstoreResponseParser when parsing is complete. | 86 // Client callbacks for SafeWebstoreResponseParser when parsing is complete. |
83 void OnWebstoreResponseParseSuccess(DictionaryValue* webstore_data); | 87 void OnWebstoreResponseParseSuccess(DictionaryValue* webstore_data); |
84 void OnWebstoreResponseParseFailure(const std::string& error); | 88 void OnWebstoreResponseParseFailure(const std::string& error); |
85 | 89 |
86 // WebstoreInstallHelper::Delegate interface implementation. | 90 // WebstoreInstallHelper::Delegate interface implementation. |
87 virtual void OnWebstoreParseSuccess( | 91 virtual void OnWebstoreParseSuccess( |
88 const std::string& id, | 92 const std::string& id, |
89 const SkBitmap& icon, | 93 const SkBitmap& icon, |
(...skipping 24 matching lines...) Expand all Loading... |
114 const std::string& verified_site); | 118 const std::string& verified_site); |
115 | 119 |
116 int install_id_; | 120 int install_id_; |
117 int return_route_id_; | 121 int return_route_id_; |
118 std::string id_; | 122 std::string id_; |
119 GURL requestor_url_; | 123 GURL requestor_url_; |
120 Delegate* delegate_; | 124 Delegate* delegate_; |
121 scoped_ptr<ExtensionInstallUI> install_ui_; | 125 scoped_ptr<ExtensionInstallUI> install_ui_; |
122 | 126 |
123 // For fetching webstore JSON data. | 127 // For fetching webstore JSON data. |
124 scoped_ptr<content::URLFetcher> webstore_data_url_fetcher_; | 128 scoped_ptr<net::URLFetcher> webstore_data_url_fetcher_; |
125 | 129 |
126 // Extracted from the webstore JSON data response. | 130 // Extracted from the webstore JSON data response. |
127 std::string localized_name_; | 131 std::string localized_name_; |
128 std::string localized_description_; | 132 std::string localized_description_; |
129 std::string localized_user_count_; | 133 std::string localized_user_count_; |
130 double average_rating_; | 134 double average_rating_; |
131 int rating_count_; | 135 int rating_count_; |
132 scoped_ptr<DictionaryValue> webstore_data_; | 136 scoped_ptr<DictionaryValue> webstore_data_; |
133 scoped_ptr<DictionaryValue> manifest_; | 137 scoped_ptr<DictionaryValue> manifest_; |
134 scoped_refptr<extensions::Extension> dummy_extension_; | 138 scoped_refptr<extensions::Extension> dummy_extension_; |
135 SkBitmap icon_; | 139 SkBitmap icon_; |
136 | 140 |
137 DISALLOW_IMPLICIT_CONSTRUCTORS(WebstoreInlineInstaller); | 141 DISALLOW_IMPLICIT_CONSTRUCTORS(WebstoreInlineInstaller); |
138 }; | 142 }; |
139 | 143 |
140 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INLINE_INSTALLER_H_ | 144 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INLINE_INSTALLER_H_ |
OLD | NEW |