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" | |
9 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
10 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
11 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
12 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
13 #include "base/strings/string_util.h" | |
14 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
15 #include "base/strings/utf_string_conversions.h" | |
16 #include "base/values.h" | 13 #include "base/values.h" |
17 #include "base/version.h" | 14 #include "base/version.h" |
18 #include "chrome/browser/about_flags.h" | |
19 #include "chrome/browser/apps/ephemeral_app_launcher.h" | 15 #include "chrome/browser/apps/ephemeral_app_launcher.h" |
20 #include "chrome/browser/browser_process.h" | |
21 #include "chrome/browser/chrome_notification_types.h" | |
22 #include "chrome/browser/extensions/crx_installer.h" | 16 #include "chrome/browser/extensions/crx_installer.h" |
23 #include "chrome/browser/extensions/extension_install_ui_util.h" | 17 #include "chrome/browser/extensions/extension_install_ui_util.h" |
24 #include "chrome/browser/extensions/extension_service.h" | 18 #include "chrome/browser/extensions/extension_service.h" |
25 #include "chrome/browser/extensions/install_tracker.h" | 19 #include "chrome/browser/extensions/install_tracker.h" |
26 #include "chrome/browser/extensions/webstore_installer.h" | |
27 #include "chrome/browser/gpu/gpu_feature_checker.h" | 20 #include "chrome/browser/gpu/gpu_feature_checker.h" |
28 #include "chrome/browser/profiles/profile_manager.h" | 21 #include "chrome/browser/profiles/profile.h" |
29 #include "chrome/browser/signin/signin_manager_factory.h" | 22 #include "chrome/browser/signin/signin_manager_factory.h" |
30 #include "chrome/browser/sync/profile_sync_service.h" | |
31 #include "chrome/browser/sync/profile_sync_service_factory.h" | |
32 #include "chrome/browser/ui/app_list/app_list_service.h" | 23 #include "chrome/browser/ui/app_list/app_list_service.h" |
33 #include "chrome/browser/ui/app_list/app_list_util.h" | 24 #include "chrome/browser/ui/app_list/app_list_util.h" |
34 #include "chrome/common/extensions/extension_constants.h" | 25 #include "chrome/common/extensions/extension_constants.h" |
35 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
36 #include "components/crx_file/id_util.h" | 27 #include "components/crx_file/id_util.h" |
37 #include "components/signin/core/browser/signin_manager.h" | 28 #include "components/signin/core/browser/signin_manager.h" |
38 #include "content/public/browser/gpu_data_manager.h" | |
39 #include "content/public/browser/notification_details.h" | |
40 #include "content/public/browser/notification_source.h" | |
41 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
42 #include "extensions/browser/extension_function_dispatcher.h" | |
43 #include "extensions/browser/extension_prefs.h" | |
44 #include "extensions/browser/extension_registry.h" | 30 #include "extensions/browser/extension_registry.h" |
45 #include "extensions/browser/extension_system.h" | 31 #include "extensions/browser/extension_system.h" |
46 #include "extensions/browser/extension_util.h" | 32 #include "extensions/browser/extension_util.h" |
47 #include "extensions/common/error_utils.h" | |
48 #include "extensions/common/extension.h" | 33 #include "extensions/common/extension.h" |
49 #include "ui/base/l10n/l10n_util.h" | |
50 | |
51 using content::GpuDataManager; | |
52 | 34 |
53 namespace extensions { | 35 namespace extensions { |
54 | 36 |
55 namespace BeginInstallWithManifest3 = | 37 namespace BeginInstallWithManifest3 = |
56 api::webstore_private::BeginInstallWithManifest3; | 38 api::webstore_private::BeginInstallWithManifest3; |
| 39 namespace CompleteInstall = api::webstore_private::CompleteInstall; |
| 40 namespace GetBrowserLogin = api::webstore_private::GetBrowserLogin; |
57 namespace GetEphemeralAppsEnabled = | 41 namespace GetEphemeralAppsEnabled = |
58 api::webstore_private::GetEphemeralAppsEnabled; | 42 api::webstore_private::GetEphemeralAppsEnabled; |
59 namespace CompleteInstall = api::webstore_private::CompleteInstall; | |
60 namespace GetBrowserLogin = api::webstore_private::GetBrowserLogin; | |
61 namespace GetIsLauncherEnabled = api::webstore_private::GetIsLauncherEnabled; | 43 namespace GetIsLauncherEnabled = api::webstore_private::GetIsLauncherEnabled; |
62 namespace GetStoreLogin = api::webstore_private::GetStoreLogin; | 44 namespace GetStoreLogin = api::webstore_private::GetStoreLogin; |
63 namespace GetWebGLStatus = api::webstore_private::GetWebGLStatus; | 45 namespace GetWebGLStatus = api::webstore_private::GetWebGLStatus; |
64 namespace IsInIncognitoMode = api::webstore_private::IsInIncognitoMode; | 46 namespace IsInIncognitoMode = api::webstore_private::IsInIncognitoMode; |
65 namespace LaunchEphemeralApp = api::webstore_private::LaunchEphemeralApp; | 47 namespace LaunchEphemeralApp = api::webstore_private::LaunchEphemeralApp; |
66 namespace LaunchEphemeralAppResult = LaunchEphemeralApp::Results; | 48 namespace LaunchEphemeralAppResult = LaunchEphemeralApp::Results; |
67 namespace SetStoreLogin = api::webstore_private::SetStoreLogin; | 49 namespace SetStoreLogin = api::webstore_private::SetStoreLogin; |
68 | 50 |
69 namespace { | 51 namespace { |
70 | 52 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 } | 140 } |
159 | 141 |
160 // static | 142 // static |
161 scoped_ptr<WebstoreInstaller::Approval> | 143 scoped_ptr<WebstoreInstaller::Approval> |
162 WebstorePrivateApi::PopApprovalForTesting( | 144 WebstorePrivateApi::PopApprovalForTesting( |
163 Profile* profile, const std::string& extension_id) { | 145 Profile* profile, const std::string& extension_id) { |
164 return g_pending_approvals.Get().PopApproval(profile, extension_id); | 146 return g_pending_approvals.Get().PopApproval(profile, extension_id); |
165 } | 147 } |
166 | 148 |
167 WebstorePrivateBeginInstallWithManifest3Function:: | 149 WebstorePrivateBeginInstallWithManifest3Function:: |
168 WebstorePrivateBeginInstallWithManifest3Function() { | 150 WebstorePrivateBeginInstallWithManifest3Function() : chrome_details_(this) { |
169 } | 151 } |
170 | 152 |
171 WebstorePrivateBeginInstallWithManifest3Function:: | 153 WebstorePrivateBeginInstallWithManifest3Function:: |
172 ~WebstorePrivateBeginInstallWithManifest3Function() { | 154 ~WebstorePrivateBeginInstallWithManifest3Function() { |
173 } | 155 } |
174 | 156 |
175 bool WebstorePrivateBeginInstallWithManifest3Function::RunAsync() { | 157 ExtensionFunction::ResponseAction |
| 158 WebstorePrivateBeginInstallWithManifest3Function::Run() { |
176 params_ = BeginInstallWithManifest3::Params::Create(*args_); | 159 params_ = BeginInstallWithManifest3::Params::Create(*args_); |
177 EXTENSION_FUNCTION_VALIDATE(params_); | 160 EXTENSION_FUNCTION_VALIDATE(params_); |
178 | 161 |
179 if (!crx_file::id_util::IdIsValid(params_->details.id)) { | 162 if (!crx_file::id_util::IdIsValid(params_->details.id)) |
180 SetResultCode(INVALID_ID); | 163 return RespondNow(BuildResponseForError(INVALID_ID, kInvalidIdError)); |
181 error_ = kInvalidIdError; | |
182 return false; | |
183 } | |
184 | 164 |
185 if (params_->details.icon_data && params_->details.icon_url) { | 165 if (params_->details.icon_data && params_->details.icon_url) { |
186 SetResultCode(ICON_ERROR); | 166 return RespondNow(BuildResponseForError(ICON_ERROR, |
187 error_ = kCannotSpecifyIconDataAndUrlError; | 167 kCannotSpecifyIconDataAndUrlError)); |
188 return false; | |
189 } | 168 } |
190 | 169 |
191 GURL icon_url; | 170 GURL icon_url; |
192 if (params_->details.icon_url) { | 171 if (params_->details.icon_url) { |
193 std::string tmp_url; | 172 std::string tmp_url; |
194 icon_url = source_url().Resolve(*params_->details.icon_url); | 173 icon_url = source_url().Resolve(*params_->details.icon_url); |
195 if (!icon_url.is_valid()) { | 174 if (!icon_url.is_valid()) { |
196 SetResultCode(INVALID_ICON_URL); | 175 return RespondNow(BuildResponseForError(INVALID_ICON_URL, |
197 error_ = kInvalidIconUrlError; | 176 kInvalidIconUrlError)); |
198 return false; | |
199 } | 177 } |
200 } | 178 } |
201 | 179 |
202 if (params_->details.authuser) { | 180 if (params_->details.authuser) { |
203 authuser_ = *params_->details.authuser; | 181 authuser_ = *params_->details.authuser; |
204 } | 182 } |
205 | 183 |
206 std::string icon_data = params_->details.icon_data ? | 184 std::string icon_data = params_->details.icon_data ? |
207 *params_->details.icon_data : std::string(); | 185 *params_->details.icon_data : std::string(); |
208 | 186 |
209 Profile* profile = GetProfile(); | 187 InstallTracker* tracker = InstallTracker::Get(browser_context()); |
210 InstallTracker* tracker = InstallTracker::Get(profile); | |
211 DCHECK(tracker); | 188 DCHECK(tracker); |
212 if (util::IsExtensionInstalledPermanently(params_->details.id, profile) || | 189 if (util::IsExtensionInstalledPermanently(params_->details.id, |
| 190 browser_context()) || |
213 tracker->GetActiveInstall(params_->details.id)) { | 191 tracker->GetActiveInstall(params_->details.id)) { |
214 SetResultCode(ALREADY_INSTALLED); | 192 return RespondNow(BuildResponseForError(ALREADY_INSTALLED, |
215 error_ = kAlreadyInstalledError; | 193 kAlreadyInstalledError)); |
216 return false; | |
217 } | 194 } |
218 ActiveInstallData install_data(params_->details.id); | 195 ActiveInstallData install_data(params_->details.id); |
219 scoped_active_install_.reset(new ScopedActiveInstall(tracker, install_data)); | 196 scoped_active_install_.reset(new ScopedActiveInstall(tracker, install_data)); |
220 | 197 |
221 net::URLRequestContextGetter* context_getter = NULL; | 198 net::URLRequestContextGetter* context_getter = NULL; |
222 if (!icon_url.is_empty()) | 199 if (!icon_url.is_empty()) |
223 context_getter = GetProfile()->GetRequestContext(); | 200 context_getter = browser_context()->GetRequestContext(); |
224 | 201 |
225 scoped_refptr<WebstoreInstallHelper> helper = new WebstoreInstallHelper( | 202 scoped_refptr<WebstoreInstallHelper> helper = new WebstoreInstallHelper( |
226 this, params_->details.id, params_->details.manifest, icon_data, icon_url, | 203 this, params_->details.id, params_->details.manifest, icon_data, icon_url, |
227 context_getter); | 204 context_getter); |
228 | 205 |
229 // The helper will call us back via OnWebstoreParseSuccess or | 206 // The helper will call us back via OnWebstoreParseSuccess or |
230 // OnWebstoreParseFailure. | 207 // OnWebstoreParseFailure. |
231 helper->Start(); | 208 helper->Start(); |
232 | 209 |
233 // Matched with a Release in OnWebstoreParseSuccess/OnWebstoreParseFailure. | 210 // Matched with a Release in OnWebstoreParseSuccess/OnWebstoreParseFailure. |
234 AddRef(); | 211 AddRef(); |
235 | 212 |
236 // The response is sent asynchronously in OnWebstoreParseSuccess/ | 213 // The response is sent asynchronously in OnWebstoreParseSuccess/ |
237 // OnWebstoreParseFailure. | 214 // OnWebstoreParseFailure. |
238 return true; | 215 return RespondLater(); |
239 } | |
240 | |
241 const char* WebstorePrivateBeginInstallWithManifest3Function:: | |
242 ResultCodeToString(ResultCode code) { | |
243 switch (code) { | |
244 case ERROR_NONE: | |
245 return ""; | |
246 case UNKNOWN_ERROR: | |
247 return "unknown_error"; | |
248 case USER_CANCELLED: | |
249 return "user_cancelled"; | |
250 case MANIFEST_ERROR: | |
251 return "manifest_error"; | |
252 case ICON_ERROR: | |
253 return "icon_error"; | |
254 case INVALID_ID: | |
255 return "invalid_id"; | |
256 case PERMISSION_DENIED: | |
257 return "permission_denied"; | |
258 case INVALID_ICON_URL: | |
259 return "invalid_icon_url"; | |
260 case ALREADY_INSTALLED: | |
261 return "already_installed"; | |
262 } | |
263 NOTREACHED(); | |
264 return ""; | |
265 } | |
266 | |
267 void WebstorePrivateBeginInstallWithManifest3Function::SetResultCode( | |
268 ResultCode code) { | |
269 results_ = BeginInstallWithManifest3::Results::Create( | |
270 ResultCodeToString(code)); | |
271 } | 216 } |
272 | 217 |
273 void WebstorePrivateBeginInstallWithManifest3Function::OnWebstoreParseSuccess( | 218 void WebstorePrivateBeginInstallWithManifest3Function::OnWebstoreParseSuccess( |
274 const std::string& id, | 219 const std::string& id, |
275 const SkBitmap& icon, | 220 const SkBitmap& icon, |
276 base::DictionaryValue* parsed_manifest) { | 221 base::DictionaryValue* parsed_manifest) { |
277 CHECK_EQ(params_->details.id, id); | 222 CHECK_EQ(params_->details.id, id); |
278 CHECK(parsed_manifest); | 223 CHECK(parsed_manifest); |
279 icon_ = icon; | 224 icon_ = icon; |
280 parsed_manifest_.reset(parsed_manifest); | 225 parsed_manifest_.reset(parsed_manifest); |
(...skipping 29 matching lines...) Expand all Loading... |
310 // Control flow finishes up in InstallUIProceed or InstallUIAbort. | 255 // Control flow finishes up in InstallUIProceed or InstallUIAbort. |
311 } | 256 } |
312 | 257 |
313 void WebstorePrivateBeginInstallWithManifest3Function::OnWebstoreParseFailure( | 258 void WebstorePrivateBeginInstallWithManifest3Function::OnWebstoreParseFailure( |
314 const std::string& id, | 259 const std::string& id, |
315 WebstoreInstallHelper::Delegate::InstallHelperResultCode result_code, | 260 WebstoreInstallHelper::Delegate::InstallHelperResultCode result_code, |
316 const std::string& error_message) { | 261 const std::string& error_message) { |
317 CHECK_EQ(params_->details.id, id); | 262 CHECK_EQ(params_->details.id, id); |
318 | 263 |
319 // Map from WebstoreInstallHelper's result codes to ours. | 264 // Map from WebstoreInstallHelper's result codes to ours. |
| 265 ResultCode code = ERROR_NONE; |
320 switch (result_code) { | 266 switch (result_code) { |
321 case WebstoreInstallHelper::Delegate::UNKNOWN_ERROR: | 267 case WebstoreInstallHelper::Delegate::UNKNOWN_ERROR: |
322 SetResultCode(UNKNOWN_ERROR); | 268 code = UNKNOWN_ERROR; |
323 break; | 269 break; |
324 case WebstoreInstallHelper::Delegate::ICON_ERROR: | 270 case WebstoreInstallHelper::Delegate::ICON_ERROR: |
325 SetResultCode(ICON_ERROR); | 271 code = ICON_ERROR; |
326 break; | 272 break; |
327 case WebstoreInstallHelper::Delegate::MANIFEST_ERROR: | 273 case WebstoreInstallHelper::Delegate::MANIFEST_ERROR: |
328 SetResultCode(MANIFEST_ERROR); | 274 code = MANIFEST_ERROR; |
329 break; | 275 break; |
330 default: | |
331 CHECK(false); | |
332 } | 276 } |
333 error_ = error_message; | 277 DCHECK_NE(code, ERROR_NONE); |
334 SendResponse(false); | 278 Respond(BuildResponseForError(code, error_message)); |
335 | 279 |
336 // Matches the AddRef in RunAsync(). | 280 // Matches the AddRef in Run(). |
337 Release(); | 281 Release(); |
338 } | 282 } |
339 | 283 |
340 void WebstorePrivateBeginInstallWithManifest3Function::InstallUIProceed() { | 284 void WebstorePrivateBeginInstallWithManifest3Function::InstallUIProceed() { |
341 // This gets cleared in CrxInstaller::ConfirmInstall(). TODO(asargent) - in | 285 // This gets cleared in CrxInstaller::ConfirmInstall(). TODO(asargent) - in |
342 // the future we may also want to add time-based expiration, where a whitelist | 286 // the future we may also want to add time-based expiration, where a whitelist |
343 // entry is only valid for some number of minutes. | 287 // entry is only valid for some number of minutes. |
344 scoped_ptr<WebstoreInstaller::Approval> approval( | 288 scoped_ptr<WebstoreInstaller::Approval> approval( |
345 WebstoreInstaller::Approval::CreateWithNoInstallPrompt( | 289 WebstoreInstaller::Approval::CreateWithNoInstallPrompt( |
346 GetProfile(), params_->details.id, parsed_manifest_.Pass(), false)); | 290 chrome_details_.GetProfile(), |
| 291 params_->details.id, |
| 292 parsed_manifest_.Pass(), |
| 293 false)); |
347 approval->use_app_installed_bubble = params_->details.app_install_bubble; | 294 approval->use_app_installed_bubble = params_->details.app_install_bubble; |
348 approval->enable_launcher = params_->details.enable_launcher; | 295 approval->enable_launcher = params_->details.enable_launcher; |
349 // If we are enabling the launcher, we should not show the app list in order | 296 // If we are enabling the launcher, we should not show the app list in order |
350 // to train the user to open it themselves at least once. | 297 // to train the user to open it themselves at least once. |
351 approval->skip_post_install_ui = params_->details.enable_launcher; | 298 approval->skip_post_install_ui = params_->details.enable_launcher; |
352 approval->dummy_extension = dummy_extension_; | 299 approval->dummy_extension = dummy_extension_; |
353 approval->installing_icon = gfx::ImageSkia::CreateFrom1xBitmap(icon_); | 300 approval->installing_icon = gfx::ImageSkia::CreateFrom1xBitmap(icon_); |
354 approval->authuser = authuser_; | 301 approval->authuser = authuser_; |
355 g_pending_approvals.Get().PushApproval(approval.Pass()); | 302 g_pending_approvals.Get().PushApproval(approval.Pass()); |
356 | 303 |
357 DCHECK(scoped_active_install_.get()); | 304 DCHECK(scoped_active_install_.get()); |
358 scoped_active_install_->CancelDeregister(); | 305 scoped_active_install_->CancelDeregister(); |
359 | 306 |
360 SetResultCode(ERROR_NONE); | 307 Respond(BuildResponseForSuccess()); |
361 SendResponse(true); | |
362 | 308 |
363 // The Permissions_Install histogram is recorded from the ExtensionService | 309 // The Permissions_Install histogram is recorded from the ExtensionService |
364 // for all extension installs, so we only need to record the web store | 310 // for all extension installs, so we only need to record the web store |
365 // specific histogram here. | 311 // specific histogram here. |
366 ExtensionService::RecordPermissionMessagesHistogram( | 312 ExtensionService::RecordPermissionMessagesHistogram( |
367 dummy_extension_.get(), "Extensions.Permissions_WebStoreInstall2"); | 313 dummy_extension_.get(), "Extensions.Permissions_WebStoreInstall2"); |
368 | 314 |
369 // Matches the AddRef in RunAsync(). | 315 // Matches the AddRef in Run(). |
370 Release(); | 316 Release(); |
371 } | 317 } |
372 | 318 |
373 void WebstorePrivateBeginInstallWithManifest3Function::InstallUIAbort( | 319 void WebstorePrivateBeginInstallWithManifest3Function::InstallUIAbort( |
374 bool user_initiated) { | 320 bool user_initiated) { |
375 error_ = kUserCancelledError; | 321 Respond(BuildResponseForError(USER_CANCELLED, kUserCancelledError)); |
376 SetResultCode(USER_CANCELLED); | |
377 SendResponse(false); | |
378 | 322 |
379 // The web store install histograms are a subset of the install histograms. | 323 // The web store install histograms are a subset of the install histograms. |
380 // We need to record both histograms here since CrxInstaller::InstallUIAbort | 324 // We need to record both histograms here since CrxInstaller::InstallUIAbort |
381 // is never called for web store install cancellations. | 325 // is never called for web store install cancellations. |
382 std::string histogram_name = | 326 std::string histogram_name = |
383 user_initiated ? "Extensions.Permissions_WebStoreInstallCancel2" | 327 user_initiated ? "Extensions.Permissions_WebStoreInstallCancel2" |
384 : "Extensions.Permissions_WebStoreInstallAbort2"; | 328 : "Extensions.Permissions_WebStoreInstallAbort2"; |
385 ExtensionService::RecordPermissionMessagesHistogram(dummy_extension_.get(), | 329 ExtensionService::RecordPermissionMessagesHistogram(dummy_extension_.get(), |
386 histogram_name.c_str()); | 330 histogram_name.c_str()); |
387 | 331 |
388 histogram_name = user_initiated ? "Extensions.Permissions_InstallCancel2" | 332 histogram_name = user_initiated ? "Extensions.Permissions_InstallCancel2" |
389 : "Extensions.Permissions_InstallAbort2"; | 333 : "Extensions.Permissions_InstallAbort2"; |
390 ExtensionService::RecordPermissionMessagesHistogram(dummy_extension_.get(), | 334 ExtensionService::RecordPermissionMessagesHistogram(dummy_extension_.get(), |
391 histogram_name.c_str()); | 335 histogram_name.c_str()); |
392 | 336 |
393 // Matches the AddRef in RunAsync(). | 337 // Matches the AddRef in Run(). |
394 Release(); | 338 Release(); |
395 } | 339 } |
396 | 340 |
| 341 const char* WebstorePrivateBeginInstallWithManifest3Function:: |
| 342 ResultCodeToString(ResultCode code) const { |
| 343 switch (code) { |
| 344 case ERROR_NONE: |
| 345 return ""; |
| 346 case UNKNOWN_ERROR: |
| 347 return "unknown_error"; |
| 348 case USER_CANCELLED: |
| 349 return "user_cancelled"; |
| 350 case MANIFEST_ERROR: |
| 351 return "manifest_error"; |
| 352 case ICON_ERROR: |
| 353 return "icon_error"; |
| 354 case INVALID_ID: |
| 355 return "invalid_id"; |
| 356 case PERMISSION_DENIED: |
| 357 return "permission_denied"; |
| 358 case INVALID_ICON_URL: |
| 359 return "invalid_icon_url"; |
| 360 case ALREADY_INSTALLED: |
| 361 return "already_installed"; |
| 362 } |
| 363 NOTREACHED(); |
| 364 return ""; |
| 365 } |
| 366 |
| 367 ExtensionFunction::ResponseValue |
| 368 WebstorePrivateBeginInstallWithManifest3Function::BuildResponseForSuccess() { |
| 369 return ArgumentList( |
| 370 BeginInstallWithManifest3::Results::Create( |
| 371 ResultCodeToString(ERROR_NONE))); |
| 372 } |
| 373 |
| 374 ExtensionFunction::ResponseValue |
| 375 WebstorePrivateBeginInstallWithManifest3Function::BuildResponseForError( |
| 376 ResultCode code, const std::string& error) { |
| 377 return ErrorWithArguments( |
| 378 BeginInstallWithManifest3::Results::Create(ResultCodeToString(code)), |
| 379 error); |
| 380 } |
| 381 |
397 WebstorePrivateCompleteInstallFunction:: | 382 WebstorePrivateCompleteInstallFunction:: |
398 WebstorePrivateCompleteInstallFunction() {} | 383 WebstorePrivateCompleteInstallFunction() : chrome_details_(this) {} |
399 | 384 |
400 WebstorePrivateCompleteInstallFunction:: | 385 WebstorePrivateCompleteInstallFunction:: |
401 ~WebstorePrivateCompleteInstallFunction() {} | 386 ~WebstorePrivateCompleteInstallFunction() {} |
402 | 387 |
403 bool WebstorePrivateCompleteInstallFunction::RunAsync() { | 388 ExtensionFunction::ResponseAction |
| 389 WebstorePrivateCompleteInstallFunction::Run() { |
404 scoped_ptr<CompleteInstall::Params> params( | 390 scoped_ptr<CompleteInstall::Params> params( |
405 CompleteInstall::Params::Create(*args_)); | 391 CompleteInstall::Params::Create(*args_)); |
406 EXTENSION_FUNCTION_VALIDATE(params); | 392 EXTENSION_FUNCTION_VALIDATE(params); |
407 if (!crx_file::id_util::IdIsValid(params->expected_id)) { | 393 if (!crx_file::id_util::IdIsValid(params->expected_id)) |
408 error_ = kInvalidIdError; | 394 return RespondNow(Error(kInvalidIdError)); |
409 return false; | |
410 } | |
411 | 395 |
412 approval_ = g_pending_approvals.Get() | 396 approval_ = |
413 .PopApproval(GetProfile(), params->expected_id) | 397 g_pending_approvals.Get().PopApproval(chrome_details_.GetProfile(), |
414 .Pass(); | 398 params->expected_id).Pass(); |
415 if (!approval_) { | 399 if (!approval_) { |
416 error_ = ErrorUtils::FormatErrorMessage( | 400 return RespondNow(Error(kNoPreviousBeginInstallWithManifestError, |
417 kNoPreviousBeginInstallWithManifestError, params->expected_id); | 401 params->expected_id)); |
418 return false; | |
419 } | 402 } |
420 | 403 |
421 scoped_active_install_.reset(new ScopedActiveInstall( | 404 scoped_active_install_.reset(new ScopedActiveInstall( |
422 InstallTracker::Get(GetProfile()), params->expected_id)); | 405 InstallTracker::Get(browser_context()), params->expected_id)); |
423 | 406 |
424 AppListService* app_list_service = AppListService::Get( | 407 AppListService* app_list_service = AppListService::Get( |
425 GetHostDesktopTypeForWebContents(GetAssociatedWebContents())); | 408 GetHostDesktopTypeForWebContents(GetAssociatedWebContents())); |
426 | 409 |
427 if (approval_->enable_launcher) { | 410 if (approval_->enable_launcher) { |
428 app_list_service->EnableAppList(GetProfile(), | 411 app_list_service->EnableAppList(chrome_details_.GetProfile(), |
429 AppListService::ENABLE_FOR_APP_INSTALL); | 412 AppListService::ENABLE_FOR_APP_INSTALL); |
430 } | 413 } |
431 | 414 |
432 if (IsAppLauncherEnabled() && approval_->manifest->is_app()) { | 415 if (IsAppLauncherEnabled() && approval_->manifest->is_app()) { |
433 // Show the app list to show download is progressing. Don't show the app | 416 // Show the app list to show download is progressing. Don't show the app |
434 // list on first app install so users can be trained to open it themselves. | 417 // list on first app install so users can be trained to open it themselves. |
435 app_list_service->ShowForAppInstall( | 418 app_list_service->ShowForAppInstall( |
436 GetProfile(), params->expected_id, approval_->enable_launcher); | 419 chrome_details_.GetProfile(), |
| 420 params->expected_id, |
| 421 approval_->enable_launcher); |
437 } | 422 } |
438 | 423 |
439 // If the target extension has already been installed ephemerally and is | 424 // If the target extension has already been installed ephemerally and is |
440 // up to date, it can be promoted to a regular installed extension and | 425 // up to date, it can be promoted to a regular installed extension and |
441 // downloading from the Web Store is not necessary. | 426 // downloading from the Web Store is not necessary. |
442 const Extension* extension = ExtensionRegistry::Get(GetProfile())-> | 427 const Extension* extension = ExtensionRegistry::Get(browser_context())-> |
443 GetExtensionById(params->expected_id, ExtensionRegistry::EVERYTHING); | 428 GetExtensionById(params->expected_id, ExtensionRegistry::EVERYTHING); |
444 if (extension && approval_->dummy_extension.get() && | 429 if (extension && approval_->dummy_extension.get() && |
445 util::IsEphemeralApp(extension->id(), GetProfile()) && | 430 util::IsEphemeralApp(extension->id(), browser_context()) && |
446 extension->version()->CompareTo(*approval_->dummy_extension->version()) >= | 431 extension->version()->CompareTo(*approval_->dummy_extension->version()) >= |
447 0) { | 432 0) { |
448 install_ui::ShowPostInstallUIForApproval( | 433 install_ui::ShowPostInstallUIForApproval( |
449 GetProfile(), *approval_, extension); | 434 browser_context(), *approval_, extension); |
450 | 435 |
451 ExtensionService* extension_service = | 436 ExtensionService* extension_service = |
452 ExtensionSystem::Get(GetProfile())->extension_service(); | 437 ExtensionSystem::Get(browser_context())->extension_service(); |
453 extension_service->PromoteEphemeralApp(extension, false); | 438 extension_service->PromoteEphemeralApp(extension, false); |
454 OnInstallSuccess(extension->id()); | 439 OnInstallSuccess(extension->id()); |
455 return true; | 440 VLOG(1) << "Install success, sending response"; |
| 441 return RespondNow(NoArguments()); |
456 } | 442 } |
457 | 443 |
458 // Balanced in OnExtensionInstallSuccess() or OnExtensionInstallFailure(). | 444 // Balanced in OnExtensionInstallSuccess() or OnExtensionInstallFailure(). |
459 AddRef(); | 445 AddRef(); |
460 | 446 |
461 // The extension will install through the normal extension install flow, but | 447 // The extension will install through the normal extension install flow, but |
462 // the whitelist entry will bypass the normal permissions install dialog. | 448 // the whitelist entry will bypass the normal permissions install dialog. |
463 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller( | 449 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller( |
464 GetProfile(), | 450 chrome_details_.GetProfile(), |
465 this, | 451 this, |
466 dispatcher()->delegate()->GetAssociatedWebContents(), | 452 chrome_details_.GetAssociatedWebContents(), |
467 params->expected_id, | 453 params->expected_id, |
468 approval_.Pass(), | 454 approval_.Pass(), |
469 WebstoreInstaller::INSTALL_SOURCE_OTHER); | 455 WebstoreInstaller::INSTALL_SOURCE_OTHER); |
470 installer->Start(); | 456 installer->Start(); |
471 | 457 |
472 return true; | 458 return RespondLater(); |
473 } | 459 } |
474 | 460 |
475 void WebstorePrivateCompleteInstallFunction::OnExtensionInstallSuccess( | 461 void WebstorePrivateCompleteInstallFunction::OnExtensionInstallSuccess( |
476 const std::string& id) { | 462 const std::string& id) { |
477 OnInstallSuccess(id); | 463 OnInstallSuccess(id); |
| 464 VLOG(1) << "Install success, sending response"; |
| 465 Respond(NoArguments()); |
| 466 |
478 RecordWebstoreExtensionInstallResult(true); | 467 RecordWebstoreExtensionInstallResult(true); |
479 | 468 |
480 // Matches the AddRef in RunAsync(). | 469 // Matches the AddRef in Run(). |
481 Release(); | 470 Release(); |
482 } | 471 } |
483 | 472 |
484 void WebstorePrivateCompleteInstallFunction::OnExtensionInstallFailure( | 473 void WebstorePrivateCompleteInstallFunction::OnExtensionInstallFailure( |
485 const std::string& id, | 474 const std::string& id, |
486 const std::string& error, | 475 const std::string& error, |
487 WebstoreInstaller::FailureReason reason) { | 476 WebstoreInstaller::FailureReason reason) { |
488 if (test_webstore_installer_delegate) { | 477 if (test_webstore_installer_delegate) { |
489 test_webstore_installer_delegate->OnExtensionInstallFailure( | 478 test_webstore_installer_delegate->OnExtensionInstallFailure( |
490 id, error, reason); | 479 id, error, reason); |
491 } | 480 } |
492 | 481 |
493 error_ = error; | |
494 VLOG(1) << "Install failed, sending response"; | 482 VLOG(1) << "Install failed, sending response"; |
495 SendResponse(false); | 483 Respond(Error(error)); |
496 | 484 |
497 RecordWebstoreExtensionInstallResult(false); | 485 RecordWebstoreExtensionInstallResult(false); |
498 | 486 |
499 // Matches the AddRef in RunAsync(). | 487 // Matches the AddRef in Run(). |
500 Release(); | 488 Release(); |
501 } | 489 } |
502 | 490 |
503 void WebstorePrivateCompleteInstallFunction::OnInstallSuccess( | 491 void WebstorePrivateCompleteInstallFunction::OnInstallSuccess( |
504 const std::string& id) { | 492 const std::string& id) { |
505 if (test_webstore_installer_delegate) | 493 if (test_webstore_installer_delegate) |
506 test_webstore_installer_delegate->OnExtensionInstallSuccess(id); | 494 test_webstore_installer_delegate->OnExtensionInstallSuccess(id); |
507 | |
508 VLOG(1) << "Install success, sending response"; | |
509 SendResponse(true); | |
510 } | 495 } |
511 | 496 |
512 WebstorePrivateEnableAppLauncherFunction:: | 497 WebstorePrivateEnableAppLauncherFunction:: |
513 WebstorePrivateEnableAppLauncherFunction() {} | 498 WebstorePrivateEnableAppLauncherFunction() : chrome_details_(this) {} |
514 | 499 |
515 WebstorePrivateEnableAppLauncherFunction:: | 500 WebstorePrivateEnableAppLauncherFunction:: |
516 ~WebstorePrivateEnableAppLauncherFunction() {} | 501 ~WebstorePrivateEnableAppLauncherFunction() {} |
517 | 502 |
518 bool WebstorePrivateEnableAppLauncherFunction::RunSync() { | 503 ExtensionFunction::ResponseAction |
| 504 WebstorePrivateEnableAppLauncherFunction::Run() { |
519 AppListService* app_list_service = AppListService::Get( | 505 AppListService* app_list_service = AppListService::Get( |
520 GetHostDesktopTypeForWebContents(GetAssociatedWebContents())); | 506 GetHostDesktopTypeForWebContents( |
521 app_list_service->EnableAppList(GetProfile(), | 507 chrome_details_.GetAssociatedWebContents())); |
| 508 app_list_service->EnableAppList(chrome_details_.GetProfile(), |
522 AppListService::ENABLE_VIA_WEBSTORE_LINK); | 509 AppListService::ENABLE_VIA_WEBSTORE_LINK); |
523 return true; | 510 return RespondNow(NoArguments()); |
524 } | 511 } |
525 | 512 |
526 bool WebstorePrivateGetBrowserLoginFunction::RunSync() { | 513 WebstorePrivateGetBrowserLoginFunction:: |
| 514 WebstorePrivateGetBrowserLoginFunction() : chrome_details_(this) {} |
| 515 |
| 516 WebstorePrivateGetBrowserLoginFunction:: |
| 517 ~WebstorePrivateGetBrowserLoginFunction() {} |
| 518 |
| 519 ExtensionFunction::ResponseAction |
| 520 WebstorePrivateGetBrowserLoginFunction::Run() { |
527 GetBrowserLogin::Results::Info info; | 521 GetBrowserLogin::Results::Info info; |
528 info.login = | 522 info.login = SigninManagerFactory::GetForProfile( |
529 SigninManagerFactory::GetForProfile(GetProfile()->GetOriginalProfile()) | 523 chrome_details_.GetProfile()->GetOriginalProfile()) |
530 ->GetAuthenticatedUsername(); | 524 ->GetAuthenticatedUsername(); |
531 results_ = GetBrowserLogin::Results::Create(info); | 525 return RespondNow(ArgumentList(GetBrowserLogin::Results::Create(info))); |
532 return true; | |
533 } | 526 } |
534 | 527 |
535 bool WebstorePrivateGetStoreLoginFunction::RunSync() { | 528 WebstorePrivateGetStoreLoginFunction:: |
536 results_ = GetStoreLogin::Results::Create(GetWebstoreLogin(GetProfile())); | 529 WebstorePrivateGetStoreLoginFunction() : chrome_details_(this) {} |
537 return true; | 530 |
| 531 WebstorePrivateGetStoreLoginFunction:: |
| 532 ~WebstorePrivateGetStoreLoginFunction() {} |
| 533 |
| 534 ExtensionFunction::ResponseAction WebstorePrivateGetStoreLoginFunction::Run() { |
| 535 return RespondNow(ArgumentList(GetStoreLogin::Results::Create( |
| 536 GetWebstoreLogin(chrome_details_.GetProfile())))); |
538 } | 537 } |
539 | 538 |
540 bool WebstorePrivateSetStoreLoginFunction::RunSync() { | 539 WebstorePrivateSetStoreLoginFunction:: |
| 540 WebstorePrivateSetStoreLoginFunction() : chrome_details_(this) {} |
| 541 |
| 542 WebstorePrivateSetStoreLoginFunction:: |
| 543 ~WebstorePrivateSetStoreLoginFunction() {} |
| 544 |
| 545 ExtensionFunction::ResponseAction WebstorePrivateSetStoreLoginFunction::Run() { |
541 scoped_ptr<SetStoreLogin::Params> params( | 546 scoped_ptr<SetStoreLogin::Params> params( |
542 SetStoreLogin::Params::Create(*args_)); | 547 SetStoreLogin::Params::Create(*args_)); |
543 EXTENSION_FUNCTION_VALIDATE(params); | 548 EXTENSION_FUNCTION_VALIDATE(params); |
544 SetWebstoreLogin(GetProfile(), params->login); | 549 SetWebstoreLogin(chrome_details_.GetProfile(), params->login); |
545 return true; | 550 return RespondNow(NoArguments()); |
546 } | 551 } |
547 | 552 |
548 WebstorePrivateGetWebGLStatusFunction::WebstorePrivateGetWebGLStatusFunction() { | 553 WebstorePrivateGetWebGLStatusFunction::WebstorePrivateGetWebGLStatusFunction() |
549 feature_checker_ = new GPUFeatureChecker( | 554 : feature_checker_(new GPUFeatureChecker( |
550 gpu::GPU_FEATURE_TYPE_WEBGL, | 555 gpu::GPU_FEATURE_TYPE_WEBGL, |
551 base::Bind(&WebstorePrivateGetWebGLStatusFunction::OnFeatureCheck, | 556 base::Bind(&WebstorePrivateGetWebGLStatusFunction::OnFeatureCheck, |
552 base::Unretained(this))); | 557 base::Unretained(this)))) { |
553 } | 558 } |
554 | 559 |
555 WebstorePrivateGetWebGLStatusFunction:: | 560 WebstorePrivateGetWebGLStatusFunction:: |
556 ~WebstorePrivateGetWebGLStatusFunction() {} | 561 ~WebstorePrivateGetWebGLStatusFunction() {} |
557 | 562 |
558 void WebstorePrivateGetWebGLStatusFunction::CreateResult(bool webgl_allowed) { | 563 ExtensionFunction::ResponseAction WebstorePrivateGetWebGLStatusFunction::Run() { |
559 results_ = GetWebGLStatus::Results::Create(GetWebGLStatus::Results:: | 564 feature_checker_->CheckGPUFeatureAvailability(); |
560 ParseWebgl_status(webgl_allowed ? "webgl_allowed" : "webgl_blocked")); | 565 return RespondLater(); |
561 } | 566 } |
562 | 567 |
563 bool WebstorePrivateGetWebGLStatusFunction::RunAsync() { | 568 void WebstorePrivateGetWebGLStatusFunction::OnFeatureCheck( |
564 feature_checker_->CheckGPUFeatureAvailability(); | 569 bool feature_allowed) { |
565 return true; | 570 Respond(ArgumentList(GetWebGLStatus::Results::Create( |
| 571 GetWebGLStatus::Results::ParseWebgl_status( |
| 572 feature_allowed ? "webgl_allowed" : "webgl_blocked")))); |
566 } | 573 } |
567 | 574 |
568 void WebstorePrivateGetWebGLStatusFunction:: | 575 WebstorePrivateGetIsLauncherEnabledFunction:: |
569 OnFeatureCheck(bool feature_allowed) { | 576 WebstorePrivateGetIsLauncherEnabledFunction() {} |
570 CreateResult(feature_allowed); | 577 |
571 SendResponse(true); | 578 WebstorePrivateGetIsLauncherEnabledFunction:: |
| 579 ~WebstorePrivateGetIsLauncherEnabledFunction() {} |
| 580 |
| 581 ExtensionFunction::ResponseAction |
| 582 WebstorePrivateGetIsLauncherEnabledFunction::Run() { |
| 583 return RespondNow(ArgumentList( |
| 584 GetIsLauncherEnabled::Results::Create(IsAppLauncherEnabled()))); |
572 } | 585 } |
573 | 586 |
574 bool WebstorePrivateGetIsLauncherEnabledFunction::RunSync() { | 587 WebstorePrivateIsInIncognitoModeFunction:: |
575 results_ = GetIsLauncherEnabled::Results::Create(IsAppLauncherEnabled()); | 588 WebstorePrivateIsInIncognitoModeFunction() : chrome_details_(this) {} |
576 return true; | |
577 } | |
578 | 589 |
579 bool WebstorePrivateIsInIncognitoModeFunction::RunSync() { | 590 WebstorePrivateIsInIncognitoModeFunction:: |
580 results_ = IsInIncognitoMode::Results::Create( | 591 ~WebstorePrivateIsInIncognitoModeFunction() {} |
581 GetProfile() != GetProfile()->GetOriginalProfile()); | 592 |
582 return true; | 593 ExtensionFunction::ResponseAction |
| 594 WebstorePrivateIsInIncognitoModeFunction::Run() { |
| 595 Profile* profile = chrome_details_.GetProfile(); |
| 596 return RespondNow(ArgumentList(IsInIncognitoMode::Results::Create( |
| 597 profile != profile->GetOriginalProfile()))); |
583 } | 598 } |
584 | 599 |
585 WebstorePrivateLaunchEphemeralAppFunction:: | 600 WebstorePrivateLaunchEphemeralAppFunction:: |
586 WebstorePrivateLaunchEphemeralAppFunction() {} | 601 WebstorePrivateLaunchEphemeralAppFunction() : chrome_details_(this) {} |
587 | 602 |
588 WebstorePrivateLaunchEphemeralAppFunction:: | 603 WebstorePrivateLaunchEphemeralAppFunction:: |
589 ~WebstorePrivateLaunchEphemeralAppFunction() {} | 604 ~WebstorePrivateLaunchEphemeralAppFunction() {} |
590 | 605 |
591 bool WebstorePrivateLaunchEphemeralAppFunction::RunAsync() { | 606 ExtensionFunction::ResponseAction |
| 607 WebstorePrivateLaunchEphemeralAppFunction::Run() { |
592 // Check whether the browser window still exists. | 608 // Check whether the browser window still exists. |
593 content::WebContents* web_contents = GetAssociatedWebContents(); | 609 content::WebContents* web_contents = |
594 if (!web_contents) { | 610 chrome_details_.GetAssociatedWebContents(); |
595 error_ = "aborted"; | 611 if (!web_contents) |
596 return false; | 612 return RespondNow(Error("aborted")); |
597 } | |
598 | 613 |
599 if (!user_gesture()) { | 614 if (!user_gesture()) { |
600 SetResult(LaunchEphemeralAppResult::RESULT_USER_GESTURE_REQUIRED, | 615 return RespondNow(BuildResponse( |
601 "User gesture is required"); | 616 LaunchEphemeralAppResult::RESULT_USER_GESTURE_REQUIRED, |
602 return false; | 617 "User gesture is required")); |
603 } | 618 } |
604 | 619 |
605 scoped_ptr<LaunchEphemeralApp::Params> params( | 620 scoped_ptr<LaunchEphemeralApp::Params> params( |
606 LaunchEphemeralApp::Params::Create(*args_)); | 621 LaunchEphemeralApp::Params::Create(*args_)); |
607 EXTENSION_FUNCTION_VALIDATE(params); | 622 EXTENSION_FUNCTION_VALIDATE(params); |
608 | 623 |
609 AddRef(); // Balanced in OnLaunchComplete() | 624 AddRef(); // Balanced in OnLaunchComplete() |
610 | 625 |
611 scoped_refptr<EphemeralAppLauncher> launcher = | 626 scoped_refptr<EphemeralAppLauncher> launcher = |
612 EphemeralAppLauncher::CreateForWebContents( | 627 EphemeralAppLauncher::CreateForWebContents( |
613 params->id, | 628 params->id, |
614 web_contents, | 629 web_contents, |
615 base::Bind( | 630 base::Bind( |
616 &WebstorePrivateLaunchEphemeralAppFunction::OnLaunchComplete, | 631 &WebstorePrivateLaunchEphemeralAppFunction::OnLaunchComplete, |
617 base::Unretained(this))); | 632 base::Unretained(this))); |
618 launcher->Start(); | 633 launcher->Start(); |
619 return true; | 634 |
| 635 return RespondLater(); |
620 } | 636 } |
621 | 637 |
622 void WebstorePrivateLaunchEphemeralAppFunction::OnLaunchComplete( | 638 void WebstorePrivateLaunchEphemeralAppFunction::OnLaunchComplete( |
623 webstore_install::Result result, const std::string& error) { | 639 webstore_install::Result result, const std::string& error) { |
624 // Translate between the EphemeralAppLauncher's error codes and the API | 640 // Translate between the EphemeralAppLauncher's error codes and the API |
625 // error codes. | 641 // error codes. |
626 LaunchEphemeralAppResult::Result api_result = | 642 LaunchEphemeralAppResult::Result api_result = |
627 LaunchEphemeralAppResult::RESULT_UNKNOWN_ERROR; | 643 LaunchEphemeralAppResult::RESULT_UNKNOWN_ERROR; |
628 switch (result) { | 644 switch (result) { |
629 case webstore_install::SUCCESS: | 645 case webstore_install::SUCCESS: |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 break; | 677 break; |
662 case webstore_install::LAUNCH_UNSUPPORTED_EXTENSION_TYPE: | 678 case webstore_install::LAUNCH_UNSUPPORTED_EXTENSION_TYPE: |
663 api_result = LaunchEphemeralAppResult::RESULT_UNSUPPORTED_EXTENSION_TYPE; | 679 api_result = LaunchEphemeralAppResult::RESULT_UNSUPPORTED_EXTENSION_TYPE; |
664 break; | 680 break; |
665 case webstore_install::INSTALL_IN_PROGRESS: | 681 case webstore_install::INSTALL_IN_PROGRESS: |
666 api_result = LaunchEphemeralAppResult::RESULT_INSTALL_IN_PROGRESS; | 682 api_result = LaunchEphemeralAppResult::RESULT_INSTALL_IN_PROGRESS; |
667 break; | 683 break; |
668 case webstore_install::LAUNCH_IN_PROGRESS: | 684 case webstore_install::LAUNCH_IN_PROGRESS: |
669 api_result = LaunchEphemeralAppResult::RESULT_LAUNCH_IN_PROGRESS; | 685 api_result = LaunchEphemeralAppResult::RESULT_LAUNCH_IN_PROGRESS; |
670 break; | 686 break; |
671 default: | |
672 NOTREACHED(); | |
673 break; | |
674 } | 687 } |
675 | 688 |
676 SetResult(api_result, error); | 689 Respond(BuildResponse(api_result, error)); |
677 Release(); // Matches AddRef() in RunAsync() | 690 Release(); // Matches AddRef() in Run() |
678 } | 691 } |
679 | 692 |
680 void WebstorePrivateLaunchEphemeralAppFunction::SetResult( | 693 ExtensionFunction::ResponseValue |
| 694 WebstorePrivateLaunchEphemeralAppFunction::BuildResponse( |
681 LaunchEphemeralAppResult::Result result, const std::string& error) { | 695 LaunchEphemeralAppResult::Result result, const std::string& error) { |
682 if (result != LaunchEphemeralAppResult::RESULT_SUCCESS) { | 696 if (result != LaunchEphemeralAppResult::RESULT_SUCCESS) { |
| 697 std::string error_message; |
683 if (error.empty()) { | 698 if (error.empty()) { |
684 error_ = base::StringPrintf( | 699 error_message = base::StringPrintf( |
685 "[%s]", LaunchEphemeralAppResult::ToString(result).c_str()); | 700 "[%s]", LaunchEphemeralAppResult::ToString(result).c_str()); |
686 } else { | 701 } else { |
687 error_ = base::StringPrintf( | 702 error_message = base::StringPrintf( |
688 "[%s]: %s", | 703 "[%s]: %s", |
689 LaunchEphemeralAppResult::ToString(result).c_str(), | 704 LaunchEphemeralAppResult::ToString(result).c_str(), |
690 error.c_str()); | 705 error.c_str()); |
691 } | 706 } |
| 707 return ErrorWithArguments(LaunchEphemeralAppResult::Create(result), |
| 708 error_message); |
692 } | 709 } |
693 | 710 return ArgumentList(LaunchEphemeralAppResult::Create(result)); |
694 results_ = LaunchEphemeralAppResult::Create(result); | |
695 SendResponse(result == LaunchEphemeralAppResult::RESULT_SUCCESS); | |
696 } | 711 } |
697 | 712 |
698 WebstorePrivateGetEphemeralAppsEnabledFunction:: | 713 WebstorePrivateGetEphemeralAppsEnabledFunction:: |
699 WebstorePrivateGetEphemeralAppsEnabledFunction() {} | 714 WebstorePrivateGetEphemeralAppsEnabledFunction() {} |
700 | 715 |
701 WebstorePrivateGetEphemeralAppsEnabledFunction:: | 716 WebstorePrivateGetEphemeralAppsEnabledFunction:: |
702 ~WebstorePrivateGetEphemeralAppsEnabledFunction() {} | 717 ~WebstorePrivateGetEphemeralAppsEnabledFunction() {} |
703 | 718 |
704 bool WebstorePrivateGetEphemeralAppsEnabledFunction::RunSync() { | 719 ExtensionFunction::ResponseAction |
705 results_ = GetEphemeralAppsEnabled::Results::Create( | 720 WebstorePrivateGetEphemeralAppsEnabledFunction::Run() { |
706 EphemeralAppLauncher::IsFeatureEnabledInWebstore()); | 721 return RespondNow(ArgumentList(GetEphemeralAppsEnabled::Results::Create( |
707 return true; | 722 EphemeralAppLauncher::IsFeatureEnabledInWebstore()))); |
708 } | 723 } |
709 | 724 |
710 } // namespace extensions | 725 } // namespace extensions |
OLD | NEW |