| 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 #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 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "content/browser/tab_contents/tab_contents.h" | 30 #include "content/browser/tab_contents/tab_contents.h" |
| 31 #include "content/common/notification_details.h" | 31 #include "content/common/notification_details.h" |
| 32 #include "content/common/notification_source.h" | 32 #include "content/common/notification_source.h" |
| 33 #include "grit/chromium_strings.h" | 33 #include "grit/chromium_strings.h" |
| 34 #include "grit/generated_resources.h" | 34 #include "grit/generated_resources.h" |
| 35 #include "net/base/escape.h" | 35 #include "net/base/escape.h" |
| 36 #include "ui/base/l10n/l10n_util.h" | 36 #include "ui/base/l10n/l10n_util.h" |
| 37 | 37 |
| 38 namespace { | 38 namespace { |
| 39 | 39 |
| 40 const char kAppInstallBubbleKey[] = "appInstallBubble"; |
| 40 const char kIconDataKey[] = "iconData"; | 41 const char kIconDataKey[] = "iconData"; |
| 41 const char kIdKey[] = "id"; | 42 const char kIdKey[] = "id"; |
| 42 const char kLocalizedNameKey[] = "localizedName"; | 43 const char kLocalizedNameKey[] = "localizedName"; |
| 43 const char kLoginKey[] = "login"; | 44 const char kLoginKey[] = "login"; |
| 44 const char kManifestKey[] = "manifest"; | 45 const char kManifestKey[] = "manifest"; |
| 45 const char kTokenKey[] = "token"; | 46 const char kTokenKey[] = "token"; |
| 46 | 47 |
| 47 const char kImageDecodeError[] = "Image decode failed"; | 48 const char kImageDecodeError[] = "Image decode failed"; |
| 48 const char kInvalidIdError[] = "Invalid id"; | 49 const char kInvalidIdError[] = "Invalid id"; |
| 49 const char kInvalidManifestError[] = "Invalid manifest"; | 50 const char kInvalidManifestError[] = "Invalid manifest"; |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 scoped_ptr<DictionaryValue> parsed_manifest_; | 287 scoped_ptr<DictionaryValue> parsed_manifest_; |
| 287 | 288 |
| 288 // A details string for keeping track of any errors. | 289 // A details string for keeping track of any errors. |
| 289 std::string error_; | 290 std::string error_; |
| 290 | 291 |
| 291 // A code to distinguish between an error with the icon, and an error with the | 292 // A code to distinguish between an error with the icon, and an error with the |
| 292 // manifest. | 293 // manifest. |
| 293 BeginInstallWithManifestFunction::ResultCode parse_error_; | 294 BeginInstallWithManifestFunction::ResultCode parse_error_; |
| 294 }; | 295 }; |
| 295 | 296 |
| 296 BeginInstallWithManifestFunction::BeginInstallWithManifestFunction() {} | 297 BeginInstallWithManifestFunction::BeginInstallWithManifestFunction() |
| 298 : use_app_installed_bubble_(false) {} |
| 297 | 299 |
| 298 BeginInstallWithManifestFunction::~BeginInstallWithManifestFunction() {} | 300 BeginInstallWithManifestFunction::~BeginInstallWithManifestFunction() {} |
| 299 | 301 |
| 300 bool BeginInstallWithManifestFunction::RunImpl() { | 302 bool BeginInstallWithManifestFunction::RunImpl() { |
| 301 if (!IsWebStoreURL(profile_, source_url())) { | 303 if (!IsWebStoreURL(profile_, source_url())) { |
| 302 SetResult(PERMISSION_DENIED); | 304 SetResult(PERMISSION_DENIED); |
| 303 return false; | 305 return false; |
| 304 } | 306 } |
| 305 | 307 |
| 306 if (!user_gesture() && !ignore_user_gesture_for_tests) { | 308 if (!user_gesture() && !ignore_user_gesture_for_tests) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 322 | 324 |
| 323 EXTENSION_FUNCTION_VALIDATE(details->GetString(kManifestKey, &manifest_)); | 325 EXTENSION_FUNCTION_VALIDATE(details->GetString(kManifestKey, &manifest_)); |
| 324 | 326 |
| 325 if (details->HasKey(kIconDataKey)) | 327 if (details->HasKey(kIconDataKey)) |
| 326 EXTENSION_FUNCTION_VALIDATE(details->GetString(kIconDataKey, &icon_data_)); | 328 EXTENSION_FUNCTION_VALIDATE(details->GetString(kIconDataKey, &icon_data_)); |
| 327 | 329 |
| 328 if (details->HasKey(kLocalizedNameKey)) | 330 if (details->HasKey(kLocalizedNameKey)) |
| 329 EXTENSION_FUNCTION_VALIDATE(details->GetString(kLocalizedNameKey, | 331 EXTENSION_FUNCTION_VALIDATE(details->GetString(kLocalizedNameKey, |
| 330 &localized_name_)); | 332 &localized_name_)); |
| 331 | 333 |
| 334 if (details->HasKey(kAppInstallBubbleKey)) |
| 335 EXTENSION_FUNCTION_VALIDATE(details->GetBoolean( |
| 336 kAppInstallBubbleKey, &use_app_installed_bubble_)); |
| 337 |
| 332 scoped_refptr<SafeBeginInstallHelper> helper = | 338 scoped_refptr<SafeBeginInstallHelper> helper = |
| 333 new SafeBeginInstallHelper(this, icon_data_, manifest_); | 339 new SafeBeginInstallHelper(this, icon_data_, manifest_); |
| 334 // The helper will call us back via OnParseSucces or OnParseFailure. | 340 // The helper will call us back via OnParseSucces or OnParseFailure. |
| 335 helper->Start(); | 341 helper->Start(); |
| 336 | 342 |
| 337 // Matched with a Release in OnSuccess/OnFailure. | 343 // Matched with a Release in OnSuccess/OnFailure. |
| 338 AddRef(); | 344 AddRef(); |
| 339 | 345 |
| 340 // The response is sent asynchronously in OnSuccess/OnFailure. | 346 // The response is sent asynchronously in OnSuccess/OnFailure. |
| 341 return true; | 347 return true; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 SendResponse(false); | 450 SendResponse(false); |
| 445 | 451 |
| 446 // Matches the AddRef in RunImpl(). | 452 // Matches the AddRef in RunImpl(). |
| 447 Release(); | 453 Release(); |
| 448 } | 454 } |
| 449 | 455 |
| 450 void BeginInstallWithManifestFunction::InstallUIProceed() { | 456 void BeginInstallWithManifestFunction::InstallUIProceed() { |
| 451 CrxInstaller::WhitelistEntry* entry = new CrxInstaller::WhitelistEntry; | 457 CrxInstaller::WhitelistEntry* entry = new CrxInstaller::WhitelistEntry; |
| 452 entry->parsed_manifest.reset(parsed_manifest_.release()); | 458 entry->parsed_manifest.reset(parsed_manifest_.release()); |
| 453 entry->localized_name = localized_name_; | 459 entry->localized_name = localized_name_; |
| 460 entry->use_app_installed_bubble = use_app_installed_bubble_; |
| 454 CrxInstaller::SetWhitelistEntry(id_, entry); | 461 CrxInstaller::SetWhitelistEntry(id_, entry); |
| 455 SetResult(ERROR_NONE); | 462 SetResult(ERROR_NONE); |
| 456 SendResponse(true); | 463 SendResponse(true); |
| 457 | 464 |
| 458 // The Permissions_Install histogram is recorded from the ExtensionService | 465 // The Permissions_Install histogram is recorded from the ExtensionService |
| 459 // for all extension installs, so we only need to record the web store | 466 // for all extension installs, so we only need to record the web store |
| 460 // specific histogram here. | 467 // specific histogram here. |
| 461 ExtensionService::RecordPermissionMessagesHistogram( | 468 ExtensionService::RecordPermissionMessagesHistogram( |
| 462 dummy_extension_, "Extensions.Permissions_WebStoreInstall"); | 469 dummy_extension_, "Extensions.Permissions_WebStoreInstall"); |
| 463 | 470 |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 } | 676 } |
| 670 | 677 |
| 671 DCHECK(waiting_for_token_); | 678 DCHECK(waiting_for_token_); |
| 672 | 679 |
| 673 result_.reset(CreateLoginResult(profile_->GetOriginalProfile())); | 680 result_.reset(CreateLoginResult(profile_->GetOriginalProfile())); |
| 674 SendResponse(true); | 681 SendResponse(true); |
| 675 | 682 |
| 676 // Matches the AddRef in RunImpl(). | 683 // Matches the AddRef in RunImpl(). |
| 677 Release(); | 684 Release(); |
| 678 } | 685 } |
| OLD | NEW |