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_INSTALLER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/supports_user_data.h" | 14 #include "base/supports_user_data.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "base/version.h" | 16 #include "base/version.h" |
17 #include "chrome/browser/extensions/extension_install_prompt.h" | 17 #include "chrome/browser/extensions/extension_install_prompt.h" |
18 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
19 #include "content/public/browser/download_interrupt_reasons.h" | 19 #include "content/public/browser/download_interrupt_reasons.h" |
20 #include "content/public/browser/download_item.h" | 20 #include "content/public/browser/download_item.h" |
21 #include "content/public/browser/notification_observer.h" | 21 #include "content/public/browser/notification_observer.h" |
22 #include "content/public/browser/notification_registrar.h" | 22 #include "content/public/browser/notification_registrar.h" |
| 23 #include "content/public/browser/web_contents_observer.h" |
23 #include "extensions/common/manifest_handlers/shared_module_info.h" | 24 #include "extensions/common/manifest_handlers/shared_module_info.h" |
24 #include "ui/gfx/image/image_skia.h" | 25 #include "ui/gfx/image/image_skia.h" |
25 #include "url/gurl.h" | 26 #include "url/gurl.h" |
26 | 27 |
27 class Profile; | 28 class Profile; |
28 | 29 |
29 namespace base { | 30 namespace base { |
30 class FilePath; | 31 class FilePath; |
31 } | 32 } |
32 | 33 |
33 namespace content { | 34 namespace content { |
34 class NavigationController; | 35 class WebContents; |
35 } | 36 } |
36 | 37 |
37 namespace extensions { | 38 namespace extensions { |
38 | 39 |
39 class Extension; | 40 class Extension; |
40 class Manifest; | 41 class Manifest; |
41 | 42 |
42 // Downloads and installs extensions from the web store. | 43 // Downloads and installs extensions from the web store. |
43 class WebstoreInstaller :public content::NotificationObserver, | 44 class WebstoreInstaller : public content::NotificationObserver, |
44 public content::DownloadItem::Observer, | 45 public content::DownloadItem::Observer, |
45 public base::RefCountedThreadSafe< | 46 public content::WebContentsObserver, |
| 47 public base::RefCountedThreadSafe< |
46 WebstoreInstaller, content::BrowserThread::DeleteOnUIThread> { | 48 WebstoreInstaller, content::BrowserThread::DeleteOnUIThread> { |
47 public: | 49 public: |
48 enum InstallSource { | 50 enum InstallSource { |
49 // Inline installs trigger slightly different behavior (install source | 51 // Inline installs trigger slightly different behavior (install source |
50 // is different, download referrers are the item's page in the gallery). | 52 // is different, download referrers are the item's page in the gallery). |
51 INSTALL_SOURCE_INLINE, | 53 INSTALL_SOURCE_INLINE, |
52 INSTALL_SOURCE_APP_LAUNCHER, | 54 INSTALL_SOURCE_APP_LAUNCHER, |
53 INSTALL_SOURCE_OTHER | 55 INSTALL_SOURCE_OTHER |
54 }; | 56 }; |
55 | 57 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 | 167 |
166 // Creates a WebstoreInstaller for downloading and installing the extension | 168 // Creates a WebstoreInstaller for downloading and installing the extension |
167 // with the given |id| from the Chrome Web Store. If |delegate| is not NULL, | 169 // with the given |id| from the Chrome Web Store. If |delegate| is not NULL, |
168 // it will be notified when the install succeeds or fails. The installer will | 170 // it will be notified when the install succeeds or fails. The installer will |
169 // use the specified |controller| to download the extension. Only one | 171 // use the specified |controller| to download the extension. Only one |
170 // WebstoreInstaller can use a specific controller at any given time. This | 172 // WebstoreInstaller can use a specific controller at any given time. This |
171 // also associates the |approval| with this install. | 173 // also associates the |approval| with this install. |
172 // Note: the delegate should stay alive until being called back. | 174 // Note: the delegate should stay alive until being called back. |
173 WebstoreInstaller(Profile* profile, | 175 WebstoreInstaller(Profile* profile, |
174 Delegate* delegate, | 176 Delegate* delegate, |
175 content::NavigationController* controller, | 177 content::WebContents* web_contents, |
176 const std::string& id, | 178 const std::string& id, |
177 scoped_ptr<Approval> approval, | 179 scoped_ptr<Approval> approval, |
178 InstallSource source); | 180 InstallSource source); |
179 | 181 |
180 // Starts downloading and installing the extension. | 182 // Starts downloading and installing the extension. |
181 void Start(); | 183 void Start(); |
182 | 184 |
183 // content::NotificationObserver | 185 // content::NotificationObserver |
184 virtual void Observe(int type, | 186 virtual void Observe(int type, |
185 const content::NotificationSource& source, | 187 const content::NotificationSource& source, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 // this managed its installation. This also removes the associated | 232 // this managed its installation. This also removes the associated |
231 // PendingInstall. | 233 // PendingInstall. |
232 void ReportSuccess(); | 234 void ReportSuccess(); |
233 | 235 |
234 // Records stats regarding an interrupted webstore download item. | 236 // Records stats regarding an interrupted webstore download item. |
235 void RecordInterrupt(const content::DownloadItem* download) const; | 237 void RecordInterrupt(const content::DownloadItem* download) const; |
236 | 238 |
237 content::NotificationRegistrar registrar_; | 239 content::NotificationRegistrar registrar_; |
238 Profile* profile_; | 240 Profile* profile_; |
239 Delegate* delegate_; | 241 Delegate* delegate_; |
240 content::NavigationController* controller_; | |
241 std::string id_; | 242 std::string id_; |
242 InstallSource install_source_; | 243 InstallSource install_source_; |
243 // The DownloadItem is owned by the DownloadManager and is valid from when | 244 // The DownloadItem is owned by the DownloadManager and is valid from when |
244 // OnDownloadStarted is called (with no error) until OnDownloadDestroyed(). | 245 // OnDownloadStarted is called (with no error) until OnDownloadDestroyed(). |
245 content::DownloadItem* download_item_; | 246 content::DownloadItem* download_item_; |
246 scoped_ptr<Approval> approval_; | 247 scoped_ptr<Approval> approval_; |
247 GURL download_url_; | 248 GURL download_url_; |
248 | 249 |
249 // Pending modules. | 250 // Pending modules. |
250 std::list<SharedModuleInfo::ImportInfo> pending_modules_; | 251 std::list<SharedModuleInfo::ImportInfo> pending_modules_; |
251 // Total extension modules we need download and install (the main module and | 252 // Total extension modules we need download and install (the main module and |
252 // depedences). | 253 // depedences). |
253 int total_modules_; | 254 int total_modules_; |
254 bool download_started_; | 255 bool download_started_; |
255 }; | 256 }; |
256 | 257 |
257 } // namespace extensions | 258 } // namespace extensions |
258 | 259 |
259 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_H_ | 260 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_H_ |
OLD | NEW |