Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(580)

Side by Side Diff: chrome/browser/extensions/component_loader.cc

Issue 2291133005: Re-land: Move ChromeVox loading out of ComponentLoader. (Closed)
Patch Set: Update component_loader comment Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/extensions/component_loader.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 26 matching lines...) Expand all
37 #include "extensions/common/constants.h" 37 #include "extensions/common/constants.h"
38 #include "extensions/common/extension.h" 38 #include "extensions/common/extension.h"
39 #include "extensions/common/extension_l10n_util.h" 39 #include "extensions/common/extension_l10n_util.h"
40 #include "extensions/common/file_util.h" 40 #include "extensions/common/file_util.h"
41 #include "extensions/common/manifest_constants.h" 41 #include "extensions/common/manifest_constants.h"
42 #include "ui/base/l10n/l10n_util.h" 42 #include "ui/base/l10n/l10n_util.h"
43 #include "ui/base/resource/resource_bundle.h" 43 #include "ui/base/resource/resource_bundle.h"
44 44
45 #if defined(OS_CHROMEOS) 45 #if defined(OS_CHROMEOS)
46 #include "ash/common/system/chromeos/devicetype_utils.h" 46 #include "ash/common/system/chromeos/devicetype_utils.h"
47 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
48 #include "chromeos/chromeos_switches.h" 47 #include "chromeos/chromeos_switches.h"
49 #include "components/chrome_apps/grit/chrome_apps_resources.h" 48 #include "components/chrome_apps/grit/chrome_apps_resources.h"
50 #include "components/user_manager/user_manager.h" 49 #include "components/user_manager/user_manager.h"
51 #include "content/public/browser/site_instance.h" 50 #include "content/public/browser/site_instance.h"
52 #include "content/public/browser/storage_partition.h" 51 #include "content/public/browser/storage_partition.h"
53 #include "extensions/browser/extensions_browser_client.h" 52 #include "extensions/browser/extensions_browser_client.h"
54 #include "storage/browser/fileapi/file_system_context.h" 53 #include "storage/browser/fileapi/file_system_context.h"
55 #include "ui/file_manager/grit/file_manager_resources.h" 54 #include "ui/file_manager/grit/file_manager_resources.h"
56 #include "ui/keyboard/grit/keyboard_resources.h" 55 #include "ui/keyboard/grit/keyboard_resources.h"
57 #include "ui/keyboard/keyboard_util.h" 56 #include "ui/keyboard/keyboard_util.h"
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 base::FilePath(FILE_PATH_LITERAL("image_loader"))); 366 base::FilePath(FILE_PATH_LITERAL("image_loader")));
368 #endif // defined(IMAGE_LOADER_EXTENSION) 367 #endif // defined(IMAGE_LOADER_EXTENSION)
369 } 368 }
370 369
371 void ComponentLoader::AddNetworkSpeechSynthesisExtension() { 370 void ComponentLoader::AddNetworkSpeechSynthesisExtension() {
372 Add(IDR_NETWORK_SPEECH_SYNTHESIS_MANIFEST, 371 Add(IDR_NETWORK_SPEECH_SYNTHESIS_MANIFEST,
373 base::FilePath(FILE_PATH_LITERAL("network_speech_synthesis"))); 372 base::FilePath(FILE_PATH_LITERAL("network_speech_synthesis")));
374 } 373 }
375 374
376 #if defined(OS_CHROMEOS) 375 #if defined(OS_CHROMEOS)
377 void ComponentLoader::AddChromeVoxExtension(
378 const base::Closure& done_cb) {
379 base::FilePath resources_path;
380 CHECK(PathService::Get(chrome::DIR_RESOURCES, &resources_path));
381
382 base::FilePath chromevox_path =
383 resources_path.Append(extension_misc::kChromeVoxExtensionPath);
384
385 const base::FilePath::CharType* manifest_filename =
386 IsNormalSession() ? extensions::kManifestFilename
387 : extension_misc::kGuestManifestFilename;
388 AddWithManifestFile(
389 manifest_filename,
390 chromevox_path,
391 extension_misc::kChromeVoxExtensionId,
392 done_cb);
393 }
394
395 void ComponentLoader::AddChromeOsSpeechSynthesisExtension() { 376 void ComponentLoader::AddChromeOsSpeechSynthesisExtension() {
396 const base::FilePath::CharType* manifest_filename = 377 AddComponentFromDir(
397 IsNormalSession() ? extensions::kManifestFilename
398 : extension_misc::kGuestManifestFilename;
399 AddWithManifestFile(
400 manifest_filename,
401 base::FilePath(extension_misc::kSpeechSynthesisExtensionPath), 378 base::FilePath(extension_misc::kSpeechSynthesisExtensionPath),
402 extension_misc::kSpeechSynthesisExtensionId, 379 extension_misc::kSpeechSynthesisExtensionId,
403 base::Bind(&ComponentLoader::EnableFileSystemInGuestMode, 380 base::Bind(&ComponentLoader::EnableFileSystemInGuestMode,
404 weak_factory_.GetWeakPtr(), 381 weak_factory_.GetWeakPtr(),
405 extension_misc::kChromeVoxExtensionId)); 382 extension_misc::kChromeVoxExtensionId));
406 } 383 }
407 #endif 384 #endif
408 385
409 void ComponentLoader::AddWithNameAndDescription( 386 void ComponentLoader::AddWithNameAndDescription(
410 int manifest_resource_id, 387 int manifest_resource_id,
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 base::FilePath(FILE_PATH_LITERAL("chromeos/first_run/app"))); 592 base::FilePath(FILE_PATH_LITERAL("chromeos/first_run/app")));
616 593
617 Add(IDR_CONNECTIVITY_DIAGNOSTICS_MANIFEST, 594 Add(IDR_CONNECTIVITY_DIAGNOSTICS_MANIFEST,
618 base::FilePath(extension_misc::kConnectivityDiagnosticsPath)); 595 base::FilePath(extension_misc::kConnectivityDiagnosticsPath));
619 Add(IDR_CONNECTIVITY_DIAGNOSTICS_LAUNCHER_MANIFEST, 596 Add(IDR_CONNECTIVITY_DIAGNOSTICS_LAUNCHER_MANIFEST,
620 base::FilePath(extension_misc::kConnectivityDiagnosticsLauncherPath)); 597 base::FilePath(extension_misc::kConnectivityDiagnosticsLauncherPath));
621 598
622 Add(IDR_ARC_SUPPORT_MANIFEST, 599 Add(IDR_ARC_SUPPORT_MANIFEST,
623 base::FilePath(FILE_PATH_LITERAL("chromeos/arc_support"))); 600 base::FilePath(FILE_PATH_LITERAL("chromeos/arc_support")));
624 } 601 }
625
626 // Load ChromeVox extension now if spoken feedback is enabled.
627 if (chromeos::AccessibilityManager::Get() &&
628 chromeos::AccessibilityManager::Get()->IsSpokenFeedbackEnabled()) {
629 AddChromeVoxExtension(base::Closure());
630 }
631 #endif // defined(OS_CHROMEOS) 602 #endif // defined(OS_CHROMEOS)
632 603
633 #if defined(GOOGLE_CHROME_BUILD) 604 #if defined(GOOGLE_CHROME_BUILD)
634 #if !defined(OS_CHROMEOS) // http://crbug.com/314799 605 #if !defined(OS_CHROMEOS) // http://crbug.com/314799
635 AddNetworkSpeechSynthesisExtension(); 606 AddNetworkSpeechSynthesisExtension();
636 #endif 607 #endif
637 608
638 #endif // defined(GOOGLE_CHROME_BUILD) 609 #endif // defined(GOOGLE_CHROME_BUILD)
639 610
640 Add(IDR_CRYPTOTOKEN_MANIFEST, 611 Add(IDR_CRYPTOTOKEN_MANIFEST,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 off_the_record_context, Extension::GetBaseURLFromExtensionId(id)); 650 off_the_record_context, Extension::GetBaseURLFromExtensionId(id));
680 storage::FileSystemContext* file_system_context = 651 storage::FileSystemContext* file_system_context =
681 content::BrowserContext::GetStoragePartitionForSite( 652 content::BrowserContext::GetStoragePartitionForSite(
682 off_the_record_context, site)->GetFileSystemContext(); 653 off_the_record_context, site)->GetFileSystemContext();
683 file_system_context->EnableTemporaryFileSystemInIncognito(); 654 file_system_context->EnableTemporaryFileSystemInIncognito();
684 } 655 }
685 #endif 656 #endif
686 } 657 }
687 658
688 #if defined(OS_CHROMEOS) 659 #if defined(OS_CHROMEOS)
689 void ComponentLoader::AddWithManifestFile( 660 void ComponentLoader::AddComponentFromDir(
690 const base::FilePath::CharType* manifest_filename,
691 const base::FilePath& root_directory, 661 const base::FilePath& root_directory,
692 const char* extension_id, 662 const char* extension_id,
693 const base::Closure& done_cb) { 663 const base::Closure& done_cb) {
694 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 664 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
665 const base::FilePath::CharType* manifest_filename =
666 IsNormalSession() ? extensions::kManifestFilename
667 : extension_misc::kGuestManifestFilename;
695 BrowserThread::PostTaskAndReplyWithResult( 668 BrowserThread::PostTaskAndReplyWithResult(
696 BrowserThread::FILE, 669 BrowserThread::FILE,
697 FROM_HERE, 670 FROM_HERE,
698 base::Bind(&LoadManifestOnFileThread, root_directory, manifest_filename), 671 base::Bind(&LoadManifestOnFileThread, root_directory, manifest_filename),
699 base::Bind(&ComponentLoader::FinishAddWithManifestFile, 672 base::Bind(&ComponentLoader::FinishAddComponentFromDir,
700 weak_factory_.GetWeakPtr(), 673 weak_factory_.GetWeakPtr(),
701 root_directory, 674 root_directory,
702 extension_id, 675 extension_id,
703 done_cb)); 676 done_cb));
704 } 677 }
705 678
706 void ComponentLoader::FinishAddWithManifestFile( 679 void ComponentLoader::FinishAddComponentFromDir(
707 const base::FilePath& root_directory, 680 const base::FilePath& root_directory,
708 const char* extension_id, 681 const char* extension_id,
709 const base::Closure& done_cb, 682 const base::Closure& done_cb,
710 std::unique_ptr<base::DictionaryValue> manifest) { 683 std::unique_ptr<base::DictionaryValue> manifest) {
711 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 684 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
712 if (!manifest) 685 if (!manifest)
713 return; // Error already logged. 686 return; // Error already logged.
714 std::string actual_extension_id = Add( 687 std::string actual_extension_id = Add(
715 manifest.release(), 688 manifest.release(),
716 root_directory, 689 root_directory,
717 false); 690 false);
718 CHECK_EQ(extension_id, actual_extension_id); 691 CHECK_EQ(extension_id, actual_extension_id);
719 if (!done_cb.is_null()) 692 if (!done_cb.is_null())
720 done_cb.Run(); 693 done_cb.Run();
721 } 694 }
722 #endif 695 #endif
723 696
724 } // namespace extensions 697 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/component_loader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698