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 "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
13 #include "chrome/browser/prefs/pref_change_registrar.h" | 13 #include "chrome/browser/prefs/pref_change_registrar.h" |
14 #include "chrome/browser/prefs/pref_notifier.h" | 14 #include "chrome/browser/prefs/pref_notifier.h" |
15 #include "chrome/browser/prefs/pref_service.h" | 15 #include "chrome/browser/prefs/pref_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 "content/public/browser/notification_details.h" | 24 #include "content/public/browser/notification_details.h" |
25 #include "content/public/browser/notification_source.h" | 25 #include "content/public/browser/notification_source.h" |
26 #include "grit/browser_resources.h" | 26 #include "grit/browser_resources.h" |
| 27 #include "ui/base/layout.h" |
27 #include "ui/base/resource/resource_bundle.h" | 28 #include "ui/base/resource/resource_bundle.h" |
28 | 29 |
29 #if defined(OFFICIAL_BUILD) | 30 #if defined(OFFICIAL_BUILD) |
30 #include "chrome/browser/defaults.h" | 31 #include "chrome/browser/defaults.h" |
31 #endif | 32 #endif |
32 | 33 |
33 #if defined(OS_CHROMEOS) | 34 #if defined(OS_CHROMEOS) |
34 #include "chrome/browser/chromeos/login/user_manager.h" | 35 #include "chrome/browser/chromeos/login/user_manager.h" |
35 #endif | 36 #endif |
36 | 37 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 } | 83 } |
83 | 84 |
84 component_extensions_.clear(); | 85 component_extensions_.clear(); |
85 } | 86 } |
86 | 87 |
87 const Extension* ComponentLoader::Add( | 88 const Extension* ComponentLoader::Add( |
88 int manifest_resource_id, | 89 int manifest_resource_id, |
89 const FilePath& root_directory) { | 90 const FilePath& root_directory) { |
90 std::string manifest_contents = | 91 std::string manifest_contents = |
91 ResourceBundle::GetSharedInstance().GetRawDataResource( | 92 ResourceBundle::GetSharedInstance().GetRawDataResource( |
92 manifest_resource_id).as_string(); | 93 manifest_resource_id, |
| 94 ui::SCALE_FACTOR_NONE).as_string(); |
93 return Add(manifest_contents, root_directory); | 95 return Add(manifest_contents, root_directory); |
94 } | 96 } |
95 | 97 |
96 const Extension* ComponentLoader::Add( | 98 const Extension* ComponentLoader::Add( |
97 std::string& manifest_contents, | 99 std::string& manifest_contents, |
98 const FilePath& root_directory) { | 100 const FilePath& root_directory) { |
99 // The Value is kept for the lifetime of the ComponentLoader. This is | 101 // The Value is kept for the lifetime of the ComponentLoader. This is |
100 // required in case LoadAll() is called again. | 102 // required in case LoadAll() is called again. |
101 DictionaryValue* manifest = ParseManifest(manifest_contents); | 103 DictionaryValue* manifest = ParseManifest(manifest_contents); |
102 if (manifest) | 104 if (manifest) |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 // Remove the extension if it was already loaded. | 244 // Remove the extension if it was already loaded. |
243 Remove(path); | 245 Remove(path); |
244 | 246 |
245 std::string enterprise_webstore_url = | 247 std::string enterprise_webstore_url = |
246 prefs_->GetString(prefs::kEnterpriseWebStoreURL); | 248 prefs_->GetString(prefs::kEnterpriseWebStoreURL); |
247 | 249 |
248 // Load the extension only if the URL preference is set. | 250 // Load the extension only if the URL preference is set. |
249 if (!enterprise_webstore_url.empty()) { | 251 if (!enterprise_webstore_url.empty()) { |
250 std::string manifest_contents = | 252 std::string manifest_contents = |
251 ResourceBundle::GetSharedInstance().GetRawDataResource( | 253 ResourceBundle::GetSharedInstance().GetRawDataResource( |
252 IDR_ENTERPRISE_WEBSTORE_MANIFEST).as_string(); | 254 IDR_ENTERPRISE_WEBSTORE_MANIFEST, |
| 255 ui::SCALE_FACTOR_NONE).as_string(); |
253 | 256 |
254 // The manifest is missing some values that are provided by policy. | 257 // The manifest is missing some values that are provided by policy. |
255 DictionaryValue* manifest = ParseManifest(manifest_contents); | 258 DictionaryValue* manifest = ParseManifest(manifest_contents); |
256 if (manifest) { | 259 if (manifest) { |
257 std::string name = prefs_->GetString(prefs::kEnterpriseWebStoreName); | 260 std::string name = prefs_->GetString(prefs::kEnterpriseWebStoreName); |
258 manifest->SetString("app.launch.web_url", enterprise_webstore_url); | 261 manifest->SetString("app.launch.web_url", enterprise_webstore_url); |
259 manifest->SetString("name", name); | 262 manifest->SetString("name", name); |
260 Add(manifest, path); | 263 Add(manifest, path); |
261 } | 264 } |
262 } | 265 } |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 void ComponentLoader::RegisterUserPrefs(PrefService* prefs) { | 359 void ComponentLoader::RegisterUserPrefs(PrefService* prefs) { |
357 prefs->RegisterStringPref(prefs::kEnterpriseWebStoreURL, | 360 prefs->RegisterStringPref(prefs::kEnterpriseWebStoreURL, |
358 std::string() /* default_value */, | 361 std::string() /* default_value */, |
359 PrefService::UNSYNCABLE_PREF); | 362 PrefService::UNSYNCABLE_PREF); |
360 prefs->RegisterStringPref(prefs::kEnterpriseWebStoreName, | 363 prefs->RegisterStringPref(prefs::kEnterpriseWebStoreName, |
361 std::string() /* default_value */, | 364 std::string() /* default_value */, |
362 PrefService::UNSYNCABLE_PREF); | 365 PrefService::UNSYNCABLE_PREF); |
363 } | 366 } |
364 | 367 |
365 } // namespace extensions | 368 } // namespace extensions |
OLD | NEW |