OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/extension_management.h" | 5 #include "chrome/browser/extensions/extension_management.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 if (subdict->GetList(schema_constants::kAllowedTypes, &list_value)) | 292 if (subdict->GetList(schema_constants::kAllowedTypes, &list_value)) |
293 allowed_types_pref = list_value; | 293 allowed_types_pref = list_value; |
294 } | 294 } |
295 | 295 |
296 // Parse legacy preferences. | 296 // Parse legacy preferences. |
297 ExtensionId id; | 297 ExtensionId id; |
298 | 298 |
299 if (allowed_list_pref) { | 299 if (allowed_list_pref) { |
300 for (base::ListValue::const_iterator it = allowed_list_pref->begin(); | 300 for (base::ListValue::const_iterator it = allowed_list_pref->begin(); |
301 it != allowed_list_pref->end(); ++it) { | 301 it != allowed_list_pref->end(); ++it) { |
302 if ((*it)->GetAsString(&id) && crx_file::id_util::IdIsValid(id)) | 302 if (it->GetAsString(&id) && crx_file::id_util::IdIsValid(id)) |
303 AccessById(id)->installation_mode = INSTALLATION_ALLOWED; | 303 AccessById(id)->installation_mode = INSTALLATION_ALLOWED; |
304 } | 304 } |
305 } | 305 } |
306 | 306 |
307 if (denied_list_pref) { | 307 if (denied_list_pref) { |
308 for (base::ListValue::const_iterator it = denied_list_pref->begin(); | 308 for (base::ListValue::const_iterator it = denied_list_pref->begin(); |
309 it != denied_list_pref->end(); ++it) { | 309 it != denied_list_pref->end(); ++it) { |
310 if ((*it)->GetAsString(&id) && crx_file::id_util::IdIsValid(id)) | 310 if (it->GetAsString(&id) && crx_file::id_util::IdIsValid(id)) |
311 AccessById(id)->installation_mode = INSTALLATION_BLOCKED; | 311 AccessById(id)->installation_mode = INSTALLATION_BLOCKED; |
312 } | 312 } |
313 } | 313 } |
314 | 314 |
315 UpdateForcedExtensions(forced_list_pref); | 315 UpdateForcedExtensions(forced_list_pref); |
316 UpdateForcedExtensions(login_screen_app_list_pref); | 316 UpdateForcedExtensions(login_screen_app_list_pref); |
317 | 317 |
318 if (install_sources_pref) { | 318 if (install_sources_pref) { |
319 global_settings_->has_restricted_install_sources = true; | 319 global_settings_->has_restricted_install_sources = true; |
320 for (base::ListValue::const_iterator it = install_sources_pref->begin(); | 320 for (base::ListValue::const_iterator it = install_sources_pref->begin(); |
321 it != install_sources_pref->end(); ++it) { | 321 it != install_sources_pref->end(); ++it) { |
322 std::string url_pattern; | 322 std::string url_pattern; |
323 if ((*it)->GetAsString(&url_pattern)) { | 323 if (it->GetAsString(&url_pattern)) { |
324 URLPattern entry(URLPattern::SCHEME_ALL); | 324 URLPattern entry(URLPattern::SCHEME_ALL); |
325 if (entry.Parse(url_pattern) == URLPattern::PARSE_SUCCESS) { | 325 if (entry.Parse(url_pattern) == URLPattern::PARSE_SUCCESS) { |
326 global_settings_->install_sources.AddPattern(entry); | 326 global_settings_->install_sources.AddPattern(entry); |
327 } else { | 327 } else { |
328 LOG(WARNING) << "Invalid URL pattern in for preference " | 328 LOG(WARNING) << "Invalid URL pattern in for preference " |
329 << pref_names::kAllowedInstallSites << ": " | 329 << pref_names::kAllowedInstallSites << ": " |
330 << url_pattern << "."; | 330 << url_pattern << "."; |
331 } | 331 } |
332 } | 332 } |
333 } | 333 } |
334 } | 334 } |
335 | 335 |
336 if (allowed_types_pref) { | 336 if (allowed_types_pref) { |
337 global_settings_->has_restricted_allowed_types = true; | 337 global_settings_->has_restricted_allowed_types = true; |
338 for (base::ListValue::const_iterator it = allowed_types_pref->begin(); | 338 for (base::ListValue::const_iterator it = allowed_types_pref->begin(); |
339 it != allowed_types_pref->end(); ++it) { | 339 it != allowed_types_pref->end(); ++it) { |
340 int int_value; | 340 int int_value; |
341 std::string string_value; | 341 std::string string_value; |
342 if ((*it)->GetAsInteger(&int_value) && int_value >= 0 && | 342 if (it->GetAsInteger(&int_value) && int_value >= 0 && |
343 int_value < Manifest::Type::NUM_LOAD_TYPES) { | 343 int_value < Manifest::Type::NUM_LOAD_TYPES) { |
344 global_settings_->allowed_types.push_back( | 344 global_settings_->allowed_types.push_back( |
345 static_cast<Manifest::Type>(int_value)); | 345 static_cast<Manifest::Type>(int_value)); |
346 } else if ((*it)->GetAsString(&string_value)) { | 346 } else if (it->GetAsString(&string_value)) { |
347 Manifest::Type manifest_type = | 347 Manifest::Type manifest_type = |
348 schema_constants::GetManifestType(string_value); | 348 schema_constants::GetManifestType(string_value); |
349 if (manifest_type != Manifest::TYPE_UNKNOWN) | 349 if (manifest_type != Manifest::TYPE_UNKNOWN) |
350 global_settings_->allowed_types.push_back(manifest_type); | 350 global_settings_->allowed_types.push_back(manifest_type); |
351 } | 351 } |
352 } | 352 } |
353 } | 353 } |
354 | 354 |
355 if (dict_pref) { | 355 if (dict_pref) { |
356 // Parse new extension management preference. | 356 // Parse new extension management preference. |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 content::BrowserContext* context) const { | 513 content::BrowserContext* context) const { |
514 return chrome::GetBrowserContextRedirectedInIncognito(context); | 514 return chrome::GetBrowserContextRedirectedInIncognito(context); |
515 } | 515 } |
516 | 516 |
517 void ExtensionManagementFactory::RegisterProfilePrefs( | 517 void ExtensionManagementFactory::RegisterProfilePrefs( |
518 user_prefs::PrefRegistrySyncable* user_prefs) { | 518 user_prefs::PrefRegistrySyncable* user_prefs) { |
519 user_prefs->RegisterDictionaryPref(pref_names::kExtensionManagement); | 519 user_prefs->RegisterDictionaryPref(pref_names::kExtensionManagement); |
520 } | 520 } |
521 | 521 |
522 } // namespace extensions | 522 } // namespace extensions |
OLD | NEW |