diff options
| author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-08-28 15:28:34 +0200 |
|---|---|---|
| committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-08-28 13:54:51 +0000 |
| commit | 2a19c63448c84c1805fb1a585c3651318bb86ca7 (patch) | |
| tree | eb17888e8531aa6ee5e85721bd553b832a7e5156 /chromium/extensions/common | |
| parent | b014812705fc80bff0a5c120dfcef88f349816dc (diff) | |
| download | qtwebengine-chromium-2a19c63448c84c1805fb1a585c3651318bb86ca7.tar.gz | |
BASELINE: Update Chromium to 69.0.3497.70
Change-Id: I2b7b56e4e7a8b26656930def0d4575dc32b900a0
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/extensions/common')
48 files changed, 612 insertions, 135 deletions
diff --git a/chromium/extensions/common/BUILD.gn b/chromium/extensions/common/BUILD.gn index cb4a7414da8..d8d9299b229 100644 --- a/chromium/extensions/common/BUILD.gn +++ b/chromium/extensions/common/BUILD.gn @@ -11,6 +11,10 @@ import("//mojo/public/tools/bindings/mojom.gni") # TODO(crbug.com/731689): Assert that extensions are enabled. source_set("common_constants") { + if (is_chromecast) { + defines = [ "IS_CHROMECAST" ] + } + sources = [ "constants.cc", "constants.h", @@ -38,6 +42,7 @@ if (enable_extensions) { public_deps = [ "//content/public/common:interfaces", + "//extensions/common/api:mojom", "//mojo/public/mojom/base", "//ui/gfx/geometry/mojo", "//url/mojom:url_mojom_gurl", diff --git a/chromium/extensions/common/api/API_OWNERS b/chromium/extensions/common/api/API_OWNERS index 9853e492306..e47ac1a967f 100644 --- a/chromium/extensions/common/api/API_OWNERS +++ b/chromium/extensions/common/api/API_OWNERS @@ -1,7 +1,8 @@ # For Extensions and Apps APIs. -rdevlin.cronin@chromium.org lazyboy@chromium.org +rdevlin.cronin@chromium.org # For Chrome OS apps APIs. -tbarzic@chromium.org +benwells@chromium.org stevenjb@chromium.org +tbarzic@chromium.org diff --git a/chromium/extensions/common/api/BUILD.gn b/chromium/extensions/common/api/BUILD.gn index 90095620764..05a0129878c 100644 --- a/chromium/extensions/common/api/BUILD.gn +++ b/chromium/extensions/common/api/BUILD.gn @@ -6,6 +6,7 @@ import("//build/config/features.gni") import("//extensions/common/api/schema.gni") import("//extensions/buildflags/buildflags.gni") import("//mojo/public/tools/bindings/mojom.gni") +import("//tools/json_schema_compiler/json_features.gni") import("//tools/json_schema_compiler/json_schema_api.gni") assert(enable_extensions) @@ -38,3 +39,44 @@ group("api") { "//extensions/buildflags", ] } + +json_features("api_features") { + feature_type = "APIFeature" + method_name = "AddCoreAPIFeatures" + sources = [ + "_api_features.json", + ] +} + +json_features("permission_features") { + feature_type = "PermissionFeature" + method_name = "AddCorePermissionFeatures" + sources = [ + "_permission_features.json", + ] +} + +json_features("manifest_features") { + feature_type = "ManifestFeature" + method_name = "AddCoreManifestFeatures" + sources = [ + "_manifest_features.json", + ] +} + +json_features("behavior_features") { + feature_type = "BehaviorFeature" + method_name = "AddCoreBehaviorFeatures" + sources = [ + "_behavior_features.json", + ] +} + +group("extensions_features") { + public_deps = [ + ":api_features", + ":behavior_features", + ":manifest_features", + ":permission_features", + ] +} diff --git a/chromium/extensions/common/api/OWNERS b/chromium/extensions/common/api/OWNERS index 7ccf6b57080..9c77fc8e798 100644 --- a/chromium/extensions/common/api/OWNERS +++ b/chromium/extensions/common/api/OWNERS @@ -6,4 +6,7 @@ per-file *.idl=file://extensions/common/api/API_OWNERS per-file *view*.json=file://components/guest_view/OWNERS +per-file *.mojom=set noparent +per-file *.mojom=file://ipc/SECURITY_OWNERS + # COMPONENT: Platform>Extensions>API diff --git a/chromium/extensions/common/api/_api_features.json b/chromium/extensions/common/api/_api_features.json index 70278843879..c0eb07872f0 100644 --- a/chromium/extensions/common/api/_api_features.json +++ b/chromium/extensions/common/api/_api_features.json @@ -274,7 +274,8 @@ "matches": [ "chrome://bookmarks/*", "chrome://extensions/*", - "chrome://settings/*" + "chrome://settings/*", + "chrome://sync-confirmation/*" ] }], "metricsPrivate.getIsCrashReportingEnabled": { @@ -493,6 +494,10 @@ "dependencies": ["permission:system.network"], "contexts": ["blessed_extension"] }, + "system.powerSource": { + "dependencies": ["permission:system.powerSource"], + "contexts": ["blessed_extension"] + }, "system.storage": { "dependencies": ["permission:system.storage"], "contexts": ["blessed_extension"] diff --git a/chromium/extensions/common/api/_manifest_features.json b/chromium/extensions/common/api/_manifest_features.json index 57920b68f14..c38b30bae42 100644 --- a/chromium/extensions/common/api/_manifest_features.json +++ b/chromium/extensions/common/api/_manifest_features.json @@ -55,6 +55,11 @@ ], "min_manifest_version": 2 }, + "background.service_worker_script": { + "channel": "trunk", + "extension_types": ["extension"], + "min_manifest_version": 2 + }, "bluetooth": [{ // Note: The "bluetooth" manifest permission is used by the // chrome.bluetooth, chrome.bluetoothSocket and chrome.bluetoothLowEnergy diff --git a/chromium/extensions/common/api/_permission_features.json b/chromium/extensions/common/api/_permission_features.json index ac188fe8a23..d430c8b49ec 100644 --- a/chromium/extensions/common/api/_permission_features.json +++ b/chromium/extensions/common/api/_permission_features.json @@ -305,6 +305,16 @@ "3F65507A3B39259B38C8173C6FFA3D12DF64CCE9" // http://crbug.com/371562 ] }], + "fileSystem.requestDownloads": { + "channel": "dev", + "extension_types": ["platform_app"], + "platforms": ["chromeos"], + "whitelist": [ + "A3E3DE9E9F16B41D4A2FAD106BD6CA76B94A0C94", // http://crbug.com/845423 + "C2ABD68C33A5B485971C9638B80D6A2E9CBA78C4", // http://crbug.com/845423 + "B41E7F08E1179CC03CBD1F49E57CF353A40ADE07" // http://crbug.com/845423 + ] + }, "fileSystem.requestFileSystem": { "platforms": ["chromeos"] }, @@ -599,6 +609,12 @@ "whitelist": ["B44D08FD98F1523ED5837D78D0A606EA9D6206E5"] // Web Store } ], + "system.powerSource": { + "channel": "stable", + "extension_types": ["platform_app"], + "platforms": ["chromeos"], + "session_types": ["kiosk"] + }, "u2fDevices": { "channel": "stable", "extension_types": ["extension", "platform_app"], diff --git a/chromium/extensions/common/api/app_runtime.idl b/chromium/extensions/common/api/app_runtime.idl index 25175b1bc91..494731ff371 100644 --- a/chromium/extensions/common/api/app_runtime.idl +++ b/chromium/extensions/common/api/app_runtime.idl @@ -107,6 +107,10 @@ namespace app.runtime { // matching URL handler in the <code>url_handlers</code> manifest key. DOMString? referrerUrl; + // Whether the app is launched in a Chrome OS Demo Mode session. Used for + // default-installed Demo Mode Chrome apps. + [nodoc] boolean? isDemoSession; + // Whether the app is being launched in a <a // href="https://support.google.com/chromebook/answer/3134673">Chrome OS // kiosk session</a>. diff --git a/chromium/extensions/common/api/app_window.idl b/chromium/extensions/common/api/app_window.idl index 39fd79e4183..7cf585852ed 100644 --- a/chromium/extensions/common/api/app_window.idl +++ b/chromium/extensions/common/api/app_window.idl @@ -136,11 +136,11 @@ namespace app.window { enum State { normal, fullscreen, maximized, minimized }; // Specifies the type of window to create. - enum WindowType { + enum WindowType { // Default window type. shell, - // OS managed window (Chrome OS only). - panel + // OS managed window (Deprecated). + panel }; [noinline_doc] dictionary CreateWindowOptions { @@ -217,7 +217,7 @@ namespace app.window { [deprecated="Use innerBounds or outerBounds."] long? maxHeight; // Type of window to create. - WindowType? type; + [deprecated="All app windows use the 'shell' window type"] WindowType? type; // Creates a special ime window. This window is not focusable and can be // stacked above virtual keyboard window. This is restriced to component ime diff --git a/chromium/extensions/common/api/declarative_net_request.idl b/chromium/extensions/common/api/declarative_net_request.idl index 5d2608e43b7..fca2bd8c0ae 100644 --- a/chromium/extensions/common/api/declarative_net_request.idl +++ b/chromium/extensions/common/api/declarative_net_request.idl @@ -35,12 +35,12 @@ namespace declarativeNetRequest { // Describes the kind of action to take if a given RuleCondition matches. enum RuleActionType { // Block the network request. - blacklist, + block, // Redirect the network request. redirect, - // Whitelist the network request. The request won't be blocked even if there + // Allow the network request. The request won't be blocked even if there // is a blocking rule which matches it. - whitelist + allow }; dictionary RuleCondition { @@ -113,39 +113,37 @@ namespace declarativeNetRequest { }; callback EmptyCallback = void(); - callback GetWhitelistedPagesCallback = void(DOMString[] result); + callback GetAllowedPagesCallback = void(DOMString[] result); interface Functions { - // Adds |page_patterns| to the set of whitelisted pages. Requests from these + // Adds |page_patterns| to the set of allowed pages. Requests from these // pages are not intercepted by the extension. These are persisted across // browser sessions. - // Note: MAX_NUMBER_OF_WHITELISTED_PAGES is the maximum number of - // whitelisted page an extension can add. Also, adding page patterns is + // Note: MAX_NUMBER_OF_ALLOWED_PAGES is the maximum number of + // allowed page an extension can add. Also, adding page patterns is // atomic. In case of an error, no page pattern is added. - // |page_patterns| : Array of match patterns which are to be added to the - // whitelist. + // |page_patterns| : Array of match patterns which are to be allowed. // |callback|: Called after the |page_patterns| have been added. // chrome.runtime.lastError will be set in case of an error, for example if // an invalid page pattern is specified or the extension exceeded the // maximum page patterns limit. - static void addWhitelistedPages(DOMString[] page_patterns, optional EmptyCallback callback); + static void addAllowedPages(DOMString[] page_patterns, optional EmptyCallback callback); - // Removes |page_patterns| from the set of whitelisted pages. + // Removes |page_patterns| from the set of allowed pages. // Note: Removing page patterns is atomic. In case of an error, no page // pattern is removed. - // |page_patterns| : Array of match patterns which are to be removed from - // the whitelist. + // |page_patterns| : Array of match patterns which are to removed. // |callback|: Called after the |page_patterns| have been removed. // chrome.runtime.lastError will be set in case of an error. - static void removeWhitelistedPages(DOMString[] page_patterns, optional EmptyCallback callback); + static void removeAllowedPages(DOMString[] page_patterns, optional EmptyCallback callback); - // Returns the current set of whitelisted pages. - // |callback|: Called with the set of currently whitelisted pages. - static void getWhitelistedPages(GetWhitelistedPagesCallback callback); + // Returns the current set of allowed pages. + // |callback|: Called with the set of currently allowed pages. + static void getAllowedPages(GetAllowedPagesCallback callback); }; interface Properties { - // The maximum number of whitelisted pages that an extension can add. - [value=100] static long MAX_NUMBER_OF_WHITELISTED_PAGES(); + // The maximum number of allowed pages that an extension can add. + [value=100] static long MAX_NUMBER_OF_ALLOWED_PAGES(); }; }; diff --git a/chromium/extensions/common/api/declarative_net_request/test_utils.cc b/chromium/extensions/common/api/declarative_net_request/test_utils.cc index be77366982c..8e12117cf4c 100644 --- a/chromium/extensions/common/api/declarative_net_request/test_utils.cc +++ b/chromium/extensions/common/api/declarative_net_request/test_utils.cc @@ -87,7 +87,7 @@ TestRule CreateGenericRule() { TestRuleCondition condition; condition.url_filter = std::string("filter"); TestRuleAction action; - action.type = std::string("blacklist"); + action.type = std::string("block"); TestRule rule; rule.id = kMinValidID; rule.action = action; diff --git a/chromium/extensions/common/api/declarative_web_request.json b/chromium/extensions/common/api/declarative_web_request.json index e2a3bbb8142..713250648a3 100644 --- a/chromium/extensions/common/api/declarative_web_request.json +++ b/chromium/extensions/common/api/declarative_web_request.json @@ -5,7 +5,7 @@ [ { "namespace": "declarativeWebRequest", - "description": "<em><strong>Note:</strong> this API is currently on hold, without concrete plans to move to stable.</em> Use the <code>chrome.declarativeWebRequest</code> API to intercept, block, or modify requests in-flight. It is significantly faster than the <a href='webRequest'><code>chrome.webRequest</code> API</a> because you can register rules that are evaluated in the browser rather than the JavaScript engine with reduces roundtrip latencies and allows higher efficiency.", + "description": "<em><strong>Note:</strong> this API is currently on hold, without concrete plans to move to stable.</em> Use the <code>chrome.declarativeWebRequest</code> API to intercept, block, or modify requests in-flight. It is significantly faster than the <a href='webRequest'><code>chrome.webRequest</code> API</a> because you can register rules that are evaluated in the browser rather than the JavaScript engine, which reduces roundtrip latencies and allows higher efficiency.", "types": [ // TODO(devlin): The declarativeWebRequest API uses these enums as a form // of RTTI, but it's a rather verbose implementation. We should see if we diff --git a/chromium/extensions/common/api/media_perception_private.idl b/chromium/extensions/common/api/media_perception_private.idl index f786bbf121b..b39882fe74e 100644 --- a/chromium/extensions/common/api/media_perception_private.idl +++ b/chromium/extensions/common/api/media_perception_private.idl @@ -25,8 +25,8 @@ namespace mediaPerceptionPrivate { RUNNING, // Analytics process is running and the media processing pipeline is ready - // to be set to state <code>RUNNING</code>. The D-Bus communications are enabled but - // the media processing pipeline is suspended. + // to be set to state <code>RUNNING</code>. The D-Bus communications + // are enabled but the media processing pipeline is suspended. SUSPENDED, // Enum for restarting the media analytics process using Upstart. @@ -57,7 +57,10 @@ namespace mediaPerceptionPrivate { SERVICE_BUSY_LAUNCHING, // The component is not installed properly. - SERVICE_NOT_INSTALLED + SERVICE_NOT_INSTALLED, + + // Failed to establish a Mojo connection to the service. + MOJO_CONNECTION_FAILURE }; enum ComponentType { @@ -140,6 +143,36 @@ namespace mediaPerceptionPrivate { long? frameRate; }; + dictionary Point { + // The horizontal distance from the top left corner of the image. + double? x; + + // The vertical distance from the top left corner of the image. + double? y; + }; + + // The parameters for a whiteboard in the image frame. Corners are given in + // pixel coordinates normalized to the size of the image frame (i.e. in the + // range [(0.0, 0.0), (1.0, 1.0)]. The aspectRatio is the physical aspect + // ratio of the whiteboard (e.g. for a 1m high and 2m wide whiteboard, the + // aspect ratio would be 2). + dictionary Whiteboard { + // The top left corner of the whiteboard in the image frame. + Point? topLeft; + + // The top right corner of the whiteboard in the image frame. + Point? topRight; + + // The bottom left corner of the whiteboard in the image frame. + Point? bottomLeft; + + // The bottom right corner of the whiteboard in the image frame. + Point? bottomRight; + + // The physical aspect ratio of the whiteboard. + double? aspectRatio; + }; + // The system and configuration state of the analytics process. dictionary State { Status status; @@ -160,14 +193,11 @@ namespace mediaPerceptionPrivate { // Media analytics configuration. It can only be used when setting state to // RUNNING. DOMString? configuration; - }; - dictionary Point { - // The horizontal distance from the top left corner of the image. - double? x; - - // The vertical distance from the top left corner of the image. - double? y; + // Corners and aspect ratio of the whiteboard in the image frame. Should + // only be set when setting state to <code>RUNNING</code> and configuration + // to whiteboard. + Whiteboard? whiteboard; }; dictionary BoundingBox { diff --git a/chromium/extensions/common/api/mime_handler.mojom b/chromium/extensions/common/api/mime_handler.mojom index 7eefc02c1be..b7de32676c1 100644 --- a/chromium/extensions/common/api/mime_handler.mojom +++ b/chromium/extensions/common/api/mime_handler.mojom @@ -37,4 +37,18 @@ interface MimeHandlerService { // Aborts the stream associated with this service instance. This is an // idempotent operation. AbortStream() => (); + +}; + +// Provides a mime handler guest with control over beforeunload event handling +// when running in a PluginDocument. +// +// For full-frame mime handler guests, an instance of this interface is passed +// from the embedding renderer to the browser when creating the mime handler +// guest. If the frame hosting the guest requests this interface from the +// browser, that instance is provided to the guest. +interface BeforeUnloadControl { + // Instructs the containing PluginDocument whether to show a beforeunload + // dialog. + SetShowBeforeUnloadDialog(bool show_dialog) => (); }; diff --git a/chromium/extensions/common/api/mime_handler_private.idl b/chromium/extensions/common/api/mime_handler_private.idl index dfd47be6ae9..01fa200bb3c 100644 --- a/chromium/extensions/common/api/mime_handler_private.idl +++ b/chromium/extensions/common/api/mime_handler_private.idl @@ -30,6 +30,7 @@ callback AbortCallback = void (); callback GetStreamDetailsCallback = void (StreamInfo streamInfo); + callback SetShowBeforeUnloadDialogCallback = void (); interface Functions { // Returns the StreamInfo for the stream for this context if there is one. @@ -37,5 +38,11 @@ // Aborts the stream for this context if there is one. [nocompile] static void abortStream(optional AbortCallback callback); + + // Instructs the PluginDocument, if running in one, to show a dialog in + // response to beforeunload events. + [nocompile] static void setShowBeforeUnloadDialog( + boolean showDialog, + optional SetShowBeforeUnloadDialogCallback callback); }; }; diff --git a/chromium/extensions/common/api/networking_onc.idl b/chromium/extensions/common/api/networking_onc.idl index ecbdc4622ec..587bc914d40 100644 --- a/chromium/extensions/common/api/networking_onc.idl +++ b/chromium/extensions/common/api/networking_onc.idl @@ -240,7 +240,7 @@ namespace networking.onc { // If set, the value against which to match the certificate subject's // organizational units. At least one organizational unit should match the // value. - DOMString? OrganizationalUnit; + DOMString? OrganizationalUnit; }; dictionary CertificatePattern { @@ -417,7 +417,7 @@ namespace networking.onc { [noinline_doc] dictionary CellularProperties { // Whether the cellular network should be connected automatically (when - // in range). + // in range). boolean? AutoConnect; // The cellular network activation type. DOMString? ActivationType; @@ -533,7 +533,7 @@ namespace networking.onc { }; dictionary EthernetProperties { - // Whether the Ethernet network should be connected automatically. + // Whether the Ethernet network should be connected automatically. boolean? AutoConnect; // The authentication used by the Ethernet network. Possible values are // <code>None</code> and <code>8021X</code>. @@ -874,6 +874,11 @@ namespace networking.onc { // If true, only policy networks may be connected to and no new networks may // be added or configured. Defaults to false. boolean? AllowOnlyPolicyNetworksToConnect; + + // List of blacklisted networks. Connections to blacklisted networks are + // prohibited. Networks can be whitelisted again by specifying an explicit + // network configuration. Defaults to an empty list. + DOMString[]? BlacklistedHexSSIDs; }; callback VoidCallback = void(); diff --git a/chromium/extensions/common/api/networking_private.idl b/chromium/extensions/common/api/networking_private.idl index 13a8c40ab71..c17c71ccb28 100644 --- a/chromium/extensions/common/api/networking_private.idl +++ b/chromium/extensions/common/api/networking_private.idl @@ -154,6 +154,7 @@ namespace networkingPrivate { dictionary APNProperties { DOMString AccessPointName; + DOMString? Authentication; DOMString? Language; DOMString? LocalizedName; DOMString? Name; @@ -163,6 +164,7 @@ namespace networkingPrivate { dictionary ManagedAPNProperties { ManagedDOMString AccessPointName; + ManagedDOMString? Authentication; ManagedDOMString? Language; ManagedDOMString? LocalizedName; ManagedDOMString? Name; @@ -862,6 +864,11 @@ namespace networkingPrivate { // If true, only policy networks may be connected to and no new networks may // be added or configured. Defaults to false. boolean? AllowOnlyPolicyNetworksToConnect; + + // List of blacklisted networks. Connections to blacklisted networks are + // prohibited. Networks can be whitelisted again by specifying an explicit + // network configuration. Defaults to an empty list. + DOMString[]? BlacklistedHexSSIDs; }; dictionary Certificate { diff --git a/chromium/extensions/common/api/schema.gni b/chromium/extensions/common/api/schema.gni index 455f8314f95..084f7be2a18 100644 --- a/chromium/extensions/common/api/schema.gni +++ b/chromium/extensions/common/api/schema.gni @@ -50,6 +50,7 @@ extensions_api_schema_files_ = [ "system_display.idl", "system_memory.idl", "system_network.idl", + "system_power_source.idl", "system_storage.idl", "test.json", "usb.idl", diff --git a/chromium/extensions/common/api/system_power_source.idl b/chromium/extensions/common/api/system_power_source.idl new file mode 100644 index 00000000000..012db294632 --- /dev/null +++ b/chromium/extensions/common/api/system_power_source.idl @@ -0,0 +1,53 @@ +// Copyright 2018 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. + +// The <code>chrome.system.powerSource</code> API allows Chrome Kiosk Apps to +// query the state of connected power sources. +[platforms=("chromeos")] +namespace system.powerSource { + enum PowerSourceType { + // Unspecified type. + unknown, + + // Dedicated charger. Typically single-purpose and non-USB (e.g. barrel + // jack plugs). + mains, + + // USB charger, including both low-power Type-A chargers and high-power + // Type-C chargers using USB Power Delivery. + usb + }; + + dictionary PowerSourceInfo { + // Type of power source. + PowerSourceType type; + + // Maximum power this source is capable of delivering if known. Reported in + // watts, rounded to two significant digits. + double? maxPower; + + // Whether this power source is connected to the device. + boolean active; + }; + + callback PowerSourceInfoCallback = + void(optional PowerSourceInfo[] powerSourceInfo); + + interface Functions { + // Requests information on attached power sources. + // |callback|: The callback to invoke with the results or + // undefined if the power source information is not known. + static void getPowerSourceInfo(PowerSourceInfoCallback callback); + + // Requests a power source status update. Resulting power source status + // updates are observable using $(ref:onPowerChanged). + static void requestStatusUpdate(); + }; + + interface Events { + // Event for changes in the set of connected power sources. + static void onPowerChanged(PowerSourceInfo[] powerSourceInfo); + }; +}; + diff --git a/chromium/extensions/common/api/test.json b/chromium/extensions/common/api/test.json index 4539fc19c8d..7e046cf3be9 100644 --- a/chromium/extensions/common/api/test.json +++ b/chromium/extensions/common/api/test.json @@ -65,6 +65,23 @@ "type": "boolean", "optional": true, "description": "Whether native extension bindings are enabled." + }, + "loginStatus": { + "type": "object", + "optional": true, + "description": "Login status.", + "properties": { + "isLoggedIn": { + "type": "boolean", + "optional": true, + "description": "Whether there's a logged-in user." + }, + "isScreenLocked": { + "type": "boolean", + "optional": true, + "description": "Whether the screen is locked." + } + } } } } diff --git a/chromium/extensions/common/api/virtual_keyboard_private.json b/chromium/extensions/common/api/virtual_keyboard_private.json index b397f22a656..a08d1ccaaf0 100644 --- a/chromium/extensions/common/api/virtual_keyboard_private.json +++ b/chromium/extensions/common/api/virtual_keyboard_private.json @@ -200,26 +200,6 @@ ] }, { - "name": "setMode", - "type": "function", - "description": "Sets the virtual keyboard container mode.", - "parameters": [ - { - "$ref": "KeyboardMode", - "name": "mode", - "description": "The value of the virtual keyboard mode to set to." - }, - { - "type": "function", - "name": "callback", - "optional": true, - "description": "Called when container mode is ready to change.", - "parameters": [] - } - ], - "deprecated": "Please use $(ref:setContainerBehavior)" - }, - { "name": "setContainerBehavior", "type": "function", "description": "Sets the virtual keyboard container behavior", @@ -261,8 +241,33 @@ "description": "The value of the virtual keyboard state to change to." } ] + }, + { + "name": "setOccludedBounds", + "type": "function", + "description": "Sets the areas on the screen that are blocked by the virtual keyboard.", + "parameters": [ + { + "name": "boundsList", + "type": "array", + "description": "List of rectangles representing regions occluded by the keyboard.", + "items": { "$ref": "Bounds" } + } + ] + }, + { + "name": "setHitTestBounds", + "type": "function", + "description": "Sets the areas on the keyboard window where events are handled. Any event outside of these areas are passed on to the window behind it.", + "parameters": [ + { + "name": "boundsList", + "type": "array", + "description": "List of rectangles representing regions where events targeting the keyboard should be handled.", + "items": { "$ref": "Bounds" } + } + ] } - ], "events": [ { diff --git a/chromium/extensions/common/api/web_view_request.json b/chromium/extensions/common/api/web_view_request.json index 826cfa3d2e1..659ac2cef3c 100644 --- a/chromium/extensions/common/api/web_view_request.json +++ b/chromium/extensions/common/api/web_view_request.json @@ -5,6 +5,6 @@ [ { "namespace": "webViewRequest", - "description": "Use the <code>chrome.webViewRequest</code> API to intercept, block, or modify requests in-flight. It is potentially faster than the <a href='webRequest'><code>chrome.webRequest</code> API</a> because you can register rules that are evaluated in the browser rather than the JavaScript engine with reduces roundtrip latencies and allows higher efficiency." + "description": "Use the <code>chrome.webViewRequest</code> API to intercept, block, or modify requests in-flight. It is potentially faster than the <a href='webRequest'><code>chrome.webRequest</code> API</a> because you can register rules that are evaluated in the browser rather than the JavaScript engine, which reduces roundtrip latencies and allows higher efficiency." } ] diff --git a/chromium/extensions/common/constants.cc b/chromium/extensions/common/constants.cc index 602765b10ef..6f410f6c8d7 100644 --- a/chromium/extensions/common/constants.cc +++ b/chromium/extensions/common/constants.cc @@ -94,7 +94,7 @@ const int64_t kInvalidServiceWorkerVersionId = -1; namespace extension_misc { -#if defined(OS_CHROMEOS) +#if defined(OS_CHROMEOS) || defined(IS_CHROMECAST) // The extension id for the built-in component extension. const char kChromeVoxExtensionId[] = "mndnfokpggljbaajbnioimlmbfngpief"; #else diff --git a/chromium/extensions/common/extension.cc b/chromium/extensions/common/extension.cc index 1d543044ab7..c2aca3f34c9 100644 --- a/chromium/extensions/common/extension.cc +++ b/chromium/extensions/common/extension.cc @@ -18,6 +18,7 @@ #include "base/memory/singleton.h" #include "base/metrics/histogram_macros.h" #include "base/stl_util.h" +#include "base/strings/strcat.h" #include "base/strings/string16.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_piece.h" @@ -322,8 +323,8 @@ bool Extension::FormatPEMForFileOutput(const std::string& input, // static GURL Extension::GetBaseURLFromExtensionId(const std::string& extension_id) { - return GURL(std::string(extensions::kExtensionScheme) + - url::kStandardSchemeSeparator + extension_id + "/"); + return GURL(base::StrCat({extensions::kExtensionScheme, + url::kStandardSchemeSeparator, extension_id})); } bool Extension::OverlapsWithOrigin(const GURL& origin) const { diff --git a/chromium/extensions/common/extension_messages.cc b/chromium/extensions/common/extension_messages.cc index 3e0367c4ecf..8f8ca1bc9f3 100644 --- a/chromium/extensions/common/extension_messages.cc +++ b/chromium/extensions/common/extension_messages.cc @@ -8,7 +8,6 @@ #include <memory> -#include "base/memory/ptr_util.h" #include "content/public/common/common_param_traits.h" #include "extensions/common/extension.h" #include "extensions/common/manifest.h" @@ -46,8 +45,8 @@ ExtensionMsg_PermissionSetStruct::~ExtensionMsg_PermissionSetStruct() { std::unique_ptr<const PermissionSet> ExtensionMsg_PermissionSetStruct::ToPermissionSet() const { - return base::WrapUnique(new PermissionSet(apis, manifest_permissions, - explicit_hosts, scriptable_hosts)); + return std::make_unique<PermissionSet>(apis, manifest_permissions, + explicit_hosts, scriptable_hosts); } ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params() @@ -59,7 +58,8 @@ ExtensionMsg_Loaded_Params::~ExtensionMsg_Loaded_Params() {} ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params( const Extension* extension, bool include_tab_permissions) - : manifest(extension->manifest()->value()->DeepCopy()), + : manifest(static_cast<base::DictionaryValue&&>( + extension->manifest()->value()->Clone())), location(extension->location()), path(extension->path()), active_permissions(extension->permissions_data()->active_permissions()), @@ -83,7 +83,9 @@ ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params( } ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params( - const ExtensionMsg_Loaded_Params& other) = default; + ExtensionMsg_Loaded_Params&& other) = default; +ExtensionMsg_Loaded_Params& ExtensionMsg_Loaded_Params::operator=( + ExtensionMsg_Loaded_Params&& other) = default; scoped_refptr<Extension> ExtensionMsg_Loaded_Params::ConvertToExtension( std::string* error) const { @@ -91,7 +93,7 @@ scoped_refptr<Extension> ExtensionMsg_Loaded_Params::ConvertToExtension( // normal case, and because in tests, extensions may not have paths or keys, // but it's important to retain the same id. scoped_refptr<Extension> extension = - Extension::Create(path, location, *manifest, creation_flags, id, error); + Extension::Create(path, location, manifest, creation_flags, id, error); if (extension.get()) { const extensions::PermissionsData* permissions_data = extension->permissions_data(); @@ -316,7 +318,7 @@ void ParamTraits<ExtensionMsg_Loaded_Params>::Write(base::Pickle* m, const param_type& p) { WriteParam(m, p.location); WriteParam(m, p.path); - WriteParam(m, *(p.manifest)); + WriteParam(m, p.manifest); WriteParam(m, p.creation_flags); WriteParam(m, p.id); WriteParam(m, p.active_permissions); @@ -330,9 +332,9 @@ void ParamTraits<ExtensionMsg_Loaded_Params>::Write(base::Pickle* m, bool ParamTraits<ExtensionMsg_Loaded_Params>::Read(const base::Pickle* m, base::PickleIterator* iter, param_type* p) { - p->manifest.reset(new base::DictionaryValue()); + p->manifest.Clear(); return ReadParam(m, iter, &p->location) && ReadParam(m, iter, &p->path) && - ReadParam(m, iter, p->manifest.get()) && + ReadParam(m, iter, &p->manifest) && ReadParam(m, iter, &p->creation_flags) && ReadParam(m, iter, &p->id) && ReadParam(m, iter, &p->active_permissions) && ReadParam(m, iter, &p->withheld_permissions) && diff --git a/chromium/extensions/common/extension_messages.h b/chromium/extensions/common/extension_messages.h index 8ffcd074740..4d418ab201a 100644 --- a/chromium/extensions/common/extension_messages.h +++ b/chromium/extensions/common/extension_messages.h @@ -327,14 +327,16 @@ struct ExtensionMsg_Loaded_Params { ~ExtensionMsg_Loaded_Params(); ExtensionMsg_Loaded_Params(const extensions::Extension* extension, bool include_tab_permissions); - ExtensionMsg_Loaded_Params(const ExtensionMsg_Loaded_Params& other); + + ExtensionMsg_Loaded_Params(ExtensionMsg_Loaded_Params&& other); + ExtensionMsg_Loaded_Params& operator=(ExtensionMsg_Loaded_Params&& other); // Creates a new extension from the data in this object. scoped_refptr<extensions::Extension> ConvertToExtension( std::string* error) const; // The subset of the extension manifest data we send to renderers. - linked_ptr<base::DictionaryValue> manifest; + base::DictionaryValue manifest; // The location the extension was installed from. extensions::Manifest::Location location; @@ -361,6 +363,9 @@ struct ExtensionMsg_Loaded_Params { // Send creation flags so extension is initialized identically. int creation_flags; + + private: + DISALLOW_COPY_AND_ASSIGN(ExtensionMsg_Loaded_Params); }; struct ExtensionHostMsg_AutomationQuerySelector_Error { diff --git a/chromium/extensions/common/extension_messages_unittest.cc b/chromium/extensions/common/extension_messages_unittest.cc index bfd0a138064..98ffbbf6153 100644 --- a/chromium/extensions/common/extension_messages_unittest.cc +++ b/chromium/extensions/common/extension_messages_unittest.cc @@ -102,7 +102,7 @@ TEST(ExtensionMessageTypesTest, TestLoadedParams) { &msg, &iter, ¶ms_out)); EXPECT_EQ(params_in.id, params_out.id); - EXPECT_TRUE(params_in.manifest->Equals(params_out.manifest.get())); + EXPECT_TRUE(params_in.manifest.Equals(¶ms_out.manifest)); EXPECT_EQ(params_in.location, params_out.location); EXPECT_EQ(params_in.path, params_out.path); EXPECT_EQ(params_in.creation_flags, params_out.creation_flags); diff --git a/chromium/extensions/common/extension_set.cc b/chromium/extensions/common/extension_set.cc index d22e729d1bb..6930efba6ba 100644 --- a/chromium/extensions/common/extension_set.cc +++ b/chromium/extensions/common/extension_set.cc @@ -10,9 +10,28 @@ #include "extensions/common/constants.h" #include "extensions/common/extension.h" #include "extensions/common/manifest_handlers/sandboxed_page_info.h" +#include "url/origin.h" namespace extensions { +namespace { + +std::string GetExtensionIdByURL(const GURL& url) { + if (url.SchemeIs(kExtensionScheme)) + return url.host(); + + // Trying url::Origin is important to properly handle extension schemes inside + // blob: and filesystem: URLs, which won't match the extension scheme check + // above. + url::Origin origin = url::Origin::Create(url); + if (origin.scheme() == kExtensionScheme) + return origin.host(); + + return std::string(); +} + +} // namespace + ExtensionSet::const_iterator::const_iterator() {} ExtensionSet::const_iterator::const_iterator(const const_iterator& other) @@ -67,9 +86,12 @@ void ExtensionSet::Clear() { } std::string ExtensionSet::GetExtensionOrAppIDByURL(const GURL& url) const { - if (url.SchemeIs(kExtensionScheme)) - return url.host(); + std::string extension_id = GetExtensionIdByURL(url); + if (!extension_id.empty()) + return extension_id; + // GetHostedAppByURL already supports filesystem: URLs (via MatchesURL). + // TODO(crbug/852162): Add support for blob: URLs in MatchesURL. const Extension* extension = GetHostedAppByURL(url); if (!extension) return std::string(); @@ -78,9 +100,12 @@ std::string ExtensionSet::GetExtensionOrAppIDByURL(const GURL& url) const { } const Extension* ExtensionSet::GetExtensionOrAppByURL(const GURL& url) const { - if (url.SchemeIs(kExtensionScheme)) - return GetByID(url.host()); + std::string extension_id = GetExtensionIdByURL(url); + if (!extension_id.empty()) + return GetByID(extension_id); + // GetHostedAppByURL already supports filesystem: URLs (via MatchesURL). + // TODO(crbug/852162): Add support for blob: URLs in MatchesURL. return GetHostedAppByURL(url); } diff --git a/chromium/extensions/common/extension_set_unittest.cc b/chromium/extensions/common/extension_set_unittest.cc index 8e131206684..2027b889c13 100644 --- a/chromium/extensions/common/extension_set_unittest.cc +++ b/chromium/extensions/common/extension_set_unittest.cc @@ -97,6 +97,16 @@ TEST(ExtensionSetTest, ExtensionSet) { ext4.get(), extensions.GetExtensionOrAppByURL(ext4->GetResourceURL("test.html"))); + // Get extension by a filesystem or blob URL within it. + GURL ext2_filesystem_url = + GURL("filesystem:" + ext2->GetResourceURL("test.html").spec()); + EXPECT_EQ(ext2.get(), extensions.GetExtensionOrAppByURL(ext2_filesystem_url)); + EXPECT_EQ(ext2->id(), + extensions.GetExtensionOrAppIDByURL(ext2_filesystem_url)); + GURL ext3_blob_url = GURL("blob:" + ext3->GetResourceURL("test.html").spec()); + EXPECT_EQ(ext3.get(), extensions.GetExtensionOrAppByURL(ext3_blob_url)); + EXPECT_EQ(ext3->id(), extensions.GetExtensionOrAppIDByURL(ext3_blob_url)); + // Get extension by web extent. EXPECT_EQ(ext2.get(), extensions.GetExtensionOrAppByURL( @@ -107,6 +117,17 @@ TEST(ExtensionSetTest, ExtensionSet) { EXPECT_FALSE(extensions.GetExtensionOrAppByURL( GURL("http://blog.chromium.org/"))); + // Get extension by web extent with filesystem URL. Paths still matter. + EXPECT_EQ(ext3.get(), extensions.GetExtensionOrAppByURL( + GURL("filesystem:http://dev.chromium.org/foo"))); + EXPECT_EQ(ext3->id(), extensions.GetExtensionOrAppIDByURL( + GURL("filesystem:http://dev.chromium.org/foo"))); + EXPECT_EQ(nullptr, extensions.GetExtensionOrAppByURL( + GURL("filesystem:http://code.google.com/foo"))); + // TODO(crbug/852162): Support blob URLs. This should return ext3. + EXPECT_EQ(nullptr, extensions.GetExtensionOrAppByURL( + GURL("blob:http://dev.chromium.org/abcd"))); + // Test InSameExtent(). EXPECT_TRUE(extensions.InSameExtent( GURL("http://code.google.com/p/chromium/monkey/"), diff --git a/chromium/extensions/common/guest_view/extensions_guest_view_messages.h b/chromium/extensions/common/guest_view/extensions_guest_view_messages.h index d227b1f19d6..14e2d429f27 100644 --- a/chromium/extensions/common/guest_view/extensions_guest_view_messages.h +++ b/chromium/extensions/common/guest_view/extensions_guest_view_messages.h @@ -35,13 +35,6 @@ IPC_SYNC_MESSAGE_CONTROL2_1( int /* script_id */, bool /* allowed */) -// Tells the browser to create a mime handler guest view for a plugin. -IPC_MESSAGE_CONTROL4(ExtensionsGuestViewHostMsg_CreateMimeHandlerViewGuest, - int /* render_frame_id */, - std::string /* view_id */, - int /* element_instance_id */, - gfx::Size /* element_size */) - // A renderer sends this message when it wants to resize a guest. IPC_MESSAGE_CONTROL3(ExtensionsGuestViewHostMsg_ResizeGuest, int /* routing_id */, diff --git a/chromium/extensions/common/manifest_constants.cc b/chromium/extensions/common/manifest_constants.cc index 542132d5a23..996f1de26e8 100644 --- a/chromium/extensions/common/manifest_constants.cc +++ b/chromium/extensions/common/manifest_constants.cc @@ -22,6 +22,8 @@ const char kBackgroundAllowJsAccess[] = "background.allow_js_access"; const char kBackgroundPage[] = "background.page"; const char kBackgroundPersistent[] = "background.persistent"; const char kBackgroundScripts[] = "background.scripts"; +const char kBackgroundServiceWorkerScript[] = + "background.service_worker_script"; const char kBluetooth[] = "bluetooth"; const char kBookmarkUI[] = "bookmarks_ui"; const char kBrowserAction[] = "browser_action"; @@ -295,8 +297,8 @@ const char kChromeVersionTooLow[] = "This extension requires * version * or greater."; const char kDeclarativeNetRequestPermissionNeeded[] = "The extension requires '*' permission for the '*' manifest key."; -const char kDeclarativeNetRequestListNotPassed[] = - "Declarative Net Request: Ruleset must be a list."; +const char kDeclarativeNetRequestJSONRulesFileReadError[] = + "Declarative Net Request: Error in reading JSON rules file."; const char kDefaultStateShouldNotBeSet[] = "The default_state key cannot be set for browser_action or page_action " "keys."; @@ -322,6 +324,8 @@ const char kInvalidBackgroundScript[] = "Invalid value for 'background.scripts[*]'."; const char kInvalidBackgroundScripts[] = "Invalid value for 'background.scripts'."; +const char kInvalidBackgroundServiceWorkerScript[] = + "Invalid value for 'background.service_worker_script'."; const char kInvalidBackgroundInHostedApp[] = "Invalid value for 'background_page'. Hosted apps must specify an " "absolute HTTPS URL for the background page."; diff --git a/chromium/extensions/common/manifest_constants.h b/chromium/extensions/common/manifest_constants.h index cb69cae2e7e..63bfcd38273 100644 --- a/chromium/extensions/common/manifest_constants.h +++ b/chromium/extensions/common/manifest_constants.h @@ -25,6 +25,7 @@ extern const char kBackgroundAllowJsAccess[]; extern const char kBackgroundPage[]; extern const char kBackgroundPersistent[]; extern const char kBackgroundScripts[]; +extern const char kBackgroundServiceWorkerScript[]; extern const char kBluetooth[]; extern const char kBookmarkUI[]; extern const char kBrowserAction[]; @@ -269,7 +270,7 @@ extern const char kCannotScriptSigninPage[]; extern const char kCannotUninstallManagedExtension[]; extern const char kChromeVersionTooLow[]; extern const char kDeclarativeNetRequestPermissionNeeded[]; -extern const char kDeclarativeNetRequestListNotPassed[]; +extern const char kDeclarativeNetRequestJSONRulesFileReadError[]; extern const char kDefaultStateShouldNotBeSet[]; extern const char kDevToolsExperimental[]; extern const char kExpectString[]; @@ -286,6 +287,7 @@ extern const char kInvalidBackgroundAllowJsAccess[]; extern const char kInvalidBackgroundCombination[]; extern const char kInvalidBackgroundScript[]; extern const char kInvalidBackgroundScripts[]; +extern const char kInvalidBackgroundServiceWorkerScript[]; extern const char kInvalidBackgroundInHostedApp[]; extern const char kInvalidBackgroundPersistent[]; extern const char kInvalidBackgroundPersistentInPlatformApp[]; diff --git a/chromium/extensions/common/manifest_handlers/background_info.cc b/chromium/extensions/common/manifest_handlers/background_info.cc index c48be2ecfb2..0c19f814e56 100644 --- a/chromium/extensions/common/manifest_handlers/background_info.cc +++ b/chromium/extensions/common/manifest_handlers/background_info.cc @@ -67,6 +67,14 @@ GURL BackgroundInfo::GetBackgroundURL(const Extension* extension) { } // static +const std::string& BackgroundInfo::GetBackgroundServiceWorkerScript( + const Extension* extension) { + const BackgroundInfo& info = GetBackgroundInfo(extension); + DCHECK(info.background_service_worker_script_.has_value()); + return *info.background_service_worker_script_; +} + +// static const std::vector<std::string>& BackgroundInfo::GetBackgroundScripts( const Extension* extension) { return GetBackgroundInfo(extension).background_scripts_; @@ -98,18 +106,27 @@ bool BackgroundInfo::AllowJSAccess(const Extension* extension) { return GetBackgroundInfo(extension).allow_js_access_; } +// static +bool BackgroundInfo::IsServiceWorkerBased(const Extension* extension) { + return GetBackgroundInfo(extension) + .background_service_worker_script_.has_value(); +} + bool BackgroundInfo::Parse(const Extension* extension, base::string16* error) { const std::string& bg_scripts_key = extension->is_platform_app() ? keys::kPlatformAppBackgroundScripts : keys::kBackgroundScripts; if (!LoadBackgroundScripts(extension, bg_scripts_key, error) || !LoadBackgroundPage(extension, error) || + !LoadBackgroundServiceWorkerScript(extension, error) || !LoadBackgroundPersistent(extension, error) || !LoadAllowJSAccess(extension, error)) { return false; } - int background_solution_sum = (background_url_.is_valid() ? 1 : 0) + - (!background_scripts_.empty() ? 1 : 0); + int background_solution_sum = + (background_url_.is_valid() ? 1 : 0) + + (!background_scripts_.empty() ? 1 : 0) + + (background_service_worker_script_.has_value() ? 1 : 0); if (background_solution_sum > 1) { *error = ASCIIToUTF16(errors::kInvalidBackgroundCombination); return false; @@ -187,6 +204,26 @@ bool BackgroundInfo::LoadBackgroundPage(const Extension* extension, return true; } +bool BackgroundInfo::LoadBackgroundServiceWorkerScript( + const Extension* extension, + base::string16* error) { + const base::Value* scripts_value = nullptr; + if (!extension->manifest()->Get(keys::kBackgroundServiceWorkerScript, + &scripts_value)) { + return true; + } + + DCHECK(scripts_value); + if (!scripts_value->is_string()) { + *error = ASCIIToUTF16(errors::kInvalidBackgroundServiceWorkerScript); + return false; + } + + background_service_worker_script_ = scripts_value->GetString(); + + return true; +} + bool BackgroundInfo::LoadBackgroundPage(const Extension* extension, base::string16* error) { const char* key = extension->is_platform_app() @@ -282,6 +319,20 @@ bool BackgroundManifestHandler::Validate( } } + if (BackgroundInfo::IsServiceWorkerBased(extension)) { + DCHECK(extension->is_extension()); + const std::string& background_service_worker_script = + BackgroundInfo::GetBackgroundServiceWorkerScript(extension); + if (!base::PathExists( + extension->GetResource(background_service_worker_script) + .GetFilePath())) { + *error = l10n_util::GetStringFUTF8( + IDS_EXTENSION_LOAD_BACKGROUND_SCRIPT_FAILED, + base::UTF8ToUTF16(background_service_worker_script)); + return false; + } + } + // Validate background page location, except for hosted apps, which should use // an external URL. Background page for hosted apps are verified when the // extension is created (in Extension::InitFromValue) @@ -327,9 +378,10 @@ bool BackgroundManifestHandler::AlwaysParseForType(Manifest::Type type) const { base::span<const char* const> BackgroundManifestHandler::Keys() const { static constexpr const char* kKeys[] = { - keys::kBackgroundAllowJsAccess, keys::kBackgroundPage, - keys::kBackgroundPersistent, keys::kBackgroundScripts, - keys::kPlatformAppBackgroundPage, keys::kPlatformAppBackgroundScripts}; + keys::kBackgroundAllowJsAccess, keys::kBackgroundPage, + keys::kBackgroundPersistent, keys::kBackgroundScripts, + keys::kBackgroundServiceWorkerScript, keys::kPlatformAppBackgroundPage, + keys::kPlatformAppBackgroundScripts}; return kKeys; } diff --git a/chromium/extensions/common/manifest_handlers/background_info.h b/chromium/extensions/common/manifest_handlers/background_info.h index dfc3a8fe763..b40f412c6b8 100644 --- a/chromium/extensions/common/manifest_handlers/background_info.h +++ b/chromium/extensions/common/manifest_handlers/background_info.h @@ -9,6 +9,7 @@ #include <vector> #include "base/macros.h" +#include "base/optional.h" #include "base/values.h" #include "extensions/common/extension.h" #include "extensions/common/manifest_handler.h" @@ -24,11 +25,14 @@ class BackgroundInfo : public Extension::ManifestData { static GURL GetBackgroundURL(const Extension* extension); static const std::vector<std::string>& GetBackgroundScripts( const Extension* extension); + static const std::string& GetBackgroundServiceWorkerScript( + const Extension* extension); static bool HasBackgroundPage(const Extension* extension); static bool HasPersistentBackgroundPage(const Extension* extension); static bool HasLazyBackgroundPage(const Extension* extension); static bool HasGeneratedBackgroundPage(const Extension* extension); static bool AllowJSAccess(const Extension* extension); + static bool IsServiceWorkerBased(const Extension* extension); bool has_background_page() const { return background_url_.is_valid() || !background_scripts_.empty(); @@ -52,6 +56,8 @@ class BackgroundInfo : public Extension::ManifestData { const std::string& key, base::string16* error); bool LoadBackgroundPage(const Extension* extension, base::string16* error); + bool LoadBackgroundServiceWorkerScript(const Extension* extension, + base::string16* error); bool LoadBackgroundPersistent(const Extension* extension, base::string16* error); bool LoadAllowJSAccess(const Extension* extension, base::string16* error); @@ -64,6 +70,9 @@ class BackgroundInfo : public Extension::ManifestData { // present, background_url_ will be empty and generated by GetBackgroundURL(). std::vector<std::string> background_scripts_; + // Optional service worker based background script. + base::Optional<std::string> background_service_worker_script_; + // True if the background page should stay loaded forever; false if it should // load on-demand (when it needs to handle an event). Defaults to true. bool is_persistent_; diff --git a/chromium/extensions/common/mojo/guest_view.mojom b/chromium/extensions/common/mojo/guest_view.mojom index 5cc5de9ab2a..448949c1367 100644 --- a/chromium/extensions/common/mojo/guest_view.mojom +++ b/chromium/extensions/common/mojo/guest_view.mojom @@ -5,6 +5,7 @@ module extensions.mojom; import "content/public/common/transferrable_url_loader.mojom"; +import "extensions/common/api/mime_handler.mojom"; import "ui/gfx/geometry/mojo/geometry.mojom"; import "url/mojom/url.mojom"; @@ -19,4 +20,14 @@ interface GuestView { int32 element_instance_id, gfx.mojom.Size element_size, content.mojom.TransferrableURLLoader transferrable_url_loader); + + // Tells the browser to create a mime handler guest view for a plugin. + // This method is called for full-frame plugins or for all plugins when the + // network service is disabled. + CreateMimeHandlerViewGuest( + int32 render_frame_id, + string view_id, + int32 element_instance_id, + gfx.mojom.Size element_size, + extensions.mime_handler.BeforeUnloadControl? before_unload_control); }; diff --git a/chromium/extensions/common/one_shot_event.cc b/chromium/extensions/common/one_shot_event.cc index ae52b445582..2ab097016e1 100644 --- a/chromium/extensions/common/one_shot_event.cc +++ b/chromium/extensions/common/one_shot_event.cc @@ -72,15 +72,19 @@ void OneShotEvent::Signal() { // could proceed immediately, but the fact that this object is // single-threaded prevents that from being relevant. - // We could randomize tasks_ in debug mode in order to check that + // Move tasks to a temporary to ensure no new ones are added. + std::vector<TaskInfo> moved_tasks; + std::swap(moved_tasks, tasks_); + + // We could randomize tasks in debug mode in order to check that // the order doesn't matter... - for (size_t i = 0; i < tasks_.size(); ++i) { - const TaskInfo& task = tasks_[i]; + for (const TaskInfo& task : moved_tasks) { if (task.delay.is_zero()) task.runner->PostTask(task.from_here, task.task); else task.runner->PostDelayedTask(task.from_here, task.task, task.delay); } + DCHECK(tasks_.empty()) << "No new tasks should be added during task running!"; } void OneShotEvent::PostImpl(const base::Location& from_here, diff --git a/chromium/extensions/common/one_shot_event_unittest.cc b/chromium/extensions/common/one_shot_event_unittest.cc index f2096198ead..f8e702ee4b8 100644 --- a/chromium/extensions/common/one_shot_event_unittest.cc +++ b/chromium/extensions/common/one_shot_event_unittest.cc @@ -17,6 +17,29 @@ namespace { void Increment(int* i) { ++*i; } +// |*did_delete_instance| will be set to true upon its destruction. +class RefCountedClass : public base::RefCounted<RefCountedClass> { + public: + explicit RefCountedClass(bool* did_delete_instance) + : did_delete_instance_(did_delete_instance) { + DCHECK(!*did_delete_instance_); + } + + void PerformTask() { did_perform_task_ = true; } + bool did_perform_task() const { return did_perform_task_; } + + private: + friend class base::RefCounted<RefCountedClass>; + + ~RefCountedClass() { *did_delete_instance_ = true; } + + bool* const did_delete_instance_; // Not owned. + + bool did_perform_task_ = false; + + DISALLOW_COPY_AND_ASSIGN(RefCountedClass); +}; + TEST(OneShotEventTest, RecordsSignal) { OneShotEvent event; EXPECT_FALSE(event.is_signaled()); @@ -124,5 +147,29 @@ TEST(OneShotEventTest, IsSignaledAndPostsFromCallbackWork) { EXPECT_EQ(1, i); } +// Tests that OneShotEvent does not keep references to tasks once OneShotEvent +// Signal()s. +TEST(OneShotEventTest, DropsCallbackRefUponSignalled) { + auto runner = base::MakeRefCounted<base::TestSimpleTaskRunner>(); + bool did_delete_instance = false; + OneShotEvent event; + + { + auto ref_counted_class = + base::MakeRefCounted<RefCountedClass>(&did_delete_instance); + event.Post( + FROM_HERE, + base::BindRepeating(&RefCountedClass::PerformTask, ref_counted_class), + runner); + event.Signal(); + runner->RunPendingTasks(); + EXPECT_TRUE(ref_counted_class->did_perform_task()); + } + + // Once OneShotEvent doesn't have any queued events, it should have dropped + // all the references to the callbacks it received through Post(). + EXPECT_TRUE(did_delete_instance); +} + } // namespace } // namespace extensions diff --git a/chromium/extensions/common/permissions/api_permission.h b/chromium/extensions/common/permissions/api_permission.h index 7ab192bb643..da8e29aa2e4 100644 --- a/chromium/extensions/common/permissions/api_permission.h +++ b/chromium/extensions/common/permissions/api_permission.h @@ -254,6 +254,8 @@ class APIPermission { kEnterpriseReportingPrivate, kCecPrivate, kSafeBrowsingPrivate, + kFileSystemRequestDownloads, + kSystemPowerSource, // Last entry: Add new entries above and ensure to update the // "ExtensionPermission3" enum in tools/metrics/histograms/histograms.xml // (by running update_extension_permission.py). diff --git a/chromium/extensions/common/permissions/extensions_api_permissions.cc b/chromium/extensions/common/permissions/extensions_api_permissions.cc index d9521a370d7..dd670c41837 100644 --- a/chromium/extensions/common/permissions/extensions_api_permissions.cc +++ b/chromium/extensions/common/permissions/extensions_api_permissions.cc @@ -105,6 +105,7 @@ ExtensionsAPIPermissions::GetAllPermissions() const { {APIPermission::kSystemMemory, "system.memory"}, {APIPermission::kSystemNetwork, "system.network"}, {APIPermission::kSystemDisplay, "system.display"}, + {APIPermission::kSystemPowerSource, "system.powerSource"}, {APIPermission::kSystemStorage, "system.storage"}, {APIPermission::kU2fDevices, "u2fDevices"}, {APIPermission::kUnlimitedStorage, "unlimitedStorage", @@ -130,6 +131,8 @@ ExtensionsAPIPermissions::GetAllPermissions() const { {APIPermission::kWebView, "webview", APIPermissionInfo::kFlagCannotBeOptional}, {APIPermission::kWindowShape, "app.window.shape"}, + {APIPermission::kFileSystemRequestDownloads, + "fileSystem.requestDownloads"}, }; std::vector<std::unique_ptr<APIPermissionInfo>> permissions; diff --git a/chromium/extensions/common/permissions/permissions_data.cc b/chromium/extensions/common/permissions/permissions_data.cc index b496d900e5d..57607454ce6 100644 --- a/chromium/extensions/common/permissions/permissions_data.cc +++ b/chromium/extensions/common/permissions/permissions_data.cc @@ -309,14 +309,6 @@ PermissionMessages PermissionsData::GetNewPermissionMessages( manifest_type_)); } -bool PermissionsData::HasWithheldImpliedAllHosts() const { - base::AutoLock auto_lock(runtime_lock_); - // Since we currently only withhold all_hosts, it's sufficient to check - // that either set is not empty. - return !withheld_permissions_unsafe_->explicit_hosts().is_empty() || - !withheld_permissions_unsafe_->scriptable_hosts().is_empty(); -} - bool PermissionsData::CanAccessPage(const GURL& document_url, int tab_id, std::string* error) const { diff --git a/chromium/extensions/common/permissions/permissions_data.h b/chromium/extensions/common/permissions/permissions_data.h index 265d2e8c97a..68cba77b844 100644 --- a/chromium/extensions/common/permissions/permissions_data.h +++ b/chromium/extensions/common/permissions/permissions_data.h @@ -176,10 +176,6 @@ class PermissionsData { PermissionMessages GetNewPermissionMessages( const PermissionSet& granted_permissions) const; - // Returns true if the extension has requested all-hosts permissions (or - // something close to it), but has had it withheld. - bool HasWithheldImpliedAllHosts() const; - // Returns true if the associated extension has permission to access and // interact with the specified page, in order to do things like inject // scripts or modify the content. diff --git a/chromium/extensions/common/permissions/settings_override_permission.cc b/chromium/extensions/common/permissions/settings_override_permission.cc index 00075e92ad5..40308a3554a 100644 --- a/chromium/extensions/common/permissions/settings_override_permission.cc +++ b/chromium/extensions/common/permissions/settings_override_permission.cc @@ -50,14 +50,7 @@ bool SettingsOverrideAPIPermission::FromValue( const base::Value* value, std::string* /*error*/, std::vector<std::string>* unhandled_permissions) { - // Ugly hack: |value| being null should be an error. But before M46 beta, we - // didn't store the parameter for settings override permissions in prefs. - // See crbug.com/533086 and crbug.com/619759. - // TODO(treib,devlin): Remove this for M56, when hopefully all users will have - // updated prefs. - // This should read: - // return value && value->GetAsString(&setting_value_); - return !value || value->GetAsString(&setting_value_); + return value && value->GetAsString(&setting_value_); } std::unique_ptr<base::Value> SettingsOverrideAPIPermission::ToValue() const { diff --git a/chromium/extensions/common/url_pattern.cc b/chromium/extensions/common/url_pattern.cc index f6051012a44..1d61d20f8fe 100644 --- a/chromium/extensions/common/url_pattern.cc +++ b/chromium/extensions/common/url_pattern.cc @@ -161,8 +161,13 @@ URLPattern::URLPattern(int valid_schemes, base::StringPiece pattern) match_effective_tld_(true), port_("*") { ParseResult result = Parse(pattern); - if (PARSE_SUCCESS != result) + if (PARSE_SUCCESS != result) { + // Temporarily add more logging to investigate why this code path is + // reached. For http://crbug.com/856948 + LOG(ERROR) << "Invalid pattern was given " << pattern << " result " + << result; NOTREACHED() << "URLPattern invalid: " << pattern << " result " << result; + } } URLPattern::URLPattern(const URLPattern& other) = default; @@ -261,16 +266,35 @@ URLPattern::ParseResult URLPattern::Parse(base::StringPiece pattern, base::StringPiece host_and_port = pattern.substr(host_start_pos, host_end_pos - host_start_pos); - // Ports are only valid with standard (and non-file) schemes. - base::StringPiece host_piece; - size_t port_pos = host_and_port.find(':'); - if (port_pos != base::StringPiece::npos && - !SetPort(host_and_port.substr(port_pos + 1))) { + size_t port_separator_pos = base::StringPiece::npos; + if (host_and_port[0] != '[') { + // Not IPv6 (either IPv4 or just a normal address). + port_separator_pos = host_and_port.find(':'); + } else { // IPv6. + size_t host_end_pos = host_and_port.find(']'); + if (host_end_pos == base::StringPiece::npos) + return PARSE_ERROR_INVALID_HOST; + if (host_end_pos == 1) + return PARSE_ERROR_EMPTY_HOST; + + if (host_end_pos < host_and_port.length() - 1) { + // The host isn't the only component. Check for a port. This would + // require a ':' to follow the closing ']' from the host. + if (host_and_port[host_end_pos + 1] != ':') + return PARSE_ERROR_INVALID_HOST; + + port_separator_pos = host_end_pos + 1; + } + } + + if (port_separator_pos != base::StringPiece::npos && + !SetPort(host_and_port.substr(port_separator_pos + 1))) { return PARSE_ERROR_INVALID_PORT; } - // Note: this substr() will be the entire string if the port position wasn't - // found. - host_piece = host_and_port.substr(0, port_pos); + + // Note: this substr() will be the entire string if the port position + // wasn't found. + base::StringPiece host_piece = host_and_port.substr(0, port_separator_pos); // The first component can optionally be '*' to match all subdomains. std::vector<base::StringPiece> host_components = base::SplitStringPiece( diff --git a/chromium/extensions/common/url_pattern.h b/chromium/extensions/common/url_pattern.h index 86523bd8623..89f81bbb925 100644 --- a/chromium/extensions/common/url_pattern.h +++ b/chromium/extensions/common/url_pattern.h @@ -20,7 +20,8 @@ class GURL; // <url-pattern> := <scheme>://<host><port><path> | '<all_urls>' // <scheme> := '*' | 'http' | 'https' | 'file' | 'ftp' | 'chrome' | // 'chrome-extension' | 'filesystem' -// <host> := '*' | '*.' <anychar except '/' and '*'>+ +// <host> := '*' | <IPv4 address> | [<IPv6 address>] | +// '*.' <anychar except '/' and '*'>+ // <port> := [':' ('*' | <port number between 0 and 65535>)] // <path> := '/' <any chars> // @@ -36,6 +37,7 @@ class GURL; // - https://*.google.com/foo*bar // - file://monkey* // - http://127.0.0.1/* +// - http://[2607:f8b0:4005:805::200e]/* // // Examples of invalid patterns: // - http://* -- path not specified diff --git a/chromium/extensions/common/url_pattern_set_unittest.cc b/chromium/extensions/common/url_pattern_set_unittest.cc index 86e4a4ded02..9a93a565fb5 100644 --- a/chromium/extensions/common/url_pattern_set_unittest.cc +++ b/chromium/extensions/common/url_pattern_set_unittest.cc @@ -458,6 +458,19 @@ TEST(URLPatternSetTest, AddOrigin) { URLPattern::SCHEME_HTTP, GURL("https://google.com/"))); } +TEST(URLPatternSet, AddOriginIPv6) { + { + URLPatternSet set; + EXPECT_TRUE(set.AddOrigin(URLPattern::SCHEME_HTTP, + GURL("http://[2607:f8b0:4005:805::200e]/*"))); + } + { + URLPatternSet set; + EXPECT_TRUE(set.AddOrigin(URLPattern::SCHEME_HTTP, + GURL("http://[2607:f8b0:4005:805::200e]/"))); + } +} + TEST(URLPatternSetTest, ToStringVector) { URLPatternSet set; AddPattern(&set, "https://google.com/"); diff --git a/chromium/extensions/common/url_pattern_unittest.cc b/chromium/extensions/common/url_pattern_unittest.cc index 130e8b5d6fa..64700bd09c1 100644 --- a/chromium/extensions/common/url_pattern_unittest.cc +++ b/chromium/extensions/common/url_pattern_unittest.cc @@ -101,6 +101,62 @@ TEST(ExtensionURLPatternTest, Ports) { } } +TEST(ExtensionURLPatternTest, IPv6Patterns) { + constexpr struct { + const char* pattern; + const char* expected_host; + const char* expected_port; + } kSuccessTestPatterns[] = { + {"http://[2607:f8b0:4005:805::200e]/", "[2607:f8b0:4005:805::200e]", "*"}, + {"http://[2607:f8b0:4005:805::200e]/*", "[2607:f8b0:4005:805::200e]", + "*"}, + {"http://[2607:f8b0:4005:805::200e]:8888/*", "[2607:f8b0:4005:805::200e]", + "8888"}, + }; + + for (const auto& test_case : kSuccessTestPatterns) { + SCOPED_TRACE(test_case.pattern); + URLPattern pattern(URLPattern::SCHEME_HTTP); + EXPECT_EQ(URLPattern::PARSE_SUCCESS, pattern.Parse(test_case.pattern)); + EXPECT_EQ(test_case.expected_host, pattern.host()); + EXPECT_EQ(test_case.expected_port, pattern.port()); + } + + constexpr struct { + const char* pattern; + URLPattern::ParseResult expected_failure; + } kFailureTestPatterns[] = { + // No port specified, but port separator. + {"http://[2607:f8b0:4005:805::200e]:/*", + URLPattern::PARSE_ERROR_INVALID_PORT}, + // No host. + {"http://[]:8888/*", URLPattern::PARSE_ERROR_EMPTY_HOST}, + // No closing bracket (`]`). + {"http://[2607:f8b0:4005:805::200e/*", + URLPattern::PARSE_ERROR_INVALID_HOST}, + // Two closing brackets (`]]`). + {"http://[2607:f8b0:4005:805::200e]]/*", + URLPattern::PARSE_ERROR_INVALID_HOST}, + // Two open brackets (`[[`). + {"http://[[2607:f8b0:4005:805::200e]/*", + URLPattern::PARSE_ERROR_INVALID_HOST}, + // Too few colons in the last chunk. + {"http://[2607:f8b0:4005:805:200e]/*", + URLPattern::PARSE_ERROR_INVALID_HOST}, + // Non-hex piece. + {"http://[2607:f8b0:4005:805:200e:12:bogus]/*", + URLPattern::PARSE_ERROR_INVALID_HOST}, + {"http://[[2607:f8b0:4005:805::200e]:abc/*", + URLPattern::PARSE_ERROR_INVALID_PORT}, + }; + + for (const auto& test_case : kFailureTestPatterns) { + SCOPED_TRACE(test_case.pattern); + URLPattern pattern(URLPattern::SCHEME_HTTP); + EXPECT_EQ(test_case.expected_failure, pattern.Parse(test_case.pattern)); + } +} + // all pages for a given scheme TEST(ExtensionURLPatternTest, Match1) { URLPattern pattern(kAllSchemes); diff --git a/chromium/extensions/common/view_type.cc b/chromium/extensions/common/view_type.cc index 6d5912b73d0..2b35474cc90 100644 --- a/chromium/extensions/common/view_type.cc +++ b/chromium/extensions/common/view_type.cc @@ -18,12 +18,11 @@ bool GetViewTypeFromString(const std::string& view_type, static const struct { ViewType type; base::StringPiece name; - } kTypeMap[] = { + } constexpr kTypeMap[] = { {VIEW_TYPE_APP_WINDOW, "APP_WINDOW"}, {VIEW_TYPE_EXTENSION_BACKGROUND_PAGE, "BACKGROUND"}, {VIEW_TYPE_EXTENSION_DIALOG, "EXTENSION_DIALOG"}, {VIEW_TYPE_EXTENSION_POPUP, "POPUP"}, - {VIEW_TYPE_PANEL, "PANEL"}, {VIEW_TYPE_TAB_CONTENTS, "TAB"}, }; diff --git a/chromium/extensions/common/view_type.h b/chromium/extensions/common/view_type.h index a58524f9970..0a986fc3934 100644 --- a/chromium/extensions/common/view_type.h +++ b/chromium/extensions/common/view_type.h @@ -12,8 +12,8 @@ namespace extensions { // Icky RTTI used by a few systems to distinguish the host type of a given // WebContents. // -// Do not change the order of entries or remove entries in this list as this -// is used in ExtensionViewType enum in tools/metrics/histograms/enums.xml. +// Do not change or reuse the the entry values in this list as this is used in +// ExtensionViewType enum in tools/metrics/histograms/enums.xml. // // TODO(aa): Remove this and teach those systems to keep track of their own // data. @@ -29,7 +29,10 @@ enum ViewType { VIEW_TYPE_EXTENSION_DIALOG = 5, VIEW_TYPE_EXTENSION_GUEST = 6, VIEW_TYPE_EXTENSION_POPUP = 7, - VIEW_TYPE_PANEL = 8, + + // Panels were removed in https://crbug.com/571511. + // DEPRECATED_VIEW_TYPE_PANEL = 8, + VIEW_TYPE_TAB_CONTENTS = 9, VIEW_TYPE_LAST = VIEW_TYPE_TAB_CONTENTS |
