diff options
author | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-30 09:31:30 +0000 |
---|---|---|
committer | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-30 09:31:30 +0000 |
commit | 0d462462ec30bf81d47c79617beb4fff6eff3624 (patch) | |
tree | 453ebfbb763923091016aeb44b3c441cac5a3eee | |
parent | 0397077945597d982f61aa3f2114f59e4c78336b (diff) | |
download | chromium_src-0d462462ec30bf81d47c79617beb4fff6eff3624.zip chromium_src-0d462462ec30bf81d47c79617beb4fff6eff3624.tar.gz chromium_src-0d462462ec30bf81d47c79617beb4fff6eff3624.tar.bz2 |
Use primary/secondary for URLs and patterns everywhere in the content settings extension API.
BUG=71067
Review URL: http://codereview.chromium.org/7253041
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91106 0039d316-1c4b-4281-b951-d872f2087c98
11 files changed, 147 insertions, 127 deletions
diff --git a/chrome/browser/extensions/extension_content_settings_api.cc b/chrome/browser/extensions/extension_content_settings_api.cc index 58f8343..b76024e 100644 --- a/chrome/browser/extensions/extension_content_settings_api.cc +++ b/chrome/browser/extensions/extension_content_settings_api.cc @@ -85,24 +85,25 @@ bool GetContentSettingFunction::RunImpl() { DictionaryValue* details = NULL; EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &details)); - std::string embedded_url_spec; + std::string primary_url_spec; EXTENSION_FUNCTION_VALIDATE( - details->GetString(keys::kEmbeddedUrlKey, &embedded_url_spec)); - GURL embedded_url(embedded_url_spec); - if (!embedded_url.is_valid()) { + details->GetString(keys::kPrimaryUrlKey, &primary_url_spec)); + GURL primary_url(primary_url_spec); + if (!primary_url.is_valid()) { error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kInvalidUrlError, - embedded_url_spec); + primary_url_spec); return false; } - std::string top_level_url_spec; - EXTENSION_FUNCTION_VALIDATE( - details->GetString(keys::kTopLevelUrlKey, &top_level_url_spec)); - GURL top_level_url(top_level_url_spec); - if (!top_level_url.is_valid()) { - error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kInvalidUrlError, - top_level_url_spec); - return false; + GURL secondary_url(primary_url); + std::string secondary_url_spec; + if (details->GetString(keys::kSecondaryUrlKey, &secondary_url_spec)) { + secondary_url = GURL(secondary_url_spec); + if (!secondary_url.is_valid()) { + error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kInvalidUrlError, + secondary_url_spec); + return false; + } } std::string resource_identifier; @@ -143,10 +144,10 @@ bool GetContentSettingFunction::RunImpl() { if (content_type == CONTENT_SETTINGS_TYPE_COOKIES) { // TODO(jochen): Do we return the value for setting or for reading cookies? bool setting_cookie = false; - setting = map->GetCookieContentSetting(embedded_url, top_level_url, + setting = map->GetCookieContentSetting(primary_url, secondary_url, setting_cookie); } else { - setting = map->GetContentSetting(embedded_url, top_level_url, content_type, + setting = map->GetContentSetting(primary_url, secondary_url, content_type, resource_identifier); } @@ -169,26 +170,27 @@ bool SetContentSettingFunction::RunImpl() { DictionaryValue* details = NULL; EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &details)); - std::string top_level_pattern_str; - std::string top_level_error; + std::string primary_pattern_str; EXTENSION_FUNCTION_VALIDATE( - details->GetString(keys::kTopLevelPatternKey, &top_level_pattern_str)); - ContentSettingsPattern top_level_pattern = - helpers::ParseExtensionPattern(top_level_pattern_str, &top_level_error); - if (!top_level_pattern.IsValid()) { - error_ = top_level_error; + details->GetString(keys::kPrimaryPatternKey, &primary_pattern_str)); + std::string primary_error; + ContentSettingsPattern primary_pattern = + helpers::ParseExtensionPattern(primary_pattern_str, &primary_error); + if (!primary_pattern.IsValid()) { + error_ = primary_error; return false; } - std::string embedded_pattern_str; - std::string embedded_error; - EXTENSION_FUNCTION_VALIDATE( - details->GetString(keys::kEmbeddedPatternKey, &embedded_pattern_str)); - ContentSettingsPattern embedded_pattern = - helpers::ParseExtensionPattern(embedded_pattern_str, &embedded_error); - if (!embedded_pattern.IsValid()) { - error_ = embedded_error; - return false; + ContentSettingsPattern secondary_pattern = ContentSettingsPattern::Wildcard(); + std::string secondary_pattern_str; + if (details->GetString(keys::kSecondaryPatternKey, &secondary_pattern_str)) { + std::string secondary_error; + secondary_pattern = + helpers::ParseExtensionPattern(secondary_pattern_str, &secondary_error); + if (!secondary_pattern.IsValid()) { + error_ = secondary_error; + return false; + } } std::string resource_identifier; @@ -247,8 +249,8 @@ bool SetContentSettingFunction::RunImpl() { ExtensionContentSettingsStore* store = profile_->GetExtensionService()->GetExtensionContentSettingsStore(); - store->SetExtensionContentSetting(extension_id(), top_level_pattern, - embedded_pattern, content_type, + store->SetExtensionContentSetting(extension_id(), primary_pattern, + secondary_pattern, content_type, resource_identifier, setting, scope); return true; } diff --git a/chrome/browser/extensions/extension_content_settings_api_constants.cc b/chrome/browser/extensions/extension_content_settings_api_constants.cc index 3e7c638..c01b3c90 100644 --- a/chrome/browser/extensions/extension_content_settings_api_constants.cc +++ b/chrome/browser/extensions/extension_content_settings_api_constants.cc @@ -10,14 +10,14 @@ namespace extension_content_settings_api_constants { const char kContentSettingKey[] = "setting"; const char kContentSettingsTypeKey[] = "type"; const char kDescriptionKey[] = "description"; -const char kEmbeddedPatternKey[] = "embeddedPattern"; -const char kEmbeddedUrlKey[] = "embeddedUrl"; const char kIdKey[] = "id"; const char kPatternKey[] = "pattern"; +const char kPrimaryPatternKey[] = "primaryPattern"; +const char kPrimaryUrlKey[] = "primaryUrl"; const char kResourceIdentifierKey[] = "resourceIdentifier"; const char kRuleKey[] = "rule"; -const char kTopLevelPatternKey[] = "topLevelPattern"; -const char kTopLevelUrlKey[] = "topLevelUrl"; +const char kSecondaryPatternKey[] = "secondaryPattern"; +const char kSecondaryUrlKey[] = "secondaryUrl"; // Errors. const char kIncognitoContextError[] = diff --git a/chrome/browser/extensions/extension_content_settings_api_constants.h b/chrome/browser/extensions/extension_content_settings_api_constants.h index 8938f85..4ada146 100644 --- a/chrome/browser/extensions/extension_content_settings_api_constants.h +++ b/chrome/browser/extensions/extension_content_settings_api_constants.h @@ -14,14 +14,14 @@ namespace extension_content_settings_api_constants { extern const char kContentSettingKey[]; extern const char kContentSettingsTypeKey[]; extern const char kDescriptionKey[]; -extern const char kEmbeddedPatternKey[]; -extern const char kEmbeddedUrlKey[]; extern const char kIdKey[]; extern const char kPatternKey[]; +extern const char kPrimaryPatternKey[]; +extern const char kPrimaryUrlKey[]; extern const char kResourceIdentifierKey[]; extern const char kRuleKey[]; -extern const char kTopLevelPatternKey[]; -extern const char kTopLevelUrlKey[]; +extern const char kSecondaryPatternKey[]; +extern const char kSecondaryUrlKey[]; // Errors. extern const char kIncognitoContextError[]; diff --git a/chrome/browser/extensions/extension_content_settings_store.cc b/chrome/browser/extensions/extension_content_settings_store.cc index ee02ce4..d8617b6 100644 --- a/chrome/browser/extensions/extension_content_settings_store.cc +++ b/chrome/browser/extensions/extension_content_settings_store.cc @@ -16,6 +16,24 @@ namespace helpers = extension_content_settings_helpers; namespace keys = extension_content_settings_api_constants; +namespace { + +bool ComparePatternPairs(const ContentSettingsPattern& first_primary, + const ContentSettingsPattern& first_secondary, + const ContentSettingsPattern& second_primary, + const ContentSettingsPattern& second_secondary) { + ContentSettingsPattern::Relation relation = + first_primary.Compare(second_primary); + if (relation == ContentSettingsPattern::SUCCESSOR) + return true; + if (relation == ContentSettingsPattern::PREDECESSOR) + return false; + return (first_secondary.Compare(second_secondary) == + ContentSettingsPattern::SUCCESSOR); +} + +} // namespace + using content_settings::ResourceIdentifier; struct ExtensionContentSettingsStore::ExtensionEntry { @@ -43,8 +61,8 @@ ExtensionContentSettingsStore::~ExtensionContentSettingsStore() { void ExtensionContentSettingsStore::SetExtensionContentSetting( const std::string& ext_id, - const ContentSettingsPattern& embedded_pattern, - const ContentSettingsPattern& top_level_pattern, + const ContentSettingsPattern& primary_pattern, + const ContentSettingsPattern& secondary_pattern, ContentSettingsType type, const content_settings::ResourceIdentifier& identifier, ContentSetting setting, @@ -57,8 +75,8 @@ void ExtensionContentSettingsStore::SetExtensionContentSetting( // Find |ContentSettingSpec|. ContentSettingSpecList::iterator setting_spec = setting_spec_list->begin(); while (setting_spec != setting_spec_list->end()) { - if (setting_spec->embedded_pattern == embedded_pattern && - setting_spec->top_level_pattern == top_level_pattern && + if (setting_spec->primary_pattern == primary_pattern && + setting_spec->secondary_pattern == secondary_pattern && setting_spec->content_type == type && setting_spec->resource_identifier == identifier) { break; @@ -66,8 +84,8 @@ void ExtensionContentSettingsStore::SetExtensionContentSetting( ++setting_spec; } if (setting_spec == setting_spec_list->end()) { - setting_spec_list->push_back(ContentSettingSpec(embedded_pattern, - top_level_pattern, + setting_spec_list->push_back(ContentSettingSpec(primary_pattern, + secondary_pattern, type, identifier, setting)); @@ -181,8 +199,8 @@ const ExtensionContentSettingsStore::ContentSettingSpecList* } ContentSetting ExtensionContentSettingsStore::GetContentSettingFromSpecList( - const GURL& embedded_url, - const GURL& top_level_url, + const GURL& primary_url, + const GURL& secondary_url, ContentSettingsType type, const content_settings::ResourceIdentifier& identifier, const ContentSettingSpecList& setting_spec_list) const { @@ -190,17 +208,18 @@ ContentSetting ExtensionContentSettingsStore::GetContentSettingFromSpecList( for (ContentSettingSpecList::const_iterator spec = setting_spec_list.begin(); spec != setting_spec_list.end(); ++spec) { - if (!spec->embedded_pattern.Matches(embedded_url) || - !spec->top_level_pattern.Matches(top_level_url) || + if (!spec->primary_pattern.Matches(primary_url) || + !spec->secondary_pattern.Matches(secondary_url) || spec->content_type != type || spec->resource_identifier != identifier) { continue; } - // TODO(markusheintz): Compare embedded patterns as well? if (winner_spec == setting_spec_list.end() || - winner_spec->top_level_pattern.Compare(spec->top_level_pattern) == - ContentSettingsPattern::SUCCESSOR) { + ComparePatternPairs(winner_spec->primary_pattern, + winner_spec->secondary_pattern, + spec->primary_pattern, + spec->secondary_pattern)) { winner_spec = spec; } } @@ -284,7 +303,7 @@ void ExtensionContentSettingsStore::AddRules( for (it = setting_spec_list->begin(); it != setting_spec_list->end(); ++it) { if (it->content_type == type && it->resource_identifier == identifier) { rules->push_back(content_settings::ProviderInterface::Rule( - it->embedded_pattern, it->top_level_pattern, it->setting)); + it->primary_pattern, it->secondary_pattern, it->setting)); } } } @@ -328,10 +347,10 @@ ListValue* ExtensionContentSettingsStore::GetSettingsForExtension( ContentSettingSpecList::const_iterator it; for (it = setting_spec_list->begin(); it != setting_spec_list->end(); ++it) { DictionaryValue* setting_dict = new DictionaryValue(); - setting_dict->SetString(keys::kEmbeddedPatternKey, - it->embedded_pattern.ToString()); - setting_dict->SetString(keys::kTopLevelPatternKey, - it->top_level_pattern.ToString()); + setting_dict->SetString(keys::kPrimaryPatternKey, + it->primary_pattern.ToString()); + setting_dict->SetString(keys::kSecondaryPatternKey, + it->secondary_pattern.ToString()); setting_dict->SetString( keys::kContentSettingsTypeKey, helpers::ContentSettingsTypeToString(it->content_type)); @@ -354,17 +373,17 @@ void ExtensionContentSettingsStore::SetExtensionContentSettingsFromList( continue; } DictionaryValue* dict = static_cast<DictionaryValue*>(*it); - std::string pattern_str; - dict->GetString(keys::kTopLevelPatternKey, &pattern_str); - ContentSettingsPattern pattern = - ContentSettingsPattern::LegacyFromString(pattern_str); - DCHECK(pattern.IsValid()); - - std::string embedded_pattern_str; - dict->GetString(keys::kEmbeddedPatternKey, &embedded_pattern_str); - ContentSettingsPattern embedded_pattern = - ContentSettingsPattern::LegacyFromString(embedded_pattern_str); - DCHECK(embedded_pattern.IsValid()); + std::string primary_pattern_str; + dict->GetString(keys::kPrimaryPatternKey, &primary_pattern_str); + ContentSettingsPattern primary_pattern = + ContentSettingsPattern::LegacyFromString(primary_pattern_str); + DCHECK(primary_pattern.IsValid()); + + std::string secondary_pattern_str; + dict->GetString(keys::kSecondaryPatternKey, &secondary_pattern_str); + ContentSettingsPattern secondary_pattern = + ContentSettingsPattern::LegacyFromString(secondary_pattern_str); + DCHECK(secondary_pattern.IsValid()); std::string content_settings_type_str; dict->GetString(keys::kContentSettingsTypeKey, &content_settings_type_str); @@ -383,8 +402,8 @@ void ExtensionContentSettingsStore::SetExtensionContentSettingsFromList( DCHECK(result); SetExtensionContentSetting(extension_id, - pattern, - embedded_pattern, + primary_pattern, + secondary_pattern, content_settings_type, resource_identifier, setting, @@ -403,13 +422,13 @@ void ExtensionContentSettingsStore::RemoveObserver(Observer* observer) { } ExtensionContentSettingsStore::ContentSettingSpec::ContentSettingSpec( - const ContentSettingsPattern& embedded_pattern, - const ContentSettingsPattern& top_level_pattern, + const ContentSettingsPattern& primary_pattern, + const ContentSettingsPattern& secondary_pattern, ContentSettingsType type, const content_settings::ResourceIdentifier& identifier, ContentSetting setting) - : embedded_pattern(embedded_pattern), - top_level_pattern(top_level_pattern), + : primary_pattern(primary_pattern), + secondary_pattern(secondary_pattern), content_type(type), resource_identifier(identifier), setting(setting) { diff --git a/chrome/browser/extensions/extension_content_settings_store.h b/chrome/browser/extensions/extension_content_settings_store.h index 67ec02c..1f090a6 100644 --- a/chrome/browser/extensions/extension_content_settings_store.h +++ b/chrome/browser/extensions/extension_content_settings_store.h @@ -118,14 +118,14 @@ class ExtensionContentSettingsStore { private: struct ExtensionEntry; struct ContentSettingSpec { - ContentSettingSpec(const ContentSettingsPattern& pattern, - const ContentSettingsPattern& embedder_pattern, + ContentSettingSpec(const ContentSettingsPattern& primary_pattern, + const ContentSettingsPattern& secondary_pattern, ContentSettingsType type, const content_settings::ResourceIdentifier& identifier, ContentSetting setting); - ContentSettingsPattern embedded_pattern; - ContentSettingsPattern top_level_pattern; + ContentSettingsPattern primary_pattern; + ContentSettingsPattern secondary_pattern; ContentSettingsType content_type; content_settings::ResourceIdentifier resource_identifier; ContentSetting setting; diff --git a/chrome/common/extensions/api/extension_api.json b/chrome/common/extensions/api/extension_api.json index cc30bf6..93f5be0 100644 --- a/chrome/common/extensions/api/extension_api.json +++ b/chrome/common/extensions/api/extension_api.json @@ -5862,13 +5862,14 @@ "name": "details", "type": "object", "properties": { - "embeddedUrl": { + "primaryUrl": { "type": "string", - "description": "The URL of the frame or object for which the content settings should be retrieved." + "description": "The primary URL for which the content setting should be retrieved. Note that the meaning of a primary URL depends on the content type." }, - "topLevelUrl": { + "secondaryUrl": { "type": "string", - "description": "The URL of the top-level frame." + "description": "The secondary URL for which the content setting should be retrieved. Defaults to the primary URL. Note that the meaning of a secondary URL depends on the content type, and not all content types use secondary URLs.", + "optional": true }, "resourceIdentifier": { "$ref": "ResourceIdentifier", @@ -5909,13 +5910,14 @@ "name": "details", "type": "object", "properties": { - "topLevelPattern": { + "primaryPattern": { "type": "string", - "description": "The pattern for the top-level frame URL. For details on the format of a pattern, see <a href='match_patterns.html'>Match Patterns</a>." + "description": "The pattern for the primary URL. For details on the format of a pattern, see <a href='match_patterns.html'>Match Patterns</a>." }, - "embeddedPattern": { + "secondaryPattern": { "type": "string", - "description": "The pattern for the frame or object URL. For details on the format of a pattern, see <a href='match_patterns.html'>Match Patterns</a>." + "description": "The pattern for the secondary URL. Defaults to matching all URLs. For details on the format of a pattern, see <a href='match_patterns.html'>Match Patterns</a>.", + "optional": true }, "resourceIdentifier": { "$ref": "ResourceIdentifier", @@ -5990,7 +5992,7 @@ }, "cookies": { "$ref": "ContentSetting", - "description": "Whether to allow cookies and other local data to be set by websites. One of<br><var>allow</var>: Accept cookies,<br><var>block</var>: Block cookies,<br><var>session_only</var>: Accept cookies only for the current session. Default is <var>allow</var>.", + "description": "Whether to allow cookies and other local data to be set by websites. One of<br><var>allow</var>: Accept cookies,<br><var>block</var>: Block cookies,<br><var>session_only</var>: Accept cookies only for the current session. Default is <var>allow</var>.<br>The primary URL is the URL representing the cookie origin. The secondary URL is the URL of the top-level frame.", "value": [ "cookies", {"type":"string", "enum": ["allow", "block", "session_only"]} @@ -5998,7 +6000,7 @@ }, "images": { "$ref": "ContentSetting", - "description": "Whether to show images. One of<br><var>allow</var>: Show images,<br><var>block</var>: Don't show images. Default is <var>allow</var>.", + "description": "Whether to show images. One of<br><var>allow</var>: Show images,<br><var>block</var>: Don't show images. Default is <var>allow</var>.<br>The primary URL is the main-frame URL. The secondary URL is not used.", "value": [ "images", {"type":"string", "enum": ["allow", "block"]} @@ -6006,7 +6008,7 @@ }, "javascript": { "$ref": "ContentSetting", - "description": "Whether to run Javascript. One of<br><var>allow</var>: Run Javascript,<br><var>block</var>: Don't run Javascript. Default is <var>allow</var>.", + "description": "Whether to run Javascript. One of<br><var>allow</var>: Run Javascript,<br><var>block</var>: Don't run Javascript. Default is <var>allow</var>.<br>The primary URL is the main-frame URL. The secondary URL is not used.", "value": [ "javascript", {"type":"string", "enum": ["allow", "block"]} @@ -6014,7 +6016,7 @@ }, "plugins": { "$ref": "ContentSetting", - "description": "Whether to run plug-ins. One of<br><var>allow</var>: Run plug-ins automatically,<br><var>block</var>: Don't run plug-ins automatically. Default is <var>allow</var>.", + "description": "Whether to run plug-ins. One of<br><var>allow</var>: Run plug-ins automatically,<br><var>block</var>: Don't run plug-ins automatically. Default is <var>allow</var>.<br>The primary URL is the main-frame URL. The secondary URL is not used.", "value": [ "plugins", {"type":"string", "enum": ["allow", "block"]} @@ -6022,7 +6024,7 @@ }, "popups": { "$ref": "ContentSetting", - "description": "Whether to allow sites to show pop-ups. One of<br><var>allow</var>: Allow sites to show pop-ups,<br><var>block</var>: Don't allow sites to show pop-ups. Default is <var>block</var>.", + "description": "Whether to allow sites to show pop-ups. One of<br><var>allow</var>: Allow sites to show pop-ups,<br><var>block</var>: Don't allow sites to show pop-ups. Default is <var>block</var>.<br>The primary URL is the main-frame URL. The secondary URL is not used.", "value": [ "popups", {"type":"string", "enum": ["allow", "block"]} @@ -6030,7 +6032,7 @@ }, "notifications": { "$ref": "ContentSetting", - "description": "Whether to allow sites to show desktop notifications. One of<br><var>allow</var>: Allow sites to show desktop notifications,<br><var>block</var>: Don't allow sites to show desktop notifications,<br><var>ask</var>: Ask when a site wants to show desktop notifications. Default is <var>ask</var>.", + "description": "Whether to allow sites to show desktop notifications. One of<br><var>allow</var>: Allow sites to show desktop notifications,<br><var>block</var>: Don't allow sites to show desktop notifications,<br><var>ask</var>: Ask when a site wants to show desktop notifications. Default is <var>ask</var>.<br>The primary URL is the main-frame URL. The secondary URL is not used.", "value": [ "notifications", {"type":"string", "enum": ["allow", "block", "ask"]} diff --git a/chrome/common/extensions/docs/examples/api/contentSettings.zip b/chrome/common/extensions/docs/examples/api/contentSettings.zip Binary files differindex 38a2a2a..d174d96 100644 --- a/chrome/common/extensions/docs/examples/api/contentSettings.zip +++ b/chrome/common/extensions/docs/examples/api/contentSettings.zip diff --git a/chrome/common/extensions/docs/examples/api/contentSettings/popup.html b/chrome/common/extensions/docs/examples/api/contentSettings/popup.html index d83e1d1..4d8541af 100644 --- a/chrome/common/extensions/docs/examples/api/contentSettings/popup.html +++ b/chrome/common/extensions/docs/examples/api/contentSettings/popup.html @@ -13,8 +13,7 @@ function init() { "notifications"]; types.forEach(function(type) { chrome.experimental.contentSettings[type].get({ - 'topLevelUrl': url, - 'embeddedUrl': url, + 'primaryUrl': url, 'incognito': incognito }, function(details) { @@ -30,8 +29,7 @@ function settingChanged(element) { var pattern = /^file:/.test(url) ? url : url.replace(/\/[^\/]*?$/, '/*'); console.log(type+" setting for "+pattern+": "+setting); chrome.experimental.contentSettings[type].set({ - 'topLevelPattern': pattern, - 'embeddedPattern': pattern, + 'primaryPattern': pattern, 'setting': setting, 'scope': (incognito ? 'incognito_session_only' : 'regular') }); diff --git a/chrome/common/extensions/docs/experimental.contentSettings.html b/chrome/common/extensions/docs/experimental.contentSettings.html index fcb153b..b58ea1c 100644 --- a/chrome/common/extensions/docs/experimental.contentSettings.html +++ b/chrome/common/extensions/docs/experimental.contentSettings.html @@ -654,7 +654,7 @@ <dd class="todo" style="display: none; "> Undocumented. </dd> - <dd>Whether to allow cookies and other local data to be set by websites. One of<br><var>allow</var>: Accept cookies,<br><var>block</var>: Block cookies,<br><var>session_only</var>: Accept cookies only for the current session. Default is <var>allow</var>.</dd> + <dd>Whether to allow cookies and other local data to be set by websites. One of<br><var>allow</var>: Accept cookies,<br><var>block</var>: Block cookies,<br><var>session_only</var>: Accept cookies only for the current session. Default is <var>allow</var>.<br>The primary URL is the URL representing the cookie origin. The secondary URL is the URL of the top-level frame.</dd> <dd style="display: none; "> This parameter was added in version <b><span></span></b>. @@ -728,7 +728,7 @@ <dd class="todo" style="display: none; "> Undocumented. </dd> - <dd>Whether to show images. One of<br><var>allow</var>: Show images,<br><var>block</var>: Don't show images. Default is <var>allow</var>.</dd> + <dd>Whether to show images. One of<br><var>allow</var>: Show images,<br><var>block</var>: Don't show images. Default is <var>allow</var>.<br>The primary URL is the main-frame URL. The secondary URL is not used.</dd> <dd style="display: none; "> This parameter was added in version <b><span></span></b>. @@ -802,7 +802,7 @@ <dd class="todo" style="display: none; "> Undocumented. </dd> - <dd>Whether to run Javascript. One of<br><var>allow</var>: Run Javascript,<br><var>block</var>: Don't run Javascript. Default is <var>allow</var>.</dd> + <dd>Whether to run Javascript. One of<br><var>allow</var>: Run Javascript,<br><var>block</var>: Don't run Javascript. Default is <var>allow</var>.<br>The primary URL is the main-frame URL. The secondary URL is not used.</dd> <dd style="display: none; "> This parameter was added in version <b><span></span></b>. @@ -876,7 +876,7 @@ <dd class="todo" style="display: none; "> Undocumented. </dd> - <dd>Whether to run plug-ins. One of<br><var>allow</var>: Run plug-ins automatically,<br><var>block</var>: Don't run plug-ins automatically. Default is <var>allow</var>.</dd> + <dd>Whether to run plug-ins. One of<br><var>allow</var>: Run plug-ins automatically,<br><var>block</var>: Don't run plug-ins automatically. Default is <var>allow</var>.<br>The primary URL is the main-frame URL. The secondary URL is not used.</dd> <dd style="display: none; "> This parameter was added in version <b><span></span></b>. @@ -950,7 +950,7 @@ <dd class="todo" style="display: none; "> Undocumented. </dd> - <dd>Whether to allow sites to show pop-ups. One of<br><var>allow</var>: Allow sites to show pop-ups,<br><var>block</var>: Don't allow sites to show pop-ups. Default is <var>block</var>.</dd> + <dd>Whether to allow sites to show pop-ups. One of<br><var>allow</var>: Allow sites to show pop-ups,<br><var>block</var>: Don't allow sites to show pop-ups. Default is <var>block</var>.<br>The primary URL is the main-frame URL. The secondary URL is not used.</dd> <dd style="display: none; "> This parameter was added in version <b><span></span></b>. @@ -1024,7 +1024,7 @@ <dd class="todo" style="display: none; "> Undocumented. </dd> - <dd>Whether to allow sites to show desktop notifications. One of<br><var>allow</var>: Allow sites to show desktop notifications,<br><var>block</var>: Don't allow sites to show desktop notifications,<br><var>ask</var>: Ask when a site wants to show desktop notifications. Default is <var>ask</var>.</dd> + <dd>Whether to allow sites to show desktop notifications. One of<br><var>allow</var>: Allow sites to show desktop notifications,<br><var>block</var>: Don't allow sites to show desktop notifications,<br><var>ask</var>: Ask when a site wants to show desktop notifications. Default is <var>ask</var>.<br>The primary URL is the main-frame URL. The secondary URL is not used.</dd> <dd style="display: none; "> This parameter was added in version <b><span></span></b>. @@ -2149,7 +2149,7 @@ <div> <div> <dt> - <var>embeddedUrl</var> + <var>primaryUrl</var> <em> <!-- TYPE --> @@ -2177,7 +2177,7 @@ <dd class="todo" style="display: none; "> Undocumented. </dd> - <dd>The URL of the frame or object for which the content settings should be retrieved.</dd> + <dd>The primary URL for which the content setting should be retrieved. Note that the meaning of a primary URL depends on the content type.</dd> <dd style="display: none; "> This parameter was added in version <b><span></span></b>. @@ -2217,13 +2217,13 @@ </div><div> <div> <dt> - <var>topLevelUrl</var> + <var>secondaryUrl</var> <em> <!-- TYPE --> <div style="display:inline"> ( - <span class="optional" style="display: none; ">optional</span> + <span class="optional">optional</span> <span class="enum" style="display: none; ">enumerated</span> <span id="typeTemplate"> <span style="display: none; "> @@ -2245,7 +2245,7 @@ <dd class="todo" style="display: none; "> Undocumented. </dd> - <dd>The URL of the top-level frame.</dd> + <dd>The secondary URL for which the content setting should be retrieved. Defaults to the primary URL. Note that the meaning of a secondary URL depends on the content type, and not all content types use secondary URLs.</dd> <dd style="display: none; "> This parameter was added in version <b><span></span></b>. @@ -2961,7 +2961,7 @@ <div> <div> <dt> - <var>topLevelPattern</var> + <var>primaryPattern</var> <em> <!-- TYPE --> @@ -2989,7 +2989,7 @@ <dd class="todo" style="display: none; "> Undocumented. </dd> - <dd>The pattern for the top-level frame URL. For details on the format of a pattern, see <a href="match_patterns.html">Match Patterns</a>.</dd> + <dd>The pattern for the primary URL. For details on the format of a pattern, see <a href="match_patterns.html">Match Patterns</a>.</dd> <dd style="display: none; "> This parameter was added in version <b><span></span></b>. @@ -3029,13 +3029,13 @@ </div><div> <div> <dt> - <var>embeddedPattern</var> + <var>secondaryPattern</var> <em> <!-- TYPE --> <div style="display:inline"> ( - <span class="optional" style="display: none; ">optional</span> + <span class="optional">optional</span> <span class="enum" style="display: none; ">enumerated</span> <span id="typeTemplate"> <span style="display: none; "> @@ -3057,7 +3057,7 @@ <dd class="todo" style="display: none; "> Undocumented. </dd> - <dd>The pattern for the frame or object URL. For details on the format of a pattern, see <a href="match_patterns.html">Match Patterns</a>.</dd> + <dd>The pattern for the secondary URL. Defaults to matching all URLs. For details on the format of a pattern, see <a href="match_patterns.html">Match Patterns</a>.</dd> <dd style="display: none; "> This parameter was added in version <b><span></span></b>. diff --git a/chrome/common/extensions/docs/samples.json b/chrome/common/extensions/docs/samples.json index 3b6e746..fa7a9cb 100644 --- a/chrome/common/extensions/docs/samples.json +++ b/chrome/common/extensions/docs/samples.json @@ -563,7 +563,7 @@ "manifest.json", "popup.html" ], - "source_hash": "1bd5e6d89bc8090a55837c26d0ba3911fd63b362", + "source_hash": "aab21662d31c6d61f2304eacce32a3b6ca8bb207", "zip_path": "examples\/api\/contentSettings.zip" }, { diff --git a/chrome/test/data/extensions/api_test/content_settings/standard/test.html b/chrome/test/data/extensions/api_test/content_settings/standard/test.html index 99f47df..9249024 100644 --- a/chrome/test/data/extensions/api_test/content_settings/standard/test.html +++ b/chrome/test/data/extensions/api_test/content_settings/standard/test.html @@ -65,8 +65,8 @@ chrome.test.runTests([ function setDefaultContentSettings() { default_content_settings.forEach(function(type, setting) { cs[type].set({ - 'topLevelPattern': '<all_urls>', - 'embeddedPattern': '<all_urls>', + 'primaryPattern': '<all_urls>', + 'secondaryPattern': '<all_urls>', 'setting': setting }, chrome.test.callbackPass()); }); @@ -74,8 +74,8 @@ chrome.test.runTests([ function setContentSettings() { settings.forEach(function(type, setting) { cs[type].set({ - 'topLevelPattern': 'http://*.google.com/*', - 'embeddedPattern': 'http://*.google.com/*', + 'primaryPattern': 'http://*.google.com/*', + 'secondaryPattern': 'http://*.google.com/*', 'setting': setting }, chrome.test.callbackPass()); }); @@ -84,24 +84,23 @@ chrome.test.runTests([ settings.forEach(function(type, setting) { var message = "Setting for " + type + " should be " + setting; cs[type].get({ - 'topLevelUrl': 'http://www.google.com', - 'embeddedUrl': 'http://www.google.com' + 'primaryUrl': 'http://www.google.com', + 'secondaryUrl': 'http://www.google.com' }, expect({'setting':setting}, message)); }); }, function invalidSettings() { cs.cookies.get({ - 'topLevelUrl': '', - 'embeddedUrl': 'moo' + 'primaryUrl': 'moo', }, chrome.test.callbackFail("The URL \"moo\" is invalid.")); cs.plugins.set({ - 'topLevelPattern': 'http://example.com/*', - 'embeddedPattern': 'http://example.com/path', + 'primaryPattern': 'http://example.com/*', + 'secondaryPattern': 'http://example.com/path', 'setting': 'block' }, chrome.test.callbackFail("Specific paths are not allowed.")); cs.javascript.set({ - 'topLevelPattern': 'http://example.com/*', - 'embeddedPattern': 'file:///home/hansmoleman/*', + 'primaryPattern': 'http://example.com/*', + 'secondaryPattern': 'file:///home/hansmoleman/*', 'setting': 'allow' }, chrome.test.callbackFail("Path wildcards in file URL patterns are not allowed.")); } |