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 12 matching lines...) Expand all Loading... |
23 #include "chrome/browser/extensions/extension_install_ui_util.h" | 23 #include "chrome/browser/extensions/extension_install_ui_util.h" |
24 #include "chrome/browser/extensions/extension_service.h" | 24 #include "chrome/browser/extensions/extension_service.h" |
25 #include "chrome/browser/extensions/install_tracker.h" | 25 #include "chrome/browser/extensions/install_tracker.h" |
26 #include "chrome/browser/extensions/webstore_installer.h" | 26 #include "chrome/browser/extensions/webstore_installer.h" |
27 #include "chrome/browser/gpu/gpu_feature_checker.h" | 27 #include "chrome/browser/gpu/gpu_feature_checker.h" |
28 #include "chrome/browser/profiles/profile_manager.h" | 28 #include "chrome/browser/profiles/profile_manager.h" |
29 #include "chrome/browser/sync/profile_sync_service.h" | 29 #include "chrome/browser/sync/profile_sync_service.h" |
30 #include "chrome/browser/sync/profile_sync_service_factory.h" | 30 #include "chrome/browser/sync/profile_sync_service_factory.h" |
31 #include "chrome/browser/ui/app_list/app_list_service.h" | 31 #include "chrome/browser/ui/app_list/app_list_service.h" |
32 #include "chrome/browser/ui/app_list/app_list_util.h" | 32 #include "chrome/browser/ui/app_list/app_list_util.h" |
33 #include "chrome/browser/ui/browser.h" | |
34 #include "chrome/common/extensions/extension_constants.h" | 33 #include "chrome/common/extensions/extension_constants.h" |
35 #include "chrome/common/pref_names.h" | 34 #include "chrome/common/pref_names.h" |
36 #include "components/crx_file/id_util.h" | 35 #include "components/crx_file/id_util.h" |
37 #include "content/public/browser/gpu_data_manager.h" | 36 #include "content/public/browser/gpu_data_manager.h" |
38 #include "content/public/browser/notification_details.h" | 37 #include "content/public/browser/notification_details.h" |
39 #include "content/public/browser/notification_source.h" | 38 #include "content/public/browser/notification_source.h" |
40 #include "content/public/browser/web_contents.h" | 39 #include "content/public/browser/web_contents.h" |
41 #include "extensions/browser/extension_function_dispatcher.h" | 40 #include "extensions/browser/extension_function_dispatcher.h" |
42 #include "extensions/browser/extension_prefs.h" | 41 #include "extensions/browser/extension_prefs.h" |
43 #include "extensions/browser/extension_registry.h" | 42 #include "extensions/browser/extension_registry.h" |
44 #include "extensions/browser/extension_system.h" | 43 #include "extensions/browser/extension_system.h" |
45 #include "extensions/browser/extension_util.h" | 44 #include "extensions/browser/extension_util.h" |
46 #include "extensions/common/error_utils.h" | 45 #include "extensions/common/error_utils.h" |
47 #include "extensions/common/extension.h" | 46 #include "extensions/common/extension.h" |
48 #include "ui/base/l10n/l10n_util.h" | 47 #include "ui/base/l10n/l10n_util.h" |
49 | 48 |
50 using content::GpuDataManager; | 49 using content::GpuDataManager; |
51 | 50 |
52 namespace extensions { | 51 namespace extensions { |
53 | 52 |
54 namespace BeginInstallWithManifest3 = | 53 namespace BeginInstallWithManifest3 = |
55 api::webstore_private::BeginInstallWithManifest3; | 54 api::webstore_private::BeginInstallWithManifest3; |
56 namespace GetEphemeralAppsEnabled = | 55 namespace GetEphemeralAppsEnabled = |
57 api::webstore_private::GetEphemeralAppsEnabled; | 56 api::webstore_private::GetEphemeralAppsEnabled; |
58 namespace CompleteInstall = api::webstore_private::CompleteInstall; | 57 namespace CompleteInstall = api::webstore_private::CompleteInstall; |
59 namespace GetBrowserLogin = api::webstore_private::GetBrowserLogin; | 58 namespace GetBrowserLogin = api::webstore_private::GetBrowserLogin; |
60 namespace GetIsLauncherEnabled = api::webstore_private::GetIsLauncherEnabled; | 59 namespace GetIsLauncherEnabled = api::webstore_private::GetIsLauncherEnabled; |
61 namespace GetStoreLogin = api::webstore_private::GetStoreLogin; | 60 namespace GetStoreLogin = api::webstore_private::GetStoreLogin; |
62 namespace GetWebGLStatus = api::webstore_private::GetWebGLStatus; | 61 namespace GetWebGLStatus = api::webstore_private::GetWebGLStatus; |
63 namespace InstallBundle = api::webstore_private::InstallBundle; | |
64 namespace IsInIncognitoMode = api::webstore_private::IsInIncognitoMode; | 62 namespace IsInIncognitoMode = api::webstore_private::IsInIncognitoMode; |
65 namespace LaunchEphemeralApp = api::webstore_private::LaunchEphemeralApp; | 63 namespace LaunchEphemeralApp = api::webstore_private::LaunchEphemeralApp; |
66 namespace LaunchEphemeralAppResult = LaunchEphemeralApp::Results; | 64 namespace LaunchEphemeralAppResult = LaunchEphemeralApp::Results; |
67 namespace SetStoreLogin = api::webstore_private::SetStoreLogin; | 65 namespace SetStoreLogin = api::webstore_private::SetStoreLogin; |
68 | 66 |
69 namespace { | 67 namespace { |
70 | 68 |
71 // Holds the Approvals between the time we prompt and start the installs. | 69 // Holds the Approvals between the time we prompt and start the installs. |
72 class PendingApprovals { | 70 class PendingApprovals { |
73 public: | 71 public: |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 test_webstore_installer_delegate = delegate; | 155 test_webstore_installer_delegate = delegate; |
158 } | 156 } |
159 | 157 |
160 // static | 158 // static |
161 scoped_ptr<WebstoreInstaller::Approval> | 159 scoped_ptr<WebstoreInstaller::Approval> |
162 WebstorePrivateApi::PopApprovalForTesting( | 160 WebstorePrivateApi::PopApprovalForTesting( |
163 Profile* profile, const std::string& extension_id) { | 161 Profile* profile, const std::string& extension_id) { |
164 return g_pending_approvals.Get().PopApproval(profile, extension_id); | 162 return g_pending_approvals.Get().PopApproval(profile, extension_id); |
165 } | 163 } |
166 | 164 |
167 WebstorePrivateInstallBundleFunction::WebstorePrivateInstallBundleFunction() {} | |
168 WebstorePrivateInstallBundleFunction::~WebstorePrivateInstallBundleFunction() {} | |
169 | |
170 bool WebstorePrivateInstallBundleFunction::RunAsync() { | |
171 scoped_ptr<InstallBundle::Params> params( | |
172 InstallBundle::Params::Create(*args_)); | |
173 EXTENSION_FUNCTION_VALIDATE(params); | |
174 | |
175 BundleInstaller::ItemList items; | |
176 if (!ReadBundleInfo(*params, &items)) | |
177 return false; | |
178 | |
179 bundle_ = new BundleInstaller(GetCurrentBrowser(), items); | |
180 | |
181 AddRef(); // Balanced in OnBundleInstallCompleted / OnBundleInstallCanceled. | |
182 | |
183 bundle_->PromptForApproval(this); | |
184 return true; | |
185 } | |
186 | |
187 bool WebstorePrivateInstallBundleFunction:: | |
188 ReadBundleInfo(const InstallBundle::Params& params, | |
189 BundleInstaller::ItemList* items) { | |
190 for (size_t i = 0; i < params.details.size(); ++i) { | |
191 BundleInstaller::Item item; | |
192 item.id = params.details[i]->id; | |
193 item.manifest = params.details[i]->manifest; | |
194 item.localized_name = params.details[i]->localized_name; | |
195 items->push_back(item); | |
196 } | |
197 | |
198 return true; | |
199 } | |
200 | |
201 void WebstorePrivateInstallBundleFunction::OnBundleInstallApproved() { | |
202 bundle_->CompleteInstall( | |
203 dispatcher()->delegate()->GetAssociatedWebContents(), | |
204 this); | |
205 } | |
206 | |
207 void WebstorePrivateInstallBundleFunction::OnBundleInstallCanceled( | |
208 bool user_initiated) { | |
209 if (user_initiated) | |
210 error_ = "user_canceled"; | |
211 else | |
212 error_ = "unknown_error"; | |
213 | |
214 SendResponse(false); | |
215 | |
216 Release(); // Balanced in RunAsync(). | |
217 } | |
218 | |
219 void WebstorePrivateInstallBundleFunction::OnBundleInstallCompleted() { | |
220 SendResponse(true); | |
221 | |
222 Release(); // Balanced in RunAsync(). | |
223 } | |
224 | |
225 WebstorePrivateBeginInstallWithManifest3Function:: | 165 WebstorePrivateBeginInstallWithManifest3Function:: |
226 WebstorePrivateBeginInstallWithManifest3Function() { | 166 WebstorePrivateBeginInstallWithManifest3Function() { |
227 } | 167 } |
228 | 168 |
229 WebstorePrivateBeginInstallWithManifest3Function:: | 169 WebstorePrivateBeginInstallWithManifest3Function:: |
230 ~WebstorePrivateBeginInstallWithManifest3Function() { | 170 ~WebstorePrivateBeginInstallWithManifest3Function() { |
231 } | 171 } |
232 | 172 |
233 bool WebstorePrivateBeginInstallWithManifest3Function::RunAsync() { | 173 bool WebstorePrivateBeginInstallWithManifest3Function::RunAsync() { |
234 params_ = BeginInstallWithManifest3::Params::Create(*args_); | 174 params_ = BeginInstallWithManifest3::Params::Create(*args_); |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 WebstorePrivateGetEphemeralAppsEnabledFunction:: | 698 WebstorePrivateGetEphemeralAppsEnabledFunction:: |
759 ~WebstorePrivateGetEphemeralAppsEnabledFunction() {} | 699 ~WebstorePrivateGetEphemeralAppsEnabledFunction() {} |
760 | 700 |
761 bool WebstorePrivateGetEphemeralAppsEnabledFunction::RunSync() { | 701 bool WebstorePrivateGetEphemeralAppsEnabledFunction::RunSync() { |
762 results_ = GetEphemeralAppsEnabled::Results::Create( | 702 results_ = GetEphemeralAppsEnabled::Results::Create( |
763 EphemeralAppLauncher::IsFeatureEnabled()); | 703 EphemeralAppLauncher::IsFeatureEnabled()); |
764 return true; | 704 return true; |
765 } | 705 } |
766 | 706 |
767 } // namespace extensions | 707 } // namespace extensions |
OLD | NEW |