| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
| 13 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 14 #include "base/prefs/pref_service.h" | 15 #include "base/prefs/pref_service.h" |
| 15 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 17 #include "base/thread_task_runner_handle.h" | 18 #include "base/thread_task_runner_handle.h" |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 // Matches the AddRef in Run(). | 308 // Matches the AddRef in Run(). |
| 308 Release(); | 309 Release(); |
| 309 } | 310 } |
| 310 | 311 |
| 311 void WebstorePrivateBeginInstallWithManifest3Function::InstallUIProceed() { | 312 void WebstorePrivateBeginInstallWithManifest3Function::InstallUIProceed() { |
| 312 // This gets cleared in CrxInstaller::ConfirmInstall(). TODO(asargent) - in | 313 // This gets cleared in CrxInstaller::ConfirmInstall(). TODO(asargent) - in |
| 313 // the future we may also want to add time-based expiration, where a whitelist | 314 // the future we may also want to add time-based expiration, where a whitelist |
| 314 // entry is only valid for some number of minutes. | 315 // entry is only valid for some number of minutes. |
| 315 scoped_ptr<WebstoreInstaller::Approval> approval( | 316 scoped_ptr<WebstoreInstaller::Approval> approval( |
| 316 WebstoreInstaller::Approval::CreateWithNoInstallPrompt( | 317 WebstoreInstaller::Approval::CreateWithNoInstallPrompt( |
| 317 chrome_details_.GetProfile(), | 318 chrome_details_.GetProfile(), details().id, |
| 318 details().id, | 319 std::move(parsed_manifest_), false)); |
| 319 parsed_manifest_.Pass(), | |
| 320 false)); | |
| 321 approval->use_app_installed_bubble = details().app_install_bubble; | 320 approval->use_app_installed_bubble = details().app_install_bubble; |
| 322 approval->enable_launcher = details().enable_launcher; | 321 approval->enable_launcher = details().enable_launcher; |
| 323 // If we are enabling the launcher, we should not show the app list in order | 322 // If we are enabling the launcher, we should not show the app list in order |
| 324 // to train the user to open it themselves at least once. | 323 // to train the user to open it themselves at least once. |
| 325 approval->skip_post_install_ui = details().enable_launcher; | 324 approval->skip_post_install_ui = details().enable_launcher; |
| 326 approval->dummy_extension = dummy_extension_.get(); | 325 approval->dummy_extension = dummy_extension_.get(); |
| 327 approval->installing_icon = gfx::ImageSkia::CreateFrom1xBitmap(icon_); | 326 approval->installing_icon = gfx::ImageSkia::CreateFrom1xBitmap(icon_); |
| 328 if (details().authuser) | 327 if (details().authuser) |
| 329 approval->authuser = *details().authuser; | 328 approval->authuser = *details().authuser; |
| 330 g_pending_approvals.Get().PushApproval(approval.Pass()); | 329 g_pending_approvals.Get().PushApproval(std::move(approval)); |
| 331 | 330 |
| 332 DCHECK(scoped_active_install_.get()); | 331 DCHECK(scoped_active_install_.get()); |
| 333 scoped_active_install_->CancelDeregister(); | 332 scoped_active_install_->CancelDeregister(); |
| 334 | 333 |
| 335 // The Permissions_Install histogram is recorded from the ExtensionService | 334 // The Permissions_Install histogram is recorded from the ExtensionService |
| 336 // for all extension installs, so we only need to record the web store | 335 // for all extension installs, so we only need to record the web store |
| 337 // specific histogram here. | 336 // specific histogram here. |
| 338 ExtensionService::RecordPermissionMessagesHistogram( | 337 ExtensionService::RecordPermissionMessagesHistogram( |
| 339 dummy_extension_.get(), "WebStoreInstall"); | 338 dummy_extension_.get(), "WebStoreInstall"); |
| 340 | 339 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 CompleteInstall::Params::Create(*args_)); | 394 CompleteInstall::Params::Create(*args_)); |
| 396 EXTENSION_FUNCTION_VALIDATE(params); | 395 EXTENSION_FUNCTION_VALIDATE(params); |
| 397 if (chrome_details_.GetProfile()->IsGuestSession() || | 396 if (chrome_details_.GetProfile()->IsGuestSession() || |
| 398 chrome_details_.GetProfile()->IsOffTheRecord()) { | 397 chrome_details_.GetProfile()->IsOffTheRecord()) { |
| 399 return RespondNow(Error(kIncognitoError)); | 398 return RespondNow(Error(kIncognitoError)); |
| 400 } | 399 } |
| 401 | 400 |
| 402 if (!crx_file::id_util::IdIsValid(params->expected_id)) | 401 if (!crx_file::id_util::IdIsValid(params->expected_id)) |
| 403 return RespondNow(Error(kInvalidIdError)); | 402 return RespondNow(Error(kInvalidIdError)); |
| 404 | 403 |
| 405 approval_ = | 404 approval_ = g_pending_approvals.Get().PopApproval( |
| 406 g_pending_approvals.Get().PopApproval(chrome_details_.GetProfile(), | 405 chrome_details_.GetProfile(), params->expected_id); |
| 407 params->expected_id).Pass(); | |
| 408 if (!approval_) { | 406 if (!approval_) { |
| 409 return RespondNow(Error(kNoPreviousBeginInstallWithManifestError, | 407 return RespondNow(Error(kNoPreviousBeginInstallWithManifestError, |
| 410 params->expected_id)); | 408 params->expected_id)); |
| 411 } | 409 } |
| 412 | 410 |
| 413 scoped_active_install_.reset(new ScopedActiveInstall( | 411 scoped_active_install_.reset(new ScopedActiveInstall( |
| 414 InstallTracker::Get(browser_context()), params->expected_id)); | 412 InstallTracker::Get(browser_context()), params->expected_id)); |
| 415 | 413 |
| 416 AppListService* app_list_service = AppListService::Get( | 414 AppListService* app_list_service = AppListService::Get( |
| 417 GetHostDesktopTypeForWebContents(GetAssociatedWebContents())); | 415 GetHostDesktopTypeForWebContents(GetAssociatedWebContents())); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 429 params->expected_id, | 427 params->expected_id, |
| 430 approval_->enable_launcher); | 428 approval_->enable_launcher); |
| 431 } | 429 } |
| 432 | 430 |
| 433 // Balanced in OnExtensionInstallSuccess() or OnExtensionInstallFailure(). | 431 // Balanced in OnExtensionInstallSuccess() or OnExtensionInstallFailure(). |
| 434 AddRef(); | 432 AddRef(); |
| 435 | 433 |
| 436 // The extension will install through the normal extension install flow, but | 434 // The extension will install through the normal extension install flow, but |
| 437 // the whitelist entry will bypass the normal permissions install dialog. | 435 // the whitelist entry will bypass the normal permissions install dialog. |
| 438 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller( | 436 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller( |
| 439 chrome_details_.GetProfile(), | 437 chrome_details_.GetProfile(), this, |
| 440 this, | 438 chrome_details_.GetAssociatedWebContents(), params->expected_id, |
| 441 chrome_details_.GetAssociatedWebContents(), | 439 std::move(approval_), WebstoreInstaller::INSTALL_SOURCE_OTHER); |
| 442 params->expected_id, | |
| 443 approval_.Pass(), | |
| 444 WebstoreInstaller::INSTALL_SOURCE_OTHER); | |
| 445 installer->Start(); | 440 installer->Start(); |
| 446 | 441 |
| 447 return RespondLater(); | 442 return RespondLater(); |
| 448 } | 443 } |
| 449 | 444 |
| 450 void WebstorePrivateCompleteInstallFunction::OnExtensionInstallSuccess( | 445 void WebstorePrivateCompleteInstallFunction::OnExtensionInstallSuccess( |
| 451 const std::string& id) { | 446 const std::string& id) { |
| 452 OnInstallSuccess(id); | 447 OnInstallSuccess(id); |
| 453 VLOG(1) << "Install success, sending response"; | 448 VLOG(1) << "Install success, sending response"; |
| 454 Respond(NoArguments()); | 449 Respond(NoArguments()); |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 WebstorePrivateGetEphemeralAppsEnabledFunction:: | 699 WebstorePrivateGetEphemeralAppsEnabledFunction:: |
| 705 ~WebstorePrivateGetEphemeralAppsEnabledFunction() {} | 700 ~WebstorePrivateGetEphemeralAppsEnabledFunction() {} |
| 706 | 701 |
| 707 ExtensionFunction::ResponseAction | 702 ExtensionFunction::ResponseAction |
| 708 WebstorePrivateGetEphemeralAppsEnabledFunction::Run() { | 703 WebstorePrivateGetEphemeralAppsEnabledFunction::Run() { |
| 709 return RespondNow(ArgumentList(GetEphemeralAppsEnabled::Results::Create( | 704 return RespondNow(ArgumentList(GetEphemeralAppsEnabled::Results::Create( |
| 710 false))); | 705 false))); |
| 711 } | 706 } |
| 712 | 707 |
| 713 } // namespace extensions | 708 } // namespace extensions |
| OLD | NEW |