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" | |
29 #include "ui/base/resource/resource_bundle.h" | 30 #include "ui/base/resource/resource_bundle.h" |
30 | 31 |
31 #if defined(OFFICIAL_BUILD) | 32 #if defined(OFFICIAL_BUILD) |
32 #include "chrome/browser/defaults.h" | 33 #include "chrome/browser/defaults.h" |
33 #endif | 34 #endif |
34 | 35 |
35 #if defined(OS_CHROMEOS) | 36 #if defined(OS_CHROMEOS) |
36 #include "chrome/browser/chromeos/login/user_manager.h" | 37 #include "chrome/browser/chromeos/login/user_manager.h" |
37 #include "chromeos/chromeos_switches.h" | 38 #include "chromeos/chromeos_switches.h" |
38 #endif | 39 #endif |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
326 | 327 |
327 if (manifest) { | 328 if (manifest) { |
328 // Update manifest to use a proper name. | 329 // Update manifest to use a proper name. |
329 manifest->SetString(extension_manifest_keys::kName, | 330 manifest->SetString(extension_manifest_keys::kName, |
330 l10n_util::GetStringUTF8(IDS_SHORT_PRODUCT_NAME)); | 331 l10n_util::GetStringUTF8(IDS_SHORT_PRODUCT_NAME)); |
331 Add(manifest, base::FilePath(FILE_PATH_LITERAL("chrome_app"))); | 332 Add(manifest, base::FilePath(FILE_PATH_LITERAL("chrome_app"))); |
332 } | 333 } |
333 #endif | 334 #endif |
334 } | 335 } |
335 | 336 |
337 void ComponentLoader::AddKeyboardApp() { | |
338 #if defined(USE_ASH) | |
339 std::string id = Add(IDR_KEYBOARD_MANIFEST, | |
340 base::FilePath(FILE_PATH_LITERAL("keyboard"))); | |
sadrul
2013/04/15 17:17:27
Did you plan on using |id|?
bryeung
2013/04/15 17:50:56
Leftover from debugging (where I was LOG'ing it).
| |
341 #endif | |
342 } | |
343 | |
336 // static | 344 // static |
337 void ComponentLoader::EnableBackgroundExtensionsForTesting() { | 345 void ComponentLoader::EnableBackgroundExtensionsForTesting() { |
338 enable_background_extensions_during_testing = true; | 346 enable_background_extensions_during_testing = true; |
339 } | 347 } |
340 | 348 |
341 void ComponentLoader::AddDefaultComponentExtensions( | 349 void ComponentLoader::AddDefaultComponentExtensions( |
342 bool skip_session_components) { | 350 bool skip_session_components) { |
343 // Do not add component extensions that have background pages here -- add them | 351 // Do not add component extensions that have background pages here -- add them |
344 // to AddDefaultComponentExtensionsWithBackgroundPages. | 352 // to AddDefaultComponentExtensionsWithBackgroundPages. |
345 #if defined(OS_CHROMEOS) | 353 #if defined(OS_CHROMEOS) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
380 | 388 |
381 // If a URL for the enterprise webstore has been specified, load the | 389 // If a URL for the enterprise webstore has been specified, load the |
382 // component extension. This extension might also be loaded later, because | 390 // component extension. This extension might also be loaded later, because |
383 // it is specified by policy, and on ChromeOS policies are loaded after | 391 // it is specified by policy, and on ChromeOS policies are loaded after |
384 // the browser process has started. | 392 // the browser process has started. |
385 AddOrReloadEnterpriseWebStore(); | 393 AddOrReloadEnterpriseWebStore(); |
386 | 394 |
387 AddChromeApp(); | 395 AddChromeApp(); |
388 } | 396 } |
389 | 397 |
398 #if defined(USE_AURA) | |
399 AddKeyboardApp(); | |
400 #endif | |
401 | |
390 AddDefaultComponentExtensionsWithBackgroundPages(skip_session_components); | 402 AddDefaultComponentExtensionsWithBackgroundPages(skip_session_components); |
391 } | 403 } |
392 | 404 |
393 void ComponentLoader::AddDefaultComponentExtensionsWithBackgroundPages( | 405 void ComponentLoader::AddDefaultComponentExtensionsWithBackgroundPages( |
394 bool skip_session_components) { | 406 bool skip_session_components) { |
395 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 407 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
396 | 408 |
397 // Component extensions with background pages are not enabled during tests | 409 // Component extensions with background pages are not enabled during tests |
398 // because they generate a lot of background behavior that can interfere. | 410 // because they generate a lot of background behavior that can interfere. |
399 if (!enable_background_extensions_during_testing && | 411 if (!enable_background_extensions_during_testing && |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
475 void ComponentLoader::RegisterUserPrefs(PrefRegistrySyncable* registry) { | 487 void ComponentLoader::RegisterUserPrefs(PrefRegistrySyncable* registry) { |
476 registry->RegisterStringPref(prefs::kEnterpriseWebStoreURL, | 488 registry->RegisterStringPref(prefs::kEnterpriseWebStoreURL, |
477 std::string() /* default_value */, | 489 std::string() /* default_value */, |
478 PrefRegistrySyncable::UNSYNCABLE_PREF); | 490 PrefRegistrySyncable::UNSYNCABLE_PREF); |
479 registry->RegisterStringPref(prefs::kEnterpriseWebStoreName, | 491 registry->RegisterStringPref(prefs::kEnterpriseWebStoreName, |
480 std::string() /* default_value */, | 492 std::string() /* default_value */, |
481 PrefRegistrySyncable::UNSYNCABLE_PREF); | 493 PrefRegistrySyncable::UNSYNCABLE_PREF); |
482 } | 494 } |
483 | 495 |
484 } // namespace extensions | 496 } // namespace extensions |
OLD | NEW |