| 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/extension_webstore_private_api.h" | 5 #include "chrome/browser/extensions/extension_webstore_private_api.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 Release(); // Balanced in RunImpl(). | 243 Release(); // Balanced in RunImpl(). |
| 244 } | 244 } |
| 245 | 245 |
| 246 void InstallBundleFunction::OnBundleInstallCompleted() { | 246 void InstallBundleFunction::OnBundleInstallCompleted() { |
| 247 SendResponse(true); | 247 SendResponse(true); |
| 248 | 248 |
| 249 Release(); // Balanced in RunImpl(). | 249 Release(); // Balanced in RunImpl(). |
| 250 } | 250 } |
| 251 | 251 |
| 252 BeginInstallWithManifestFunction::BeginInstallWithManifestFunction() | 252 BeginInstallWithManifestFunction::BeginInstallWithManifestFunction() |
| 253 : use_app_installed_bubble_(false) {} | 253 : use_app_installed_bubble_(false) {} |
| 254 | 254 |
| 255 BeginInstallWithManifestFunction::~BeginInstallWithManifestFunction() {} | 255 BeginInstallWithManifestFunction::~BeginInstallWithManifestFunction() {} |
| 256 | 256 |
| 257 bool BeginInstallWithManifestFunction::RunImpl() { | 257 bool BeginInstallWithManifestFunction::RunImpl() { |
| 258 DictionaryValue* details = NULL; | 258 DictionaryValue* details = NULL; |
| 259 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &details)); | 259 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &details)); |
| 260 CHECK(details); | 260 CHECK(details); |
| 261 | 261 |
| 262 EXTENSION_FUNCTION_VALIDATE(details->GetString(kIdKey, &id_)); | 262 EXTENSION_FUNCTION_VALIDATE(details->GetString(kIdKey, &id_)); |
| 263 if (!Extension::IdIsValid(id_)) { | 263 if (!Extension::IdIsValid(id_)) { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 | 350 |
| 351 void BeginInstallWithManifestFunction::OnWebstoreParseSuccess( | 351 void BeginInstallWithManifestFunction::OnWebstoreParseSuccess( |
| 352 const std::string& id, | 352 const std::string& id, |
| 353 const SkBitmap& icon, | 353 const SkBitmap& icon, |
| 354 DictionaryValue* parsed_manifest) { | 354 DictionaryValue* parsed_manifest) { |
| 355 CHECK_EQ(id_, id); | 355 CHECK_EQ(id_, id); |
| 356 CHECK(parsed_manifest); | 356 CHECK(parsed_manifest); |
| 357 icon_ = icon; | 357 icon_ = icon; |
| 358 parsed_manifest_.reset(parsed_manifest); | 358 parsed_manifest_.reset(parsed_manifest); |
| 359 | 359 |
| 360 ExtensionInstallUI::Prompt prompt(ExtensionInstallUI::INSTALL_PROMPT); | 360 std::string error; |
| 361 dummy_extension_ = ExtensionInstallUI::LocalizeExtensionForDisplay( |
| 362 parsed_manifest_.get(), id, localized_name_, "", &error); |
| 361 | 363 |
| 362 if (!ShowExtensionInstallDialogForManifest( | 364 if (!dummy_extension_) { |
| 363 profile(), | |
| 364 this, | |
| 365 parsed_manifest, | |
| 366 id_, | |
| 367 localized_name_, | |
| 368 "", // no localized description | |
| 369 &icon_, | |
| 370 prompt, | |
| 371 &dummy_extension_)) { | |
| 372 OnWebstoreParseFailure(id_, WebstoreInstallHelper::Delegate::MANIFEST_ERROR, | 365 OnWebstoreParseFailure(id_, WebstoreInstallHelper::Delegate::MANIFEST_ERROR, |
| 373 kInvalidManifestError); | 366 kInvalidManifestError); |
| 374 return; | 367 return; |
| 375 } | 368 } |
| 376 | 369 |
| 370 install_ui_.reset(new ExtensionInstallUI(profile())); |
| 371 install_ui_->ConfirmWebstoreInstall(this, dummy_extension_, &icon_); |
| 377 // Control flow finishes up in InstallUIProceed or InstallUIAbort. | 372 // Control flow finishes up in InstallUIProceed or InstallUIAbort. |
| 378 } | 373 } |
| 379 | 374 |
| 380 void BeginInstallWithManifestFunction::OnWebstoreParseFailure( | 375 void BeginInstallWithManifestFunction::OnWebstoreParseFailure( |
| 381 const std::string& id, | 376 const std::string& id, |
| 382 WebstoreInstallHelper::Delegate::InstallHelperResultCode result_code, | 377 WebstoreInstallHelper::Delegate::InstallHelperResultCode result_code, |
| 383 const std::string& error_message) { | 378 const std::string& error_message) { |
| 384 CHECK_EQ(id_, id); | 379 CHECK_EQ(id_, id); |
| 385 | 380 |
| 386 // Map from WebstoreInstallHelper's result codes to ours. | 381 // Map from WebstoreInstallHelper's result codes to ours. |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 SendResponse(true); | 635 SendResponse(true); |
| 641 } else { | 636 } else { |
| 642 // Matched with a Release in OnGpuInfoUpdate. | 637 // Matched with a Release in OnGpuInfoUpdate. |
| 643 AddRef(); | 638 AddRef(); |
| 644 | 639 |
| 645 manager->AddObserver(this); | 640 manager->AddObserver(this); |
| 646 manager->RequestCompleteGpuInfoIfNeeded(); | 641 manager->RequestCompleteGpuInfoIfNeeded(); |
| 647 } | 642 } |
| 648 return true; | 643 return true; |
| 649 } | 644 } |
| OLD | NEW |