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 #include "chrome/browser/extensions/webstore_standalone_installer.h" | 5 #include "chrome/browser/extensions/webstore_standalone_installer.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/values.h" | 9 #include "base/values.h" |
8 #include "base/version.h" | 10 #include "base/version.h" |
9 #include "chrome/browser/extensions/crx_installer.h" | 11 #include "chrome/browser/extensions/crx_installer.h" |
10 #include "chrome/browser/extensions/extension_install_prompt.h" | 12 #include "chrome/browser/extensions/extension_install_prompt.h" |
11 #include "chrome/browser/extensions/extension_install_ui_util.h" | 13 #include "chrome/browser/extensions/extension_install_ui_util.h" |
12 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
13 #include "chrome/browser/extensions/install_tracker.h" | 15 #include "chrome/browser/extensions/install_tracker.h" |
14 #include "chrome/browser/extensions/webstore_data_fetcher.h" | 16 #include "chrome/browser/extensions/webstore_data_fetcher.h" |
15 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
16 #include "components/crx_file/id_util.h" | 18 #include "components/crx_file/id_util.h" |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 WebstoreStandaloneInstaller::CreateApproval() const { | 179 WebstoreStandaloneInstaller::CreateApproval() const { |
178 scoped_ptr<WebstoreInstaller::Approval> approval( | 180 scoped_ptr<WebstoreInstaller::Approval> approval( |
179 WebstoreInstaller::Approval::CreateWithNoInstallPrompt( | 181 WebstoreInstaller::Approval::CreateWithNoInstallPrompt( |
180 profile_, | 182 profile_, |
181 id_, | 183 id_, |
182 scoped_ptr<base::DictionaryValue>(manifest_.get()->DeepCopy()), | 184 scoped_ptr<base::DictionaryValue>(manifest_.get()->DeepCopy()), |
183 true)); | 185 true)); |
184 approval->skip_post_install_ui = !ShouldShowPostInstallUI(); | 186 approval->skip_post_install_ui = !ShouldShowPostInstallUI(); |
185 approval->use_app_installed_bubble = ShouldShowAppInstalledBubble(); | 187 approval->use_app_installed_bubble = ShouldShowAppInstalledBubble(); |
186 approval->installing_icon = gfx::ImageSkia::CreateFrom1xBitmap(icon_); | 188 approval->installing_icon = gfx::ImageSkia::CreateFrom1xBitmap(icon_); |
187 return approval.Pass(); | 189 return approval; |
188 } | 190 } |
189 | 191 |
190 void WebstoreStandaloneInstaller::InstallUIProceed() { | 192 void WebstoreStandaloneInstaller::InstallUIProceed() { |
191 if (!CheckRequestorAlive()) { | 193 if (!CheckRequestorAlive()) { |
192 CompleteInstall(webstore_install::ABORTED, std::string()); | 194 CompleteInstall(webstore_install::ABORTED, std::string()); |
193 return; | 195 return; |
194 } | 196 } |
195 | 197 |
196 scoped_ptr<WebstoreInstaller::Approval> approval = CreateApproval(); | 198 scoped_ptr<WebstoreInstaller::Approval> approval = CreateApproval(); |
197 | 199 |
(...skipping 15 matching lines...) Expand all Loading... |
213 // enable it. | 215 // enable it. |
214 extension_service->EnableExtension(id_); | 216 extension_service->EnableExtension(id_); |
215 } // else extension is installed and enabled; no work to be done. | 217 } // else extension is installed and enabled; no work to be done. |
216 | 218 |
217 if (done) { | 219 if (done) { |
218 CompleteInstall(install_result, install_message); | 220 CompleteInstall(install_result, install_message); |
219 return; | 221 return; |
220 } | 222 } |
221 } | 223 } |
222 | 224 |
223 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller( | 225 scoped_refptr<WebstoreInstaller> installer = |
224 profile_, | 226 new WebstoreInstaller(profile_, this, GetWebContents(), id_, |
225 this, | 227 std::move(approval), install_source_); |
226 GetWebContents(), | |
227 id_, | |
228 approval.Pass(), | |
229 install_source_); | |
230 installer->Start(); | 228 installer->Start(); |
231 } | 229 } |
232 | 230 |
233 void WebstoreStandaloneInstaller::InstallUIAbort(bool user_initiated) { | 231 void WebstoreStandaloneInstaller::InstallUIAbort(bool user_initiated) { |
234 CompleteInstall(webstore_install::USER_CANCELLED, kUserCancelledError); | 232 CompleteInstall(webstore_install::USER_CANCELLED, kUserCancelledError); |
235 } | 233 } |
236 | 234 |
237 void WebstoreStandaloneInstaller::OnWebstoreRequestFailure() { | 235 void WebstoreStandaloneInstaller::OnWebstoreRequestFailure() { |
238 OnWebStoreDataFetcherDone(); | 236 OnWebStoreDataFetcherDone(); |
239 CompleteInstall(webstore_install::WEBSTORE_REQUEST_ERROR, | 237 CompleteInstall(webstore_install::WEBSTORE_REQUEST_ERROR, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 icon_url = GURL(extension_urls::GetWebstoreLaunchURL()).Resolve( | 304 icon_url = GURL(extension_urls::GetWebstoreLaunchURL()).Resolve( |
307 icon_url_string); | 305 icon_url_string); |
308 if (!icon_url.is_valid()) { | 306 if (!icon_url.is_valid()) { |
309 CompleteInstall(webstore_install::INVALID_WEBSTORE_RESPONSE, | 307 CompleteInstall(webstore_install::INVALID_WEBSTORE_RESPONSE, |
310 kInvalidWebstoreResponseError); | 308 kInvalidWebstoreResponseError); |
311 return; | 309 return; |
312 } | 310 } |
313 } | 311 } |
314 | 312 |
315 // Assume ownership of webstore_data. | 313 // Assume ownership of webstore_data. |
316 webstore_data_ = webstore_data.Pass(); | 314 webstore_data_ = std::move(webstore_data); |
317 | 315 |
318 scoped_refptr<WebstoreInstallHelper> helper = | 316 scoped_refptr<WebstoreInstallHelper> helper = |
319 new WebstoreInstallHelper(this, | 317 new WebstoreInstallHelper(this, |
320 id_, | 318 id_, |
321 manifest, | 319 manifest, |
322 icon_url, | 320 icon_url, |
323 profile_->GetRequestContext()); | 321 profile_->GetRequestContext()); |
324 // The helper will call us back via OnWebstoreParseSucces or | 322 // The helper will call us back via OnWebstoreParseSucces or |
325 // OnWebstoreParseFailure. | 323 // OnWebstoreParseFailure. |
326 helper->Start(); | 324 helper->Start(); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 void WebstoreStandaloneInstaller::ShowInstallUI() { | 397 void WebstoreStandaloneInstaller::ShowInstallUI() { |
400 scoped_refptr<const Extension> localized_extension = | 398 scoped_refptr<const Extension> localized_extension = |
401 GetLocalizedExtensionForDisplay(); | 399 GetLocalizedExtensionForDisplay(); |
402 if (!localized_extension.get()) { | 400 if (!localized_extension.get()) { |
403 CompleteInstall(webstore_install::INVALID_MANIFEST, kInvalidManifestError); | 401 CompleteInstall(webstore_install::INVALID_MANIFEST, kInvalidManifestError); |
404 return; | 402 return; |
405 } | 403 } |
406 | 404 |
407 install_ui_ = CreateInstallUI(); | 405 install_ui_ = CreateInstallUI(); |
408 install_ui_->ShowDialog( | 406 install_ui_->ShowDialog( |
409 this, localized_extension.get(), &icon_, install_prompt_.Pass(), | 407 this, localized_extension.get(), &icon_, std::move(install_prompt_), |
410 ExtensionInstallPrompt::GetDefaultShowDialogCallback()); | 408 ExtensionInstallPrompt::GetDefaultShowDialogCallback()); |
411 } | 409 } |
412 | 410 |
413 void WebstoreStandaloneInstaller::OnWebStoreDataFetcherDone() { | 411 void WebstoreStandaloneInstaller::OnWebStoreDataFetcherDone() { |
414 // An instance of this class is passed in as a delegate for the | 412 // An instance of this class is passed in as a delegate for the |
415 // WebstoreInstallHelper, ExtensionInstallPrompt and WebstoreInstaller, and | 413 // WebstoreInstallHelper, ExtensionInstallPrompt and WebstoreInstaller, and |
416 // therefore needs to remain alive until they are done. Clear the webstore | 414 // therefore needs to remain alive until they are done. Clear the webstore |
417 // data fetcher to avoid calling Release in AbortInstall while any of these | 415 // data fetcher to avoid calling Release in AbortInstall while any of these |
418 // operations are in progress. | 416 // operations are in progress. |
419 webstore_data_fetcher_.reset(); | 417 webstore_data_fetcher_.reset(); |
420 } | 418 } |
421 | 419 |
422 } // namespace extensions | 420 } // namespace extensions |
OLD | NEW |