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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
176 std::string ComponentLoader::Add(const std::string& manifest_contents, | 176 std::string ComponentLoader::Add(const std::string& manifest_contents, |
177 const base::FilePath& root_directory) { | 177 const base::FilePath& root_directory) { |
178 // The Value is kept for the lifetime of the ComponentLoader. This is | 178 // The Value is kept for the lifetime of the ComponentLoader. This is |
179 // required in case LoadAll() is called again. | 179 // required in case LoadAll() is called again. |
180 base::DictionaryValue* manifest = ParseManifest(manifest_contents); | 180 base::DictionaryValue* manifest = ParseManifest(manifest_contents); |
181 if (manifest) | 181 if (manifest) |
182 return Add(manifest, root_directory); | 182 return Add(manifest, root_directory); |
183 return std::string(); | 183 return std::string(); |
184 } | 184 } |
185 | 185 |
186 std::string ComponentLoader::Add(const base::DictionaryValue* parsed_manifest, | 186 std::string ComponentLoader::Add(base::DictionaryValue* parsed_manifest, |
187 const base::FilePath& root_directory) { | 187 const base::FilePath& root_directory) { |
188 ComponentExtensionInfo info(parsed_manifest, root_directory); | 188 ComponentExtensionInfo info(parsed_manifest, root_directory); |
189 #if defined(OS_CHROMEOS) | |
190 // Force incognito split in Guest mode for some component extensions. | |
191 // In Guest mode non-incognito background pages are not allowed so | |
192 // split mode is required. | |
193 if (info.extension_id == extension_misc::kChromeVoxExtensionId || | |
194 info.extension_id == extension_misc::kSpeechSynthesisExtensionId) { | |
195 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
196 if (command_line->HasSwitch(chromeos::switches::kGuestSession)) { | |
197 parsed_manifest->SetString(manifest_keys::kIncognito, | |
198 manifest_values::kIncognitoSplit); | |
199 } | |
200 } | |
201 #endif | |
asargent_no_longer_on_chrome
2014/02/06 00:58:02
It seems a little hacky to inject a value into the
Dmitry Polukhin
2014/02/06 01:30:21
I'm not aware of the fix for the file manager. Do
| |
189 component_extensions_.push_back(info); | 202 component_extensions_.push_back(info); |
190 if (extension_service_->is_ready()) | 203 if (extension_service_->is_ready()) |
191 Load(info); | 204 Load(info); |
192 return info.extension_id; | 205 return info.extension_id; |
193 } | 206 } |
194 | 207 |
195 std::string ComponentLoader::AddOrReplace(const base::FilePath& path) { | 208 std::string ComponentLoader::AddOrReplace(const base::FilePath& path) { |
196 base::FilePath absolute_path = base::MakeAbsoluteFilePath(path); | 209 base::FilePath absolute_path = base::MakeAbsoluteFilePath(path); |
197 std::string error; | 210 std::string error; |
198 scoped_ptr<base::DictionaryValue> manifest( | 211 scoped_ptr<base::DictionaryValue> manifest( |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
319 #endif | 332 #endif |
320 } | 333 } |
321 | 334 |
322 void ComponentLoader::AddNetworkSpeechSynthesisExtension() { | 335 void ComponentLoader::AddNetworkSpeechSynthesisExtension() { |
323 Add(IDR_NETWORK_SPEECH_SYNTHESIS_MANIFEST, | 336 Add(IDR_NETWORK_SPEECH_SYNTHESIS_MANIFEST, |
324 base::FilePath(FILE_PATH_LITERAL("network_speech_synthesis"))); | 337 base::FilePath(FILE_PATH_LITERAL("network_speech_synthesis"))); |
325 } | 338 } |
326 | 339 |
327 #if defined(OS_CHROMEOS) | 340 #if defined(OS_CHROMEOS) |
328 void ComponentLoader::AddChromeOsSpeechSynthesisExtension() { | 341 void ComponentLoader::AddChromeOsSpeechSynthesisExtension() { |
329 Add(IDR_SPEECH_SYNTHESIS_MANIFEST, | 342 std::string id = Add(IDR_SPEECH_SYNTHESIS_MANIFEST, |
330 base::FilePath(extension_misc::kSpeechSynthesisExtensionPath)); | 343 base::FilePath(extension_misc::kSpeechSynthesisExtensionPath)); |
344 EnbaleFileSystemInGuestMode(id); | |
331 } | 345 } |
332 #endif | 346 #endif |
333 | 347 |
334 void ComponentLoader::AddWithName(int manifest_resource_id, | 348 void ComponentLoader::AddWithName(int manifest_resource_id, |
335 const base::FilePath& root_directory, | 349 const base::FilePath& root_directory, |
336 const std::string& name) { | 350 const std::string& name) { |
337 std::string manifest_contents = | 351 std::string manifest_contents = |
338 ResourceBundle::GetSharedInstance().GetRawDataResource( | 352 ResourceBundle::GetSharedInstance().GetRawDataResource( |
339 manifest_resource_id).as_string(); | 353 manifest_resource_id).as_string(); |
340 | 354 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
473 if (install_feedback) | 487 if (install_feedback) |
474 Add(IDR_FEEDBACK_MANIFEST, base::FilePath(FILE_PATH_LITERAL("feedback"))); | 488 Add(IDR_FEEDBACK_MANIFEST, base::FilePath(FILE_PATH_LITERAL("feedback"))); |
475 | 489 |
476 #if defined(OS_CHROMEOS) | 490 #if defined(OS_CHROMEOS) |
477 if (!skip_session_components) { | 491 if (!skip_session_components) { |
478 #if defined(GOOGLE_CHROME_BUILD) | 492 #if defined(GOOGLE_CHROME_BUILD) |
479 if (!command_line->HasSwitch( | 493 if (!command_line->HasSwitch( |
480 chromeos::switches::kDisableQuickofficeComponentApp)) { | 494 chromeos::switches::kDisableQuickofficeComponentApp)) { |
481 std::string id = Add(IDR_QUICKOFFICE_MANIFEST, base::FilePath( | 495 std::string id = Add(IDR_QUICKOFFICE_MANIFEST, base::FilePath( |
482 FILE_PATH_LITERAL("/usr/share/chromeos-assets/quick_office"))); | 496 FILE_PATH_LITERAL("/usr/share/chromeos-assets/quick_office"))); |
483 if (command_line->HasSwitch(chromeos::switches::kGuestSession)) { | 497 EnbaleFileSystemInGuestMode(id); |
484 // TODO(dpolukhin): Hack to enable HTML5 temporary file system for | |
485 // Quickoffice. It doesn't work without temporary file system access. | |
486 // Make sure temporary file system is enabled in the off the record | |
487 // browser context (as that is the one used in guest session). | |
488 content::BrowserContext* off_the_record_context = | |
489 ExtensionsBrowserClient::Get()->GetOffTheRecordContext( | |
490 browser_context_); | |
491 GURL site = content::SiteInstance::GetSiteForURL( | |
492 off_the_record_context, Extension::GetBaseURLFromExtensionId(id)); | |
493 fileapi::FileSystemContext* file_system_context = | |
494 content::BrowserContext::GetStoragePartitionForSite( | |
495 off_the_record_context, site)->GetFileSystemContext(); | |
496 file_system_context->EnableTemporaryFileSystemInIncognito(); | |
497 } | |
498 } | 498 } |
499 #endif // defined(GOOGLE_CHROME_BUILD) | 499 #endif // defined(GOOGLE_CHROME_BUILD) |
500 | 500 |
501 base::FilePath echo_extension_path(FILE_PATH_LITERAL( | 501 base::FilePath echo_extension_path(FILE_PATH_LITERAL( |
502 "/usr/share/chromeos-assets/echo")); | 502 "/usr/share/chromeos-assets/echo")); |
503 if (command_line->HasSwitch(chromeos::switches::kEchoExtensionPath)) { | 503 if (command_line->HasSwitch(chromeos::switches::kEchoExtensionPath)) { |
504 echo_extension_path = command_line->GetSwitchValuePath( | 504 echo_extension_path = command_line->GetSwitchValuePath( |
505 chromeos::switches::kEchoExtensionPath); | 505 chromeos::switches::kEchoExtensionPath); |
506 } | 506 } |
507 Add(IDR_ECHO_MANIFEST, echo_extension_path); | 507 Add(IDR_ECHO_MANIFEST, echo_extension_path); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
592 } | 592 } |
593 | 593 |
594 void ComponentLoader::UnloadComponent(ComponentExtensionInfo* component) { | 594 void ComponentLoader::UnloadComponent(ComponentExtensionInfo* component) { |
595 delete component->manifest; | 595 delete component->manifest; |
596 if (extension_service_->is_ready()) { | 596 if (extension_service_->is_ready()) { |
597 extension_service_-> | 597 extension_service_-> |
598 RemoveComponentExtension(component->extension_id); | 598 RemoveComponentExtension(component->extension_id); |
599 } | 599 } |
600 } | 600 } |
601 | 601 |
602 void ComponentLoader::EnbaleFileSystemInGuestMode(const std::string& id) { | |
603 #if defined(OS_CHROMEOS) | |
604 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
605 if (command_line->HasSwitch(chromeos::switches::kGuestSession)) { | |
606 // TODO(dpolukhin): Hack to enable HTML5 temporary file system for | |
607 // the extension. Some component extensions don't work without temporary | |
608 // file system access. Make sure temporary file system is enabled in the off | |
609 // the record browser context (as that is the one used in guest session). | |
610 content::BrowserContext* off_the_record_context = | |
611 ExtensionsBrowserClient::Get()->GetOffTheRecordContext( | |
612 browser_context_); | |
613 GURL site = content::SiteInstance::GetSiteForURL( | |
614 off_the_record_context, Extension::GetBaseURLFromExtensionId(id)); | |
615 fileapi::FileSystemContext* file_system_context = | |
616 content::BrowserContext::GetStoragePartitionForSite( | |
617 off_the_record_context, site)->GetFileSystemContext(); | |
618 file_system_context->EnableTemporaryFileSystemInIncognito(); | |
619 } | |
620 #endif | |
621 } | |
622 | |
602 } // namespace extensions | 623 } // namespace extensions |
OLD | NEW |