| 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_install_helper.h" | 15 #include "chrome/browser/extensions/webstore_install_helper.h" |
| 16 #include "content/common/url_fetcher.h" | 16 #include "content/common/url_fetcher.h" |
| 17 #include "googleurl/src/gurl.h" |
| 17 #include "third_party/skia/include/core/SkBitmap.h" | 18 #include "third_party/skia/include/core/SkBitmap.h" |
| 18 | 19 |
| 19 class TabContents; | 20 class TabContents; |
| 20 class SafeWebstoreResponseParser; | 21 class SafeWebstoreResponseParser; |
| 21 | 22 |
| 22 // Manages inline installs requested by a page (downloads and parses metadata | 23 // Manages inline installs requested by a page (downloads and parses metadata |
| 23 // from the webstore, shows the install UI, starts the download once the user | 24 // from the webstore, shows the install UI, starts the download once the user |
| 24 // confirms). Clients must implement the WebstoreInlineInstaller::Delegate | 25 // confirms). Clients must implement the WebstoreInlineInstaller::Delegate |
| 25 // interface to be notified when the inline install completes (successfully or | 26 // interface to be notified when the inline install completes (successfully or |
| 26 // not). | 27 // not). |
| 27 class WebstoreInlineInstaller | 28 class WebstoreInlineInstaller |
| 28 : public base::RefCountedThreadSafe<WebstoreInlineInstaller>, | 29 : public base::RefCountedThreadSafe<WebstoreInlineInstaller>, |
| 29 public ExtensionInstallUI::Delegate, | 30 public ExtensionInstallUI::Delegate, |
| 30 public URLFetcher::Delegate, | 31 public URLFetcher::Delegate, |
| 31 public WebstoreInstallHelper::Delegate { | 32 public WebstoreInstallHelper::Delegate { |
| 32 public: | 33 public: |
| 33 class Delegate { | 34 class Delegate { |
| 34 public: | 35 public: |
| 35 virtual void OnInlineInstallSuccess() = 0; | 36 virtual void OnInlineInstallSuccess(int install_id) = 0; |
| 36 virtual void OnInlineInstallFailure(const std::string& error) = 0; | 37 virtual void OnInlineInstallFailure(int install_id, |
| 38 const std::string& error) = 0; |
| 37 }; | 39 }; |
| 38 | 40 |
| 39 WebstoreInlineInstaller(TabContents* tab_contents, | 41 WebstoreInlineInstaller(TabContents* tab_contents, |
| 42 int install_id, |
| 40 std::string webstore_item_id, | 43 std::string webstore_item_id, |
| 44 GURL requestor_url, |
| 41 Delegate* d); | 45 Delegate* d); |
| 42 void BeginInstall(); | 46 void BeginInstall(); |
| 43 | 47 |
| 44 private: | 48 private: |
| 45 friend class base::RefCountedThreadSafe<WebstoreInlineInstaller>; | 49 friend class base::RefCountedThreadSafe<WebstoreInlineInstaller>; |
| 46 friend class SafeWebstoreResponseParser; | 50 friend class SafeWebstoreResponseParser; |
| 47 | 51 |
| 48 virtual ~WebstoreInlineInstaller(); | 52 virtual ~WebstoreInlineInstaller(); |
| 49 | 53 |
| 50 // Several delegate/client inteface implementations follow. The normal flow | 54 // Several delegate/client inteface implementations follow. The normal flow |
| (...skipping 24 matching lines...) Expand all Loading... |
| 75 InstallHelperResultCode result_code, | 79 InstallHelperResultCode result_code, |
| 76 const std::string& error_message) OVERRIDE; | 80 const std::string& error_message) OVERRIDE; |
| 77 | 81 |
| 78 // ExtensionInstallUI::Delegate interface implementation. | 82 // ExtensionInstallUI::Delegate interface implementation. |
| 79 virtual void InstallUIProceed() OVERRIDE; | 83 virtual void InstallUIProceed() OVERRIDE; |
| 80 virtual void InstallUIAbort(bool user_initiated) OVERRIDE; | 84 virtual void InstallUIAbort(bool user_initiated) OVERRIDE; |
| 81 | 85 |
| 82 void CompleteInstall(const std::string& error); | 86 void CompleteInstall(const std::string& error); |
| 83 | 87 |
| 84 TabContents* tab_contents_; | 88 TabContents* tab_contents_; |
| 89 int install_id_; |
| 85 std::string id_; | 90 std::string id_; |
| 91 GURL requestor_url_; |
| 86 Delegate* delegate_; | 92 Delegate* delegate_; |
| 87 | 93 |
| 88 // For fetching webstore JSON data. | 94 // For fetching webstore JSON data. |
| 89 scoped_ptr<URLFetcher> webstore_data_url_fetcher_; | 95 scoped_ptr<URLFetcher> webstore_data_url_fetcher_; |
| 90 | 96 |
| 91 // Extracted from the webstore JSON data response. | 97 // Extracted from the webstore JSON data response. |
| 92 std::string localized_name_; | 98 std::string localized_name_; |
| 93 std::string localized_description_; | 99 std::string localized_description_; |
| 94 std::string localized_user_count_; | 100 std::string localized_user_count_; |
| 95 double average_rating_; | 101 double average_rating_; |
| 96 int rating_count_; | 102 int rating_count_; |
| 97 scoped_ptr<DictionaryValue> webstore_data_; | 103 scoped_ptr<DictionaryValue> webstore_data_; |
| 98 scoped_ptr<DictionaryValue> manifest_; | 104 scoped_ptr<DictionaryValue> manifest_; |
| 99 scoped_refptr<Extension> dummy_extension_; | 105 scoped_refptr<Extension> dummy_extension_; |
| 100 SkBitmap icon_; | 106 SkBitmap icon_; |
| 101 | 107 |
| 102 DISALLOW_IMPLICIT_CONSTRUCTORS(WebstoreInlineInstaller); | 108 DISALLOW_IMPLICIT_CONSTRUCTORS(WebstoreInlineInstaller); |
| 103 }; | 109 }; |
| 104 | 110 |
| 105 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INLINE_INSTALLER_H_ | 111 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INLINE_INSTALLER_H_ |
| OLD | NEW |