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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 test_webstore_installer_delegate = delegate; | 120 test_webstore_installer_delegate = delegate; |
121 } | 121 } |
122 | 122 |
123 // static | 123 // static |
124 scoped_ptr<WebstoreInstaller::Approval> | 124 scoped_ptr<WebstoreInstaller::Approval> |
125 WebstorePrivateApi::PopApprovalForTesting( | 125 WebstorePrivateApi::PopApprovalForTesting( |
126 Profile* profile, const std::string& extension_id) { | 126 Profile* profile, const std::string& extension_id) { |
127 return g_pending_approvals.Get().PopApproval(profile, extension_id); | 127 return g_pending_approvals.Get().PopApproval(profile, extension_id); |
128 } | 128 } |
129 | 129 |
130 InstallBundleFunction::InstallBundleFunction() {} | 130 WebstorePrivateInstallBundleFunction::WebstorePrivateInstallBundleFunction() {} |
131 InstallBundleFunction::~InstallBundleFunction() {} | 131 WebstorePrivateInstallBundleFunction::~WebstorePrivateInstallBundleFunction() {} |
132 | 132 |
133 bool InstallBundleFunction::RunImpl() { | 133 bool WebstorePrivateInstallBundleFunction::RunImpl() { |
134 ListValue* extensions = NULL; | 134 ListValue* extensions = NULL; |
135 EXTENSION_FUNCTION_VALIDATE(args_->GetList(0, &extensions)); | 135 EXTENSION_FUNCTION_VALIDATE(args_->GetList(0, &extensions)); |
136 | 136 |
137 BundleInstaller::ItemList items; | 137 BundleInstaller::ItemList items; |
138 if (!ReadBundleInfo(extensions, &items)) | 138 if (!ReadBundleInfo(extensions, &items)) |
139 return false; | 139 return false; |
140 | 140 |
141 bundle_ = new BundleInstaller(GetCurrentBrowser(), items); | 141 bundle_ = new BundleInstaller(GetCurrentBrowser(), items); |
142 | 142 |
143 AddRef(); // Balanced in OnBundleInstallCompleted / OnBundleInstallCanceled. | 143 AddRef(); // Balanced in OnBundleInstallCompleted / OnBundleInstallCanceled. |
144 | 144 |
145 bundle_->PromptForApproval(this); | 145 bundle_->PromptForApproval(this); |
146 return true; | 146 return true; |
147 } | 147 } |
148 | 148 |
149 bool InstallBundleFunction::ReadBundleInfo(ListValue* extensions, | 149 bool WebstorePrivateInstallBundleFunction::ReadBundleInfo(ListValue* extensions, |
150 BundleInstaller::ItemList* items) { | 150 BundleInstaller::ItemList* items) { |
151 for (size_t i = 0; i < extensions->GetSize(); ++i) { | 151 for (size_t i = 0; i < extensions->GetSize(); ++i) { |
152 DictionaryValue* details = NULL; | 152 DictionaryValue* details = NULL; |
153 EXTENSION_FUNCTION_VALIDATE(extensions->GetDictionary(i, &details)); | 153 EXTENSION_FUNCTION_VALIDATE(extensions->GetDictionary(i, &details)); |
154 | 154 |
155 BundleInstaller::Item item; | 155 BundleInstaller::Item item; |
156 EXTENSION_FUNCTION_VALIDATE(details->GetString( | 156 EXTENSION_FUNCTION_VALIDATE(details->GetString( |
157 kIdKey, &item.id)); | 157 kIdKey, &item.id)); |
158 EXTENSION_FUNCTION_VALIDATE(details->GetString( | 158 EXTENSION_FUNCTION_VALIDATE(details->GetString( |
159 kManifestKey, &item.manifest)); | 159 kManifestKey, &item.manifest)); |
160 EXTENSION_FUNCTION_VALIDATE(details->GetString( | 160 EXTENSION_FUNCTION_VALIDATE(details->GetString( |
161 kLocalizedNameKey, &item.localized_name)); | 161 kLocalizedNameKey, &item.localized_name)); |
162 | 162 |
163 items->push_back(item); | 163 items->push_back(item); |
164 } | 164 } |
165 | 165 |
166 return true; | 166 return true; |
167 } | 167 } |
168 | 168 |
169 void InstallBundleFunction::OnBundleInstallApproved() { | 169 void WebstorePrivateInstallBundleFunction::OnBundleInstallApproved() { |
170 bundle_->CompleteInstall( | 170 bundle_->CompleteInstall( |
171 &(dispatcher()->delegate()->GetAssociatedWebContents()->GetController()), | 171 &(dispatcher()->delegate()->GetAssociatedWebContents()->GetController()), |
172 this); | 172 this); |
173 } | 173 } |
174 | 174 |
175 void InstallBundleFunction::OnBundleInstallCanceled(bool user_initiated) { | 175 void WebstorePrivateInstallBundleFunction::OnBundleInstallCanceled( |
| 176 bool user_initiated) { |
176 if (user_initiated) | 177 if (user_initiated) |
177 error_ = "user_canceled"; | 178 error_ = "user_canceled"; |
178 else | 179 else |
179 error_ = "unknown_error"; | 180 error_ = "unknown_error"; |
180 | 181 |
181 SendResponse(false); | 182 SendResponse(false); |
182 | 183 |
183 Release(); // Balanced in RunImpl(). | 184 Release(); // Balanced in RunImpl(). |
184 } | 185 } |
185 | 186 |
186 void InstallBundleFunction::OnBundleInstallCompleted() { | 187 void WebstorePrivateInstallBundleFunction::OnBundleInstallCompleted() { |
187 SendResponse(true); | 188 SendResponse(true); |
188 | 189 |
189 Release(); // Balanced in RunImpl(). | 190 Release(); // Balanced in RunImpl(). |
190 } | 191 } |
191 | 192 |
192 BeginInstallWithManifestFunction::BeginInstallWithManifestFunction() | 193 WebstorePrivateBeginInstallWithManifest3Function:: |
193 : use_app_installed_bubble_(false) {} | 194 WebstorePrivateBeginInstallWithManifest3Function() |
| 195 : use_app_installed_bubble_(false) {} |
194 | 196 |
195 BeginInstallWithManifestFunction::~BeginInstallWithManifestFunction() {} | 197 WebstorePrivateBeginInstallWithManifest3Function:: |
| 198 ~WebstorePrivateBeginInstallWithManifest3Function() {} |
196 | 199 |
197 bool BeginInstallWithManifestFunction::RunImpl() { | 200 bool WebstorePrivateBeginInstallWithManifest3Function::RunImpl() { |
198 DictionaryValue* details = NULL; | 201 DictionaryValue* details = NULL; |
199 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &details)); | 202 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &details)); |
200 CHECK(details); | 203 CHECK(details); |
201 | 204 |
202 EXTENSION_FUNCTION_VALIDATE(details->GetString(kIdKey, &id_)); | 205 EXTENSION_FUNCTION_VALIDATE(details->GetString(kIdKey, &id_)); |
203 if (!extensions::Extension::IdIsValid(id_)) { | 206 if (!extensions::Extension::IdIsValid(id_)) { |
204 SetResultCode(INVALID_ID); | 207 SetResultCode(INVALID_ID); |
205 error_ = kInvalidIdError; | 208 error_ = kInvalidIdError; |
206 return false; | 209 return false; |
207 } | 210 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 | 253 |
251 // Matched with a Release in OnWebstoreParseSuccess/OnWebstoreParseFailure. | 254 // Matched with a Release in OnWebstoreParseSuccess/OnWebstoreParseFailure. |
252 AddRef(); | 255 AddRef(); |
253 | 256 |
254 // The response is sent asynchronously in OnWebstoreParseSuccess/ | 257 // The response is sent asynchronously in OnWebstoreParseSuccess/ |
255 // OnWebstoreParseFailure. | 258 // OnWebstoreParseFailure. |
256 return true; | 259 return true; |
257 } | 260 } |
258 | 261 |
259 | 262 |
260 void BeginInstallWithManifestFunction::SetResultCode(ResultCode code) { | 263 void WebstorePrivateBeginInstallWithManifest3Function::SetResultCode( |
| 264 ResultCode code) { |
261 switch (code) { | 265 switch (code) { |
262 case ERROR_NONE: | 266 case ERROR_NONE: |
263 SetResult(Value::CreateStringValue("")); | 267 SetResult(Value::CreateStringValue("")); |
264 break; | 268 break; |
265 case UNKNOWN_ERROR: | 269 case UNKNOWN_ERROR: |
266 SetResult(Value::CreateStringValue("unknown_error")); | 270 SetResult(Value::CreateStringValue("unknown_error")); |
267 break; | 271 break; |
268 case USER_CANCELLED: | 272 case USER_CANCELLED: |
269 SetResult(Value::CreateStringValue("user_cancelled")); | 273 SetResult(Value::CreateStringValue("user_cancelled")); |
270 break; | 274 break; |
(...skipping 10 matching lines...) Expand all Loading... |
281 SetResult(Value::CreateStringValue("permission_denied")); | 285 SetResult(Value::CreateStringValue("permission_denied")); |
282 break; | 286 break; |
283 case INVALID_ICON_URL: | 287 case INVALID_ICON_URL: |
284 SetResult(Value::CreateStringValue("invalid_icon_url")); | 288 SetResult(Value::CreateStringValue("invalid_icon_url")); |
285 break; | 289 break; |
286 default: | 290 default: |
287 CHECK(false); | 291 CHECK(false); |
288 } | 292 } |
289 } | 293 } |
290 | 294 |
291 void BeginInstallWithManifestFunction::OnWebstoreParseSuccess( | 295 void WebstorePrivateBeginInstallWithManifest3Function::OnWebstoreParseSuccess( |
292 const std::string& id, | 296 const std::string& id, |
293 const SkBitmap& icon, | 297 const SkBitmap& icon, |
294 DictionaryValue* parsed_manifest) { | 298 DictionaryValue* parsed_manifest) { |
295 CHECK_EQ(id_, id); | 299 CHECK_EQ(id_, id); |
296 CHECK(parsed_manifest); | 300 CHECK(parsed_manifest); |
297 icon_ = icon; | 301 icon_ = icon; |
298 parsed_manifest_.reset(parsed_manifest); | 302 parsed_manifest_.reset(parsed_manifest); |
299 | 303 |
300 std::string error; | 304 std::string error; |
301 dummy_extension_ = ExtensionInstallPrompt::GetLocalizedExtensionForDisplay( | 305 dummy_extension_ = ExtensionInstallPrompt::GetLocalizedExtensionForDisplay( |
(...skipping 15 matching lines...) Expand all Loading... |
317 return; | 321 return; |
318 install_prompt_.reset(new ExtensionInstallPrompt(web_contents)); | 322 install_prompt_.reset(new ExtensionInstallPrompt(web_contents)); |
319 install_prompt_->ConfirmWebstoreInstall( | 323 install_prompt_->ConfirmWebstoreInstall( |
320 this, | 324 this, |
321 dummy_extension_, | 325 dummy_extension_, |
322 &icon_, | 326 &icon_, |
323 ExtensionInstallPrompt::GetDefaultShowDialogCallback()); | 327 ExtensionInstallPrompt::GetDefaultShowDialogCallback()); |
324 // Control flow finishes up in InstallUIProceed or InstallUIAbort. | 328 // Control flow finishes up in InstallUIProceed or InstallUIAbort. |
325 } | 329 } |
326 | 330 |
327 void BeginInstallWithManifestFunction::OnWebstoreParseFailure( | 331 void WebstorePrivateBeginInstallWithManifest3Function::OnWebstoreParseFailure( |
328 const std::string& id, | 332 const std::string& id, |
329 WebstoreInstallHelper::Delegate::InstallHelperResultCode result_code, | 333 WebstoreInstallHelper::Delegate::InstallHelperResultCode result_code, |
330 const std::string& error_message) { | 334 const std::string& error_message) { |
331 CHECK_EQ(id_, id); | 335 CHECK_EQ(id_, id); |
332 | 336 |
333 // Map from WebstoreInstallHelper's result codes to ours. | 337 // Map from WebstoreInstallHelper's result codes to ours. |
334 switch (result_code) { | 338 switch (result_code) { |
335 case WebstoreInstallHelper::Delegate::UNKNOWN_ERROR: | 339 case WebstoreInstallHelper::Delegate::UNKNOWN_ERROR: |
336 SetResultCode(UNKNOWN_ERROR); | 340 SetResultCode(UNKNOWN_ERROR); |
337 break; | 341 break; |
338 case WebstoreInstallHelper::Delegate::ICON_ERROR: | 342 case WebstoreInstallHelper::Delegate::ICON_ERROR: |
339 SetResultCode(ICON_ERROR); | 343 SetResultCode(ICON_ERROR); |
340 break; | 344 break; |
341 case WebstoreInstallHelper::Delegate::MANIFEST_ERROR: | 345 case WebstoreInstallHelper::Delegate::MANIFEST_ERROR: |
342 SetResultCode(MANIFEST_ERROR); | 346 SetResultCode(MANIFEST_ERROR); |
343 break; | 347 break; |
344 default: | 348 default: |
345 CHECK(false); | 349 CHECK(false); |
346 } | 350 } |
347 error_ = error_message; | 351 error_ = error_message; |
348 SendResponse(false); | 352 SendResponse(false); |
349 | 353 |
350 // Matches the AddRef in RunImpl(). | 354 // Matches the AddRef in RunImpl(). |
351 Release(); | 355 Release(); |
352 } | 356 } |
353 | 357 |
354 void BeginInstallWithManifestFunction::InstallUIProceed() { | 358 void WebstorePrivateBeginInstallWithManifest3Function::InstallUIProceed() { |
355 // This gets cleared in CrxInstaller::ConfirmInstall(). TODO(asargent) - in | 359 // This gets cleared in CrxInstaller::ConfirmInstall(). TODO(asargent) - in |
356 // the future we may also want to add time-based expiration, where a whitelist | 360 // the future we may also want to add time-based expiration, where a whitelist |
357 // entry is only valid for some number of minutes. | 361 // entry is only valid for some number of minutes. |
358 scoped_ptr<WebstoreInstaller::Approval> approval( | 362 scoped_ptr<WebstoreInstaller::Approval> approval( |
359 WebstoreInstaller::Approval::CreateWithNoInstallPrompt( | 363 WebstoreInstaller::Approval::CreateWithNoInstallPrompt( |
360 profile(), id_, parsed_manifest_.Pass())); | 364 profile(), id_, parsed_manifest_.Pass())); |
361 approval->use_app_installed_bubble = use_app_installed_bubble_; | 365 approval->use_app_installed_bubble = use_app_installed_bubble_; |
362 approval->record_oauth2_grant = install_prompt_->record_oauth2_grant(); | 366 approval->record_oauth2_grant = install_prompt_->record_oauth2_grant(); |
363 g_pending_approvals.Get().PushApproval(approval.Pass()); | 367 g_pending_approvals.Get().PushApproval(approval.Pass()); |
364 | 368 |
365 SetResultCode(ERROR_NONE); | 369 SetResultCode(ERROR_NONE); |
366 SendResponse(true); | 370 SendResponse(true); |
367 | 371 |
368 // The Permissions_Install histogram is recorded from the ExtensionService | 372 // The Permissions_Install histogram is recorded from the ExtensionService |
369 // for all extension installs, so we only need to record the web store | 373 // for all extension installs, so we only need to record the web store |
370 // specific histogram here. | 374 // specific histogram here. |
371 ExtensionService::RecordPermissionMessagesHistogram( | 375 ExtensionService::RecordPermissionMessagesHistogram( |
372 dummy_extension_, "Extensions.Permissions_WebStoreInstall"); | 376 dummy_extension_, "Extensions.Permissions_WebStoreInstall"); |
373 | 377 |
374 // Matches the AddRef in RunImpl(). | 378 // Matches the AddRef in RunImpl(). |
375 Release(); | 379 Release(); |
376 } | 380 } |
377 | 381 |
378 void BeginInstallWithManifestFunction::InstallUIAbort(bool user_initiated) { | 382 void WebstorePrivateBeginInstallWithManifest3Function::InstallUIAbort( |
| 383 bool user_initiated) { |
379 error_ = kUserCancelledError; | 384 error_ = kUserCancelledError; |
380 SetResultCode(USER_CANCELLED); | 385 SetResultCode(USER_CANCELLED); |
381 SendResponse(false); | 386 SendResponse(false); |
382 | 387 |
383 // The web store install histograms are a subset of the install histograms. | 388 // The web store install histograms are a subset of the install histograms. |
384 // We need to record both histograms here since CrxInstaller::InstallUIAbort | 389 // We need to record both histograms here since CrxInstaller::InstallUIAbort |
385 // is never called for web store install cancellations. | 390 // is never called for web store install cancellations. |
386 std::string histogram_name = user_initiated ? | 391 std::string histogram_name = user_initiated ? |
387 "Extensions.Permissions_WebStoreInstallCancel" : | 392 "Extensions.Permissions_WebStoreInstallCancel" : |
388 "Extensions.Permissions_WebStoreInstallAbort"; | 393 "Extensions.Permissions_WebStoreInstallAbort"; |
389 ExtensionService::RecordPermissionMessagesHistogram( | 394 ExtensionService::RecordPermissionMessagesHistogram( |
390 dummy_extension_, histogram_name.c_str()); | 395 dummy_extension_, histogram_name.c_str()); |
391 | 396 |
392 histogram_name = user_initiated ? | 397 histogram_name = user_initiated ? |
393 "Extensions.Permissions_InstallCancel" : | 398 "Extensions.Permissions_InstallCancel" : |
394 "Extensions.Permissions_InstallAbort"; | 399 "Extensions.Permissions_InstallAbort"; |
395 ExtensionService::RecordPermissionMessagesHistogram( | 400 ExtensionService::RecordPermissionMessagesHistogram( |
396 dummy_extension_, histogram_name.c_str()); | 401 dummy_extension_, histogram_name.c_str()); |
397 | 402 |
398 // Matches the AddRef in RunImpl(). | 403 // Matches the AddRef in RunImpl(). |
399 Release(); | 404 Release(); |
400 } | 405 } |
401 | 406 |
402 bool CompleteInstallFunction::RunImpl() { | 407 bool WebstorePrivateCompleteInstallFunction::RunImpl() { |
403 std::string id; | 408 std::string id; |
404 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &id)); | 409 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &id)); |
405 if (!extensions::Extension::IdIsValid(id)) { | 410 if (!extensions::Extension::IdIsValid(id)) { |
406 error_ = kInvalidIdError; | 411 error_ = kInvalidIdError; |
407 return false; | 412 return false; |
408 } | 413 } |
409 | 414 |
410 scoped_ptr<WebstoreInstaller::Approval> approval( | 415 scoped_ptr<WebstoreInstaller::Approval> approval( |
411 g_pending_approvals.Get().PopApproval(profile(), id)); | 416 g_pending_approvals.Get().PopApproval(profile(), id)); |
412 if (!approval.get()) { | 417 if (!approval.get()) { |
413 error_ = ErrorUtils::FormatErrorMessage( | 418 error_ = ErrorUtils::FormatErrorMessage( |
414 kNoPreviousBeginInstallWithManifestError, id); | 419 kNoPreviousBeginInstallWithManifestError, id); |
415 return false; | 420 return false; |
416 } | 421 } |
417 | 422 |
418 AddRef(); | 423 AddRef(); |
419 | 424 |
420 // The extension will install through the normal extension install flow, but | 425 // The extension will install through the normal extension install flow, but |
421 // the whitelist entry will bypass the normal permissions install dialog. | 426 // the whitelist entry will bypass the normal permissions install dialog. |
422 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller( | 427 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller( |
423 profile(), this, | 428 profile(), this, |
424 &(dispatcher()->delegate()->GetAssociatedWebContents()->GetController()), | 429 &(dispatcher()->delegate()->GetAssociatedWebContents()->GetController()), |
425 id, approval.Pass(), WebstoreInstaller::FLAG_NONE); | 430 id, approval.Pass(), WebstoreInstaller::FLAG_NONE); |
426 installer->Start(); | 431 installer->Start(); |
427 | 432 |
428 return true; | 433 return true; |
429 } | 434 } |
430 | 435 |
431 void CompleteInstallFunction::OnExtensionInstallSuccess( | 436 void WebstorePrivateCompleteInstallFunction::OnExtensionInstallSuccess( |
432 const std::string& id) { | 437 const std::string& id) { |
433 if (test_webstore_installer_delegate) | 438 if (test_webstore_installer_delegate) |
434 test_webstore_installer_delegate->OnExtensionInstallSuccess(id); | 439 test_webstore_installer_delegate->OnExtensionInstallSuccess(id); |
435 | 440 |
436 SendResponse(true); | 441 SendResponse(true); |
437 | 442 |
438 // Matches the AddRef in RunImpl(). | 443 // Matches the AddRef in RunImpl(). |
439 Release(); | 444 Release(); |
440 } | 445 } |
441 | 446 |
442 void CompleteInstallFunction::OnExtensionInstallFailure( | 447 void WebstorePrivateCompleteInstallFunction::OnExtensionInstallFailure( |
443 const std::string& id, | 448 const std::string& id, |
444 const std::string& error, | 449 const std::string& error, |
445 WebstoreInstaller::FailureReason reason) { | 450 WebstoreInstaller::FailureReason reason) { |
446 if (test_webstore_installer_delegate) { | 451 if (test_webstore_installer_delegate) { |
447 test_webstore_installer_delegate->OnExtensionInstallFailure( | 452 test_webstore_installer_delegate->OnExtensionInstallFailure( |
448 id, error, reason); | 453 id, error, reason); |
449 } | 454 } |
450 | 455 |
451 error_ = error; | 456 error_ = error; |
452 SendResponse(false); | 457 SendResponse(false); |
453 | 458 |
454 // Matches the AddRef in RunImpl(). | 459 // Matches the AddRef in RunImpl(). |
455 Release(); | 460 Release(); |
456 } | 461 } |
457 | 462 |
458 | 463 |
459 bool GetBrowserLoginFunction::RunImpl() { | 464 bool WebstorePrivateGetBrowserLoginFunction::RunImpl() { |
460 SetResult(CreateLoginResult(profile_->GetOriginalProfile())); | 465 SetResult(CreateLoginResult(profile_->GetOriginalProfile())); |
461 return true; | 466 return true; |
462 } | 467 } |
463 | 468 |
464 bool GetStoreLoginFunction::RunImpl() { | 469 bool WebstorePrivateGetStoreLoginFunction::RunImpl() { |
465 ExtensionService* service = | 470 ExtensionService* service = |
466 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 471 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
467 ExtensionPrefs* prefs = service->extension_prefs(); | 472 ExtensionPrefs* prefs = service->extension_prefs(); |
468 std::string login; | 473 std::string login; |
469 if (prefs->GetWebStoreLogin(&login)) { | 474 if (prefs->GetWebStoreLogin(&login)) { |
470 SetResult(Value::CreateStringValue(login)); | 475 SetResult(Value::CreateStringValue(login)); |
471 } else { | 476 } else { |
472 SetResult(Value::CreateStringValue(std::string())); | 477 SetResult(Value::CreateStringValue(std::string())); |
473 } | 478 } |
474 return true; | 479 return true; |
475 } | 480 } |
476 | 481 |
477 bool SetStoreLoginFunction::RunImpl() { | 482 bool WebstorePrivateSetStoreLoginFunction::RunImpl() { |
478 std::string login; | 483 std::string login; |
479 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &login)); | 484 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &login)); |
480 ExtensionService* service = | 485 ExtensionService* service = |
481 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 486 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
482 ExtensionPrefs* prefs = service->extension_prefs(); | 487 ExtensionPrefs* prefs = service->extension_prefs(); |
483 prefs->SetWebStoreLogin(login); | 488 prefs->SetWebStoreLogin(login); |
484 return true; | 489 return true; |
485 } | 490 } |
486 | 491 |
487 GetWebGLStatusFunction::GetWebGLStatusFunction() { | 492 WebstorePrivateGetWebGLStatusFunction::WebstorePrivateGetWebGLStatusFunction() { |
488 feature_checker_ = new GPUFeatureChecker( | 493 feature_checker_ = new GPUFeatureChecker( |
489 content::GPU_FEATURE_TYPE_WEBGL, | 494 content::GPU_FEATURE_TYPE_WEBGL, |
490 base::Bind(&GetWebGLStatusFunction::OnFeatureCheck, | 495 base::Bind(&WebstorePrivateGetWebGLStatusFunction::OnFeatureCheck, |
491 base::Unretained(this))); | 496 base::Unretained(this))); |
492 } | 497 } |
493 | 498 |
494 GetWebGLStatusFunction::~GetWebGLStatusFunction() {} | 499 WebstorePrivateGetWebGLStatusFunction:: |
| 500 ~WebstorePrivateGetWebGLStatusFunction() {} |
495 | 501 |
496 void GetWebGLStatusFunction::CreateResult(bool webgl_allowed) { | 502 void WebstorePrivateGetWebGLStatusFunction::CreateResult(bool webgl_allowed) { |
497 SetResult(Value::CreateStringValue( | 503 SetResult(Value::CreateStringValue( |
498 webgl_allowed ? "webgl_allowed" : "webgl_blocked")); | 504 webgl_allowed ? "webgl_allowed" : "webgl_blocked")); |
499 } | 505 } |
500 | 506 |
501 bool GetWebGLStatusFunction::RunImpl() { | 507 bool WebstorePrivateGetWebGLStatusFunction::RunImpl() { |
502 feature_checker_->CheckGPUFeatureAvailability(); | 508 feature_checker_->CheckGPUFeatureAvailability(); |
503 return true; | 509 return true; |
504 } | 510 } |
505 | 511 |
506 void GetWebGLStatusFunction::OnFeatureCheck(bool feature_allowed) { | 512 void WebstorePrivateGetWebGLStatusFunction::OnFeatureCheck( |
| 513 bool feature_allowed) { |
507 CreateResult(feature_allowed); | 514 CreateResult(feature_allowed); |
508 SendResponse(true); | 515 SendResponse(true); |
509 } | 516 } |
510 | 517 |
511 } // namespace extensions | 518 } // namespace extensions |
OLD | NEW |