| 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 "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 WebstoreInstaller::Approval* approval = approvals_[i]; | 99 WebstoreInstaller::Approval* approval = approvals_[i]; |
| 100 if (approval->extension_id == id && | 100 if (approval->extension_id == id && |
| 101 profile->IsSameProfile(approval->profile)) { | 101 profile->IsSameProfile(approval->profile)) { |
| 102 approvals_.weak_erase(approvals_.begin() + i); | 102 approvals_.weak_erase(approvals_.begin() + i); |
| 103 return scoped_ptr<WebstoreInstaller::Approval>(approval); | 103 return scoped_ptr<WebstoreInstaller::Approval>(approval); |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 return scoped_ptr<WebstoreInstaller::Approval>(); | 106 return scoped_ptr<WebstoreInstaller::Approval>(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 chrome::HostDesktopType GetHostDesktopTypeForWebContents( |
| 110 content::WebContents* contents) { |
| 111 return chrome::GetHostDesktopTypeForNativeWindow( |
| 112 contents->GetTopLevelNativeWindow()); |
| 113 } |
| 114 |
| 109 static base::LazyInstance<PendingApprovals> g_pending_approvals = | 115 static base::LazyInstance<PendingApprovals> g_pending_approvals = |
| 110 LAZY_INSTANCE_INITIALIZER; | 116 LAZY_INSTANCE_INITIALIZER; |
| 111 | 117 |
| 112 // A preference set by the web store to indicate login information for | 118 // A preference set by the web store to indicate login information for |
| 113 // purchased apps. | 119 // purchased apps. |
| 114 const char kWebstoreLogin[] = "extensions.webstore_login"; | 120 const char kWebstoreLogin[] = "extensions.webstore_login"; |
| 115 const char kAlreadyInstalledError[] = "This item is already installed"; | 121 const char kAlreadyInstalledError[] = "This item is already installed"; |
| 116 const char kCannotSpecifyIconDataAndUrlError[] = | 122 const char kCannotSpecifyIconDataAndUrlError[] = |
| 117 "You cannot specify both icon data and an icon url"; | 123 "You cannot specify both icon data and an icon url"; |
| 118 const char kInvalidIconUrlError[] = "Invalid icon url"; | 124 const char kInvalidIconUrlError[] = "Invalid icon url"; |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 .Pass(); | 472 .Pass(); |
| 467 if (!approval_) { | 473 if (!approval_) { |
| 468 error_ = ErrorUtils::FormatErrorMessage( | 474 error_ = ErrorUtils::FormatErrorMessage( |
| 469 kNoPreviousBeginInstallWithManifestError, params->expected_id); | 475 kNoPreviousBeginInstallWithManifestError, params->expected_id); |
| 470 return false; | 476 return false; |
| 471 } | 477 } |
| 472 | 478 |
| 473 scoped_active_install_.reset(new ScopedActiveInstall( | 479 scoped_active_install_.reset(new ScopedActiveInstall( |
| 474 InstallTracker::Get(GetProfile()), params->expected_id)); | 480 InstallTracker::Get(GetProfile()), params->expected_id)); |
| 475 | 481 |
| 476 AppListService* app_list_service = | 482 AppListService* app_list_service = AppListService::Get( |
| 477 AppListService::Get(GetCurrentBrowser()->host_desktop_type()); | 483 GetHostDesktopTypeForWebContents(GetAssociatedWebContents())); |
| 478 | 484 |
| 479 if (approval_->enable_launcher) { | 485 if (approval_->enable_launcher) { |
| 480 app_list_service->EnableAppList(GetProfile(), | 486 app_list_service->EnableAppList(GetProfile(), |
| 481 AppListService::ENABLE_FOR_APP_INSTALL); | 487 AppListService::ENABLE_FOR_APP_INSTALL); |
| 482 } | 488 } |
| 483 | 489 |
| 484 if (IsAppLauncherEnabled() && approval_->manifest->is_app()) { | 490 if (IsAppLauncherEnabled() && approval_->manifest->is_app()) { |
| 485 // Show the app list to show download is progressing. Don't show the app | 491 // Show the app list to show download is progressing. Don't show the app |
| 486 // list on first app install so users can be trained to open it themselves. | 492 // list on first app install so users can be trained to open it themselves. |
| 487 app_list_service->ShowForAppInstall( | 493 app_list_service->ShowForAppInstall( |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 SendResponse(true); | 567 SendResponse(true); |
| 562 } | 568 } |
| 563 | 569 |
| 564 WebstorePrivateEnableAppLauncherFunction:: | 570 WebstorePrivateEnableAppLauncherFunction:: |
| 565 WebstorePrivateEnableAppLauncherFunction() {} | 571 WebstorePrivateEnableAppLauncherFunction() {} |
| 566 | 572 |
| 567 WebstorePrivateEnableAppLauncherFunction:: | 573 WebstorePrivateEnableAppLauncherFunction:: |
| 568 ~WebstorePrivateEnableAppLauncherFunction() {} | 574 ~WebstorePrivateEnableAppLauncherFunction() {} |
| 569 | 575 |
| 570 bool WebstorePrivateEnableAppLauncherFunction::RunSync() { | 576 bool WebstorePrivateEnableAppLauncherFunction::RunSync() { |
| 571 AppListService::Get(GetCurrentBrowser()->host_desktop_type()) | 577 AppListService* app_list_service = AppListService::Get( |
| 572 ->EnableAppList(GetProfile(), AppListService::ENABLE_VIA_WEBSTORE_LINK); | 578 GetHostDesktopTypeForWebContents(GetAssociatedWebContents())); |
| 579 app_list_service->EnableAppList(GetProfile(), |
| 580 AppListService::ENABLE_VIA_WEBSTORE_LINK); |
| 573 return true; | 581 return true; |
| 574 } | 582 } |
| 575 | 583 |
| 576 bool WebstorePrivateGetBrowserLoginFunction::RunSync() { | 584 bool WebstorePrivateGetBrowserLoginFunction::RunSync() { |
| 577 GetBrowserLogin::Results::Info info; | 585 GetBrowserLogin::Results::Info info; |
| 578 info.login = GetProfile()->GetOriginalProfile()->GetPrefs()->GetString( | 586 info.login = GetProfile()->GetOriginalProfile()->GetPrefs()->GetString( |
| 579 prefs::kGoogleServicesUsername); | 587 prefs::kGoogleServicesUsername); |
| 580 results_ = GetBrowserLogin::Results::Create(info); | 588 results_ = GetBrowserLogin::Results::Create(info); |
| 581 return true; | 589 return true; |
| 582 } | 590 } |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 WebstorePrivateGetEphemeralAppsEnabledFunction:: | 758 WebstorePrivateGetEphemeralAppsEnabledFunction:: |
| 751 ~WebstorePrivateGetEphemeralAppsEnabledFunction() {} | 759 ~WebstorePrivateGetEphemeralAppsEnabledFunction() {} |
| 752 | 760 |
| 753 bool WebstorePrivateGetEphemeralAppsEnabledFunction::RunSync() { | 761 bool WebstorePrivateGetEphemeralAppsEnabledFunction::RunSync() { |
| 754 results_ = GetEphemeralAppsEnabled::Results::Create( | 762 results_ = GetEphemeralAppsEnabled::Results::Create( |
| 755 EphemeralAppLauncher::IsFeatureEnabled()); | 763 EphemeralAppLauncher::IsFeatureEnabled()); |
| 756 return true; | 764 return true; |
| 757 } | 765 } |
| 758 | 766 |
| 759 } // namespace extensions | 767 } // namespace extensions |
| OLD | NEW |