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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/json/json_string_value_serializer.h" | 9 #include "base/json/json_string_value_serializer.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "base/prefs/pref_change_registrar.h" | 11 #include "base/prefs/pref_change_registrar.h" |
12 #include "base/prefs/pref_notifier.h" | 12 #include "base/prefs/pref_notifier.h" |
13 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
14 #include "chrome/browser/defaults.h" | 14 #include "chrome/browser/defaults.h" |
15 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/common/chrome_notification_types.h" | 17 #include "chrome/common/chrome_notification_types.h" |
18 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
20 #include "chrome/common/extensions/extension.h" | 20 #include "chrome/common/extensions/extension.h" |
21 #include "chrome/common/extensions/extension_file_util.h" | 21 #include "chrome/common/extensions/extension_file_util.h" |
22 #include "chrome/common/extensions/extension_manifest_constants.h" | 22 #include "chrome/common/extensions/extension_manifest_constants.h" |
23 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
24 #include "components/user_prefs/pref_registry_syncable.h" | 24 #include "components/user_prefs/pref_registry_syncable.h" |
25 #include "content/public/browser/notification_details.h" | 25 #include "content/public/browser/notification_details.h" |
26 #include "content/public/browser/notification_source.h" | 26 #include "content/public/browser/notification_source.h" |
27 #include "extensions/common/id_util.h" | 27 #include "extensions/common/id_util.h" |
28 #include "grit/browser_resources.h" | 28 #include "grit/browser_resources.h" |
29 #include "grit/keyboard_resources.h" | |
30 #include "ui/base/resource/resource_bundle.h" | 29 #include "ui/base/resource/resource_bundle.h" |
31 | 30 |
32 #if defined(OFFICIAL_BUILD) | 31 #if defined(OFFICIAL_BUILD) |
33 #include "chrome/browser/defaults.h" | 32 #include "chrome/browser/defaults.h" |
34 #endif | 33 #endif |
35 | 34 |
36 #if defined(OS_CHROMEOS) | 35 #if defined(OS_CHROMEOS) |
37 #include "chrome/browser/chromeos/login/user_manager.h" | 36 #include "chrome/browser/chromeos/login/user_manager.h" |
38 #include "chromeos/chromeos_switches.h" | 37 #include "chromeos/chromeos_switches.h" |
39 #endif | 38 #endif |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 | 326 |
328 if (manifest) { | 327 if (manifest) { |
329 // Update manifest to use a proper name. | 328 // Update manifest to use a proper name. |
330 manifest->SetString(extension_manifest_keys::kName, | 329 manifest->SetString(extension_manifest_keys::kName, |
331 l10n_util::GetStringUTF8(IDS_SHORT_PRODUCT_NAME)); | 330 l10n_util::GetStringUTF8(IDS_SHORT_PRODUCT_NAME)); |
332 Add(manifest, base::FilePath(FILE_PATH_LITERAL("chrome_app"))); | 331 Add(manifest, base::FilePath(FILE_PATH_LITERAL("chrome_app"))); |
333 } | 332 } |
334 #endif | 333 #endif |
335 } | 334 } |
336 | 335 |
337 void ComponentLoader::AddKeyboardApp() { | |
338 #if defined(USE_ASH) | |
339 Add(IDR_KEYBOARD_MANIFEST, base::FilePath(FILE_PATH_LITERAL("keyboard"))); | |
340 #endif | |
341 } | |
342 | |
343 // static | 336 // static |
344 void ComponentLoader::EnableBackgroundExtensionsForTesting() { | 337 void ComponentLoader::EnableBackgroundExtensionsForTesting() { |
345 enable_background_extensions_during_testing = true; | 338 enable_background_extensions_during_testing = true; |
346 } | 339 } |
347 | 340 |
348 void ComponentLoader::AddDefaultComponentExtensions( | 341 void ComponentLoader::AddDefaultComponentExtensions( |
349 bool skip_session_components) { | 342 bool skip_session_components) { |
350 // Do not add component extensions that have background pages here -- add them | 343 // Do not add component extensions that have background pages here -- add them |
351 // to AddDefaultComponentExtensionsWithBackgroundPages. | 344 // to AddDefaultComponentExtensionsWithBackgroundPages. |
352 #if defined(OS_CHROMEOS) | 345 #if defined(OS_CHROMEOS) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 | 380 |
388 // If a URL for the enterprise webstore has been specified, load the | 381 // If a URL for the enterprise webstore has been specified, load the |
389 // component extension. This extension might also be loaded later, because | 382 // component extension. This extension might also be loaded later, because |
390 // it is specified by policy, and on ChromeOS policies are loaded after | 383 // it is specified by policy, and on ChromeOS policies are loaded after |
391 // the browser process has started. | 384 // the browser process has started. |
392 AddOrReloadEnterpriseWebStore(); | 385 AddOrReloadEnterpriseWebStore(); |
393 | 386 |
394 AddChromeApp(); | 387 AddChromeApp(); |
395 } | 388 } |
396 | 389 |
397 #if defined(USE_AURA) | |
398 AddKeyboardApp(); | |
399 #endif | |
400 | |
401 AddDefaultComponentExtensionsWithBackgroundPages(skip_session_components); | 390 AddDefaultComponentExtensionsWithBackgroundPages(skip_session_components); |
402 } | 391 } |
403 | 392 |
404 void ComponentLoader::AddDefaultComponentExtensionsWithBackgroundPages( | 393 void ComponentLoader::AddDefaultComponentExtensionsWithBackgroundPages( |
405 bool skip_session_components) { | 394 bool skip_session_components) { |
406 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 395 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
407 | 396 |
408 // Component extensions with background pages are not enabled during tests | 397 // Component extensions with background pages are not enabled during tests |
409 // because they generate a lot of background behavior that can interfere. | 398 // because they generate a lot of background behavior that can interfere. |
410 if (!enable_background_extensions_during_testing && | 399 if (!enable_background_extensions_during_testing && |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 void ComponentLoader::RegisterUserPrefs(PrefRegistrySyncable* registry) { | 475 void ComponentLoader::RegisterUserPrefs(PrefRegistrySyncable* registry) { |
487 registry->RegisterStringPref(prefs::kEnterpriseWebStoreURL, | 476 registry->RegisterStringPref(prefs::kEnterpriseWebStoreURL, |
488 std::string() /* default_value */, | 477 std::string() /* default_value */, |
489 PrefRegistrySyncable::UNSYNCABLE_PREF); | 478 PrefRegistrySyncable::UNSYNCABLE_PREF); |
490 registry->RegisterStringPref(prefs::kEnterpriseWebStoreName, | 479 registry->RegisterStringPref(prefs::kEnterpriseWebStoreName, |
491 std::string() /* default_value */, | 480 std::string() /* default_value */, |
492 PrefRegistrySyncable::UNSYNCABLE_PREF); | 481 PrefRegistrySyncable::UNSYNCABLE_PREF); |
493 } | 482 } |
494 | 483 |
495 } // namespace extensions | 484 } // namespace extensions |
OLD | NEW |