| 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/api/webstore_private/webstore_private_api.h" | 5 #include "chrome/browser/extensions/api/webstore_private/webstore_private_api.h" |
| 6 | 6 |
| 7 #include "apps/app_launcher.h" | 7 #include "apps/app_launcher.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 test_webstore_installer_delegate = delegate; | 199 test_webstore_installer_delegate = delegate; |
| 200 } | 200 } |
| 201 | 201 |
| 202 // static | 202 // static |
| 203 scoped_ptr<WebstoreInstaller::Approval> | 203 scoped_ptr<WebstoreInstaller::Approval> |
| 204 WebstorePrivateApi::PopApprovalForTesting( | 204 WebstorePrivateApi::PopApprovalForTesting( |
| 205 Profile* profile, const std::string& extension_id) { | 205 Profile* profile, const std::string& extension_id) { |
| 206 return g_pending_approvals.Get().PopApproval(profile, extension_id); | 206 return g_pending_approvals.Get().PopApproval(profile, extension_id); |
| 207 } | 207 } |
| 208 | 208 |
| 209 InstallBundleFunction::InstallBundleFunction() {} | 209 WebstorePrivateInstallBundleFunction::WebstorePrivateInstallBundleFunction() {} |
| 210 InstallBundleFunction::~InstallBundleFunction() {} | 210 WebstorePrivateInstallBundleFunction::~WebstorePrivateInstallBundleFunction() {} |
| 211 | 211 |
| 212 bool InstallBundleFunction::RunImpl() { | 212 bool WebstorePrivateInstallBundleFunction::RunImpl() { |
| 213 base::ListValue* extensions = NULL; | 213 base::ListValue* extensions = NULL; |
| 214 EXTENSION_FUNCTION_VALIDATE(args_->GetList(0, &extensions)); | 214 EXTENSION_FUNCTION_VALIDATE(args_->GetList(0, &extensions)); |
| 215 | 215 |
| 216 BundleInstaller::ItemList items; | 216 BundleInstaller::ItemList items; |
| 217 if (!ReadBundleInfo(extensions, &items)) | 217 if (!ReadBundleInfo(extensions, &items)) |
| 218 return false; | 218 return false; |
| 219 | 219 |
| 220 bundle_ = new BundleInstaller(GetCurrentBrowser(), items); | 220 bundle_ = new BundleInstaller(GetCurrentBrowser(), items); |
| 221 | 221 |
| 222 AddRef(); // Balanced in OnBundleInstallCompleted / OnBundleInstallCanceled. | 222 AddRef(); // Balanced in OnBundleInstallCompleted / OnBundleInstallCanceled. |
| 223 | 223 |
| 224 bundle_->PromptForApproval(this); | 224 bundle_->PromptForApproval(this); |
| 225 return true; | 225 return true; |
| 226 } | 226 } |
| 227 | 227 |
| 228 bool InstallBundleFunction::ReadBundleInfo(base::ListValue* extensions, | 228 bool WebstorePrivateInstallBundleFunction:: |
| 229 BundleInstaller::ItemList* items) { | 229 ReadBundleInfo(base::ListValue* extensions, |
| 230 BundleInstaller::ItemList* items) { |
| 230 for (size_t i = 0; i < extensions->GetSize(); ++i) { | 231 for (size_t i = 0; i < extensions->GetSize(); ++i) { |
| 231 base::DictionaryValue* details = NULL; | 232 base::DictionaryValue* details = NULL; |
| 232 EXTENSION_FUNCTION_VALIDATE(extensions->GetDictionary(i, &details)); | 233 EXTENSION_FUNCTION_VALIDATE(extensions->GetDictionary(i, &details)); |
| 233 | 234 |
| 234 BundleInstaller::Item item; | 235 BundleInstaller::Item item; |
| 235 EXTENSION_FUNCTION_VALIDATE(details->GetString( | 236 EXTENSION_FUNCTION_VALIDATE(details->GetString( |
| 236 kIdKey, &item.id)); | 237 kIdKey, &item.id)); |
| 237 EXTENSION_FUNCTION_VALIDATE(details->GetString( | 238 EXTENSION_FUNCTION_VALIDATE(details->GetString( |
| 238 kManifestKey, &item.manifest)); | 239 kManifestKey, &item.manifest)); |
| 239 EXTENSION_FUNCTION_VALIDATE(details->GetString( | 240 EXTENSION_FUNCTION_VALIDATE(details->GetString( |
| 240 kLocalizedNameKey, &item.localized_name)); | 241 kLocalizedNameKey, &item.localized_name)); |
| 241 | 242 |
| 242 items->push_back(item); | 243 items->push_back(item); |
| 243 } | 244 } |
| 244 | 245 |
| 245 return true; | 246 return true; |
| 246 } | 247 } |
| 247 | 248 |
| 248 void InstallBundleFunction::OnBundleInstallApproved() { | 249 void WebstorePrivateInstallBundleFunction::OnBundleInstallApproved() { |
| 249 bundle_->CompleteInstall( | 250 bundle_->CompleteInstall( |
| 250 &(dispatcher()->delegate()->GetAssociatedWebContents()->GetController()), | 251 &(dispatcher()->delegate()->GetAssociatedWebContents()->GetController()), |
| 251 this); | 252 this); |
| 252 } | 253 } |
| 253 | 254 |
| 254 void InstallBundleFunction::OnBundleInstallCanceled(bool user_initiated) { | 255 void WebstorePrivateInstallBundleFunction::OnBundleInstallCanceled( |
| 256 bool user_initiated) { |
| 255 if (user_initiated) | 257 if (user_initiated) |
| 256 error_ = "user_canceled"; | 258 error_ = "user_canceled"; |
| 257 else | 259 else |
| 258 error_ = "unknown_error"; | 260 error_ = "unknown_error"; |
| 259 | 261 |
| 260 SendResponse(false); | 262 SendResponse(false); |
| 261 | 263 |
| 262 Release(); // Balanced in RunImpl(). | 264 Release(); // Balanced in RunImpl(). |
| 263 } | 265 } |
| 264 | 266 |
| 265 void InstallBundleFunction::OnBundleInstallCompleted() { | 267 void WebstorePrivateInstallBundleFunction::OnBundleInstallCompleted() { |
| 266 SendResponse(true); | 268 SendResponse(true); |
| 267 | 269 |
| 268 Release(); // Balanced in RunImpl(). | 270 Release(); // Balanced in RunImpl(). |
| 269 } | 271 } |
| 270 | 272 |
| 271 BeginInstallWithManifestFunction::BeginInstallWithManifestFunction() | 273 WebstorePrivateBeginInstallWithManifest3Function:: |
| 274 WebstorePrivateBeginInstallWithManifest3Function() |
| 272 : use_app_installed_bubble_(false), enable_launcher_(false) {} | 275 : use_app_installed_bubble_(false), enable_launcher_(false) {} |
| 273 | 276 |
| 274 BeginInstallWithManifestFunction::~BeginInstallWithManifestFunction() {} | 277 WebstorePrivateBeginInstallWithManifest3Function:: |
| 278 ~WebstorePrivateBeginInstallWithManifest3Function() {} |
| 275 | 279 |
| 276 bool BeginInstallWithManifestFunction::RunImpl() { | 280 bool WebstorePrivateBeginInstallWithManifest3Function::RunImpl() { |
| 277 base::DictionaryValue* details = NULL; | 281 base::DictionaryValue* details = NULL; |
| 278 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &details)); | 282 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &details)); |
| 279 CHECK(details); | 283 CHECK(details); |
| 280 | 284 |
| 281 EXTENSION_FUNCTION_VALIDATE(details->GetString(kIdKey, &id_)); | 285 EXTENSION_FUNCTION_VALIDATE(details->GetString(kIdKey, &id_)); |
| 282 if (!extensions::Extension::IdIsValid(id_)) { | 286 if (!extensions::Extension::IdIsValid(id_)) { |
| 283 SetResultCode(INVALID_ID); | 287 SetResultCode(INVALID_ID); |
| 284 error_ = kInvalidIdError; | 288 error_ = kInvalidIdError; |
| 285 return false; | 289 return false; |
| 286 } | 290 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 | 346 |
| 343 // Matched with a Release in OnWebstoreParseSuccess/OnWebstoreParseFailure. | 347 // Matched with a Release in OnWebstoreParseSuccess/OnWebstoreParseFailure. |
| 344 AddRef(); | 348 AddRef(); |
| 345 | 349 |
| 346 // The response is sent asynchronously in OnWebstoreParseSuccess/ | 350 // The response is sent asynchronously in OnWebstoreParseSuccess/ |
| 347 // OnWebstoreParseFailure. | 351 // OnWebstoreParseFailure. |
| 348 return true; | 352 return true; |
| 349 } | 353 } |
| 350 | 354 |
| 351 | 355 |
| 352 void BeginInstallWithManifestFunction::SetResultCode(ResultCode code) { | 356 void WebstorePrivateBeginInstallWithManifest3Function::SetResultCode( |
| 357 ResultCode code) { |
| 353 switch (code) { | 358 switch (code) { |
| 354 case ERROR_NONE: | 359 case ERROR_NONE: |
| 355 SetResult(Value::CreateStringValue(std::string())); | 360 SetResult(Value::CreateStringValue(std::string())); |
| 356 break; | 361 break; |
| 357 case UNKNOWN_ERROR: | 362 case UNKNOWN_ERROR: |
| 358 SetResult(Value::CreateStringValue("unknown_error")); | 363 SetResult(Value::CreateStringValue("unknown_error")); |
| 359 break; | 364 break; |
| 360 case USER_CANCELLED: | 365 case USER_CANCELLED: |
| 361 SetResult(Value::CreateStringValue("user_cancelled")); | 366 SetResult(Value::CreateStringValue("user_cancelled")); |
| 362 break; | 367 break; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 379 SetResult(Value::CreateStringValue("signin_failed")); | 384 SetResult(Value::CreateStringValue("signin_failed")); |
| 380 break; | 385 break; |
| 381 case ALREADY_INSTALLED: | 386 case ALREADY_INSTALLED: |
| 382 SetResult(Value::CreateStringValue("already_installed")); | 387 SetResult(Value::CreateStringValue("already_installed")); |
| 383 break; | 388 break; |
| 384 default: | 389 default: |
| 385 CHECK(false); | 390 CHECK(false); |
| 386 } | 391 } |
| 387 } | 392 } |
| 388 | 393 |
| 389 void BeginInstallWithManifestFunction::OnWebstoreParseSuccess( | 394 void WebstorePrivateBeginInstallWithManifest3Function::OnWebstoreParseSuccess( |
| 390 const std::string& id, | 395 const std::string& id, |
| 391 const SkBitmap& icon, | 396 const SkBitmap& icon, |
| 392 base::DictionaryValue* parsed_manifest) { | 397 base::DictionaryValue* parsed_manifest) { |
| 393 CHECK_EQ(id_, id); | 398 CHECK_EQ(id_, id); |
| 394 CHECK(parsed_manifest); | 399 CHECK(parsed_manifest); |
| 395 icon_ = icon; | 400 icon_ = icon; |
| 396 parsed_manifest_.reset(parsed_manifest); | 401 parsed_manifest_.reset(parsed_manifest); |
| 397 | 402 |
| 398 std::string error; | 403 std::string error; |
| 399 dummy_extension_ = ExtensionInstallPrompt::GetLocalizedExtensionForDisplay( | 404 dummy_extension_ = ExtensionInstallPrompt::GetLocalizedExtensionForDisplay( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 417 signin_manager && | 422 signin_manager && |
| 418 signin_manager->GetAuthenticatedUsername().empty() && | 423 signin_manager->GetAuthenticatedUsername().empty() && |
| 419 signin_manager->AuthInProgress()) { | 424 signin_manager->AuthInProgress()) { |
| 420 signin_tracker_.reset(new SigninTracker(profile(), this)); | 425 signin_tracker_.reset(new SigninTracker(profile(), this)); |
| 421 return; | 426 return; |
| 422 } | 427 } |
| 423 | 428 |
| 424 SigninCompletedOrNotNeeded(); | 429 SigninCompletedOrNotNeeded(); |
| 425 } | 430 } |
| 426 | 431 |
| 427 void BeginInstallWithManifestFunction::OnWebstoreParseFailure( | 432 void WebstorePrivateBeginInstallWithManifest3Function::OnWebstoreParseFailure( |
| 428 const std::string& id, | 433 const std::string& id, |
| 429 WebstoreInstallHelper::Delegate::InstallHelperResultCode result_code, | 434 WebstoreInstallHelper::Delegate::InstallHelperResultCode result_code, |
| 430 const std::string& error_message) { | 435 const std::string& error_message) { |
| 431 CHECK_EQ(id_, id); | 436 CHECK_EQ(id_, id); |
| 432 | 437 |
| 433 // Map from WebstoreInstallHelper's result codes to ours. | 438 // Map from WebstoreInstallHelper's result codes to ours. |
| 434 switch (result_code) { | 439 switch (result_code) { |
| 435 case WebstoreInstallHelper::Delegate::UNKNOWN_ERROR: | 440 case WebstoreInstallHelper::Delegate::UNKNOWN_ERROR: |
| 436 SetResultCode(UNKNOWN_ERROR); | 441 SetResultCode(UNKNOWN_ERROR); |
| 437 break; | 442 break; |
| 438 case WebstoreInstallHelper::Delegate::ICON_ERROR: | 443 case WebstoreInstallHelper::Delegate::ICON_ERROR: |
| 439 SetResultCode(ICON_ERROR); | 444 SetResultCode(ICON_ERROR); |
| 440 break; | 445 break; |
| 441 case WebstoreInstallHelper::Delegate::MANIFEST_ERROR: | 446 case WebstoreInstallHelper::Delegate::MANIFEST_ERROR: |
| 442 SetResultCode(MANIFEST_ERROR); | 447 SetResultCode(MANIFEST_ERROR); |
| 443 break; | 448 break; |
| 444 default: | 449 default: |
| 445 CHECK(false); | 450 CHECK(false); |
| 446 } | 451 } |
| 447 error_ = error_message; | 452 error_ = error_message; |
| 448 g_pending_installs.Get().EraseInstall(profile_, id); | 453 g_pending_installs.Get().EraseInstall(profile_, id); |
| 449 SendResponse(false); | 454 SendResponse(false); |
| 450 | 455 |
| 451 // Matches the AddRef in RunImpl(). | 456 // Matches the AddRef in RunImpl(). |
| 452 Release(); | 457 Release(); |
| 453 } | 458 } |
| 454 | 459 |
| 455 void BeginInstallWithManifestFunction::SigninFailed( | 460 void WebstorePrivateBeginInstallWithManifest3Function::SigninFailed( |
| 456 const GoogleServiceAuthError& error) { | 461 const GoogleServiceAuthError& error) { |
| 457 signin_tracker_.reset(); | 462 signin_tracker_.reset(); |
| 458 | 463 |
| 459 SetResultCode(SIGNIN_FAILED); | 464 SetResultCode(SIGNIN_FAILED); |
| 460 error_ = error.ToString(); | 465 error_ = error.ToString(); |
| 461 g_pending_installs.Get().EraseInstall(profile_, id_); | 466 g_pending_installs.Get().EraseInstall(profile_, id_); |
| 462 SendResponse(false); | 467 SendResponse(false); |
| 463 | 468 |
| 464 // Matches the AddRef in RunImpl(). | 469 // Matches the AddRef in RunImpl(). |
| 465 Release(); | 470 Release(); |
| 466 } | 471 } |
| 467 | 472 |
| 468 void BeginInstallWithManifestFunction::SigninSuccess() { | 473 void WebstorePrivateBeginInstallWithManifest3Function::SigninSuccess() { |
| 469 signin_tracker_.reset(); | 474 signin_tracker_.reset(); |
| 470 | 475 |
| 471 SigninCompletedOrNotNeeded(); | 476 SigninCompletedOrNotNeeded(); |
| 472 } | 477 } |
| 473 | 478 |
| 474 void BeginInstallWithManifestFunction::SigninCompletedOrNotNeeded() { | 479 void WebstorePrivateBeginInstallWithManifest3Function:: |
| 480 SigninCompletedOrNotNeeded() { |
| 475 content::WebContents* web_contents = GetAssociatedWebContents(); | 481 content::WebContents* web_contents = GetAssociatedWebContents(); |
| 476 if (!web_contents) // The browser window has gone away. | 482 if (!web_contents) // The browser window has gone away. |
| 477 return; | 483 return; |
| 478 install_prompt_.reset(new ExtensionInstallPrompt(web_contents)); | 484 install_prompt_.reset(new ExtensionInstallPrompt(web_contents)); |
| 479 install_prompt_->ConfirmWebstoreInstall( | 485 install_prompt_->ConfirmWebstoreInstall( |
| 480 this, | 486 this, |
| 481 dummy_extension_.get(), | 487 dummy_extension_.get(), |
| 482 &icon_, | 488 &icon_, |
| 483 ExtensionInstallPrompt::GetDefaultShowDialogCallback()); | 489 ExtensionInstallPrompt::GetDefaultShowDialogCallback()); |
| 484 // Control flow finishes up in InstallUIProceed or InstallUIAbort. | 490 // Control flow finishes up in InstallUIProceed or InstallUIAbort. |
| 485 } | 491 } |
| 486 | 492 |
| 487 void BeginInstallWithManifestFunction::InstallUIProceed() { | 493 void WebstorePrivateBeginInstallWithManifest3Function::InstallUIProceed() { |
| 488 // This gets cleared in CrxInstaller::ConfirmInstall(). TODO(asargent) - in | 494 // This gets cleared in CrxInstaller::ConfirmInstall(). TODO(asargent) - in |
| 489 // the future we may also want to add time-based expiration, where a whitelist | 495 // the future we may also want to add time-based expiration, where a whitelist |
| 490 // entry is only valid for some number of minutes. | 496 // entry is only valid for some number of minutes. |
| 491 scoped_ptr<WebstoreInstaller::Approval> approval( | 497 scoped_ptr<WebstoreInstaller::Approval> approval( |
| 492 WebstoreInstaller::Approval::CreateWithNoInstallPrompt( | 498 WebstoreInstaller::Approval::CreateWithNoInstallPrompt( |
| 493 profile(), id_, parsed_manifest_.Pass())); | 499 profile(), id_, parsed_manifest_.Pass())); |
| 494 approval->use_app_installed_bubble = use_app_installed_bubble_; | 500 approval->use_app_installed_bubble = use_app_installed_bubble_; |
| 495 approval->enable_launcher = enable_launcher_; | 501 approval->enable_launcher = enable_launcher_; |
| 496 // If we are enabling the launcher, we should not show the app list in order | 502 // If we are enabling the launcher, we should not show the app list in order |
| 497 // to train the user to open it themselves at least once. | 503 // to train the user to open it themselves at least once. |
| 498 approval->skip_post_install_ui = enable_launcher_; | 504 approval->skip_post_install_ui = enable_launcher_; |
| 499 approval->installing_icon = gfx::ImageSkia::CreateFrom1xBitmap(icon_); | 505 approval->installing_icon = gfx::ImageSkia::CreateFrom1xBitmap(icon_); |
| 500 g_pending_approvals.Get().PushApproval(approval.Pass()); | 506 g_pending_approvals.Get().PushApproval(approval.Pass()); |
| 501 | 507 |
| 502 SetResultCode(ERROR_NONE); | 508 SetResultCode(ERROR_NONE); |
| 503 SendResponse(true); | 509 SendResponse(true); |
| 504 | 510 |
| 505 // The Permissions_Install histogram is recorded from the ExtensionService | 511 // The Permissions_Install histogram is recorded from the ExtensionService |
| 506 // for all extension installs, so we only need to record the web store | 512 // for all extension installs, so we only need to record the web store |
| 507 // specific histogram here. | 513 // specific histogram here. |
| 508 ExtensionService::RecordPermissionMessagesHistogram( | 514 ExtensionService::RecordPermissionMessagesHistogram( |
| 509 dummy_extension_.get(), "Extensions.Permissions_WebStoreInstall"); | 515 dummy_extension_.get(), "Extensions.Permissions_WebStoreInstall"); |
| 510 | 516 |
| 511 // Matches the AddRef in RunImpl(). | 517 // Matches the AddRef in RunImpl(). |
| 512 Release(); | 518 Release(); |
| 513 } | 519 } |
| 514 | 520 |
| 515 void BeginInstallWithManifestFunction::InstallUIAbort(bool user_initiated) { | 521 void WebstorePrivateBeginInstallWithManifest3Function::InstallUIAbort( |
| 522 bool user_initiated) { |
| 516 error_ = kUserCancelledError; | 523 error_ = kUserCancelledError; |
| 517 SetResultCode(USER_CANCELLED); | 524 SetResultCode(USER_CANCELLED); |
| 518 g_pending_installs.Get().EraseInstall(profile_, id_); | 525 g_pending_installs.Get().EraseInstall(profile_, id_); |
| 519 SendResponse(false); | 526 SendResponse(false); |
| 520 | 527 |
| 521 // The web store install histograms are a subset of the install histograms. | 528 // The web store install histograms are a subset of the install histograms. |
| 522 // We need to record both histograms here since CrxInstaller::InstallUIAbort | 529 // We need to record both histograms here since CrxInstaller::InstallUIAbort |
| 523 // is never called for web store install cancellations. | 530 // is never called for web store install cancellations. |
| 524 std::string histogram_name = user_initiated ? | 531 std::string histogram_name = user_initiated ? |
| 525 "Extensions.Permissions_WebStoreInstallCancel" : | 532 "Extensions.Permissions_WebStoreInstallCancel" : |
| 526 "Extensions.Permissions_WebStoreInstallAbort"; | 533 "Extensions.Permissions_WebStoreInstallAbort"; |
| 527 ExtensionService::RecordPermissionMessagesHistogram(dummy_extension_.get(), | 534 ExtensionService::RecordPermissionMessagesHistogram(dummy_extension_.get(), |
| 528 histogram_name.c_str()); | 535 histogram_name.c_str()); |
| 529 | 536 |
| 530 histogram_name = user_initiated ? | 537 histogram_name = user_initiated ? |
| 531 "Extensions.Permissions_InstallCancel" : | 538 "Extensions.Permissions_InstallCancel" : |
| 532 "Extensions.Permissions_InstallAbort"; | 539 "Extensions.Permissions_InstallAbort"; |
| 533 ExtensionService::RecordPermissionMessagesHistogram(dummy_extension_.get(), | 540 ExtensionService::RecordPermissionMessagesHistogram(dummy_extension_.get(), |
| 534 histogram_name.c_str()); | 541 histogram_name.c_str()); |
| 535 | 542 |
| 536 // Matches the AddRef in RunImpl(). | 543 // Matches the AddRef in RunImpl(). |
| 537 Release(); | 544 Release(); |
| 538 } | 545 } |
| 539 | 546 |
| 540 CompleteInstallFunction::CompleteInstallFunction() {} | 547 WebstorePrivateCompleteInstallFunction:: |
| 548 WebstorePrivateCompleteInstallFunction() {} |
| 541 | 549 |
| 542 CompleteInstallFunction::~CompleteInstallFunction() {} | 550 WebstorePrivateCompleteInstallFunction:: |
| 551 ~WebstorePrivateCompleteInstallFunction() {} |
| 543 | 552 |
| 544 bool CompleteInstallFunction::RunImpl() { | 553 bool WebstorePrivateCompleteInstallFunction::RunImpl() { |
| 545 std::string id; | 554 std::string id; |
| 546 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &id)); | 555 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &id)); |
| 547 if (!extensions::Extension::IdIsValid(id)) { | 556 if (!extensions::Extension::IdIsValid(id)) { |
| 548 error_ = kInvalidIdError; | 557 error_ = kInvalidIdError; |
| 549 return false; | 558 return false; |
| 550 } | 559 } |
| 551 | 560 |
| 552 approval_ = g_pending_approvals.Get().PopApproval(profile(), id).Pass(); | 561 approval_ = g_pending_approvals.Get().PopApproval(profile(), id).Pass(); |
| 553 if (!approval_) { | 562 if (!approval_) { |
| 554 error_ = ErrorUtils::FormatErrorMessage( | 563 error_ = ErrorUtils::FormatErrorMessage( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 573 // the whitelist entry will bypass the normal permissions install dialog. | 582 // the whitelist entry will bypass the normal permissions install dialog. |
| 574 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller( | 583 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller( |
| 575 profile(), this, | 584 profile(), this, |
| 576 &(dispatcher()->delegate()->GetAssociatedWebContents()->GetController()), | 585 &(dispatcher()->delegate()->GetAssociatedWebContents()->GetController()), |
| 577 id, approval_.Pass(), WebstoreInstaller::FLAG_NONE); | 586 id, approval_.Pass(), WebstoreInstaller::FLAG_NONE); |
| 578 installer->Start(); | 587 installer->Start(); |
| 579 | 588 |
| 580 return true; | 589 return true; |
| 581 } | 590 } |
| 582 | 591 |
| 583 void CompleteInstallFunction::OnExtensionInstallSuccess( | 592 void WebstorePrivateCompleteInstallFunction::OnExtensionInstallSuccess( |
| 584 const std::string& id) { | 593 const std::string& id) { |
| 585 if (test_webstore_installer_delegate) | 594 if (test_webstore_installer_delegate) |
| 586 test_webstore_installer_delegate->OnExtensionInstallSuccess(id); | 595 test_webstore_installer_delegate->OnExtensionInstallSuccess(id); |
| 587 | 596 |
| 588 LOG(INFO) << "Install success, sending response"; | 597 LOG(INFO) << "Install success, sending response"; |
| 589 g_pending_installs.Get().EraseInstall(profile_, id); | 598 g_pending_installs.Get().EraseInstall(profile_, id); |
| 590 SendResponse(true); | 599 SendResponse(true); |
| 591 | 600 |
| 592 // Matches the AddRef in RunImpl(). | 601 // Matches the AddRef in RunImpl(). |
| 593 Release(); | 602 Release(); |
| 594 } | 603 } |
| 595 | 604 |
| 596 void CompleteInstallFunction::OnExtensionInstallFailure( | 605 void WebstorePrivateCompleteInstallFunction::OnExtensionInstallFailure( |
| 597 const std::string& id, | 606 const std::string& id, |
| 598 const std::string& error, | 607 const std::string& error, |
| 599 WebstoreInstaller::FailureReason reason) { | 608 WebstoreInstaller::FailureReason reason) { |
| 600 if (test_webstore_installer_delegate) { | 609 if (test_webstore_installer_delegate) { |
| 601 test_webstore_installer_delegate->OnExtensionInstallFailure( | 610 test_webstore_installer_delegate->OnExtensionInstallFailure( |
| 602 id, error, reason); | 611 id, error, reason); |
| 603 } | 612 } |
| 604 | 613 |
| 605 error_ = error; | 614 error_ = error; |
| 606 LOG(INFO) << "Install failed, sending response"; | 615 LOG(INFO) << "Install failed, sending response"; |
| 607 g_pending_installs.Get().EraseInstall(profile_, id); | 616 g_pending_installs.Get().EraseInstall(profile_, id); |
| 608 SendResponse(false); | 617 SendResponse(false); |
| 609 | 618 |
| 610 // Matches the AddRef in RunImpl(). | 619 // Matches the AddRef in RunImpl(). |
| 611 Release(); | 620 Release(); |
| 612 } | 621 } |
| 613 | 622 |
| 614 EnableAppLauncherFunction::EnableAppLauncherFunction() {} | 623 WebstorePrivateEnableAppLauncherFunction:: |
| 624 WebstorePrivateEnableAppLauncherFunction() {} |
| 615 | 625 |
| 616 EnableAppLauncherFunction::~EnableAppLauncherFunction() {} | 626 WebstorePrivateEnableAppLauncherFunction:: |
| 627 ~WebstorePrivateEnableAppLauncherFunction() {} |
| 617 | 628 |
| 618 bool EnableAppLauncherFunction::RunImpl() { | 629 bool WebstorePrivateEnableAppLauncherFunction::RunImpl() { |
| 619 AppListService::Get()->EnableAppList(profile()); | 630 AppListService::Get()->EnableAppList(profile()); |
| 620 SendResponse(true); | 631 SendResponse(true); |
| 621 return true; | 632 return true; |
| 622 } | 633 } |
| 623 | 634 |
| 624 bool GetBrowserLoginFunction::RunImpl() { | 635 bool WebstorePrivateGetBrowserLoginFunction::RunImpl() { |
| 625 SetResult(CreateLoginResult(profile_->GetOriginalProfile())); | 636 SetResult(CreateLoginResult(profile_->GetOriginalProfile())); |
| 626 return true; | 637 return true; |
| 627 } | 638 } |
| 628 | 639 |
| 629 bool GetStoreLoginFunction::RunImpl() { | 640 bool WebstorePrivateGetStoreLoginFunction::RunImpl() { |
| 630 SetResult(Value::CreateStringValue(GetWebstoreLogin(profile_))); | 641 SetResult(Value::CreateStringValue(GetWebstoreLogin(profile_))); |
| 631 return true; | 642 return true; |
| 632 } | 643 } |
| 633 | 644 |
| 634 bool SetStoreLoginFunction::RunImpl() { | 645 bool WebstorePrivateSetStoreLoginFunction::RunImpl() { |
| 635 std::string login; | 646 std::string login; |
| 636 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &login)); | 647 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &login)); |
| 637 SetWebstoreLogin(profile_, login); | 648 SetWebstoreLogin(profile_, login); |
| 638 return true; | 649 return true; |
| 639 } | 650 } |
| 640 | 651 |
| 641 GetWebGLStatusFunction::GetWebGLStatusFunction() { | 652 WebstorePrivateGetWebGLStatusFunction::WebstorePrivateGetWebGLStatusFunction() { |
| 642 feature_checker_ = new GPUFeatureChecker( | 653 feature_checker_ = new GPUFeatureChecker( |
| 643 gpu::GPU_FEATURE_TYPE_WEBGL, | 654 gpu::GPU_FEATURE_TYPE_WEBGL, |
| 644 base::Bind(&GetWebGLStatusFunction::OnFeatureCheck, | 655 base::Bind(&WebstorePrivateGetWebGLStatusFunction::OnFeatureCheck, |
| 645 base::Unretained(this))); | 656 base::Unretained(this))); |
| 646 } | 657 } |
| 647 | 658 |
| 648 GetWebGLStatusFunction::~GetWebGLStatusFunction() {} | 659 WebstorePrivateGetWebGLStatusFunction:: |
| 660 ~WebstorePrivateGetWebGLStatusFunction() {} |
| 649 | 661 |
| 650 void GetWebGLStatusFunction::CreateResult(bool webgl_allowed) { | 662 void WebstorePrivateGetWebGLStatusFunction::CreateResult(bool webgl_allowed) { |
| 651 SetResult(Value::CreateStringValue( | 663 SetResult(Value::CreateStringValue( |
| 652 webgl_allowed ? "webgl_allowed" : "webgl_blocked")); | 664 webgl_allowed ? "webgl_allowed" : "webgl_blocked")); |
| 653 } | 665 } |
| 654 | 666 |
| 655 bool GetWebGLStatusFunction::RunImpl() { | 667 bool WebstorePrivateGetWebGLStatusFunction::RunImpl() { |
| 656 feature_checker_->CheckGPUFeatureAvailability(); | 668 feature_checker_->CheckGPUFeatureAvailability(); |
| 657 return true; | 669 return true; |
| 658 } | 670 } |
| 659 | 671 |
| 660 void GetWebGLStatusFunction::OnFeatureCheck(bool feature_allowed) { | 672 void WebstorePrivateGetWebGLStatusFunction:: |
| 673 OnFeatureCheck(bool feature_allowed) { |
| 661 CreateResult(feature_allowed); | 674 CreateResult(feature_allowed); |
| 662 SendResponse(true); | 675 SendResponse(true); |
| 663 } | 676 } |
| 664 | 677 |
| 665 bool GetIsLauncherEnabledFunction::RunImpl() { | 678 bool WebstorePrivateGetIsLauncherEnabledFunction::RunImpl() { |
| 666 SetResult(Value::CreateBooleanValue(apps::IsAppLauncherEnabled())); | 679 SetResult(Value::CreateBooleanValue(apps::IsAppLauncherEnabled())); |
| 667 SendResponse(true); | 680 SendResponse(true); |
| 668 return true; | 681 return true; |
| 669 } | 682 } |
| 670 | 683 |
| 671 bool IsInIncognitoModeFunction::RunImpl() { | 684 bool WebstorePrivateIsInIncognitoModeFunction::RunImpl() { |
| 672 SetResult( | 685 SetResult( |
| 673 Value::CreateBooleanValue(profile_ != profile_->GetOriginalProfile())); | 686 Value::CreateBooleanValue(profile_ != profile_->GetOriginalProfile())); |
| 674 SendResponse(true); | 687 SendResponse(true); |
| 675 return true; | 688 return true; |
| 676 } | 689 } |
| 677 | 690 |
| 678 } // namespace extensions | 691 } // namespace extensions |
| OLD | NEW |