| 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 <memory> |
| 9 #include <string> | 10 #include <string> |
| 10 | 11 |
| 11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 12 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
| 13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | |
| 15 #include "base/scoped_observer.h" | 15 #include "base/scoped_observer.h" |
| 16 #include "base/supports_user_data.h" | 16 #include "base/supports_user_data.h" |
| 17 #include "base/timer/timer.h" | 17 #include "base/timer/timer.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "base/version.h" | 19 #include "base/version.h" |
| 20 #include "chrome/browser/extensions/extension_install_prompt.h" | 20 #include "chrome/browser/extensions/extension_install_prompt.h" |
| 21 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 22 #include "content/public/browser/download_interrupt_reasons.h" | 22 #include "content/public/browser/download_interrupt_reasons.h" |
| 23 #include "content/public/browser/download_item.h" | 23 #include "content/public/browser/download_item.h" |
| 24 #include "content/public/browser/notification_observer.h" | 24 #include "content/public/browser/notification_observer.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 95 |
| 96 protected: | 96 protected: |
| 97 virtual ~Delegate() {} | 97 virtual ~Delegate() {} |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 // Contains information about what parts of the extension install process can | 100 // Contains information about what parts of the extension install process can |
| 101 // be skipped or modified. If one of these is present, it means that a CRX | 101 // be skipped or modified. If one of these is present, it means that a CRX |
| 102 // download was initiated by WebstoreInstaller. The Approval instance should | 102 // download was initiated by WebstoreInstaller. The Approval instance should |
| 103 // be checked further for additional details. | 103 // be checked further for additional details. |
| 104 struct Approval : public base::SupportsUserData::Data { | 104 struct Approval : public base::SupportsUserData::Data { |
| 105 static scoped_ptr<Approval> CreateWithInstallPrompt(Profile* profile); | 105 static std::unique_ptr<Approval> CreateWithInstallPrompt(Profile* profile); |
| 106 | 106 |
| 107 // Creates an Approval for installing a shared module. | 107 // Creates an Approval for installing a shared module. |
| 108 static scoped_ptr<Approval> CreateForSharedModule(Profile* profile); | 108 static std::unique_ptr<Approval> CreateForSharedModule(Profile* profile); |
| 109 | 109 |
| 110 // Creates an Approval that will skip putting up an install confirmation | 110 // Creates an Approval that will skip putting up an install confirmation |
| 111 // prompt if the actual manifest from the extension to be installed matches | 111 // prompt if the actual manifest from the extension to be installed matches |
| 112 // |parsed_manifest|. The |strict_manifest_check| controls whether we want | 112 // |parsed_manifest|. The |strict_manifest_check| controls whether we want |
| 113 // to require an exact manifest match, or are willing to tolerate a looser | 113 // to require an exact manifest match, or are willing to tolerate a looser |
| 114 // check just that the effective permissions are the same. | 114 // check just that the effective permissions are the same. |
| 115 static scoped_ptr<Approval> CreateWithNoInstallPrompt( | 115 static std::unique_ptr<Approval> CreateWithNoInstallPrompt( |
| 116 Profile* profile, | 116 Profile* profile, |
| 117 const std::string& extension_id, | 117 const std::string& extension_id, |
| 118 scoped_ptr<base::DictionaryValue> parsed_manifest, | 118 std::unique_ptr<base::DictionaryValue> parsed_manifest, |
| 119 bool strict_manifest_check); | 119 bool strict_manifest_check); |
| 120 | 120 |
| 121 ~Approval() override; | 121 ~Approval() override; |
| 122 | 122 |
| 123 // The extension id that was approved for installation. | 123 // The extension id that was approved for installation. |
| 124 std::string extension_id; | 124 std::string extension_id; |
| 125 | 125 |
| 126 // The profile the extension should be installed into. | 126 // The profile the extension should be installed into. |
| 127 Profile* profile; | 127 Profile* profile; |
| 128 | 128 |
| 129 // The expected manifest, before localization. | 129 // The expected manifest, before localization. |
| 130 scoped_ptr<Manifest> manifest; | 130 std::unique_ptr<Manifest> manifest; |
| 131 | 131 |
| 132 // Whether to use a bubble notification when an app is installed, instead of | 132 // Whether to use a bubble notification when an app is installed, instead of |
| 133 // the default behavior of transitioning to the new tab page. | 133 // the default behavior of transitioning to the new tab page. |
| 134 bool use_app_installed_bubble; | 134 bool use_app_installed_bubble; |
| 135 | 135 |
| 136 // Whether to skip the post install UI like the extension installed bubble. | 136 // Whether to skip the post install UI like the extension installed bubble. |
| 137 bool skip_post_install_ui; | 137 bool skip_post_install_ui; |
| 138 | 138 |
| 139 // Whether to skip the install dialog once the extension has been downloaded | 139 // Whether to skip the install dialog once the extension has been downloaded |
| 140 // and unpacked. One reason this can be true is that in the normal webstore | 140 // and unpacked. One reason this can be true is that in the normal webstore |
| (...skipping 11 matching lines...) Expand all Loading... |
| 152 // Used to show the install dialog. | 152 // Used to show the install dialog. |
| 153 ExtensionInstallPrompt::ShowDialogCallback show_dialog_callback; | 153 ExtensionInstallPrompt::ShowDialogCallback show_dialog_callback; |
| 154 | 154 |
| 155 // The icon to use to display the extension while it is installing. | 155 // The icon to use to display the extension while it is installing. |
| 156 gfx::ImageSkia installing_icon; | 156 gfx::ImageSkia installing_icon; |
| 157 | 157 |
| 158 // A dummy extension created from |manifest|; | 158 // A dummy extension created from |manifest|; |
| 159 scoped_refptr<Extension> dummy_extension; | 159 scoped_refptr<Extension> dummy_extension; |
| 160 | 160 |
| 161 // Required minimum version. | 161 // Required minimum version. |
| 162 scoped_ptr<Version> minimum_version; | 162 std::unique_ptr<Version> minimum_version; |
| 163 | 163 |
| 164 // The authuser index required to download the item being installed. May be | 164 // The authuser index required to download the item being installed. May be |
| 165 // the empty string, in which case no authuser parameter is used. | 165 // the empty string, in which case no authuser parameter is used. |
| 166 std::string authuser; | 166 std::string authuser; |
| 167 | 167 |
| 168 private: | 168 private: |
| 169 Approval(); | 169 Approval(); |
| 170 }; | 170 }; |
| 171 | 171 |
| 172 // Gets the Approval associated with the |download|, or NULL if there's none. | 172 // Gets the Approval associated with the |download|, or NULL if there's none. |
| 173 // Note that the Approval is owned by |download|. | 173 // Note that the Approval is owned by |download|. |
| 174 static const Approval* GetAssociatedApproval( | 174 static const Approval* GetAssociatedApproval( |
| 175 const content::DownloadItem& download); | 175 const content::DownloadItem& download); |
| 176 | 176 |
| 177 // Creates a WebstoreInstaller for downloading and installing the extension | 177 // Creates a WebstoreInstaller for downloading and installing the extension |
| 178 // with the given |id| from the Chrome Web Store. If |delegate| is not NULL, | 178 // with the given |id| from the Chrome Web Store. If |delegate| is not NULL, |
| 179 // it will be notified when the install succeeds or fails. The installer will | 179 // it will be notified when the install succeeds or fails. The installer will |
| 180 // use the specified |controller| to download the extension. Only one | 180 // use the specified |controller| to download the extension. Only one |
| 181 // WebstoreInstaller can use a specific controller at any given time. This | 181 // WebstoreInstaller can use a specific controller at any given time. This |
| 182 // also associates the |approval| with this install. | 182 // also associates the |approval| with this install. |
| 183 // Note: the delegate should stay alive until being called back. | 183 // Note: the delegate should stay alive until being called back. |
| 184 WebstoreInstaller(Profile* profile, | 184 WebstoreInstaller(Profile* profile, |
| 185 Delegate* delegate, | 185 Delegate* delegate, |
| 186 content::WebContents* web_contents, | 186 content::WebContents* web_contents, |
| 187 const std::string& id, | 187 const std::string& id, |
| 188 scoped_ptr<Approval> approval, | 188 std::unique_ptr<Approval> approval, |
| 189 InstallSource source); | 189 InstallSource source); |
| 190 | 190 |
| 191 // Starts downloading and installing the extension. | 191 // Starts downloading and installing the extension. |
| 192 void Start(); | 192 void Start(); |
| 193 | 193 |
| 194 // content::NotificationObserver. | 194 // content::NotificationObserver. |
| 195 void Observe(int type, | 195 void Observe(int type, |
| 196 const content::NotificationSource& source, | 196 const content::NotificationSource& source, |
| 197 const content::NotificationDetails& details) override; | 197 const content::NotificationDetails& details) override; |
| 198 | 198 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 Delegate* delegate_; | 268 Delegate* delegate_; |
| 269 std::string id_; | 269 std::string id_; |
| 270 InstallSource install_source_; | 270 InstallSource install_source_; |
| 271 // The DownloadItem is owned by the DownloadManager and is valid from when | 271 // The DownloadItem is owned by the DownloadManager and is valid from when |
| 272 // OnDownloadStarted is called (with no error) until OnDownloadDestroyed(). | 272 // OnDownloadStarted is called (with no error) until OnDownloadDestroyed(). |
| 273 content::DownloadItem* download_item_; | 273 content::DownloadItem* download_item_; |
| 274 // Used to periodically update the extension's download status. This will | 274 // Used to periodically update the extension's download status. This will |
| 275 // trigger at least every second, though sometimes more frequently (depending | 275 // trigger at least every second, though sometimes more frequently (depending |
| 276 // on number of modules, etc). | 276 // on number of modules, etc). |
| 277 base::OneShotTimer download_progress_timer_; | 277 base::OneShotTimer download_progress_timer_; |
| 278 scoped_ptr<Approval> approval_; | 278 std::unique_ptr<Approval> approval_; |
| 279 GURL download_url_; | 279 GURL download_url_; |
| 280 scoped_refptr<CrxInstaller> crx_installer_; | 280 scoped_refptr<CrxInstaller> crx_installer_; |
| 281 | 281 |
| 282 // Pending modules. | 282 // Pending modules. |
| 283 std::list<SharedModuleInfo::ImportInfo> pending_modules_; | 283 std::list<SharedModuleInfo::ImportInfo> pending_modules_; |
| 284 // Total extension modules we need download and install (the main module and | 284 // Total extension modules we need download and install (the main module and |
| 285 // depedences). | 285 // depedences). |
| 286 int total_modules_; | 286 int total_modules_; |
| 287 bool download_started_; | 287 bool download_started_; |
| 288 }; | 288 }; |
| 289 | 289 |
| 290 } // namespace extensions | 290 } // namespace extensions |
| 291 | 291 |
| 292 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_H_ | 292 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_H_ |
| OLD | NEW |