diff options
Diffstat (limited to 'chrome/common')
-rw-r--r-- | chrome/common/extensions/api/extension_api.json | 6 | ||||
-rw-r--r-- | chrome/common/extensions/docs/experimental.sidebar.html | 2 | ||||
-rw-r--r-- | chrome/common/extensions/docs/extension.html | 14 | ||||
-rw-r--r-- | chrome/common/extensions/docs/manifest.html | 33 | ||||
-rw-r--r-- | chrome/common/extensions/docs/static/manifest.html | 31 | ||||
-rw-r--r-- | chrome/common/extensions/extension.cc | 20 | ||||
-rw-r--r-- | chrome/common/extensions/extension.h | 5 | ||||
-rw-r--r-- | chrome/common/extensions/extension_constants.cc | 5 | ||||
-rw-r--r-- | chrome/common/extensions/extension_constants.h | 4 | ||||
-rw-r--r-- | chrome/common/render_messages_internal.h | 7 |
10 files changed, 113 insertions, 14 deletions
diff --git a/chrome/common/extensions/api/extension_api.json b/chrome/common/extensions/api/extension_api.json index 1014714..4699d3a 100644 --- a/chrome/common/extensions/api/extension_api.json +++ b/chrome/common/extensions/api/extension_api.json @@ -51,13 +51,13 @@ "message": { "type": "string", "description": "Description of the error that has taken place." } } }, - "inIncognitoTab": { + "inIncognitoContext": { "type": "object", "optional": true, "unprivileged": true, - "description": "True for content scripts running inside incognito tabs. Will be undefined for non-content scripts.", + "description": "True for content scripts running inside incognito tabs, and for extension pages running inside an incognito process. The latter only applies to extensions with 'split' incognito_behavior.", "properties": { - "message": { "type": "boolean", "description": "True if the script is in an incongito tab." } + "message": { "type": "boolean", "description": "True if the page or script is in an incongito process." } } } }, diff --git a/chrome/common/extensions/docs/experimental.sidebar.html b/chrome/common/extensions/docs/experimental.sidebar.html index 9e19c34..e4983a3 100644 --- a/chrome/common/extensions/docs/experimental.sidebar.html +++ b/chrome/common/extensions/docs/experimental.sidebar.html @@ -937,7 +937,7 @@ <dd class="todo" style="display: none; "> Undocumented. </dd> - <dd>'hidden' indicates sidebar is not defined for the specified tab (show was never called or hide() was called). Nothing is displayed for this sidebar.'shown' means sidebar is defined for the specified tab; mini tab is displayed for this sidebar. Sidebar UI is either collapsed or displaying a content of some other extension's sidebar.'active' indicates that sidebar is defined for the specified tab; sidebar UI is expanded and displaying this sidebar's content.</dd> + <dd>'hidden' indicates sidebar is not defined for the specified tab (show was never called or hide() was called). Nothing is displayed for this sidebar.<br>'shown' means sidebar is defined for the specified tab; mini tab is displayed for this sidebar. Sidebar UI is either collapsed or displaying a content of some other extension's sidebar.<br>'active' indicates that sidebar is defined for the specified tab; sidebar UI is expanded and displaying this sidebar's content.</dd> <dd style="display: none; "> This parameter was added in version <b><span></span></b>. diff --git a/chrome/common/extensions/docs/extension.html b/chrome/common/extensions/docs/extension.html index fe903e3..74ceb1e 100644 --- a/chrome/common/extensions/docs/extension.html +++ b/chrome/common/extensions/docs/extension.html @@ -249,7 +249,7 @@ <li> <a href="#property-lastError">lastError</a> </li><li> - <a href="#property-inIncognitoTab">inIncognitoTab</a> + <a href="#property-inIncognitoContext">inIncognitoContext</a> </li> </ol> </li> @@ -490,15 +490,15 @@ For details, see </div> </div><div> - <a name="property-inIncognitoTab"></a> - <h4>inIncognitoTab</h4> + <a name="property-inIncognitoContext"></a> + <h4>inIncognitoContext</h4> <div class="summary"> <!-- Note: intentionally longer 80 columns --> - <span>chrome.extension.</span><span>inIncognitoTab</span> + <span>chrome.extension.</span><span>inIncognitoContext</span> </div> <div> <dt> - <var>inIncognitoTab</var> + <var>inIncognitoContext</var> <em> <!-- TYPE --> @@ -526,7 +526,7 @@ For details, see <dd class="todo" style="display: none; "> Undocumented. </dd> - <dd>True for content scripts running inside incognito tabs. Will be undefined for non-content scripts.</dd> + <dd>True for content scripts running inside incognito tabs, and for extension pages running inside an incognito process. The latter only applies to extensions with 'split' incognito_behavior.</dd> <dd style="display: none; "> This parameter was added in version <b><span></span></b>. @@ -571,7 +571,7 @@ For details, see <dd class="todo" style="display: none; "> Undocumented. </dd> - <dd>True if the script is in an incongito tab.</dd> + <dd>True if the page or script is in an incongito process.</dd> <dd style="display: none; "> This parameter was added in version <b><span></span></b>. diff --git a/chrome/common/extensions/docs/manifest.html b/chrome/common/extensions/docs/manifest.html index a8dcda8..1c4737a 100644 --- a/chrome/common/extensions/docs/manifest.html +++ b/chrome/common/extensions/docs/manifest.html @@ -258,6 +258,8 @@ <a href="#permissions">permissions</a> </li><li> <a href="#version">version</a> + </li><li> + <a href="#incognito">incognito</a> </li> </ol> </li> @@ -352,6 +354,7 @@ are <b>name</b> and <b>version</b>. "<a href="#permissions">permissions</a>": [...], "<a href="npapi.html">plugins</a>": [...], "<a href="autoupdate.html">update_url</a>": "http://<em>path/to/updateInfo</em>.xml" + "<a href="#incognito">incognito</a>": "<em>split</em> or <em>spanning</em>", } </pre> @@ -675,6 +678,36 @@ For more information, see <a href="autoupdate.html">Autoupdating</a>. </p> +<h3 id="incognito">incognito</h3> + +<p> +Either <em>split</em> or <em>spanning</em>, to specify how this extension will +behave if allowed to run in incognito. +</p> + +<p> +<em>spanning</em> is the default for extensions, and means that the extension +will run in a single shared process. Any events or messages from an incognito +tab will be sent to the shared process, with an <em>incognito</em> flag +indicating where it came from. +</p> + +<p> +<em>split</em> is the default for apps, and it means that all app pages in +an incognito window will run in their own incognito process. If the app or extension contains a background page, that will also run in the incognito process. +This incognito process runs along side the regular process, but has a separate +memory-only cookie store. Each process sees events and messages only from its +own context (e.g. the incognito process will only see incognito tab updates). +The processes are unable to communicate with each other. +</p> + +<p> +As a rule of thumb, if your extension or app needs to load a tab in an incognito browser, use +<em>split</em> incognito behavior. If your extension or app needs to be logged +into a remote server or persist settings locally, use <em>spanning</em> +incognito behavior. +</p> + <!-- [PENDING: Possibly: point to the gallery and make a big deal of the fact that autoupdating is free if you use the gallery.] --> </div> diff --git a/chrome/common/extensions/docs/static/manifest.html b/chrome/common/extensions/docs/static/manifest.html index a4d1867..5e1758c 100644 --- a/chrome/common/extensions/docs/static/manifest.html +++ b/chrome/common/extensions/docs/static/manifest.html @@ -43,6 +43,7 @@ are <b>name</b> and <b>version</b>. "<a href="#permissions">permissions</a>": [...], "<a href="npapi.html">plugins</a>": [...], "<a href="autoupdate.html">update_url</a>": "http://<em>path/to/updateInfo</em>.xml" + "<a href="#incognito">incognito</a>": "<em>split</em> or <em>spanning</em>", } </pre> @@ -368,4 +369,34 @@ For more information, see <a href="autoupdate.html">Autoupdating</a>. </p> +<h3 id="incognito">incognito</h3> + +<p> +Either <em>split</em> or <em>spanning</em>, to specify how this extension will +behave if allowed to run in incognito. +</p> + +<p> +<em>spanning</em> is the default for extensions, and means that the extension +will run in a single shared process. Any events or messages from an incognito +tab will be sent to the shared process, with an <em>incognito</em> flag +indicating where it came from. +</p> + +<p> +<em>split</em> is the default for apps, and it means that all app pages in +an incognito window will run in their own incognito process. If the app or extension contains a background page, that will also run in the incognito process. +This incognito process runs along side the regular process, but has a separate +memory-only cookie store. Each process sees events and messages only from its +own context (e.g. the incognito process will only see incognito tab updates). +The processes are unable to communicate with each other. +</p> + +<p> +As a rule of thumb, if your extension or app needs to load a tab in an incognito browser, use +<em>split</em> incognito behavior. If your extension or app needs to be logged +into a remote server or persist settings locally, use <em>spanning</em> +incognito behavior. +</p> + <!-- [PENDING: Possibly: point to the gallery and make a big deal of the fact that autoupdating is free if you use the gallery.] --> diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc index 9c4366e..61c47cb 100644 --- a/chrome/common/extensions/extension.cc +++ b/chrome/common/extensions/extension.cc @@ -774,6 +774,7 @@ Extension::Extension(const FilePath& path) launch_container_(LAUNCH_TAB), launch_width_(0), launch_height_(0), + incognito_split_mode_(true), background_page_ready_(false), being_upgraded_(false) { DCHECK(path.IsAbsolute()); @@ -1552,6 +1553,25 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_key, devtools_url_ = GetResourceURL(devtools_str); } + // Initialize incognito behavior. Apps default to split mode, extensions + // default to spanning. + incognito_split_mode_ = is_app_; + if (source.HasKey(keys::kIncognito)) { + std::string value; + if (!source.GetString(keys::kIncognito, &value)) { + *error = errors::kInvalidIncognitoBehavior; + return false; + } + if (value == values::kIncognitoSpanning) { + incognito_split_mode_ = false; + } else if (value == values::kIncognitoSplit) { + incognito_split_mode_ = true; + } else { + *error = errors::kInvalidIncognitoBehavior; + return false; + } + } + // Although |source| is passed in as a const, it's still possible to modify // it. This is dangerous since the utility process re-uses |source| after // it calls InitFromValue, passing it up to the browser process which calls diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h index 66e12f2..bb4d4d5e 100644 --- a/chrome/common/extensions/extension.h +++ b/chrome/common/extensions/extension.h @@ -366,6 +366,7 @@ class Extension { LaunchContainer launch_container() const { return launch_container_; } int launch_width() const { return launch_width_; } int launch_height() const { return launch_height_; } + bool incognito_split_mode() const { return incognito_split_mode_; } // Gets the fully resolved absolute launch URL. GURL GetFullLaunchURL() const; @@ -582,6 +583,10 @@ class Extension { // The omnibox keyword for this extension, or empty if there is none. std::string omnibox_keyword_; + // If true, a separate process will be used for the extension in incognito + // mode. + bool incognito_split_mode_; + // Runtime data: // True if the background page is ready. diff --git a/chrome/common/extensions/extension_constants.cc b/chrome/common/extensions/extension_constants.cc index 2e9085b..a6b294b 100644 --- a/chrome/common/extensions/extension_constants.cc +++ b/chrome/common/extensions/extension_constants.cc @@ -20,6 +20,7 @@ const char* kDescription = "description"; const char* kDevToolsPage = "devtools_page"; const char* kExcludeGlobs = "exclude_globs"; const char* kIcons = "icons"; +const char* kIncognito = "incognito"; const char* kIncludeGlobs = "include_globs"; const char* kJs = "js"; const char* kLaunch = "app.launch"; @@ -64,6 +65,8 @@ const char* kWebURLs = "app.urls"; } // namespace extension_manifest_keys namespace extension_manifest_values { +const char* kIncognitoSplit = "split"; +const char* kIncognitoSpanning = "spanning"; const char* kRunAtDocumentStart = "document_start"; const char* kRunAtDocumentEnd = "document_end"; const char* kRunAtDocumentIdle = "document_idle"; @@ -125,6 +128,8 @@ const char* kInvalidIconPath = "Invalid value for 'icons[\"*\"]'."; const char* kInvalidIcons = "Invalid value for 'icons'."; +const char* kInvalidIncognitoBehavior = + "Invalid value for 'incognito'."; const char* kInvalidJs = "Invalid value for 'content_scripts[*].js[*]'."; const char* kInvalidJsList = diff --git a/chrome/common/extensions/extension_constants.h b/chrome/common/extensions/extension_constants.h index 54713f7..b1975d1 100644 --- a/chrome/common/extensions/extension_constants.h +++ b/chrome/common/extensions/extension_constants.h @@ -25,6 +25,7 @@ namespace extension_manifest_keys { extern const char* kDevToolsPage; extern const char* kExcludeGlobs; extern const char* kIcons; + extern const char* kIncognito; extern const char* kIncludeGlobs; extern const char* kJs; extern const char* kLaunch; @@ -71,6 +72,8 @@ namespace extension_manifest_keys { // Some values expected in manifests. namespace extension_manifest_values { + extern const char* kIncognitoSplit; + extern const char* kIncognitoSpanning; extern const char* kLaunchContainerPanel; extern const char* kLaunchContainerTab; extern const char* kLaunchContainerWindow; @@ -107,6 +110,7 @@ namespace extension_manifest_errors { extern const char* kInvalidGlobList; extern const char* kInvalidIconPath; extern const char* kInvalidIcons; + extern const char* kInvalidIncognitoBehavior; extern const char* kInvalidJs; extern const char* kInvalidJsList; extern const char* kInvalidKey; diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index be0e220..1becc31 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -750,10 +750,11 @@ IPC_BEGIN_MESSAGES(View) std::vector<URLPattern> /* URLPatterns the extension can access */) // Tell the renderer process that the given extension is enabled or disabled - // for incognito mode. - IPC_MESSAGE_CONTROL2(ViewMsg_Extension_ExtensionSetIncognitoEnabled, + // for incognito mode, and what kind of incognito behavior it has. + IPC_MESSAGE_CONTROL3(ViewMsg_Extension_ExtensionSetIncognitoEnabled, std::string /* extension_id */, - bool /* enabled */) + bool /* enabled */, + bool /* incognito_split_mode */) // Tell the renderer process all known page action ids for a particular // extension. |