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/runtime/runtime_api.h" | 5 #include "chrome/browser/extensions/api/runtime/runtime_api.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 | 492 |
493 void RuntimeGetBackgroundPageFunction::OnPageLoaded(ExtensionHost* host) { | 493 void RuntimeGetBackgroundPageFunction::OnPageLoaded(ExtensionHost* host) { |
494 if (host) { | 494 if (host) { |
495 SendResponse(true); | 495 SendResponse(true); |
496 } else { | 496 } else { |
497 error_ = kPageLoadError; | 497 error_ = kPageLoadError; |
498 SendResponse(false); | 498 SendResponse(false); |
499 } | 499 } |
500 } | 500 } |
501 | 501 |
502 bool RuntimeSetUninstallURLFunction::RunImpl() { | 502 bool RuntimeSetUninstallURLFunction::RunSync() { |
503 std::string url_string; | 503 std::string url_string; |
504 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url_string)); | 504 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url_string)); |
505 | 505 |
506 GURL url(url_string); | 506 GURL url(url_string); |
507 if (!url.is_valid()) { | 507 if (!url.is_valid()) { |
508 error_ = ErrorUtils::FormatErrorMessage(kInvalidUrlError, url_string); | 508 error_ = ErrorUtils::FormatErrorMessage(kInvalidUrlError, url_string); |
509 return false; | 509 return false; |
510 } | 510 } |
511 | 511 |
512 SetUninstallURL( | 512 SetUninstallURL( |
513 ExtensionPrefs::Get(GetProfile()), extension_id(), url_string); | 513 ExtensionPrefs::Get(GetProfile()), extension_id(), url_string); |
514 return true; | 514 return true; |
515 } | 515 } |
516 | 516 |
517 bool RuntimeReloadFunction::RunImpl() { | 517 bool RuntimeReloadFunction::RunSync() { |
518 RuntimeAPI::GetFactoryInstance()->Get(GetProfile())->MaybeReloadExtension( | 518 RuntimeAPI::GetFactoryInstance()->Get(GetProfile())->MaybeReloadExtension( |
519 extension_id()); | 519 extension_id()); |
520 return true; | 520 return true; |
521 } | 521 } |
522 | 522 |
523 RuntimeRequestUpdateCheckFunction::RuntimeRequestUpdateCheckFunction() { | 523 RuntimeRequestUpdateCheckFunction::RuntimeRequestUpdateCheckFunction() { |
524 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UPDATE_FOUND, | 524 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UPDATE_FOUND, |
525 content::NotificationService::AllSources()); | 525 content::NotificationService::AllSources()); |
526 } | 526 } |
527 | 527 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 const std::string& version) { | 585 const std::string& version) { |
586 did_reply_ = true; | 586 did_reply_ = true; |
587 results_.reset(new base::ListValue); | 587 results_.reset(new base::ListValue); |
588 results_->AppendString(kUpdateFound); | 588 results_->AppendString(kUpdateFound); |
589 base::DictionaryValue* details = new base::DictionaryValue; | 589 base::DictionaryValue* details = new base::DictionaryValue; |
590 results_->Append(details); | 590 results_->Append(details); |
591 details->SetString("version", version); | 591 details->SetString("version", version); |
592 SendResponse(true); | 592 SendResponse(true); |
593 } | 593 } |
594 | 594 |
595 bool RuntimeRestartFunction::RunImpl() { | 595 bool RuntimeRestartFunction::RunSync() { |
596 #if defined(OS_CHROMEOS) | 596 #if defined(OS_CHROMEOS) |
597 if (chromeos::UserManager::Get()->IsLoggedInAsKioskApp()) { | 597 if (chromeos::UserManager::Get()->IsLoggedInAsKioskApp()) { |
598 chromeos::DBusThreadManager::Get() | 598 chromeos::DBusThreadManager::Get() |
599 ->GetPowerManagerClient() | 599 ->GetPowerManagerClient() |
600 ->RequestRestart(); | 600 ->RequestRestart(); |
601 return true; | 601 return true; |
602 } | 602 } |
603 #endif | 603 #endif |
604 SetError("Function available only for ChromeOS kiosk mode."); | 604 SetError("Function available only for ChromeOS kiosk mode."); |
605 return false; | 605 return false; |
606 } | 606 } |
607 | 607 |
608 bool RuntimeGetPlatformInfoFunction::RunImpl() { | 608 bool RuntimeGetPlatformInfoFunction::RunSync() { |
609 GetPlatformInfo::Results::PlatformInfo info; | 609 GetPlatformInfo::Results::PlatformInfo info; |
610 | 610 |
611 const char* os = chrome::OmahaQueryParams::GetOS(); | 611 const char* os = chrome::OmahaQueryParams::GetOS(); |
612 if (strcmp(os, "mac") == 0) { | 612 if (strcmp(os, "mac") == 0) { |
613 info.os = GetPlatformInfo::Results::PlatformInfo::OS_MAC_; | 613 info.os = GetPlatformInfo::Results::PlatformInfo::OS_MAC_; |
614 } else if (strcmp(os, "win") == 0) { | 614 } else if (strcmp(os, "win") == 0) { |
615 info.os = GetPlatformInfo::Results::PlatformInfo::OS_WIN_; | 615 info.os = GetPlatformInfo::Results::PlatformInfo::OS_WIN_; |
616 } else if (strcmp(os, "android") == 0) { | 616 } else if (strcmp(os, "android") == 0) { |
617 info.os = GetPlatformInfo::Results::PlatformInfo::OS_ANDROID_; | 617 info.os = GetPlatformInfo::Results::PlatformInfo::OS_ANDROID_; |
618 } else if (strcmp(os, "cros") == 0) { | 618 } else if (strcmp(os, "cros") == 0) { |
(...skipping 28 matching lines...) Expand all Loading... |
647 info.nacl_arch = GetPlatformInfo::Results::PlatformInfo::NACL_ARCH_X86_64; | 647 info.nacl_arch = GetPlatformInfo::Results::PlatformInfo::NACL_ARCH_X86_64; |
648 } else { | 648 } else { |
649 NOTREACHED(); | 649 NOTREACHED(); |
650 return false; | 650 return false; |
651 } | 651 } |
652 | 652 |
653 results_ = GetPlatformInfo::Results::Create(info); | 653 results_ = GetPlatformInfo::Results::Create(info); |
654 return true; | 654 return true; |
655 } | 655 } |
656 | 656 |
657 bool RuntimeGetPackageDirectoryEntryFunction::RunImpl() { | 657 bool RuntimeGetPackageDirectoryEntryFunction::RunSync() { |
658 fileapi::IsolatedContext* isolated_context = | 658 fileapi::IsolatedContext* isolated_context = |
659 fileapi::IsolatedContext::GetInstance(); | 659 fileapi::IsolatedContext::GetInstance(); |
660 DCHECK(isolated_context); | 660 DCHECK(isolated_context); |
661 | 661 |
662 std::string relative_path = kPackageDirectoryPath; | 662 std::string relative_path = kPackageDirectoryPath; |
663 base::FilePath path = extension_->path(); | 663 base::FilePath path = extension_->path(); |
664 std::string filesystem_id = isolated_context->RegisterFileSystemForPath( | 664 std::string filesystem_id = isolated_context->RegisterFileSystemForPath( |
665 fileapi::kFileSystemTypeNativeLocal, path, &relative_path); | 665 fileapi::kFileSystemTypeNativeLocal, path, &relative_path); |
666 | 666 |
667 int renderer_id = render_view_host_->GetProcess()->GetID(); | 667 int renderer_id = render_view_host_->GetProcess()->GetID(); |
668 content::ChildProcessSecurityPolicy* policy = | 668 content::ChildProcessSecurityPolicy* policy = |
669 content::ChildProcessSecurityPolicy::GetInstance(); | 669 content::ChildProcessSecurityPolicy::GetInstance(); |
670 policy->GrantReadFileSystem(renderer_id, filesystem_id); | 670 policy->GrantReadFileSystem(renderer_id, filesystem_id); |
671 base::DictionaryValue* dict = new base::DictionaryValue(); | 671 base::DictionaryValue* dict = new base::DictionaryValue(); |
672 SetResult(dict); | 672 SetResult(dict); |
673 dict->SetString("fileSystemId", filesystem_id); | 673 dict->SetString("fileSystemId", filesystem_id); |
674 dict->SetString("baseName", relative_path); | 674 dict->SetString("baseName", relative_path); |
675 return true; | 675 return true; |
676 } | 676 } |
677 | 677 |
678 } // namespace extensions | 678 } // namespace extensions |
OLD | NEW |