OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_installer.h" | 15 #include "chrome/browser/extensions/webstore_installer.h" |
16 #include "chrome/browser/extensions/webstore_install_helper.h" | 16 #include "chrome/browser/extensions/webstore_install_helper.h" |
17 #include "content/browser/tab_contents/tab_contents_observer.h" | 17 #include "content/browser/tab_contents/tab_contents_observer.h" |
18 #include "content/common/net/url_fetcher.h" | 18 #include "content/public/common/url_fetcher_delegate.h" |
19 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
20 #include "third_party/skia/include/core/SkBitmap.h" | 20 #include "third_party/skia/include/core/SkBitmap.h" |
21 | 21 |
22 class TabContents; | 22 class TabContents; |
23 class SafeWebstoreResponseParser; | 23 class SafeWebstoreResponseParser; |
24 | 24 |
25 // Manages inline installs requested by a page (downloads and parses metadata | 25 // Manages inline installs requested by a page (downloads and parses metadata |
26 // from the webstore, shows the install UI, starts the download once the user | 26 // from the webstore, shows the install UI, starts the download once the user |
27 // confirms). Clients must implement the WebstoreInlineInstaller::Delegate | 27 // confirms). Clients must implement the WebstoreInlineInstaller::Delegate |
28 // interface to be notified when the inline install completes (successfully or | 28 // interface to be notified when the inline install completes (successfully or |
29 // not). The client will not be notified if the TabContents that this install | 29 // not). The client will not be notified if the TabContents that this install |
30 // request is attached to goes away. | 30 // request is attached to goes away. |
31 class WebstoreInlineInstaller | 31 class WebstoreInlineInstaller |
32 : public base::RefCountedThreadSafe<WebstoreInlineInstaller>, | 32 : public base::RefCountedThreadSafe<WebstoreInlineInstaller>, |
33 public ExtensionInstallUI::Delegate, | 33 public ExtensionInstallUI::Delegate, |
34 public TabContentsObserver, | 34 public TabContentsObserver, |
35 public URLFetcher::Delegate, | 35 public content::URLFetcherDelegate, |
36 public WebstoreInstaller::Delegate, | 36 public WebstoreInstaller::Delegate, |
37 public WebstoreInstallHelper::Delegate { | 37 public WebstoreInstallHelper::Delegate { |
38 public: | 38 public: |
39 class Delegate { | 39 class Delegate { |
40 public: | 40 public: |
41 virtual void OnInlineInstallSuccess(int install_id) = 0; | 41 virtual void OnInlineInstallSuccess(int install_id) = 0; |
42 virtual void OnInlineInstallFailure(int install_id, | 42 virtual void OnInlineInstallFailure(int install_id, |
43 const std::string& error) = 0; | 43 const std::string& error) = 0; |
44 }; | 44 }; |
45 | 45 |
(...skipping 16 matching lines...) Expand all Loading... |
62 // 1. BeginInstall: starts the fetch of data from the webstore | 62 // 1. BeginInstall: starts the fetch of data from the webstore |
63 // 2. OnURLFetchComplete: starts the parsing of data from the webstore | 63 // 2. OnURLFetchComplete: starts the parsing of data from the webstore |
64 // 3. OnWebstoreResponseParseSuccess: starts the parsing of the manifest and | 64 // 3. OnWebstoreResponseParseSuccess: starts the parsing of the manifest and |
65 // fetching of icon data. | 65 // fetching of icon data. |
66 // 4. OnWebstoreParseSuccess: shows the install UI | 66 // 4. OnWebstoreParseSuccess: shows the install UI |
67 // 5. InstallUIProceed: initiates the .crx download/install | 67 // 5. InstallUIProceed: initiates the .crx download/install |
68 // | 68 // |
69 // All flows (whether successful or not) end up in CompleteInstall, which | 69 // All flows (whether successful or not) end up in CompleteInstall, which |
70 // informs our delegate of success/failure. | 70 // informs our delegate of success/failure. |
71 | 71 |
72 // UrlFetcher::Delegate interface implementation. | 72 // content::URLFetcherDelegate interface implementation. |
73 virtual void OnURLFetchComplete(const URLFetcher* source) OVERRIDE; | 73 virtual void OnURLFetchComplete(const URLFetcher* source) OVERRIDE; |
74 | 74 |
75 // Client callbacks for SafeWebstoreResponseParser when parsing is complete. | 75 // Client callbacks for SafeWebstoreResponseParser when parsing is complete. |
76 void OnWebstoreResponseParseSuccess(DictionaryValue* webstore_data); | 76 void OnWebstoreResponseParseSuccess(DictionaryValue* webstore_data); |
77 void OnWebstoreResponseParseFailure(const std::string& error); | 77 void OnWebstoreResponseParseFailure(const std::string& error); |
78 | 78 |
79 // WebstoreInstallHelper::Delegate interface implementation. | 79 // WebstoreInstallHelper::Delegate interface implementation. |
80 virtual void OnWebstoreParseSuccess( | 80 virtual void OnWebstoreParseSuccess( |
81 const SkBitmap& icon, | 81 const SkBitmap& icon, |
82 base::DictionaryValue* parsed_manifest) OVERRIDE; | 82 base::DictionaryValue* parsed_manifest) OVERRIDE; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 int rating_count_; | 114 int rating_count_; |
115 scoped_ptr<DictionaryValue> webstore_data_; | 115 scoped_ptr<DictionaryValue> webstore_data_; |
116 scoped_ptr<DictionaryValue> manifest_; | 116 scoped_ptr<DictionaryValue> manifest_; |
117 scoped_refptr<Extension> dummy_extension_; | 117 scoped_refptr<Extension> dummy_extension_; |
118 SkBitmap icon_; | 118 SkBitmap icon_; |
119 | 119 |
120 DISALLOW_IMPLICIT_CONSTRUCTORS(WebstoreInlineInstaller); | 120 DISALLOW_IMPLICIT_CONSTRUCTORS(WebstoreInlineInstaller); |
121 }; | 121 }; |
122 | 122 |
123 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INLINE_INSTALLER_H_ | 123 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INLINE_INSTALLER_H_ |
OLD | NEW |