Chromium Code Reviews| 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 "extensions/browser/extension_prefs.h" | 5 #include "extensions/browser/extension_prefs.h" |
| 6 | 6 |
| 7 #include <iterator> | 7 #include <iterator> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/prefs/pref_notifier.h" | 10 #include "base/prefs/pref_notifier.h" |
| (...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 556 bool ExtensionPrefs::ReadPrefAsBooleanAndReturn( | 556 bool ExtensionPrefs::ReadPrefAsBooleanAndReturn( |
| 557 const std::string& extension_id, | 557 const std::string& extension_id, |
| 558 const std::string& pref_key) const { | 558 const std::string& pref_key) const { |
| 559 bool out_value = false; | 559 bool out_value = false; |
| 560 return ReadPrefAsBoolean(extension_id, pref_key, &out_value) && out_value; | 560 return ReadPrefAsBoolean(extension_id, pref_key, &out_value) && out_value; |
| 561 } | 561 } |
| 562 | 562 |
| 563 PermissionSet* ExtensionPrefs::ReadPrefAsPermissionSet( | 563 PermissionSet* ExtensionPrefs::ReadPrefAsPermissionSet( |
| 564 const std::string& extension_id, | 564 const std::string& extension_id, |
| 565 const std::string& pref_key) { | 565 const std::string& pref_key) { |
| 566 if (!GetExtensionPref(extension_id)) | 566 const base::DictionaryValue* extensions = GetExtensionPref(extension_id); |
| 567 if (!extensions) | |
| 567 return NULL; | 568 return NULL; |
| 568 | 569 |
| 569 // Retrieve the API permissions. Please refer SetExtensionPrefPermissionSet() | 570 // Retrieve the API permissions. Please refer SetExtensionPrefPermissionSet() |
| 570 // for api_values format. | 571 // for api_values format. |
| 571 APIPermissionSet apis; | 572 APIPermissionSet apis; |
| 572 const base::ListValue* api_values = NULL; | 573 const base::ListValue* api_values = NULL; |
| 573 std::string api_pref = JoinPrefs(pref_key, kPrefAPIs); | 574 std::string api_pref = JoinPrefs(pref_key, kPrefAPIs); |
| 574 if (ReadPrefAsList(extension_id, api_pref, &api_values)) { | 575 if (ReadPrefAsList(extension_id, api_pref, &api_values)) { |
| 575 APIPermissionSet::ParseFromJSON(api_values, | 576 APIPermissionSet::ParseFromJSON(api_values, |
| 576 APIPermissionSet::kAllowInternalPermissions, | 577 APIPermissionSet::kAllowInternalPermissions, |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 590 } | 591 } |
| 591 | 592 |
| 592 // Retrieve the explicit host permissions. | 593 // Retrieve the explicit host permissions. |
| 593 URLPatternSet explicit_hosts; | 594 URLPatternSet explicit_hosts; |
| 594 ReadPrefAsURLPatternSet( | 595 ReadPrefAsURLPatternSet( |
| 595 extension_id, JoinPrefs(pref_key, kPrefExplicitHosts), | 596 extension_id, JoinPrefs(pref_key, kPrefExplicitHosts), |
| 596 &explicit_hosts, Extension::kValidHostPermissionSchemes); | 597 &explicit_hosts, Extension::kValidHostPermissionSchemes); |
| 597 | 598 |
| 598 // Retrieve the scriptable host permissions. | 599 // Retrieve the scriptable host permissions. |
| 599 URLPatternSet scriptable_hosts; | 600 URLPatternSet scriptable_hosts; |
| 600 ReadPrefAsURLPatternSet( | 601 int location_value; |
| 601 extension_id, JoinPrefs(pref_key, kPrefScriptableHosts), | 602 int valid_schemes = UserScript::ValidUserScriptSchemes(); |
| 602 &scriptable_hosts, UserScript::ValidUserScriptSchemes()); | 603 // Adding CHROMEUI scheme in valid schemes mask if extension is component |
| 604 // extension. | |
| 605 if (extensions->GetInteger(kPrefLocation, &location_value) && | |
| 606 Manifest::COMPONENT == static_cast<Manifest::Location>(location_value)) { | |
|
Ken Rockot(use gerrit already)
2015/03/24 16:49:09
nit: Please swap the operand order here. i.e.:
st
| |
| 607 valid_schemes |= URLPattern::SCHEME_CHROMEUI; | |
| 608 } | |
| 609 ReadPrefAsURLPatternSet(extension_id, | |
| 610 JoinPrefs(pref_key, kPrefScriptableHosts), | |
| 611 &scriptable_hosts, valid_schemes); | |
| 603 | 612 |
| 604 return new PermissionSet( | 613 return new PermissionSet( |
| 605 apis, manifest_permissions, explicit_hosts, scriptable_hosts); | 614 apis, manifest_permissions, explicit_hosts, scriptable_hosts); |
| 606 } | 615 } |
| 607 | 616 |
| 608 // Set the API or Manifest permissions. | 617 // Set the API or Manifest permissions. |
| 609 // The format of api_values is: | 618 // The format of api_values is: |
| 610 // [ "permission_name1", // permissions do not support detail. | 619 // [ "permission_name1", // permissions do not support detail. |
| 611 // "permission_name2", | 620 // "permission_name2", |
| 612 // {"permission_name3": value }, | 621 // {"permission_name3": value }, |
| (...skipping 1513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2126 extension_pref_value_map_->RegisterExtension( | 2135 extension_pref_value_map_->RegisterExtension( |
| 2127 extension_id, install_time, is_enabled, is_incognito_enabled); | 2136 extension_id, install_time, is_enabled, is_incognito_enabled); |
| 2128 | 2137 |
| 2129 FOR_EACH_OBSERVER( | 2138 FOR_EACH_OBSERVER( |
| 2130 ExtensionPrefsObserver, | 2139 ExtensionPrefsObserver, |
| 2131 observer_list_, | 2140 observer_list_, |
| 2132 OnExtensionRegistered(extension_id, install_time, is_enabled)); | 2141 OnExtensionRegistered(extension_id, install_time, is_enabled)); |
| 2133 } | 2142 } |
| 2134 | 2143 |
| 2135 } // namespace extensions | 2144 } // namespace extensions |
| OLD | NEW |