diff options
author | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-24 10:03:25 +0000 |
---|---|---|
committer | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-24 10:03:25 +0000 |
commit | 598bbccdb22ad6a8319369dfb3717913238c1420 (patch) | |
tree | aa68dadbbf7cc4ca6a515f88dfacf74b32e1e7f2 /chrome | |
parent | 331ec7df0ee1194a8fe88c6fc5c6d26edfdb8f21 (diff) | |
download | chromium_src-598bbccdb22ad6a8319369dfb3717913238c1420.zip chromium_src-598bbccdb22ad6a8319369dfb3717913238c1420.tar.gz chromium_src-598bbccdb22ad6a8319369dfb3717913238c1420.tar.bz2 |
Implement experimental.contentSettings.misc.blockThirdPartyCookies.
This adds a Preference class to the extension APIs that can be used for access to other preferences in the future.
BUG=71067
TEST=ExtensionApiTest.ContentSettings:ExtensionApiTest.IncognitoContentSettings
Review URL: http://codereview.chromium.org/6480033
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75866 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
22 files changed, 2267 insertions, 11 deletions
diff --git a/chrome/browser/extensions/extension_content_settings_apitest.cc b/chrome/browser/extensions/extension_content_settings_apitest.cc new file mode 100644 index 0000000..5757702 --- /dev/null +++ b/chrome/browser/extensions/extension_content_settings_apitest.cc @@ -0,0 +1,52 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/extensions/extension_apitest.h" +#include "chrome/browser/prefs/pref_service.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/browser.h" +#include "chrome/common/chrome_switches.h" +#include "chrome/common/pref_names.h" + +IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentSettings) { + CommandLine::ForCurrentProcess()->AppendSwitch( + switches::kEnableExperimentalExtensionApis); + + PrefService* pref_service = browser()->profile()->GetPrefs(); + pref_service->SetBoolean(prefs::kBlockThirdPartyCookies, true); + + EXPECT_TRUE(RunExtensionTest("content_settings/standard")) << message_; + + const PrefService::Preference* pref = pref_service->FindPreference( + prefs::kBlockThirdPartyCookies); + ASSERT_TRUE(pref); + EXPECT_TRUE(pref->IsExtensionControlled()); + EXPECT_EQ(false, pref_service->GetBoolean(prefs::kBlockThirdPartyCookies)); +} + +IN_PROC_BROWSER_TEST_F(ExtensionApiTest, IncognitoContentSettings) { + CommandLine::ForCurrentProcess()->AppendSwitch( + switches::kEnableExperimentalExtensionApis); + + PrefService* prefs = browser()->profile()->GetPrefs(); + prefs->SetBoolean(prefs::kBlockThirdPartyCookies, false); + + EXPECT_TRUE(RunExtensionTest("content_settings/incognito")) << message_; + + // Setting an incognito preference should not create an incognito profile. + EXPECT_FALSE(browser()->profile()->HasOffTheRecordProfile()); + + PrefService* otr_prefs = + browser()->profile()->GetOffTheRecordProfile()->GetPrefs(); + const PrefService::Preference* pref = + otr_prefs->FindPreference(prefs::kBlockThirdPartyCookies); + ASSERT_TRUE(pref); + EXPECT_TRUE(pref->IsExtensionControlled()); + EXPECT_EQ(true, otr_prefs->GetBoolean(prefs::kBlockThirdPartyCookies)); + + pref = prefs->FindPreference(prefs::kBlockThirdPartyCookies); + ASSERT_TRUE(pref); + EXPECT_FALSE(pref->IsExtensionControlled()); + EXPECT_EQ(false, prefs->GetBoolean(prefs::kBlockThirdPartyCookies)); +} diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc index 9af5481..c20dc0d 100644 --- a/chrome/browser/extensions/extension_function_dispatcher.cc +++ b/chrome/browser/extensions/extension_function_dispatcher.cc @@ -32,6 +32,7 @@ #include "chrome/browser/extensions/extension_module.h" #include "chrome/browser/extensions/extension_omnibox_api.h" #include "chrome/browser/extensions/extension_page_actions_module.h" +#include "chrome/browser/extensions/extension_preference_api.h" #include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_processes_api.h" #include "chrome/browser/extensions/extension_proxy_api.h" @@ -298,6 +299,10 @@ void FactoryRegistry::ResetFunctions() { // WebRequest. RegisterFunction<WebRequestAddEventListener>(); + + // Preferences. + RegisterFunction<GetPreferenceFunction>(); + RegisterFunction<SetPreferenceFunction>(); } void FactoryRegistry::GetAllNames(std::vector<std::string>* names) { diff --git a/chrome/browser/extensions/extension_preference_api.cc b/chrome/browser/extensions/extension_preference_api.cc new file mode 100644 index 0000000..5a0bc97 --- /dev/null +++ b/chrome/browser/extensions/extension_preference_api.cc @@ -0,0 +1,133 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/extensions/extension_preference_api.h" + +#include "base/singleton.h" +#include "base/stringprintf.h" +#include "base/values.h" +#include "chrome/browser/extensions/extension_prefs.h" +#include "chrome/browser/extensions/extension_service.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/common/pref_names.h" + +namespace { + +struct PrefMappingEntry { + const char* extension_pref; + const char* browser_pref; + const char* permission; +}; + +PrefMappingEntry pref_mapping[] = { + { "blockThirdPartyCookies", + prefs::kBlockThirdPartyCookies, + Extension::kContentSettingsPermission + }, +}; + +class PrefMapping { + public: + static PrefMapping* GetInstance() { + return Singleton<PrefMapping>::get(); + } + + bool FindBrowserPrefForExtensionPref(const std::string& extension_pref, + std::string* browser_pref, + std::string* permission) { + std::map<std::string, std::pair<std::string, std::string> >::iterator it = + mapping_.find(extension_pref); + if (it != mapping_.end()) { + *browser_pref = it->second.first; + *permission = it->second.second; + return true; + } + return false; + } + + private: + friend struct DefaultSingletonTraits<PrefMapping>; + + std::map<std::string, std::pair<std::string, std::string> > mapping_; + + PrefMapping() { + for (size_t i = 0; i < arraysize(pref_mapping); ++i) { + mapping_[pref_mapping[i].extension_pref] = + std::make_pair(pref_mapping[i].browser_pref, + pref_mapping[i].permission); + } + } +}; + +const char kPermissionErrorMessage[] = + "You do not have permission to access the preference '%s'. " + "Be sure to declare in your manifest what permissions you need."; + +} // namespace + +GetPreferenceFunction::~GetPreferenceFunction() { } + +bool GetPreferenceFunction::RunImpl() { + std::string pref_key; + EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &pref_key)); + DictionaryValue* details = NULL; + EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &details)); + + bool incognito = false; + if (details->HasKey("incognito")) + EXTENSION_FUNCTION_VALIDATE(details->GetBoolean("incognito", &incognito)); + + PrefService* prefs = incognito ? profile_->GetOffTheRecordPrefs() + : profile_->GetPrefs(); + std::string browser_pref; + std::string permission; + EXTENSION_FUNCTION_VALIDATE( + PrefMapping::GetInstance()->FindBrowserPrefForExtensionPref( + pref_key, &browser_pref, &permission)); + if (!GetExtension()->HasApiPermission(permission)) { + error_ = base::StringPrintf(kPermissionErrorMessage, pref_key.c_str()); + return false; + } + const PrefService::Preference* pref = + prefs->FindPreference(browser_pref.c_str()); + CHECK(pref); + result_.reset(pref->GetValue()->DeepCopy()); + return true; +} + +SetPreferenceFunction::~SetPreferenceFunction() { } + +bool SetPreferenceFunction::RunImpl() { + std::string pref_key; + EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &pref_key)); + DictionaryValue* details = NULL; + EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &details)); + + Value* value = NULL; + EXTENSION_FUNCTION_VALIDATE(details->Get("value", &value)); + + bool incognito = false; + if (details->HasKey("incognito")) + EXTENSION_FUNCTION_VALIDATE(details->GetBoolean("incognito", &incognito)); + + std::string browser_pref; + std::string permission; + EXTENSION_FUNCTION_VALIDATE( + PrefMapping::GetInstance()->FindBrowserPrefForExtensionPref( + pref_key, &browser_pref, &permission)); + if (!GetExtension()->HasApiPermission(permission)) { + error_ = base::StringPrintf(kPermissionErrorMessage, pref_key.c_str()); + return false; + } + ExtensionPrefs* prefs = profile_->GetExtensionService()->extension_prefs(); + const PrefService::Preference* pref = + prefs->pref_service()->FindPreference(browser_pref.c_str()); + CHECK(pref); + EXTENSION_FUNCTION_VALIDATE(value->GetType() == pref->GetType()); + prefs->SetExtensionControlledPref(extension_id(), + browser_pref, + incognito, + value->DeepCopy()); + return true; +} diff --git a/chrome/browser/extensions/extension_preference_api.h b/chrome/browser/extensions/extension_preference_api.h new file mode 100644 index 0000000..2877e91 --- /dev/null +++ b/chrome/browser/extensions/extension_preference_api.h @@ -0,0 +1,25 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFERENCE_API_H__ +#define CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFERENCE_API_H__ +#pragma once + +#include "chrome/browser/extensions/extension_function.h" + +class GetPreferenceFunction : public SyncExtensionFunction { + public: + virtual ~GetPreferenceFunction(); + virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("experimental.preferences.get") +}; + +class SetPreferenceFunction : public SyncExtensionFunction { + public: + virtual ~SetPreferenceFunction(); + virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME("experimental.preferences.set") +}; + +#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFERENCE_API_H__ diff --git a/chrome/browser/extensions/extension_prefs.cc b/chrome/browser/extensions/extension_prefs.cc index 4a4c40f0..a7ff547 100644 --- a/chrome/browser/extensions/extension_prefs.cc +++ b/chrome/browser/extensions/extension_prefs.cc @@ -1277,9 +1277,14 @@ void ExtensionPrefs::SetExtensionControlledPref(const std::string& extension_id, const std::string& pref_key, bool incognito, Value* value) { - DCHECK(pref_service()->FindPreference(pref_key.c_str())) - << "Extension controlled preference key " << pref_key - << " not registered."; +#ifndef NDEBUG + const PrefService::Preference* pref = + pref_service()->FindPreference(pref_key.c_str()); + DCHECK(pref) << "Extension controlled preference key " << pref_key + << " not registered."; + DCHECK_EQ(pref->GetType(), value->GetType()) + << "Extension controlled preference " << pref_key << " has wrong type."; +#endif if (!incognito) { // Also store in persisted Preferences file to recover after a diff --git a/chrome/browser/extensions/extension_prefs.h b/chrome/browser/extensions/extension_prefs.h index b48f617..a8ebe7d 100644 --- a/chrome/browser/extensions/extension_prefs.h +++ b/chrome/browser/extensions/extension_prefs.h @@ -278,6 +278,7 @@ class ExtensionPrefs { // Sets a preference value that is controlled by the extension. In other // words, this is not a pref value *about* the extension but something // global the extension wants to override. + // Takes ownership of |value|. void SetExtensionControlledPref(const std::string& extension_id, const std::string& pref_key, bool incognito, diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 88c97ae..b290923 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1001,6 +1001,8 @@ 'browser/extensions/extension_page_actions_module.h', 'browser/extensions/extension_page_actions_module_constants.cc', 'browser/extensions/extension_page_actions_module_constants.h', + 'browser/extensions/extension_preference_api.cc', + 'browser/extensions/extension_preference_api.h', 'browser/extensions/extension_pref_store.cc', 'browser/extensions/extension_pref_store.h', 'browser/extensions/extension_pref_value_map.cc', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 2ed87b31..8c99ce1 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -2204,6 +2204,7 @@ 'browser/extensions/extension_browsertest.h', 'browser/extensions/extension_browsertests_misc.cc', 'browser/extensions/extension_clipboard_apitest.cc', + 'browser/extensions/extension_content_settings_apitest.cc', 'browser/extensions/extension_context_menu_apitest.cc', 'browser/extensions/extension_context_menu_browsertest.cc', 'browser/extensions/extension_cookies_apitest.cc', diff --git a/chrome/common/extensions/api/extension_api.json b/chrome/common/extensions/api/extension_api.json index 05c53a3..12b1f0e 100644 --- a/chrome/common/extensions/api/extension_api.json +++ b/chrome/common/extensions/api/extension_api.json @@ -4558,5 +4558,88 @@ ] } ] + }, + { + "namespace": "experimental.extension", + "types": [ + { + "id": "Preference", + "type": "object", + "customBindings": "Preference", + "description": "An object which allows access to a preference.", + "functions": [ + { + "name": "get", + "type": "function", + "description": "Get the setting from the user preferences.", + "parameters": [ + { + "name": "details", + "type": "object", + "description": "What setting to return.", + "properties": { + "incognito": { + "type": "boolean", + "optional": true, + "description": "Whether to return the setting that applies to the incognito session only (default false)." + } + } + }, + { + "name": "callback", + "type": "function", + "parameters": [ + { + "name": "value", + "description": "The value of the preference.", + "type": "any" + } + ] + } + ] + }, + { + "name": "set", + "type": "function", + "description": "Set the setting in the user preferences", + "parameters": [ + { + "name": "details", + "type": "object", + "description": "What setting to change.", + "properties": { + "value": { + "description": "The value of the preference.", + "type": "any" + }, + "incognito": { + "type": "boolean", + "optional": true, + "description": "Whether to modify the setting for the incognito session only (default false)." + } + } + }, + { + "name": "callback", + "type": "function", + "description": "Called after the preference has been set.", + "optional": true, + "parameters": [] + } + ] + } + ] + } + ] + }, + { + "namespace": "experimental.contentSettings.misc", + "properties": { + "blockThirdPartyCookies": { + "$ref": "Preference", + "value": ["blockThirdPartyCookies", {"type": "boolean"}], + "description": "Whether third party cookies should be blocked. The value of this preference is of type boolean." + } + } } ] diff --git a/chrome/common/extensions/docs/experimental.contentSettings.misc.html b/chrome/common/extensions/docs/experimental.contentSettings.misc.html new file mode 100644 index 0000000..61631d8 --- /dev/null +++ b/chrome/common/extensions/docs/experimental.contentSettings.misc.html @@ -0,0 +1,574 @@ +<!DOCTYPE html><!-- This page is a placeholder for generated extensions api doc. Note: + 1) The <head> information in this page is significant, should be uniform + across api docs and should be edited only with knowledge of the + templating mechanism. + 3) All <body>.innerHTML is genereated as an rendering step. If viewed in a + browser, it will be re-generated from the template, json schema and + authored overview content. + 4) The <body>.innerHTML is also generated by an offline step so that this + page may easily be indexed by search engines. +--><html xmlns="http://www.w3.org/1999/xhtml"><head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <link href="css/ApiRefStyles.css" rel="stylesheet" type="text/css"> + <link href="css/print.css" rel="stylesheet" type="text/css" media="print"> + <script type="text/javascript" src="../../../third_party/jstemplate/jstemplate_compiled.js"> + </script> + <script type="text/javascript" src="js/api_page_generator.js"></script> + <script type="text/javascript" src="js/bootstrap.js"></script> + <script type="text/javascript" src="js/sidebar.js"></script> + <title>chrome.experimental.contentSettings.misc - Google Chrome Extensions - Google Code</title></head> + <body> <div id="gc-container" class="labs"> + <div id="devModeWarning"> + You are viewing extension docs in chrome via the 'file:' scheme: are you expecting to see local changes when you refresh? You'll need run chrome with --allow-file-access-from-files. + </div> + <!-- SUBTEMPLATES: DO NOT MOVE FROM THIS LOCATION --> + <!-- In particular, sub-templates that recurse, must be used by allowing + jstemplate to make a copy of the template in this section which + are not operated on by way of the jsskip="true" --> + <div style="display:none"> + + <!-- VALUE --> + <div id="valueTemplate"> + <dt> + <var>paramName</var> + <em> + + <!-- TYPE --> + <div style="display:inline"> + ( + <span class="optional">optional</span> + <span class="enum">enumerated</span> + <span id="typeTemplate"> + <span> + <a> Type</a> + </span> + <span> + <span> + array of <span><span></span></span> + </span> + <span>paramType</span> + <span></span> + </span> + </span> + ) + </div> + + </em> + </dt> + <dd class="todo"> + Undocumented. + </dd> + <dd> + Description of this parameter from the json schema. + </dd> + <dd> + This parameter was added in version + <b><span></span></b>. + You must omit this parameter in earlier versions, + and you may omit it in any version. If you require this + parameter, the manifest key + <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a> + can ensure that your extension won't be run in an earlier browser version. + </dd> + + <!-- OBJECT PROPERTIES --> + <dd> + <dl> + <div> + <div> + </div> + </div> + </dl> + </dd> + + <!-- OBJECT METHODS --> + <dd> + <div></div> + </dd> + + <!-- OBJECT EVENT FIELDS --> + <dd> + <div></div> + </dd> + + <!-- FUNCTION PARAMETERS --> + <dd> + <div></div> + </dd> + + </div> <!-- /VALUE --> + + <div id="functionParametersTemplate"> + <h5>Parameters</h5> + <dl> + <div> + <div> + </div> + </div> + </dl> + </div> + </div> <!-- /SUBTEMPLATES --> + + <a id="top"></a> + <div id="skipto"> + <a href="#gc-pagecontent">Skip to page content</a> + <a href="#gc-toc">Skip to main navigation</a> + </div> + <!-- API HEADER --> + <table id="header" width="100%" cellspacing="0" border="0"> + <tbody><tr> + <td valign="middle"><a href="http://code.google.com/"><img src="images/code_labs_logo.gif" height="43" width="161" alt="Google Code Labs" style="border:0; margin:0;"></a></td> + <td valign="middle" width="100%" style="padding-left:0.6em;"> + <form action="http://www.google.com/cse" id="cse" style="margin-top:0.5em"> + <div id="gsc-search-box"> + <input type="hidden" name="cx" value="002967670403910741006:61_cvzfqtno"> + <input type="hidden" name="ie" value="UTF-8"> + <input type="text" name="q" value="" size="55"> + <input class="gsc-search-button" type="submit" name="sa" value="Search"> + <br> + <span class="greytext">e.g. "page action" or "tabs"</span> + </div> + </form> + + <script type="text/javascript" src="http://www.google.com/jsapi"></script> + <script type="text/javascript">google.load("elements", "1", {packages: "transliteration"});</script> + <script type="text/javascript" src="http://www.google.com/coop/cse/t13n?form=cse&t13n_langs=en"></script> + <script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse&lang=en"></script> + </td> + </tr> + </tbody></table> + + <div id="codesiteContent" class=""> + + <a id="gc-topnav-anchor"></a> + <div id="gc-topnav"> + <h1>Google Chrome Extensions (<a href="http://code.google.com/labs/">Labs</a>)</h1> + <ul id="home" class="gc-topnav-tabs"> + <li id="home_link"> + <a href="index.html" title="Google Chrome Extensions home page">Home</a> + </li> + <li id="docs_link"> + <a href="docs.html" title="Official Google Chrome Extensions documentation">Docs</a> + </li> + <li id="faq_link"> + <a href="faq.html" title="Answers to frequently asked questions about Google Chrome Extensions">FAQ</a> + </li> + <li id="samples_link"> + <a href="samples.html" title="Sample extensions (with source code)">Samples</a> + </li> + <li id="group_link"> + <a href="http://groups.google.com/a/chromium.org/group/chromium-extensions" title="Google Chrome Extensions developer forum">Group</a> + </li> + </ul> + </div> <!-- end gc-topnav --> + + <div class="g-section g-tpl-170"> + <!-- SIDENAV --> + <div class="g-unit g-first" id="gc-toc"> + <ul> + <li><a href="getstarted.html">Getting Started</a></li> + <li><a href="overview.html">Overview</a></li> + <li><a href="whats_new.html">What's New?</a></li> + <li><h2><a href="devguide.html">Developer's Guide</a></h2> + <ul> + <li>Browser UI + <ul> + <li><a href="browserAction.html">Browser Actions</a></li> + <li><a href="contextMenus.html">Context Menus</a></li> + <li><a href="notifications.html">Desktop Notifications</a></li> + <li><a href="omnibox.html">Omnibox</a></li> + <li><a href="options.html">Options Pages</a></li> + <li><a href="override.html">Override Pages</a></li> + <li><a href="pageAction.html">Page Actions</a></li> + </ul> + </li> + <li>Browser Interaction + <ul> + <li><a href="bookmarks.html">Bookmarks</a></li> + <li><a href="cookies.html">Cookies</a></li> + <li><a href="events.html">Events</a></li> + <li><a href="history.html">History</a></li> + <li><a href="management.html">Management</a></li> + <li><a href="tabs.html">Tabs</a></li> + <li><a href="windows.html">Windows</a></li> + </ul> + </li> + <li>Implementation + <ul> + <li><a href="a11y.html">Accessibility</a></li> + <li><a href="background_pages.html">Background Pages</a></li> + <li><a href="content_scripts.html">Content Scripts</a></li> + <li><a href="xhr.html">Cross-Origin XHR</a></li> + <li><a href="idle.html">Idle</a></li> + <li><a href="i18n.html">Internationalization</a></li> + <li><a href="messaging.html">Message Passing</a></li> + <li><a href="npapi.html">NPAPI Plugins</a></li> + </ul> + </li> + <li>Finishing + <ul> + <li><a href="hosting.html">Hosting</a></li> + <li><a href="external_extensions.html">Other Deployment Options</a></li> + </ul> + </li> + </ul> + </li> + <li><h2><a href="apps.html">Packaged Apps</a></h2></li> + <li><h2><a href="tutorials.html">Tutorials</a></h2> + <ul> + <li><a href="tut_debugging.html">Debugging</a></li> + <li><a href="tut_analytics.html">Google Analytics</a></li> + <li><a href="tut_oauth.html">OAuth</a></li> + </ul> + </li> + <li><h2>Reference</h2> + <ul> + <li>Formats + <ul> + <li><a href="manifest.html">Manifest Files</a></li> + <li><a href="match_patterns.html">Match Patterns</a></li> + </ul> + </li> + <li><a href="permission_warnings.html">Permission Warnings</a></li> + <li><a href="api_index.html">chrome.* APIs</a></li> + <li><a href="api_other.html">Other APIs</a></li> + </ul> + </li> + <li><h2><a href="samples.html">Samples</a></h2></li> + <div class="line"> </div> + <li><h2>More</h2> + <ul> + <li><a href="http://code.google.com/chrome/webstore/docs/index.html">Chrome Web Store</a></li> + <li><a href="http://code.google.com/chrome/apps/docs/developers_guide.html">Hosted Apps</a></li> + <li><a href="themes.html">Themes</a></li> + </ul> + </li> + </ul> + </div> + <script> + initToggles(); + </script> + + <div class="g-unit" id="gc-pagecontent"> + <div id="pageTitle"> + <h1 class="page_title">chrome.experimental.contentSettings.misc</h1> + </div> + <!-- TABLE OF CONTENTS --> + <div id="toc"> + <h2>Contents</h2> + <ol> + <li style="display: none; "> + <a>h2Name</a> + <ol> + <li> + <a>h3Name</a> + </li> + </ol> + </li> + <li> + <a href="#apiReference">API reference: chrome.experimental.contentSettings.misc</a> + <ol> + <li> + <a href="#properties">Properties</a> + <ol> + <li> + <a href="#property-blockThirdPartyCookies">blockThirdPartyCookies</a> + </li> + </ol> + </li> + <li style="display: none; "> + <a>Methods</a> + <ol> + <li> + <a href="#method-anchor">methodName</a> + </li> + </ol> + </li> + <li style="display: none; "> + <a>Events</a> + <ol> + <li> + <a href="#event-anchor">eventName</a> + </li> + </ol> + </li> + <li style="display: none; "> + <a href="#types">Types</a> + <ol> + <li> + <a href="#id-anchor">id</a> + </li> + </ol> + </li> + </ol> + </li> + </ol> + </div> + <!-- /TABLE OF CONTENTS --> + + <!-- Standard content lead-in for experimental API pages --> + <p id="classSummary"> + For information on how to use experimental APIs, see the <a href="experimental.html">chrome.experimental.* APIs</a> page. + </p> + + <!-- STATIC CONTENT PLACEHOLDER --> + <div id="static"></div> + + <!-- API PAGE --> + <div class="apiPage"> + <a name="apiReference"></a> + <h2>API reference: chrome.experimental.contentSettings.misc</h2> + + <!-- PROPERTIES --> + <div class="apiGroup"> + <a name="properties"></a> + <h3 id="properties">Properties</h3> + + <div> + <a name="property-blockThirdPartyCookies"></a> + <h4>blockThirdPartyCookies</h4> + <div class="summary"> + <!-- Note: intentionally longer 80 columns --> + <span>chrome.experimental.contentSettings.misc.</span><span>blockThirdPartyCookies</span> + </div> + <div> + <dt> + <var>blockThirdPartyCookies</var> + <em> + + <!-- TYPE --> + <div style="display:inline"> + ( + <span class="optional" style="display: none; ">optional</span> + <span class="enum" style="display: none; ">enumerated</span> + <span id="typeTemplate"> + <span> + <a href="experimental.extension.html#type-Preference">Preference</a> + </span> + <span style="display: none; "> + <span> + array of <span><span></span></span> + </span> + <span>paramType</span> + <span></span> + </span> + </span> + ) + </div> + + </em> + </dt> + <dd class="todo" style="display: none; "> + Undocumented. + </dd> + <dd>Whether third party cookies should be blocked. The value of this preference is of type boolean.</dd> + <dd style="display: none; "> + This parameter was added in version + <b><span></span></b>. + You must omit this parameter in earlier versions, + and you may omit it in any version. If you require this + parameter, the manifest key + <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a> + can ensure that your extension won't be run in an earlier browser version. + </dd> + + <!-- OBJECT PROPERTIES --> + <dd style="display: none; "> + <dl> + <div> + <div> + </div> + </div> + </dl> + </dd> + + <!-- OBJECT METHODS --> + <dd style="display: none; "> + <div></div> + </dd> + + <!-- OBJECT EVENT FIELDS --> + <dd style="display: none; "> + <div></div> + </dd> + + <!-- FUNCTION PARAMETERS --> + <dd style="display: none; "> + <div></div> + </dd> + + </div> + </div> + + </div> <!-- /apiGroup --> + + <!-- METHODS --> + <div id="methodsTemplate" class="apiGroup" style="display: none; "> + <a></a> + <h3>Methods</h3> + + <!-- iterates over all functions --> + <div class="apiItem"> + <a></a> <!-- method-anchor --> + <h4>method name</h4> + + <div class="summary"><span>void</span> + <!-- Note: intentionally longer 80 columns --> + <span>chrome.module.methodName</span>(<span><span>, </span><span></span> + <var><span></span></var></span>)</div> + + <div class="description"> + <p class="todo">Undocumented.</p> + <p> + A description from the json schema def of the function goes here. + </p> + + <!-- PARAMETERS --> + <h4>Parameters</h4> + <dl> + <div> + <div> + </div> + </div> + </dl> + + <!-- RETURNS --> + <h4>Returns</h4> + <dl> + <div> + <div> + </div> + </div> + </dl> + + <!-- CALLBACK --> + <div> + <div> + <h4>Callback function</h4> + <p> + The callback <em>parameter</em> should specify a function + that looks like this: + </p> + <p> + If you specify the <em>callback</em> parameter, it should + specify a function that looks like this: + </p> + + <!-- Note: intentionally longer 80 columns --> + <pre>function(<span>Type param1, Type param2</span>) <span class="subdued">{...}</span>;</pre> + <dl> + <div> + <div> + </div> + </div> + </dl> + </div> + </div> + + <!-- MIN_VERSION --> + <p> + This function was added in version <b><span></span></b>. + If you require this function, the manifest key + <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a> + can ensure that your extension won't be run in an earlier browser version. + </p> + </div> <!-- /description --> + + </div> <!-- /apiItem --> + + </div> <!-- /apiGroup --> + + <!-- EVENTS --> + <div id="eventsTemplate" class="apiGroup" style="display: none; "> + <a></a> + <h3>Events</h3> + <!-- iterates over all events --> + <div class="apiItem"> + <a></a> + <h4>event name</h4> + + <div class="summary"> + <!-- Note: intentionally longer 80 columns --> + <span class="subdued">chrome.bookmarks</span><span>onEvent</span><span class="subdued">.addListener</span>(function(<span>Type param1, Type param2</span>) <span class="subdued">{...}</span>); + </div> + + <div class="description"> + <p class="todo">Undocumented.</p> + <p> + A description from the json schema def of the event goes here. + </p> + + <!-- PARAMETERS --> + <div> + <h4>Parameters</h4> + <dl> + <div> + <div> + </div> + </div> + </dl> + </div> + </div> <!-- /decription --> + + </div> <!-- /apiItem --> + + </div> <!-- /apiGroup --> + + <!-- TYPES --> + <div class="apiGroup" style="display: none; "> + <a name="types"></a> + <h3 id="types">Types</h3> + + <!-- iterates over all types --> + <div class="apiItem"> + <a></a> + <h4>type name</h4> + + <div> + </div> + + </div> <!-- /apiItem --> + + </div> <!-- /apiGroup --> + + </div> <!-- /apiPage --> + </div> <!-- /gc-pagecontent --> + </div> <!-- /g-section --> + </div> <!-- /codesiteContent --> + <div id="gc-footer" --=""> + <div class="text"> + <p> + Except as otherwise <a href="http://code.google.com/policies.html#restrictions">noted</a>, + the content of this page is licensed under the <a rel="license" href="http://creativecommons.org/licenses/by/3.0/">Creative Commons + Attribution 3.0 License</a>, and code samples are licensed under the + <a rel="license" href="http://code.google.com/google_bsd_license.html">BSD License</a>. + </p> + <p> + ©2011 Google + </p> + +<!-- begin analytics --> +<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script> +<script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script> + +<script type="text/javascript"> + // chrome doc tracking + try { + var engdocs = _gat._getTracker("YT-10763712-2"); + engdocs._trackPageview(); + } catch(err) {} + + // code.google.com site-wide tracking + try { + _uacct="UA-18071-1"; + _uanchor=1; + _uff=0; + urchinTracker(); + } + catch(e) {/* urchinTracker not available. */} +</script> +<!-- end analytics --> + </div> + </div> <!-- /gc-footer --> + </div> <!-- /gc-container --> +</body></html> diff --git a/chrome/common/extensions/docs/experimental.extension.html b/chrome/common/extensions/docs/experimental.extension.html new file mode 100644 index 0000000..d250cb1 --- /dev/null +++ b/chrome/common/extensions/docs/experimental.extension.html @@ -0,0 +1,1242 @@ +<!DOCTYPE html><!-- This page is a placeholder for generated extensions api doc. Note: + 1) The <head> information in this page is significant, should be uniform + across api docs and should be edited only with knowledge of the + templating mechanism. + 3) All <body>.innerHTML is genereated as an rendering step. If viewed in a + browser, it will be re-generated from the template, json schema and + authored overview content. + 4) The <body>.innerHTML is also generated by an offline step so that this + page may easily be indexed by search engines. +--><html xmlns="http://www.w3.org/1999/xhtml"><head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <link href="css/ApiRefStyles.css" rel="stylesheet" type="text/css"> + <link href="css/print.css" rel="stylesheet" type="text/css" media="print"> + <script type="text/javascript" src="../../../third_party/jstemplate/jstemplate_compiled.js"> + </script> + <script type="text/javascript" src="js/api_page_generator.js"></script> + <script type="text/javascript" src="js/bootstrap.js"></script> + <script type="text/javascript" src="js/sidebar.js"></script> + <title>chrome.experimental.extension - Google Chrome Extensions - Google Code</title></head> + <body> <div id="gc-container" class="labs"> + <div id="devModeWarning"> + You are viewing extension docs in chrome via the 'file:' scheme: are you expecting to see local changes when you refresh? You'll need run chrome with --allow-file-access-from-files. + </div> + <!-- SUBTEMPLATES: DO NOT MOVE FROM THIS LOCATION --> + <!-- In particular, sub-templates that recurse, must be used by allowing + jstemplate to make a copy of the template in this section which + are not operated on by way of the jsskip="true" --> + <div style="display:none"> + + <!-- VALUE --> + <div id="valueTemplate"> + <dt> + <var>paramName</var> + <em> + + <!-- TYPE --> + <div style="display:inline"> + ( + <span class="optional">optional</span> + <span class="enum">enumerated</span> + <span id="typeTemplate"> + <span> + <a> Type</a> + </span> + <span> + <span> + array of <span><span></span></span> + </span> + <span>paramType</span> + <span></span> + </span> + </span> + ) + </div> + + </em> + </dt> + <dd class="todo"> + Undocumented. + </dd> + <dd> + Description of this parameter from the json schema. + </dd> + <dd> + This parameter was added in version + <b><span></span></b>. + You must omit this parameter in earlier versions, + and you may omit it in any version. If you require this + parameter, the manifest key + <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a> + can ensure that your extension won't be run in an earlier browser version. + </dd> + + <!-- OBJECT PROPERTIES --> + <dd> + <dl> + <div> + <div> + </div> + </div> + </dl> + </dd> + + <!-- OBJECT METHODS --> + <dd> + <div></div> + </dd> + + <!-- OBJECT EVENT FIELDS --> + <dd> + <div></div> + </dd> + + <!-- FUNCTION PARAMETERS --> + <dd> + <div></div> + </dd> + + </div> <!-- /VALUE --> + + <div id="functionParametersTemplate"> + <h5>Parameters</h5> + <dl> + <div> + <div> + </div> + </div> + </dl> + </div> + </div> <!-- /SUBTEMPLATES --> + + <a id="top"></a> + <div id="skipto"> + <a href="#gc-pagecontent">Skip to page content</a> + <a href="#gc-toc">Skip to main navigation</a> + </div> + <!-- API HEADER --> + <table id="header" width="100%" cellspacing="0" border="0"> + <tbody><tr> + <td valign="middle"><a href="http://code.google.com/"><img src="images/code_labs_logo.gif" height="43" width="161" alt="Google Code Labs" style="border:0; margin:0;"></a></td> + <td valign="middle" width="100%" style="padding-left:0.6em;"> + <form action="http://www.google.com/cse" id="cse" style="margin-top:0.5em"> + <div id="gsc-search-box"> + <input type="hidden" name="cx" value="002967670403910741006:61_cvzfqtno"> + <input type="hidden" name="ie" value="UTF-8"> + <input type="text" name="q" value="" size="55"> + <input class="gsc-search-button" type="submit" name="sa" value="Search"> + <br> + <span class="greytext">e.g. "page action" or "tabs"</span> + </div> + </form> + + <script type="text/javascript" src="http://www.google.com/jsapi"></script> + <script type="text/javascript">google.load("elements", "1", {packages: "transliteration"});</script> + <script type="text/javascript" src="http://www.google.com/coop/cse/t13n?form=cse&t13n_langs=en"></script> + <script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse&lang=en"></script> + </td> + </tr> + </tbody></table> + + <div id="codesiteContent" class=""> + + <a id="gc-topnav-anchor"></a> + <div id="gc-topnav"> + <h1>Google Chrome Extensions (<a href="http://code.google.com/labs/">Labs</a>)</h1> + <ul id="home" class="gc-topnav-tabs"> + <li id="home_link"> + <a href="index.html" title="Google Chrome Extensions home page">Home</a> + </li> + <li id="docs_link"> + <a href="docs.html" title="Official Google Chrome Extensions documentation">Docs</a> + </li> + <li id="faq_link"> + <a href="faq.html" title="Answers to frequently asked questions about Google Chrome Extensions">FAQ</a> + </li> + <li id="samples_link"> + <a href="samples.html" title="Sample extensions (with source code)">Samples</a> + </li> + <li id="group_link"> + <a href="http://groups.google.com/a/chromium.org/group/chromium-extensions" title="Google Chrome Extensions developer forum">Group</a> + </li> + </ul> + </div> <!-- end gc-topnav --> + + <div class="g-section g-tpl-170"> + <!-- SIDENAV --> + <div class="g-unit g-first" id="gc-toc"> + <ul> + <li><a href="getstarted.html">Getting Started</a></li> + <li><a href="overview.html">Overview</a></li> + <li><a href="whats_new.html">What's New?</a></li> + <li><h2><a href="devguide.html">Developer's Guide</a></h2> + <ul> + <li>Browser UI + <ul> + <li><a href="browserAction.html">Browser Actions</a></li> + <li><a href="contextMenus.html">Context Menus</a></li> + <li><a href="notifications.html">Desktop Notifications</a></li> + <li><a href="omnibox.html">Omnibox</a></li> + <li><a href="options.html">Options Pages</a></li> + <li><a href="override.html">Override Pages</a></li> + <li><a href="pageAction.html">Page Actions</a></li> + </ul> + </li> + <li>Browser Interaction + <ul> + <li><a href="bookmarks.html">Bookmarks</a></li> + <li><a href="cookies.html">Cookies</a></li> + <li><a href="events.html">Events</a></li> + <li><a href="history.html">History</a></li> + <li><a href="management.html">Management</a></li> + <li><a href="tabs.html">Tabs</a></li> + <li><a href="windows.html">Windows</a></li> + </ul> + </li> + <li>Implementation + <ul> + <li><a href="a11y.html">Accessibility</a></li> + <li><a href="background_pages.html">Background Pages</a></li> + <li><a href="content_scripts.html">Content Scripts</a></li> + <li><a href="xhr.html">Cross-Origin XHR</a></li> + <li><a href="idle.html">Idle</a></li> + <li><a href="i18n.html">Internationalization</a></li> + <li><a href="messaging.html">Message Passing</a></li> + <li><a href="npapi.html">NPAPI Plugins</a></li> + </ul> + </li> + <li>Finishing + <ul> + <li><a href="hosting.html">Hosting</a></li> + <li><a href="external_extensions.html">Other Deployment Options</a></li> + </ul> + </li> + </ul> + </li> + <li><h2><a href="apps.html">Packaged Apps</a></h2></li> + <li><h2><a href="tutorials.html">Tutorials</a></h2> + <ul> + <li><a href="tut_debugging.html">Debugging</a></li> + <li><a href="tut_analytics.html">Google Analytics</a></li> + <li><a href="tut_oauth.html">OAuth</a></li> + </ul> + </li> + <li><h2>Reference</h2> + <ul> + <li>Formats + <ul> + <li><a href="manifest.html">Manifest Files</a></li> + <li><a href="match_patterns.html">Match Patterns</a></li> + </ul> + </li> + <li><a href="permission_warnings.html">Permission Warnings</a></li> + <li><a href="api_index.html">chrome.* APIs</a></li> + <li><a href="api_other.html">Other APIs</a></li> + </ul> + </li> + <li><h2><a href="samples.html">Samples</a></h2></li> + <div class="line"> </div> + <li><h2>More</h2> + <ul> + <li><a href="http://code.google.com/chrome/webstore/docs/index.html">Chrome Web Store</a></li> + <li><a href="http://code.google.com/chrome/apps/docs/developers_guide.html">Hosted Apps</a></li> + <li><a href="themes.html">Themes</a></li> + </ul> + </li> + </ul> + </div> + <script> + initToggles(); + </script> + + <div class="g-unit" id="gc-pagecontent"> + <div id="pageTitle"> + <h1 class="page_title">chrome.experimental.extension</h1> + </div> + <!-- TABLE OF CONTENTS --> + <div id="toc"> + <h2>Contents</h2> + <ol> + <li style="display: none; "> + <a>h2Name</a> + <ol> + <li> + <a>h3Name</a> + </li> + </ol> + </li> + <li> + <a href="#apiReference">API reference: chrome.experimental.extension</a> + <ol> + <li style="display: none; "> + <a href="#properties">Properties</a> + <ol> + <li> + <a href="#property-anchor">propertyName</a> + </li> + </ol> + </li> + <li style="display: none; "> + <a>Methods</a> + <ol> + <li> + <a href="#method-anchor">methodName</a> + </li> + </ol> + </li> + <li style="display: none; "> + <a>Events</a> + <ol> + <li> + <a href="#event-anchor">eventName</a> + </li> + </ol> + </li> + <li> + <a href="#types">Types</a> + <ol> + <li> + <a href="#type-Preference">Preference</a> + </li> + </ol> + </li> + </ol> + </li> + </ol> + </div> + <!-- /TABLE OF CONTENTS --> + + <!-- Standard content lead-in for experimental API pages --> + <p id="classSummary"> + For information on how to use experimental APIs, see the <a href="experimental.html">chrome.experimental.* APIs</a> page. + </p> + + <!-- STATIC CONTENT PLACEHOLDER --> + <div id="static"></div> + + <!-- API PAGE --> + <div class="apiPage"> + <a name="apiReference"></a> + <h2>API reference: chrome.experimental.extension</h2> + + <!-- PROPERTIES --> + <div class="apiGroup" style="display: none; "> + <a name="properties"></a> + <h3 id="properties">Properties</h3> + + <div> + <a></a> + <h4>getLastError</h4> + <div class="summary"> + <!-- Note: intentionally longer 80 columns --> + <span>chrome.extension</span><span>lastError</span> + </div> + <div> + </div> + </div> + + </div> <!-- /apiGroup --> + + <!-- METHODS --> + <div id="methodsTemplate" class="apiGroup" style="display: none; "> + <a></a> + <h3>Methods</h3> + + <!-- iterates over all functions --> + <div class="apiItem"> + <a></a> <!-- method-anchor --> + <h4>method name</h4> + + <div class="summary"><span>void</span> + <!-- Note: intentionally longer 80 columns --> + <span>chrome.module.methodName</span>(<span><span>, </span><span></span> + <var><span></span></var></span>)</div> + + <div class="description"> + <p class="todo">Undocumented.</p> + <p> + A description from the json schema def of the function goes here. + </p> + + <!-- PARAMETERS --> + <h4>Parameters</h4> + <dl> + <div> + <div> + </div> + </div> + </dl> + + <!-- RETURNS --> + <h4>Returns</h4> + <dl> + <div> + <div> + </div> + </div> + </dl> + + <!-- CALLBACK --> + <div> + <div> + <h4>Callback function</h4> + <p> + The callback <em>parameter</em> should specify a function + that looks like this: + </p> + <p> + If you specify the <em>callback</em> parameter, it should + specify a function that looks like this: + </p> + + <!-- Note: intentionally longer 80 columns --> + <pre>function(<span>Type param1, Type param2</span>) <span class="subdued">{...}</span>;</pre> + <dl> + <div> + <div> + </div> + </div> + </dl> + </div> + </div> + + <!-- MIN_VERSION --> + <p> + This function was added in version <b><span></span></b>. + If you require this function, the manifest key + <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a> + can ensure that your extension won't be run in an earlier browser version. + </p> + </div> <!-- /description --> + + </div> <!-- /apiItem --> + + </div> <!-- /apiGroup --> + + <!-- EVENTS --> + <div id="eventsTemplate" class="apiGroup" style="display: none; "> + <a></a> + <h3>Events</h3> + <!-- iterates over all events --> + <div class="apiItem"> + <a></a> + <h4>event name</h4> + + <div class="summary"> + <!-- Note: intentionally longer 80 columns --> + <span class="subdued">chrome.bookmarks</span><span>onEvent</span><span class="subdued">.addListener</span>(function(<span>Type param1, Type param2</span>) <span class="subdued">{...}</span>); + </div> + + <div class="description"> + <p class="todo">Undocumented.</p> + <p> + A description from the json schema def of the event goes here. + </p> + + <!-- PARAMETERS --> + <div> + <h4>Parameters</h4> + <dl> + <div> + <div> + </div> + </div> + </dl> + </div> + </div> <!-- /decription --> + + </div> <!-- /apiItem --> + + </div> <!-- /apiGroup --> + + <!-- TYPES --> + <div class="apiGroup"> + <a name="types"></a> + <h3 id="types">Types</h3> + + <!-- iterates over all types --> + <div class="apiItem"> + <a name="type-Preference"></a> + <h4>Preference</h4> + + <div> + <dt> + <var style="display: none; ">paramName</var> + <em> + + <!-- TYPE --> + <div style="display:inline"> + ( + <span class="optional" style="display: none; ">optional</span> + <span class="enum" style="display: none; ">enumerated</span> + <span id="typeTemplate"> + <span style="display: none; "> + <a> Type</a> + </span> + <span> + <span style="display: none; "> + array of <span><span></span></span> + </span> + <span>object</span> + <span style="display: none; "></span> + </span> + </span> + ) + </div> + + </em> + </dt> + <dd class="todo" style="display: none; "> + Undocumented. + </dd> + <dd>An object which allows access to a preference.</dd> + <dd style="display: none; "> + This parameter was added in version + <b><span></span></b>. + You must omit this parameter in earlier versions, + and you may omit it in any version. If you require this + parameter, the manifest key + <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a> + can ensure that your extension won't be run in an earlier browser version. + </dd> + + <!-- OBJECT PROPERTIES --> + <dd style="display: none; "> + <dl> + <div> + <div> + </div> + </div> + </dl> + </dd> + + <!-- OBJECT METHODS --> + <dd> + <div class="apiGroup" style=""> + <a name="global-Preference-methods"></a> + <h3>Methods of Preference</h3> + + <!-- iterates over all functions --> + <div class="apiItem"> + <a name="method-Preference-get"></a> <!-- method-anchor --> + <h4>get</h4> + + <div class="summary"><span style="display: none; ">void</span> + <!-- Note: intentionally longer 80 columns --> + <span>preference.get</span>(<span class="null"><span style="display: none; ">, </span><span>object</span> + <var><span>details</span></var></span><span class="null"><span>, </span><span>function</span> + <var><span>callback</span></var></span>)</div> + + <div class="description"> + <p class="todo" style="display: none; ">Undocumented.</p> + <p>Get the setting from the user preferences.</p> + + <!-- PARAMETERS --> + <h4>Parameters</h4> + <dl> + <div> + <div> + <dt> + <var>details</var> + <em> + + <!-- TYPE --> + <div style="display:inline"> + ( + <span class="optional" style="display: none; ">optional</span> + <span class="enum" style="display: none; ">enumerated</span> + <span id="typeTemplate"> + <span style="display: none; "> + <a> Type</a> + </span> + <span> + <span style="display: none; "> + array of <span><span></span></span> + </span> + <span>object</span> + <span style="display: none; "></span> + </span> + </span> + ) + </div> + + </em> + </dt> + <dd class="todo" style="display: none; "> + Undocumented. + </dd> + <dd>What setting to return.</dd> + <dd style="display: none; "> + This parameter was added in version + <b><span></span></b>. + You must omit this parameter in earlier versions, + and you may omit it in any version. If you require this + parameter, the manifest key + <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a> + can ensure that your extension won't be run in an earlier browser version. + </dd> + + <!-- OBJECT PROPERTIES --> + <dd> + <dl> + <div> + <div> + <dt> + <var>incognito</var> + <em> + + <!-- TYPE --> + <div style="display:inline"> + ( + <span class="optional">optional</span> + <span class="enum" style="display: none; ">enumerated</span> + <span id="typeTemplate"> + <span style="display: none; "> + <a> Type</a> + </span> + <span> + <span style="display: none; "> + array of <span><span></span></span> + </span> + <span>boolean</span> + <span style="display: none; "></span> + </span> + </span> + ) + </div> + + </em> + </dt> + <dd class="todo" style="display: none; "> + Undocumented. + </dd> + <dd>Whether to return the setting that applies to the incognito session only (default false).</dd> + <dd style="display: none; "> + This parameter was added in version + <b><span></span></b>. + You must omit this parameter in earlier versions, + and you may omit it in any version. If you require this + parameter, the manifest key + <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a> + can ensure that your extension won't be run in an earlier browser version. + </dd> + + <!-- OBJECT PROPERTIES --> + <dd style="display: none; "> + <dl> + <div> + <div> + </div> + </div> + </dl> + </dd> + + <!-- OBJECT METHODS --> + <dd style="display: none; "> + <div></div> + </dd> + + <!-- OBJECT EVENT FIELDS --> + <dd style="display: none; "> + <div></div> + </dd> + + <!-- FUNCTION PARAMETERS --> + <dd style="display: none; "> + <div></div> + </dd> + + </div> + </div> + </dl> + </dd> + + <!-- OBJECT METHODS --> + <dd style="display: none; "> + <div></div> + </dd> + + <!-- OBJECT EVENT FIELDS --> + <dd style="display: none; "> + <div></div> + </dd> + + <!-- FUNCTION PARAMETERS --> + <dd style="display: none; "> + <div></div> + </dd> + + </div> + </div><div> + <div> + <dt> + <var>callback</var> + <em> + + <!-- TYPE --> + <div style="display:inline"> + ( + <span class="optional" style="display: none; ">optional</span> + <span class="enum" style="display: none; ">enumerated</span> + <span id="typeTemplate"> + <span style="display: none; "> + <a> Type</a> + </span> + <span> + <span style="display: none; "> + array of <span><span></span></span> + </span> + <span>function</span> + <span style="display: none; "></span> + </span> + </span> + ) + </div> + + </em> + </dt> + <dd class="todo"> + Undocumented. + </dd> + <dd style="display: none; "> + Description of this parameter from the json schema. + </dd> + <dd style="display: none; "> + This parameter was added in version + <b><span></span></b>. + You must omit this parameter in earlier versions, + and you may omit it in any version. If you require this + parameter, the manifest key + <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a> + can ensure that your extension won't be run in an earlier browser version. + </dd> + + <!-- OBJECT PROPERTIES --> + <dd style="display: none; "> + <dl> + <div> + <div> + </div> + </div> + </dl> + </dd> + + <!-- OBJECT METHODS --> + <dd style="display: none; "> + <div></div> + </dd> + + <!-- OBJECT EVENT FIELDS --> + <dd style="display: none; "> + <div></div> + </dd> + + <!-- FUNCTION PARAMETERS --> + <dd style="display: none; "> + <div></div> + </dd> + + </div> + </div> + </dl> + + <!-- RETURNS --> + <h4 style="display: none; ">Returns</h4> + <dl> + <div style="display: none; "> + <div> + </div> + </div> + </dl> + + <!-- CALLBACK --> + <div> + <div> + <h4>Callback function</h4> + <p> + The callback <em>parameter</em> should specify a function + that looks like this: + </p> + <p style="display: none; "> + If you specify the <em>callback</em> parameter, it should + specify a function that looks like this: + </p> + + <!-- Note: intentionally longer 80 columns --> + <pre>function(<span>any value</span>) <span class="subdued">{...}</span>;</pre> + <dl> + <div> + <div> + <dt> + <var>value</var> + <em> + + <!-- TYPE --> + <div style="display:inline"> + ( + <span class="optional" style="display: none; ">optional</span> + <span class="enum" style="display: none; ">enumerated</span> + <span id="typeTemplate"> + <span style="display: none; "> + <a> Type</a> + </span> + <span> + <span style="display: none; "> + array of <span><span></span></span> + </span> + <span>any</span> + <span style="display: none; "></span> + </span> + </span> + ) + </div> + + </em> + </dt> + <dd class="todo" style="display: none; "> + Undocumented. + </dd> + <dd>The value of the preference.</dd> + <dd style="display: none; "> + This parameter was added in version + <b><span></span></b>. + You must omit this parameter in earlier versions, + and you may omit it in any version. If you require this + parameter, the manifest key + <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a> + can ensure that your extension won't be run in an earlier browser version. + </dd> + + <!-- OBJECT PROPERTIES --> + <dd style="display: none; "> + <dl> + <div> + <div> + </div> + </div> + </dl> + </dd> + + <!-- OBJECT METHODS --> + <dd style="display: none; "> + <div></div> + </dd> + + <!-- OBJECT EVENT FIELDS --> + <dd style="display: none; "> + <div></div> + </dd> + + <!-- FUNCTION PARAMETERS --> + <dd style="display: none; "> + <div></div> + </dd> + + </div> + </div> + </dl> + </div> + </div> + + <!-- MIN_VERSION --> + <p style="display: none; "> + This function was added in version <b><span></span></b>. + If you require this function, the manifest key + <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a> + can ensure that your extension won't be run in an earlier browser version. + </p> + </div> <!-- /description --> + + </div><div class="apiItem"> + <a name="method-Preference-set"></a> <!-- method-anchor --> + <h4>set</h4> + + <div class="summary"><span style="display: none; ">void</span> + <!-- Note: intentionally longer 80 columns --> + <span>preference.set</span>(<span class="null"><span style="display: none; ">, </span><span>object</span> + <var><span>details</span></var></span><span class="optional"><span>, </span><span>function</span> + <var><span>callback</span></var></span>)</div> + + <div class="description"> + <p class="todo" style="display: none; ">Undocumented.</p> + <p>Set the setting in the user preferences</p> + + <!-- PARAMETERS --> + <h4>Parameters</h4> + <dl> + <div> + <div> + <dt> + <var>details</var> + <em> + + <!-- TYPE --> + <div style="display:inline"> + ( + <span class="optional" style="display: none; ">optional</span> + <span class="enum" style="display: none; ">enumerated</span> + <span id="typeTemplate"> + <span style="display: none; "> + <a> Type</a> + </span> + <span> + <span style="display: none; "> + array of <span><span></span></span> + </span> + <span>object</span> + <span style="display: none; "></span> + </span> + </span> + ) + </div> + + </em> + </dt> + <dd class="todo" style="display: none; "> + Undocumented. + </dd> + <dd>What setting to change.</dd> + <dd style="display: none; "> + This parameter was added in version + <b><span></span></b>. + You must omit this parameter in earlier versions, + and you may omit it in any version. If you require this + parameter, the manifest key + <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a> + can ensure that your extension won't be run in an earlier browser version. + </dd> + + <!-- OBJECT PROPERTIES --> + <dd> + <dl> + <div> + <div> + <dt> + <var>value</var> + <em> + + <!-- TYPE --> + <div style="display:inline"> + ( + <span class="optional" style="display: none; ">optional</span> + <span class="enum" style="display: none; ">enumerated</span> + <span id="typeTemplate"> + <span style="display: none; "> + <a> Type</a> + </span> + <span> + <span style="display: none; "> + array of <span><span></span></span> + </span> + <span>any</span> + <span style="display: none; "></span> + </span> + </span> + ) + </div> + + </em> + </dt> + <dd class="todo" style="display: none; "> + Undocumented. + </dd> + <dd>The value of the preference.</dd> + <dd style="display: none; "> + This parameter was added in version + <b><span></span></b>. + You must omit this parameter in earlier versions, + and you may omit it in any version. If you require this + parameter, the manifest key + <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a> + can ensure that your extension won't be run in an earlier browser version. + </dd> + + <!-- OBJECT PROPERTIES --> + <dd style="display: none; "> + <dl> + <div> + <div> + </div> + </div> + </dl> + </dd> + + <!-- OBJECT METHODS --> + <dd style="display: none; "> + <div></div> + </dd> + + <!-- OBJECT EVENT FIELDS --> + <dd style="display: none; "> + <div></div> + </dd> + + <!-- FUNCTION PARAMETERS --> + <dd style="display: none; "> + <div></div> + </dd> + + </div> + </div><div> + <div> + <dt> + <var>incognito</var> + <em> + + <!-- TYPE --> + <div style="display:inline"> + ( + <span class="optional">optional</span> + <span class="enum" style="display: none; ">enumerated</span> + <span id="typeTemplate"> + <span style="display: none; "> + <a> Type</a> + </span> + <span> + <span style="display: none; "> + array of <span><span></span></span> + </span> + <span>boolean</span> + <span style="display: none; "></span> + </span> + </span> + ) + </div> + + </em> + </dt> + <dd class="todo" style="display: none; "> + Undocumented. + </dd> + <dd>Whether to modify the setting for the incognito session only (default false).</dd> + <dd style="display: none; "> + This parameter was added in version + <b><span></span></b>. + You must omit this parameter in earlier versions, + and you may omit it in any version. If you require this + parameter, the manifest key + <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a> + can ensure that your extension won't be run in an earlier browser version. + </dd> + + <!-- OBJECT PROPERTIES --> + <dd style="display: none; "> + <dl> + <div> + <div> + </div> + </div> + </dl> + </dd> + + <!-- OBJECT METHODS --> + <dd style="display: none; "> + <div></div> + </dd> + + <!-- OBJECT EVENT FIELDS --> + <dd style="display: none; "> + <div></div> + </dd> + + <!-- FUNCTION PARAMETERS --> + <dd style="display: none; "> + <div></div> + </dd> + + </div> + </div> + </dl> + </dd> + + <!-- OBJECT METHODS --> + <dd style="display: none; "> + <div></div> + </dd> + + <!-- OBJECT EVENT FIELDS --> + <dd style="display: none; "> + <div></div> + </dd> + + <!-- FUNCTION PARAMETERS --> + <dd style="display: none; "> + <div></div> + </dd> + + </div> + </div><div> + <div> + <dt> + <var>callback</var> + <em> + + <!-- TYPE --> + <div style="display:inline"> + ( + <span class="optional">optional</span> + <span class="enum" style="display: none; ">enumerated</span> + <span id="typeTemplate"> + <span style="display: none; "> + <a> Type</a> + </span> + <span> + <span style="display: none; "> + array of <span><span></span></span> + </span> + <span>function</span> + <span style="display: none; "></span> + </span> + </span> + ) + </div> + + </em> + </dt> + <dd class="todo" style="display: none; "> + Undocumented. + </dd> + <dd>Called after the preference has been set.</dd> + <dd style="display: none; "> + This parameter was added in version + <b><span></span></b>. + You must omit this parameter in earlier versions, + and you may omit it in any version. If you require this + parameter, the manifest key + <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a> + can ensure that your extension won't be run in an earlier browser version. + </dd> + + <!-- OBJECT PROPERTIES --> + <dd style="display: none; "> + <dl> + <div> + <div> + </div> + </div> + </dl> + </dd> + + <!-- OBJECT METHODS --> + <dd style="display: none; "> + <div></div> + </dd> + + <!-- OBJECT EVENT FIELDS --> + <dd style="display: none; "> + <div></div> + </dd> + + <!-- FUNCTION PARAMETERS --> + <dd style="display: none; "> + <div></div> + </dd> + + </div> + </div> + </dl> + + <!-- RETURNS --> + <h4 style="display: none; ">Returns</h4> + <dl> + <div style="display: none; "> + <div> + </div> + </div> + </dl> + + <!-- CALLBACK --> + <div> + <div> + <h4>Callback function</h4> + <p style="display: none; "> + The callback <em>parameter</em> should specify a function + that looks like this: + </p> + <p> + If you specify the <em>callback</em> parameter, it should + specify a function that looks like this: + </p> + + <!-- Note: intentionally longer 80 columns --> + <pre>function(<span></span>) <span class="subdued">{...}</span>;</pre> + <dl> + <div style="display: none; "> + <div> + </div> + </div> + </dl> + </div> + </div> + + <!-- MIN_VERSION --> + <p style="display: none; "> + This function was added in version <b><span></span></b>. + If you require this function, the manifest key + <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a> + can ensure that your extension won't be run in an earlier browser version. + </p> + </div> <!-- /description --> + + </div> <!-- /apiItem --> + + </div> + </dd> + + <!-- OBJECT EVENT FIELDS --> + <dd style="display: none; "> + <div></div> + </dd> + + <!-- FUNCTION PARAMETERS --> + <dd style="display: none; "> + <div></div> + </dd> + + </div> + + </div> <!-- /apiItem --> + + </div> <!-- /apiGroup --> + + </div> <!-- /apiPage --> + </div> <!-- /gc-pagecontent --> + </div> <!-- /g-section --> + </div> <!-- /codesiteContent --> + <div id="gc-footer" --=""> + <div class="text"> + <p> + Except as otherwise <a href="http://code.google.com/policies.html#restrictions">noted</a>, + the content of this page is licensed under the <a rel="license" href="http://creativecommons.org/licenses/by/3.0/">Creative Commons + Attribution 3.0 License</a>, and code samples are licensed under the + <a rel="license" href="http://code.google.com/google_bsd_license.html">BSD License</a>. + </p> + <p> + ©2011 Google + </p> + +<!-- begin analytics --> +<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script> +<script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script> + +<script type="text/javascript"> + // chrome doc tracking + try { + var engdocs = _gat._getTracker("YT-10763712-2"); + engdocs._trackPageview(); + } catch(err) {} + + // code.google.com site-wide tracking + try { + _uacct="UA-18071-1"; + _uanchor=1; + _uff=0; + urchinTracker(); + } + catch(e) {/* urchinTracker not available. */} +</script> +<!-- end analytics --> + </div> + </div> <!-- /gc-footer --> + </div> <!-- /gc-container --> +</body></html> diff --git a/chrome/common/extensions/docs/experimental.html b/chrome/common/extensions/docs/experimental.html index 80a6919..aeaf6c5 100644 --- a/chrome/common/extensions/docs/experimental.html +++ b/chrome/common/extensions/docs/experimental.html @@ -322,6 +322,8 @@ on the following experimental APIs: <ul> <li> <a href="experimental.clipboard.html">experimental.clipboard</a></li><li> + <a href="experimental.contentSettings.misc.html">experimental.contentSettings.misc</a></li><li> + <a href="experimental.extension.html">experimental.extension</a></li><li> <a href="experimental.infobars.html">experimental.infobars</a></li><li> <a href="experimental.processes.html">experimental.processes</a></li><li> <a href="experimental.proxy.html">experimental.proxy</a></li><li> diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc index 1b820c5..eecf6a9 100644 --- a/chrome/common/extensions/extension.cc +++ b/chrome/common/extensions/extension.cc @@ -201,8 +201,9 @@ const int Extension::kSidebarIconMaxSize = 16; // Explicit permissions -- permission declaration required. const char Extension::kBackgroundPermission[] = "background"; -const char Extension::kContextMenusPermission[] = "contextMenus"; const char Extension::kBookmarkPermission[] = "bookmarks"; +const char Extension::kContextMenusPermission[] = "contextMenus"; +const char Extension::kContentSettingsPermission[] = "contentSettings"; const char Extension::kCookiePermission[] = "cookies"; const char Extension::kExperimentalPermission[] = "experimental"; const char Extension::kGeolocationPermission[] = "geolocation"; @@ -221,6 +222,7 @@ const char Extension::kWebstorePrivatePermission[] = "webstorePrivate"; const Extension::Permission Extension::kPermissions[] = { { kBackgroundPermission, 0 }, { kBookmarkPermission, IDS_EXTENSION_PROMPT_WARNING_BOOKMARKS }, + { kContentSettingsPermission, 0 }, { kContextMenusPermission, 0 }, { kCookiePermission, 0 }, { kExperimentalPermission, 0 }, diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h index 9eb1d65..772d72c 100644 --- a/chrome/common/extensions/extension.h +++ b/chrome/common/extensions/extension.h @@ -160,6 +160,7 @@ class Extension : public base::RefCountedThreadSafe<Extension> { // Extension::kPermissions. static const char kBackgroundPermission[]; static const char kBookmarkPermission[]; + static const char kContentSettingsPermission[]; static const char kContextMenusPermission[]; static const char kCookiePermission[]; static const char kExperimentalPermission[]; diff --git a/chrome/common/extensions/extension_unittest.cc b/chrome/common/extensions/extension_unittest.cc index 817062c..92d60fd 100644 --- a/chrome/common/extensions/extension_unittest.cc +++ b/chrome/common/extensions/extension_unittest.cc @@ -920,6 +920,7 @@ TEST(ExtensionTest, PermissionMessages) { skip.insert(Extension::kIdlePermission); skip.insert(Extension::kNotificationPermission); skip.insert(Extension::kUnlimitedStoragePermission); + skip.insert(Extension::kContentSettingsPermission); // TODO(erikkay) add a string for this permission. skip.insert(Extension::kBackgroundPermission); diff --git a/chrome/renderer/resources/extension_process_bindings.js b/chrome/renderer/resources/extension_process_bindings.js index d6e08fe..94accee 100644 --- a/chrome/renderer/resources/extension_process_bindings.js +++ b/chrome/renderer/resources/extension_process_bindings.js @@ -38,6 +38,13 @@ var chrome = chrome || {}; if (!chrome) chrome = {}; + function forEach(dict, f) { + for (key in dict) { + if (dict.hasOwnProperty(key)) + f(key, dict[key]); + } + } + // Validate arguments. chromeHidden.validationTypes = []; chromeHidden.validate = function(args, schemas) { @@ -292,6 +299,49 @@ var chrome = chrome || {}; return -1; }; + function CustomBindingsObject() { + } + CustomBindingsObject.prototype.setSchema = function(schema) { + // The functions in the schema are in list form, so we move them into a + // dictionary for easier access. + var self = this; + self.parameters = {}; + schema.functions.forEach(function(f) { + self.parameters[f.name] = f.parameters; + }); + }; + + function extendSchema(schema) { + var extendedSchema = schema.slice(); + extendedSchema.unshift({'type': 'string'}); + return extendedSchema; + } + + var customBindings = {}; + + function setupPreferences() { + customBindings['Preference'] = function(prefKey, valueSchema) { + var getSchema = this.parameters.get; + var extendedGetSchema = extendSchema(getSchema); + this.get = function(details, callback) { + chromeHidden.validate([details, callback], getSchema); + return sendRequest('experimental.preferences.get', + [prefKey, details, callback], + extendedGetSchema); + }; + var setSchema = this.parameters.set.slice(); + setSchema[0].properties.value = valueSchema; + var extendedSetSchema = extendSchema(setSchema); + this.set = function(details, callback) { + chromeHidden.validate([details, callback], setSchema); + return sendRequest('experimental.preferences.set', + [prefKey, details, callback], + extendedSetSchema); + }; + }; + customBindings['Preference'].prototype = new CustomBindingsObject(); + } + // Page action events send (pageActionId, {tabId, tabUrl}). function setupPageActionEvents(extensionId) { var pageActions = GetCurrentPageActions(extensionId); @@ -422,6 +472,10 @@ var chrome = chrome || {}; } chrome.initExtension(extensionId, false, IsIncognitoProcess()); + // Setup the Preference class so we can use it to construct Preference + // objects from the API definition. + setupPreferences(); + // |apiFunctions| is a hash of name -> object that stores the // name & definition of the apiFunction. Custom handling of api functions // is implemented by adding a "handleRequest" function to the object. @@ -447,6 +501,9 @@ var chrome = chrome || {}; if (apiDef.types) { apiDef.types.forEach(function(t) { chromeHidden.validationTypes.push(t); + if (t.type == 'object' && customBindings[t.id]) { + customBindings[t.id].prototype.setSchema(t); + } }); } @@ -514,24 +571,29 @@ var chrome = chrome || {}; // Parse any values defined for properties. if (apiDef.properties) { - for (var prop in apiDef.properties) { - if (!apiDef.properties.hasOwnProperty(prop)) - continue; - - var property = apiDef.properties[prop]; + forEach(apiDef.properties, function(prop, property) { if (property.value) { var value = property.value; if (property.type === 'integer') { value = parseInt(value); } else if (property.type === 'boolean') { value = value === "true"; + } else if (property["$ref"]) { + var constructor = customBindings[property["$ref"]]; + var args = value; + // For an object property, |value| is an array of constructor + // arguments, but we want to pass the arguments directly + // (i.e. not as an array), so we have to fake calling |new| on the + // constructor. + value = { __proto__: constructor.prototype }; + constructor.apply(value, args); } else if (property.type !== 'string') { throw "NOT IMPLEMENTED (extension_api.json error): Cannot " + "parse values for type \"" + property.type + "\""; } module[prop] = value; } - } + }); } // getTabContentses is retained for backwards compatibility diff --git a/chrome/renderer/resources/renderer_extension_bindings.js b/chrome/renderer/resources/renderer_extension_bindings.js index a7b25e5..9f6ecb3 100644 --- a/chrome/renderer/resources/renderer_extension_bindings.js +++ b/chrome/renderer/resources/renderer_extension_bindings.js @@ -275,6 +275,7 @@ var chrome = chrome || {}; "experimental.accessibility", "experimental.bookmarkManager", "experimental.clipboard", + "experimental.contentSettings.misc", "experimental.extension", "experimental.infobars", "experimental.input", diff --git a/chrome/test/data/extensions/api_test/content_settings/incognito/manifest.json b/chrome/test/data/extensions/api_test/content_settings/incognito/manifest.json new file mode 100644 index 0000000..d91bfc1 --- /dev/null +++ b/chrome/test/data/extensions/api_test/content_settings/incognito/manifest.json @@ -0,0 +1,7 @@ +{
+ "name" : "Content Settings API Test Extension",
+ "version" : "0.1",
+ "description" : "Content Settings API Test Extension",
+ "permissions": [ "experimental", "contentSettings" ],
+ "background_page": "test.html"
+}
diff --git a/chrome/test/data/extensions/api_test/content_settings/incognito/test.html b/chrome/test/data/extensions/api_test/content_settings/incognito/test.html new file mode 100644 index 0000000..e16d765 --- /dev/null +++ b/chrome/test/data/extensions/api_test/content_settings/incognito/test.html @@ -0,0 +1,29 @@ +<script>
+// Content settings API test
+// Run with browser_tests --gtest_filter=ExtensionApiTest.ContentSettings
+
+var cs = chrome.experimental.contentSettings;
+function expect(expected, message) {
+ return chrome.test.callbackPass(function(value) {
+ chrome.test.assertBool(value, expected, message);
+ });
+}
+chrome.test.runTests([
+ function testIncognito() {
+ cs.misc.blockThirdPartyCookies.get(
+ {}, expect(false, "third-party cookies should not be blocked"));
+ cs.misc.blockThirdPartyCookies.get(
+ { 'incognito': true },
+ expect(false,
+ "third-party cookies should not be blocked in incognito mode"));
+ cs.misc.blockThirdPartyCookies.set(
+ { 'incognito': true, 'value': true }, chrome.test.callbackPass());
+ cs.misc.blockThirdPartyCookies.get(
+ {}, expect(false, "third-party cookies should not be blocked"));
+ cs.misc.blockThirdPartyCookies.get(
+ { 'incognito': true },
+ expect(true,
+ "third-party cookies should be blocked in incognito mode"));
+ },
+]);
+</script>
diff --git a/chrome/test/data/extensions/api_test/content_settings/standard/manifest.json b/chrome/test/data/extensions/api_test/content_settings/standard/manifest.json new file mode 100644 index 0000000..d91bfc1 --- /dev/null +++ b/chrome/test/data/extensions/api_test/content_settings/standard/manifest.json @@ -0,0 +1,7 @@ +{
+ "name" : "Content Settings API Test Extension",
+ "version" : "0.1",
+ "description" : "Content Settings API Test Extension",
+ "permissions": [ "experimental", "contentSettings" ],
+ "background_page": "test.html"
+}
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 new file mode 100644 index 0000000..408415c --- /dev/null +++ b/chrome/test/data/extensions/api_test/content_settings/standard/test.html @@ -0,0 +1,20 @@ +<script>
+// Content settings API test
+// Run with browser_tests --gtest_filter=ExtensionApiTest.ContentSettings
+
+var cs = chrome.experimental.contentSettings;
+chrome.test.runTests([
+ function getBlockThirdPartyCookies() {
+ cs.misc.blockThirdPartyCookies.get({}, chrome.test.callbackPass(
+ function(block) {
+ chrome.test.assertBool(block, true,
+ "third-party cookies should be blocked");
+ }));
+ },
+ function setBlockThirdPartyCookies() {
+ cs.misc.blockThirdPartyCookies.set(
+ {'value': false},
+ chrome.test.callbackPass());
+ }
+]);
+</script>
diff --git a/chrome/test/data/extensions/api_test/stubs/content_script.js b/chrome/test/data/extensions/api_test/stubs/content_script.js index fde6fa8..8c8d499 100644 --- a/chrome/test/data/extensions/api_test/stubs/content_script.js +++ b/chrome/test/data/extensions/api_test/stubs/content_script.js @@ -66,7 +66,8 @@ function testPath(path, expectError) { try { module = module[parts[i]]; } catch (err) { - logToConsoleAndStdout("testPath failed on subcomponent of " + path); + logToConsoleAndStdout("testPath failed on " + + parts.slice(0, i+1).join('.') + '(' + err + ')'); return false; } } else { |