| 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_prompt.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" | 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 SafeWebstoreResponseParser; | 22 class SafeWebstoreResponseParser; |
| 23 | 23 |
| 24 namespace extensions { | 24 namespace extensions { |
| 25 class Extension; | 25 class Extension; |
| 26 } | 26 } |
| 27 | 27 |
| 28 // Manages inline installs requested by a page (downloads and parses metadata | 28 // 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 | 29 // from the webstore, shows the install UI, starts the download once the user |
| 30 // confirms). Clients must implement the WebstoreInlineInstaller::Delegate | 30 // confirms). Clients must implement the WebstoreInlineInstaller::Delegate |
| 31 // interface to be notified when the inline install completes (successfully or | 31 // 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 | 32 // not). The client will not be notified if the WebContents that this install |
| 33 // request is attached to goes away. | 33 // request is attached to goes away. |
| 34 class WebstoreInlineInstaller | 34 class WebstoreInlineInstaller |
| 35 : public base::RefCountedThreadSafe<WebstoreInlineInstaller>, | 35 : public base::RefCountedThreadSafe<WebstoreInlineInstaller>, |
| 36 public ExtensionInstallUI::Delegate, | 36 public ExtensionInstallPrompt::Delegate, |
| 37 public content::WebContentsObserver, | 37 public content::WebContentsObserver, |
| 38 public content::URLFetcherDelegate, | 38 public content::URLFetcherDelegate, |
| 39 public WebstoreInstaller::Delegate, | 39 public WebstoreInstaller::Delegate, |
| 40 public WebstoreInstallHelper::Delegate { | 40 public WebstoreInstallHelper::Delegate { |
| 41 public: | 41 public: |
| 42 class Delegate { | 42 class Delegate { |
| 43 public: | 43 public: |
| 44 virtual void OnInlineInstallSuccess(int install_id, | 44 virtual void OnInlineInstallSuccess(int install_id, |
| 45 int return_route_id) = 0; | 45 int return_route_id) = 0; |
| 46 virtual void OnInlineInstallFailure(int install_id, | 46 virtual void OnInlineInstallFailure(int install_id, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 // WebstoreInstallHelper::Delegate interface implementation. | 86 // WebstoreInstallHelper::Delegate interface implementation. |
| 87 virtual void OnWebstoreParseSuccess( | 87 virtual void OnWebstoreParseSuccess( |
| 88 const std::string& id, | 88 const std::string& id, |
| 89 const SkBitmap& icon, | 89 const SkBitmap& icon, |
| 90 base::DictionaryValue* parsed_manifest) OVERRIDE; | 90 base::DictionaryValue* parsed_manifest) OVERRIDE; |
| 91 virtual void OnWebstoreParseFailure( | 91 virtual void OnWebstoreParseFailure( |
| 92 const std::string& id, | 92 const std::string& id, |
| 93 InstallHelperResultCode result_code, | 93 InstallHelperResultCode result_code, |
| 94 const std::string& error_message) OVERRIDE; | 94 const std::string& error_message) OVERRIDE; |
| 95 | 95 |
| 96 // ExtensionInstallUI::Delegate interface implementation. | 96 // ExtensionInstallPrompt::Delegate interface implementation. |
| 97 virtual void InstallUIProceed() OVERRIDE; | 97 virtual void InstallUIProceed() OVERRIDE; |
| 98 virtual void InstallUIAbort(bool user_initiated) OVERRIDE; | 98 virtual void InstallUIAbort(bool user_initiated) OVERRIDE; |
| 99 | 99 |
| 100 // content::WebContentsObserver interface implementation. | 100 // content::WebContentsObserver interface implementation. |
| 101 virtual void WebContentsDestroyed( | 101 virtual void WebContentsDestroyed( |
| 102 content::WebContents* web_contents) OVERRIDE; | 102 content::WebContents* web_contents) OVERRIDE; |
| 103 | 103 |
| 104 // WebstoreInstaller::Delegate interface implementation. | 104 // WebstoreInstaller::Delegate interface implementation. |
| 105 virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE; | 105 virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE; |
| 106 virtual void OnExtensionInstallFailure(const std::string& id, | 106 virtual void OnExtensionInstallFailure(const std::string& id, |
| 107 const std::string& error) OVERRIDE; | 107 const std::string& error) OVERRIDE; |
| 108 | 108 |
| 109 void CompleteInstall(const std::string& error); | 109 void CompleteInstall(const std::string& error); |
| 110 | 110 |
| 111 // Checks whether the install is initiated by a page in the verified site | 111 // Checks whether the install is initiated by a page in the verified site |
| 112 // (which is at least a domain, but can also have a port or a path). | 112 // (which is at least a domain, but can also have a port or a path). |
| 113 static bool IsRequestorURLInVerifiedSite(const GURL& requestor_url, | 113 static bool IsRequestorURLInVerifiedSite(const GURL& requestor_url, |
| 114 const std::string& verified_site); | 114 const std::string& verified_site); |
| 115 | 115 |
| 116 int install_id_; | 116 int install_id_; |
| 117 int return_route_id_; | 117 int return_route_id_; |
| 118 std::string id_; | 118 std::string id_; |
| 119 GURL requestor_url_; | 119 GURL requestor_url_; |
| 120 Delegate* delegate_; | 120 Delegate* delegate_; |
| 121 scoped_ptr<ExtensionInstallUI> install_ui_; | 121 scoped_ptr<ExtensionInstallPrompt> install_ui_; |
| 122 | 122 |
| 123 // For fetching webstore JSON data. | 123 // For fetching webstore JSON data. |
| 124 scoped_ptr<content::URLFetcher> webstore_data_url_fetcher_; | 124 scoped_ptr<content::URLFetcher> webstore_data_url_fetcher_; |
| 125 | 125 |
| 126 // Extracted from the webstore JSON data response. | 126 // Extracted from the webstore JSON data response. |
| 127 std::string localized_name_; | 127 std::string localized_name_; |
| 128 std::string localized_description_; | 128 std::string localized_description_; |
| 129 std::string localized_user_count_; | 129 std::string localized_user_count_; |
| 130 double average_rating_; | 130 double average_rating_; |
| 131 int rating_count_; | 131 int rating_count_; |
| 132 scoped_ptr<DictionaryValue> webstore_data_; | 132 scoped_ptr<DictionaryValue> webstore_data_; |
| 133 scoped_ptr<DictionaryValue> manifest_; | 133 scoped_ptr<DictionaryValue> manifest_; |
| 134 scoped_refptr<extensions::Extension> dummy_extension_; | 134 scoped_refptr<extensions::Extension> dummy_extension_; |
| 135 SkBitmap icon_; | 135 SkBitmap icon_; |
| 136 | 136 |
| 137 DISALLOW_IMPLICIT_CONSTRUCTORS(WebstoreInlineInstaller); | 137 DISALLOW_IMPLICIT_CONSTRUCTORS(WebstoreInlineInstaller); |
| 138 }; | 138 }; |
| 139 | 139 |
| 140 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INLINE_INSTALLER_H_ | 140 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INLINE_INSTALLER_H_ |
| OLD | NEW |