#include "chrome/browser/extensions/component_loader.h"
-#include <map>
#include <string>
#include "base/command_line.h"
-#include "base/file_util.h"
+#include "base/files/file_util.h"
#include "base/json/json_string_value_serializer.h"
#include "base/metrics/field_trial.h"
#include "base/path_service.h"
-#include "base/prefs/pref_change_registrar.h"
-#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/search/hotword_service_factory.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/extensions/extension_constants.h"
-#include "chrome/common/pref_names.h"
+#include "chrome/grit/generated_resources.h"
+#include "components/crx_file/id_util.h"
+#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/notification_details.h"
-#include "content/public/browser/notification_source.h"
#include "content/public/browser/plugin_service.h"
#include "extensions/common/extension.h"
#include "extensions/common/file_util.h"
-#include "extensions/common/id_util.h"
#include "extensions/common/manifest_constants.h"
#include "grit/browser_resources.h"
-#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
-#include "chrome/browser/chromeos/login/users/user_manager.h"
#include "chromeos/chromeos_switches.h"
#include "content/public/browser/site_instance.h"
#include "content/public/browser/storage_partition.h"
#include "extensions/browser/extensions_browser_client.h"
-#include "webkit/browser/fileapi/file_system_context.h"
+#include "storage/browser/fileapi/file_system_context.h"
#endif
#if defined(ENABLE_APP_LIST)
-#include "grit/chromium_strings.h"
+#include "chrome/grit/chromium_strings.h"
#endif
using content::BrowserThread;
static bool enable_background_extensions_during_testing = false;
-std::string LookupWebstoreName() {
- const char kWebStoreNameFieldTrialName[] = "WebStoreName";
- const char kStoreControl[] = "StoreControl";
- const char kWebStore[] = "WebStore";
- const char kGetApps[] = "GetApps";
- const char kAddApps[] = "AddApps";
- const char kMoreApps[] = "MoreApps";
-
- typedef std::map<std::string, int> NameMap;
- CR_DEFINE_STATIC_LOCAL(NameMap, names, ());
- if (names.empty()) {
- names.insert(std::make_pair(kStoreControl, IDS_WEBSTORE_NAME_STORE));
- names.insert(std::make_pair(kWebStore, IDS_WEBSTORE_NAME_WEBSTORE));
- names.insert(std::make_pair(kGetApps, IDS_WEBSTORE_NAME_GET_APPS));
- names.insert(std::make_pair(kAddApps, IDS_WEBSTORE_NAME_ADD_APPS));
- names.insert(std::make_pair(kMoreApps, IDS_WEBSTORE_NAME_MORE_APPS));
- }
- std::string field_trial_name =
- base::FieldTrialList::FindFullName(kWebStoreNameFieldTrialName);
- NameMap::iterator it = names.find(field_trial_name);
- int string_id = it == names.end() ? names[kStoreControl] : it->second;
- return l10n_util::GetStringUTF8(string_id);
-}
-
std::string GenerateId(const base::DictionaryValue* manifest,
const base::FilePath& path) {
std::string raw_key;
std::string id_input;
CHECK(manifest->GetString(manifest_keys::kPublicKey, &raw_key));
CHECK(Extension::ParsePEMKeyBytes(raw_key, &id_input));
- std::string id = id_util::GenerateId(id_input);
+ std::string id = crx_file::id_util::GenerateId(id_input);
return id;
}
if (command_line->HasSwitch(switches::kFileManagerExtensionPath)) {
base::FilePath filemgr_extension_path(
command_line->GetSwitchValuePath(switches::kFileManagerExtensionPath));
- Add(IDR_FILEMANAGER_MANIFEST, filemgr_extension_path);
+ AddWithNameAndDescription(IDR_FILEMANAGER_MANIFEST,
+ filemgr_extension_path,
+ IDS_FILEMANAGER_APP_NAME,
+ IDS_FILEMANAGER_APP_DESCRIPTION);
return;
}
#endif // NDEBUG
- Add(IDR_FILEMANAGER_MANIFEST,
- base::FilePath(FILE_PATH_LITERAL("file_manager")));
+ AddWithNameAndDescription(IDR_FILEMANAGER_MANIFEST,
+ base::FilePath(FILE_PATH_LITERAL("file_manager")),
+ IDS_FILEMANAGER_APP_NAME,
+ IDS_FILEMANAGER_APP_DESCRIPTION);
#endif // defined(OS_CHROMEOS)
}
#endif
}
+void ComponentLoader::AddHotwordAudioVerificationApp() {
+ CommandLine* command_line = CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(switches::kEnableExperimentalHotwording)) {
+ Add(IDR_HOTWORD_AUDIO_VERIFICATION_MANIFEST,
+ base::FilePath(FILE_PATH_LITERAL("hotword_audio_verification")));
+ }
+}
+
void ComponentLoader::AddHotwordHelperExtension() {
if (HotwordServiceFactory::IsHotwordAllowed(browser_context_)) {
- Add(IDR_HOTWORD_HELPER_MANIFEST,
- base::FilePath(FILE_PATH_LITERAL("hotword_helper")));
+ CommandLine* command_line = CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(switches::kEnableExperimentalHotwording)) {
+ Add(IDR_HOTWORD_MANIFEST,
+ base::FilePath(FILE_PATH_LITERAL("hotword")));
+ } else {
+ Add(IDR_HOTWORD_HELPER_MANIFEST,
+ base::FilePath(FILE_PATH_LITERAL("hotword_helper")));
+ }
}
}
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
base::FilePath resources_path;
PathService::Get(chrome::DIR_RESOURCES, &resources_path);
+
base::FilePath chromevox_path =
resources_path.Append(extension_misc::kChromeVoxExtensionPath);
const CommandLine* command_line = CommandLine::ForCurrentProcess();
- const char* manifest_filename =
- command_line->HasSwitch(chromeos::switches::kGuestSession) ?
- extension_misc::kChromeVoxGuestManifestFilename :
- extension_misc::kChromeVoxManifestFilename;
+ bool is_chromevox_next =
+ command_line->HasSwitch(chromeos::switches::kEnableChromeVoxNext);
+ bool is_guest = command_line->HasSwitch(chromeos::switches::kGuestSession);
+ const char* manifest_filename;
+ if (is_chromevox_next) {
+ manifest_filename =
+ is_guest ? extension_misc::kChromeVoxNextGuestManifestFilename
+ : extension_misc::kChromeVoxNextManifestFilename;
+ } else {
+ manifest_filename =
+ is_guest ? extension_misc::kChromeVoxGuestManifestFilename
+ : extension_misc::kChromeVoxManifestFilename;
+ }
BrowserThread::PostTaskAndReplyWithResult(
BrowserThread::FILE,
FROM_HERE,
}
#endif
-void ComponentLoader::AddWithName(int manifest_resource_id,
- const base::FilePath& root_directory,
- const std::string& name) {
+void ComponentLoader::AddWithNameAndDescription(
+ int manifest_resource_id,
+ const base::FilePath& root_directory,
+ int name_string_id,
+ int description_string_id) {
std::string manifest_contents =
ResourceBundle::GetSharedInstance().GetRawDataResource(
manifest_resource_id).as_string();
base::DictionaryValue* manifest = ParseManifest(manifest_contents);
if (manifest) {
- // Update manifest to use a proper name.
- manifest->SetString(manifest_keys::kName, name);
+ manifest->SetString(manifest_keys::kName,
+ l10n_util::GetStringUTF8(name_string_id));
+ manifest->SetString(manifest_keys::kDescription,
+ l10n_util::GetStringUTF8(description_string_id));
Add(manifest, root_directory);
}
}
void ComponentLoader::AddChromeApp() {
#if defined(ENABLE_APP_LIST)
- AddWithName(IDR_CHROME_APP_MANIFEST,
- base::FilePath(FILE_PATH_LITERAL("chrome_app")),
- l10n_util::GetStringUTF8(IDS_SHORT_PRODUCT_NAME));
+ AddWithNameAndDescription(IDR_CHROME_APP_MANIFEST,
+ base::FilePath(FILE_PATH_LITERAL("chrome_app")),
+ IDS_SHORT_PRODUCT_NAME,
+ IDS_CHROME_SHORTCUT_DESCRIPTION);
#endif
}
}
void ComponentLoader::AddWebStoreApp() {
- AddWithName(IDR_WEBSTORE_MANIFEST,
- base::FilePath(FILE_PATH_LITERAL("web_store")),
- LookupWebstoreName());
+ AddWithNameAndDescription(IDR_WEBSTORE_MANIFEST,
+ base::FilePath(FILE_PATH_LITERAL("web_store")),
+ IDS_WEBSTORE_NAME_STORE,
+ IDS_WEBSTORE_APP_DESCRIPTION);
}
// static
#if defined(OS_CHROMEOS) && defined(GOOGLE_CHROME_BUILD)
// Since this is a v2 app it has a background page.
- if (!command_line->HasSwitch(chromeos::switches::kDisableGeniusApp)) {
- AddWithName(IDR_GENIUS_APP_MANIFEST,
- base::FilePath(FILE_PATH_LITERAL(
- "/usr/share/chromeos-assets/genius_app")),
- l10n_util::GetStringUTF8(IDS_GENIUS_APP_NAME));
- }
+ AddWithNameAndDescription(IDR_GENIUS_APP_MANIFEST,
+ base::FilePath(FILE_PATH_LITERAL(
+ "/usr/share/chromeos-assets/genius_app")),
+ IDS_GENIUS_APP_NAME,
+ IDS_GENIUS_APP_DESCRIPTION);
#endif
if (!skip_session_components) {
AddGalleryExtension();
AddHangoutServicesExtension();
+ AddHotwordAudioVerificationApp();
AddHotwordHelperExtension();
AddImageLoaderExtension();
if (!skip_session_components) {
#if defined(GOOGLE_CHROME_BUILD)
if (!command_line->HasSwitch(
- chromeos::switches::kDisableQuickofficeComponentApp)) {
+ chromeos::switches::kDisableOfficeEditingComponentApp)) {
std::string id = Add(IDR_QUICKOFFICE_MANIFEST, base::FilePath(
FILE_PATH_LITERAL("/usr/share/chromeos-assets/quickoffice")));
EnableFileSystemInGuestMode(id);
AddNetworkSpeechSynthesisExtension();
#endif
- if (!skip_session_components &&
- command_line->HasSwitch(switches::kEnableEasyUnlock)) {
- if (command_line->HasSwitch(switches::kEasyUnlockAppPath)) {
- base::FilePath easy_unlock_path(
- command_line->GetSwitchValuePath(switches::kEasyUnlockAppPath));
- Add(IDR_EASY_UNLOCK_MANIFEST, easy_unlock_path);
- } else {
-#if defined(OS_CHROMEOS)
- Add(IDR_EASY_UNLOCK_MANIFEST,
- base::FilePath(
- FILE_PATH_LITERAL("/usr/share/chromeos-assets/easy_unlock")));
-#endif
- }
- }
#endif // defined(GOOGLE_CHROME_BUILD)
#if defined(ENABLE_PLUGINS)
browser_context_);
GURL site = content::SiteInstance::GetSiteForURL(
off_the_record_context, Extension::GetBaseURLFromExtensionId(id));
- fileapi::FileSystemContext* file_system_context =
+ storage::FileSystemContext* file_system_context =
content::BrowserContext::GetStoragePartitionForSite(
off_the_record_context, site)->GetFileSystemContext();
file_system_context->EnableTemporaryFileSystemInIncognito();