| 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/component_loader.h" | 5 #include "chrome/browser/extensions/component_loader.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 Add(IDR_ENHANCED_BOOKMARKS_MANIFEST, | 326 Add(IDR_ENHANCED_BOOKMARKS_MANIFEST, |
| 327 base::FilePath(FILE_PATH_LITERAL("enhanced_bookmark_manager"))); | 327 base::FilePath(FILE_PATH_LITERAL("enhanced_bookmark_manager"))); |
| 328 #endif | 328 #endif |
| 329 } | 329 } |
| 330 | 330 |
| 331 void ComponentLoader::AddNetworkSpeechSynthesisExtension() { | 331 void ComponentLoader::AddNetworkSpeechSynthesisExtension() { |
| 332 Add(IDR_NETWORK_SPEECH_SYNTHESIS_MANIFEST, | 332 Add(IDR_NETWORK_SPEECH_SYNTHESIS_MANIFEST, |
| 333 base::FilePath(FILE_PATH_LITERAL("network_speech_synthesis"))); | 333 base::FilePath(FILE_PATH_LITERAL("network_speech_synthesis"))); |
| 334 } | 334 } |
| 335 | 335 |
| 336 #if defined(OS_CHROMEOS) |
| 337 std::string ComponentLoader::AddChromeVoxExtension() { |
| 338 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 339 int idr = command_line->HasSwitch(chromeos::switches::kGuestSession) ? |
| 340 IDR_CHROMEVOX_GUEST_MANIFEST : IDR_CHROMEVOX_MANIFEST; |
| 341 return Add(idr, base::FilePath(extension_misc::kChromeVoxExtensionPath)); |
| 342 } |
| 343 |
| 344 std::string ComponentLoader::AddChromeOsSpeechSynthesisExtension() { |
| 345 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 346 int idr = command_line->HasSwitch(chromeos::switches::kGuestSession) ? |
| 347 IDR_SPEECH_SYNTHESIS_GUEST_MANIFEST : IDR_SPEECH_SYNTHESIS_MANIFEST; |
| 348 std::string id = Add(idr, |
| 349 base::FilePath(extension_misc::kSpeechSynthesisExtensionPath)); |
| 350 EnableFileSystemInGuestMode(id); |
| 351 return id; |
| 352 } |
| 353 #endif |
| 354 |
| 336 void ComponentLoader::AddWithName(int manifest_resource_id, | 355 void ComponentLoader::AddWithName(int manifest_resource_id, |
| 337 const base::FilePath& root_directory, | 356 const base::FilePath& root_directory, |
| 338 const std::string& name) { | 357 const std::string& name) { |
| 339 std::string manifest_contents = | 358 std::string manifest_contents = |
| 340 ResourceBundle::GetSharedInstance().GetRawDataResource( | 359 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 341 manifest_resource_id).as_string(); | 360 manifest_resource_id).as_string(); |
| 342 | 361 |
| 343 // The Value is kept for the lifetime of the ComponentLoader. This is | 362 // The Value is kept for the lifetime of the ComponentLoader. This is |
| 344 // required in case LoadAll() is called again. | 363 // required in case LoadAll() is called again. |
| 345 base::DictionaryValue* manifest = ParseManifest(manifest_contents); | 364 base::DictionaryValue* manifest = ParseManifest(manifest_contents); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 if (install_feedback) | 491 if (install_feedback) |
| 473 Add(IDR_FEEDBACK_MANIFEST, base::FilePath(FILE_PATH_LITERAL("feedback"))); | 492 Add(IDR_FEEDBACK_MANIFEST, base::FilePath(FILE_PATH_LITERAL("feedback"))); |
| 474 | 493 |
| 475 #if defined(OS_CHROMEOS) | 494 #if defined(OS_CHROMEOS) |
| 476 if (!skip_session_components) { | 495 if (!skip_session_components) { |
| 477 #if defined(GOOGLE_CHROME_BUILD) | 496 #if defined(GOOGLE_CHROME_BUILD) |
| 478 if (!command_line->HasSwitch( | 497 if (!command_line->HasSwitch( |
| 479 chromeos::switches::kDisableQuickofficeComponentApp)) { | 498 chromeos::switches::kDisableQuickofficeComponentApp)) { |
| 480 std::string id = Add(IDR_QUICKOFFICE_MANIFEST, base::FilePath( | 499 std::string id = Add(IDR_QUICKOFFICE_MANIFEST, base::FilePath( |
| 481 FILE_PATH_LITERAL("/usr/share/chromeos-assets/quick_office"))); | 500 FILE_PATH_LITERAL("/usr/share/chromeos-assets/quick_office"))); |
| 482 if (command_line->HasSwitch(chromeos::switches::kGuestSession)) { | 501 EnableFileSystemInGuestMode(id); |
| 483 // TODO(dpolukhin): Hack to enable HTML5 temporary file system for | |
| 484 // Quickoffice. It doesn't work without temporary file system access. | |
| 485 // Make sure temporary file system is enabled in the off the record | |
| 486 // browser context (as that is the one used in guest session). | |
| 487 content::BrowserContext* off_the_record_context = | |
| 488 ExtensionsBrowserClient::Get()->GetOffTheRecordContext( | |
| 489 browser_context_); | |
| 490 GURL site = content::SiteInstance::GetSiteForURL( | |
| 491 off_the_record_context, Extension::GetBaseURLFromExtensionId(id)); | |
| 492 fileapi::FileSystemContext* file_system_context = | |
| 493 content::BrowserContext::GetStoragePartitionForSite( | |
| 494 off_the_record_context, site)->GetFileSystemContext(); | |
| 495 file_system_context->EnableTemporaryFileSystemInIncognito(); | |
| 496 } | |
| 497 } | 502 } |
| 498 #endif // defined(GOOGLE_CHROME_BUILD) | 503 #endif // defined(GOOGLE_CHROME_BUILD) |
| 499 | 504 |
| 500 base::FilePath echo_extension_path(FILE_PATH_LITERAL( | 505 base::FilePath echo_extension_path(FILE_PATH_LITERAL( |
| 501 "/usr/share/chromeos-assets/echo")); | 506 "/usr/share/chromeos-assets/echo")); |
| 502 if (command_line->HasSwitch(chromeos::switches::kEchoExtensionPath)) { | 507 if (command_line->HasSwitch(chromeos::switches::kEchoExtensionPath)) { |
| 503 echo_extension_path = command_line->GetSwitchValuePath( | 508 echo_extension_path = command_line->GetSwitchValuePath( |
| 504 chromeos::switches::kEchoExtensionPath); | 509 chromeos::switches::kEchoExtensionPath); |
| 505 } | 510 } |
| 506 Add(IDR_ECHO_MANIFEST, echo_extension_path); | 511 Add(IDR_ECHO_MANIFEST, echo_extension_path); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 520 | 525 |
| 521 Add(IDR_CONNECTIVITY_DIAGNOSTICS_MANIFEST, | 526 Add(IDR_CONNECTIVITY_DIAGNOSTICS_MANIFEST, |
| 522 base::FilePath(extension_misc::kConnectivityDiagnosticsPath)); | 527 base::FilePath(extension_misc::kConnectivityDiagnosticsPath)); |
| 523 Add(IDR_CONNECTIVITY_DIAGNOSTICS_LAUNCHER_MANIFEST, | 528 Add(IDR_CONNECTIVITY_DIAGNOSTICS_LAUNCHER_MANIFEST, |
| 524 base::FilePath(extension_misc::kConnectivityDiagnosticsLauncherPath)); | 529 base::FilePath(extension_misc::kConnectivityDiagnosticsLauncherPath)); |
| 525 } | 530 } |
| 526 | 531 |
| 527 // Load ChromeVox extension now if spoken feedback is enabled. | 532 // Load ChromeVox extension now if spoken feedback is enabled. |
| 528 if (chromeos::AccessibilityManager::Get() && | 533 if (chromeos::AccessibilityManager::Get() && |
| 529 chromeos::AccessibilityManager::Get()->IsSpokenFeedbackEnabled()) { | 534 chromeos::AccessibilityManager::Get()->IsSpokenFeedbackEnabled()) { |
| 530 base::FilePath path = | 535 AddChromeVoxExtension(); |
| 531 base::FilePath(extension_misc::kChromeVoxExtensionPath); | |
| 532 Add(IDR_CHROMEVOX_MANIFEST, path); | |
| 533 } | 536 } |
| 534 #endif // defined(OS_CHROMEOS) | 537 #endif // defined(OS_CHROMEOS) |
| 535 | 538 |
| 536 #if defined(ENABLE_GOOGLE_NOW) | 539 #if defined(ENABLE_GOOGLE_NOW) |
| 537 const char kEnablePrefix[] = "Enable"; | 540 const char kEnablePrefix[] = "Enable"; |
| 538 const char kFieldTrialName[] = "GoogleNow"; | 541 const char kFieldTrialName[] = "GoogleNow"; |
| 539 std::string enable_prefix(kEnablePrefix); | 542 std::string enable_prefix(kEnablePrefix); |
| 540 std::string field_trial_result = | 543 std::string field_trial_result = |
| 541 base::FieldTrialList::FindFullName(kFieldTrialName); | 544 base::FieldTrialList::FindFullName(kFieldTrialName); |
| 542 | 545 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 } | 590 } |
| 588 | 591 |
| 589 void ComponentLoader::UnloadComponent(ComponentExtensionInfo* component) { | 592 void ComponentLoader::UnloadComponent(ComponentExtensionInfo* component) { |
| 590 delete component->manifest; | 593 delete component->manifest; |
| 591 if (extension_service_->is_ready()) { | 594 if (extension_service_->is_ready()) { |
| 592 extension_service_-> | 595 extension_service_-> |
| 593 RemoveComponentExtension(component->extension_id); | 596 RemoveComponentExtension(component->extension_id); |
| 594 } | 597 } |
| 595 } | 598 } |
| 596 | 599 |
| 600 void ComponentLoader::EnableFileSystemInGuestMode(const std::string& id) { |
| 601 #if defined(OS_CHROMEOS) |
| 602 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 603 if (command_line->HasSwitch(chromeos::switches::kGuestSession)) { |
| 604 // TODO(dpolukhin): Hack to enable HTML5 temporary file system for |
| 605 // the extension. Some component extensions don't work without temporary |
| 606 // file system access. Make sure temporary file system is enabled in the off |
| 607 // the record browser context (as that is the one used in guest session). |
| 608 content::BrowserContext* off_the_record_context = |
| 609 ExtensionsBrowserClient::Get()->GetOffTheRecordContext( |
| 610 browser_context_); |
| 611 GURL site = content::SiteInstance::GetSiteForURL( |
| 612 off_the_record_context, Extension::GetBaseURLFromExtensionId(id)); |
| 613 fileapi::FileSystemContext* file_system_context = |
| 614 content::BrowserContext::GetStoragePartitionForSite( |
| 615 off_the_record_context, site)->GetFileSystemContext(); |
| 616 file_system_context->EnableTemporaryFileSystemInIncognito(); |
| 617 } |
| 618 #endif |
| 619 } |
| 620 |
| 597 } // namespace extensions | 621 } // namespace extensions |
| OLD | NEW |