diff options
| author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-07-12 14:07:37 +0200 |
|---|---|---|
| committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-07-17 10:29:26 +0000 |
| commit | ec02ee4181c49b61fce1c8fb99292dbb8139cc90 (patch) | |
| tree | 25cde714b2b71eb639d1cd53f5a22e9ba76e14ef /chromium/extensions/common | |
| parent | bb09965444b5bb20b096a291445170876225268d (diff) | |
| download | qtwebengine-chromium-ec02ee4181c49b61fce1c8fb99292dbb8139cc90.tar.gz | |
BASELINE: Update Chromium to 59.0.3071.134
Change-Id: Id02ef6fb2204c5fd21668a1c3e6911c83b17585a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/extensions/common')
75 files changed, 2009 insertions, 351 deletions
diff --git a/chromium/extensions/common/BUILD.gn b/chromium/extensions/common/BUILD.gn index edbf276efd3..8af643d9d42 100644 --- a/chromium/extensions/common/BUILD.gn +++ b/chromium/extensions/common/BUILD.gn @@ -19,11 +19,20 @@ source_set("common_constants") { if (enable_extensions) { mojom("mojo") { sources = [ + "extension_unpacker.mojom", + "manifest_parser.mojom", + "mojo/app_window.mojom", "mojo/keep_alive.mojom", ] + if (proprietary_codecs && enable_wifi_display) { sources += [ "mojo/wifi_display_session_service.mojom" ] } + + public_deps = [ + "//mojo/common:common_custom_types", + "//url/mojo:url_mojom_gurl", + ] } # This must be a static library because extensions common depends on @@ -92,6 +101,7 @@ if (enable_extensions) { "extension_urls.cc", "extension_urls.h", "extension_utility_messages.h", + "extension_utility_types.h", "extensions_aliases.cc", "extensions_aliases.h", "extensions_client.cc", @@ -170,6 +180,8 @@ if (enable_extensions) { "manifest_handlers/options_page_info.h", "manifest_handlers/permissions_parser.cc", "manifest_handlers/permissions_parser.h", + "manifest_handlers/plugins_handler.cc", + "manifest_handlers/plugins_handler.h", "manifest_handlers/requirements_info.cc", "manifest_handlers/requirements_info.h", "manifest_handlers/sandboxed_page_info.cc", @@ -180,6 +192,8 @@ if (enable_extensions) { "manifest_handlers/web_accessible_resources_info.h", "manifest_handlers/webview_info.cc", "manifest_handlers/webview_info.h", + "manifest_location_param_traits.cc", + "manifest_location_param_traits.h", "manifest_url_handlers.cc", "manifest_url_handlers.h", "message_bundle.cc", @@ -257,6 +271,7 @@ if (enable_extensions) { public_deps = [ ":common_constants", ":mojo", + "//ipc", "//skia", ] @@ -276,7 +291,6 @@ if (enable_extensions) { "//extensions:extensions_resources", "//extensions/common/api", "//extensions/strings", - "//ipc", "//net", "//third_party/boringssl", "//third_party/icu", diff --git a/chromium/extensions/common/OWNERS b/chromium/extensions/common/OWNERS index f1f3a154d50..7327a7ba58e 100644 --- a/chromium/extensions/common/OWNERS +++ b/chromium/extensions/common/OWNERS @@ -2,3 +2,12 @@ per-file *_messages*.h=set noparent per-file *_messages*.h=file://ipc/SECURITY_OWNERS per-file *_messages.cc=set noparent per-file *_messages.cc=file://ipc/SECURITY_OWNERS +per-file *.mojom=set noparent +per-file *.mojom=file://ipc/SECURITY_OWNERS +per-file *_param_traits*.*=set noparent +per-file *_param_traits*.*=file://ipc/SECURITY_OWNERS +per-file *.typemap=set noparent +per-file *.typemap=file://ipc/SECURITY_OWNERS +per-file *_struct_traits*.*=set noparent +per-file *_struct_traits*.*=file://ipc/SECURITY_OWNERS + diff --git a/chromium/extensions/common/api/_api_features.json b/chromium/extensions/common/api/_api_features.json index 808d9791674..3c12e67ab15 100644 --- a/chromium/extensions/common/api/_api_features.json +++ b/chromium/extensions/common/api/_api_features.json @@ -180,7 +180,7 @@ "contexts": ["blessed_extension"] }, { "internal": true, - "channel": "trunk", + "channel": "stable", "contexts": ["webui"], "matches": [ "chrome://cast/*", @@ -241,7 +241,7 @@ "contexts": ["blessed_extension"], "default_parent": true }, { - "channel": "trunk", + "channel": "stable", "contexts": ["webui"], "matches": [ "chrome://md-settings/*", @@ -519,7 +519,7 @@ "contexts": ["blessed_extension"] }, { "internal": true, - "channel": "dev", + "channel": "stable", "contexts": ["webui"], "matches": [ "chrome://chrome-signin/*", diff --git a/chromium/extensions/common/api/_behavior_features.json b/chromium/extensions/common/api/_behavior_features.json index c4b4fe111a0..b33eec568ad 100644 --- a/chromium/extensions/common/api/_behavior_features.json +++ b/chromium/extensions/common/api/_behavior_features.json @@ -81,7 +81,8 @@ "40FF1103292F40C34066E023B8BE8CAE18306EAE", // Chromeos help "3C654B3B6682CA194E75AD044CEDE927675DDEE8", // Easy unlock "CBCC42ABED43A4B58FE3810E62AFFA010EB0349F", // PDF Viewer - "2FCBCE08B34CCA1728A85F1EFBD9A34DD2558B2E" // ChromeVox + "2FCBCE08B34CCA1728A85F1EFBD9A34DD2558B2E", // ChromeVox + "7910EAFDAF64B947E1CB31B333A9BD14CA556B6C" // Feedback extension ] }], "allow_deprecated_audio_api": { diff --git a/chromium/extensions/common/api/_permission_features.json b/chromium/extensions/common/api/_permission_features.json index cd8b963cf9b..b64d0c40eb7 100644 --- a/chromium/extensions/common/api/_permission_features.json +++ b/chromium/extensions/common/api/_permission_features.json @@ -62,24 +62,28 @@ "channel": "stable", "extension_types": ["platform_app"] }, - "app.window.ime": [ - { - "channel": "stable", - "extension_types": ["extension"], - "platforms": ["chromeos"], - "whitelist": [ - "06BE211D5F014BAB34BC22D9DDA09C63A81D828E", - "F94EE6AB36D6C6588670B2B01EB65212D9C64E33", - "B9EF10DDFEA11EF77873CC5009809E5037FC4C7A" // http://crbug.com/435380 - ] - } - ], + "app.window.ime": { + "channel": "stable", + "extension_types": ["extension"], + "platforms": ["chromeos"], + "whitelist": [ + "06BE211D5F014BAB34BC22D9DDA09C63A81D828E", + "F94EE6AB36D6C6588670B2B01EB65212D9C64E33", + "B9EF10DDFEA11EF77873CC5009809E5037FC4C7A" // http://crbug.com/435380 + ] + }, "appview": { "channel": "stable", "extension_types": ["platform_app"] }, "audio": [ { + "channel": "stable", + "extension_types": ["platform_app"], + "platforms": ["chromeos"], + "session_types": ["kiosk"] + }, + { "channel": "dev", "extension_types": ["platform_app"] }, @@ -233,7 +237,11 @@ "496B6890097EB6E19809ADEADD095A8721FBB2E0", // FIDO U2F APIs "AD8ED80B705E1818AAD4684F9FF62B43D6D79620", // FIDO U2F APIs (dev) "E24F1786D842E91E74C27929B0B3715A4689A473", // CryptoToken - "A28C9619C4C41306FA5236FB4D94DA812F504DE8" // CryptoToken (dev) + "A28C9619C4C41306FA5236FB4D94DA812F504DE8", // CryptoToken (dev) + "D7CD4B3956B1F6E970E4AFCBCD4094B1EF4D07B9", // http://crbug.com/710541 + "D4EFCCC0CC612380762758BB96C7997224BD6395", // http://crbug.com/710541 + "4839A26B29CD1BD021B2E126EF6D28C9CB84018B", // http://crbug.com/710541 + "8F44FBB4474CCDF23450B166C9E83E85BD03AE24" // http://crbug.com/710541 ] } ], @@ -298,7 +306,7 @@ "extension_types": ["extension", "platform_app"] }, "networking.onc": [{ - "channel": "dev", + "channel": "stable", "extension_types": ["platform_app"], "platforms": ["chromeos"], "session_types": ["kiosk.autolaunched"] @@ -456,20 +464,18 @@ "whitelist": ["B44D08FD98F1523ED5837D78D0A606EA9D6206E5"] // Web Store } ], - "u2fDevices": [ - { - "channel": "stable", - "extension_types": ["extension", "platform_app"], - "whitelist": [ - "496B6890097EB6E19809ADEADD095A8721FBB2E0", // FIDO U2F APIs - "AD8ED80B705E1818AAD4684F9FF62B43D6D79620", // FIDO U2F APIs (dev) - "E24F1786D842E91E74C27929B0B3715A4689A473", // CryptoToken - "A28C9619C4C41306FA5236FB4D94DA812F504DE8", // CryptoToken (dev) - "6F9E349A0561C78A0D3F41496FE521C5151C7F71", // Security Key - "C06709A259378015404ED20F75C7D08547E0F10B" // Security Key (dev) - ] - } - ], + "u2fDevices": { + "channel": "stable", + "extension_types": ["extension", "platform_app"], + "whitelist": [ + "496B6890097EB6E19809ADEADD095A8721FBB2E0", // FIDO U2F APIs + "AD8ED80B705E1818AAD4684F9FF62B43D6D79620", // FIDO U2F APIs (dev) + "E24F1786D842E91E74C27929B0B3715A4689A473", // CryptoToken + "A28C9619C4C41306FA5236FB4D94DA812F504DE8", // CryptoToken (dev) + "6F9E349A0561C78A0D3F41496FE521C5151C7F71", // Security Key + "C06709A259378015404ED20F75C7D08547E0F10B" // Security Key (dev) + ] + }, "unlimitedStorage": { "channel": "stable", "extension_types": [ @@ -504,7 +510,11 @@ "496B6890097EB6E19809ADEADD095A8721FBB2E0", // FIDO U2F APIs "AD8ED80B705E1818AAD4684F9FF62B43D6D79620", // FIDO U2F APIs (dev) "E24F1786D842E91E74C27929B0B3715A4689A473", // CryptoToken - "A28C9619C4C41306FA5236FB4D94DA812F504DE8" // CryptoToken (dev) + "A28C9619C4C41306FA5236FB4D94DA812F504DE8", // CryptoToken (dev) + "D7CD4B3956B1F6E970E4AFCBCD4094B1EF4D07B9", // http://crbug.com/710541 + "D4EFCCC0CC612380762758BB96C7997224BD6395", // http://crbug.com/710541 + "4839A26B29CD1BD021B2E126EF6D28C9CB84018B", // http://crbug.com/710541 + "8F44FBB4474CCDF23450B166C9E83E85BD03AE24" // http://crbug.com/710541 ] } ], diff --git a/chromium/extensions/common/api/bluetooth_private.idl b/chromium/extensions/common/api/bluetooth_private.idl index f943ab5616f..b2d760b9040 100644 --- a/chromium/extensions/common/api/bluetooth_private.idl +++ b/chromium/extensions/common/api/bluetooth_private.idl @@ -45,22 +45,15 @@ namespace bluetoothPrivate { // Results for connect(). See function declaration for details. enum ConnectResultType { alreadyConnected, - attributeLengthInvalid, authCanceled, authFailed, authRejected, authTimeout, - connectionCongested, failed, inProgress, - insufficientEncryption, - offsetInvalid, - readNotPermitted, - requestNotSupported, success, unknownError, - unsupportedDevice, - writeNotPermitted + unsupportedDevice }; // Valid pairing responses. diff --git a/chromium/extensions/common/api/declarative/declarative_manifest_data.cc b/chromium/extensions/common/api/declarative/declarative_manifest_data.cc index 13bfdcc56f1..310113098de 100644 --- a/chromium/extensions/common/api/declarative/declarative_manifest_data.cc +++ b/chromium/extensions/common/api/declarative/declarative_manifest_data.cc @@ -129,9 +129,9 @@ std::unique_ptr<DeclarativeManifestData> DeclarativeManifestData::FromValue( for (const auto& element : *list) { const base::DictionaryValue* dict = nullptr; - if (!element->GetAsDictionary(&dict)) { + if (!element.GetAsDictionary(&dict)) { error_builder.Append("expected dictionary, got %s", - base::Value::GetTypeName(element->GetType())); + base::Value::GetTypeName(element.GetType())); return std::unique_ptr<DeclarativeManifestData>(); } std::string event; diff --git a/chromium/extensions/common/api/events.json b/chromium/extensions/common/api/events.json index ba31dea3ae6..5c355c0f982 100644 --- a/chromium/extensions/common/api/events.json +++ b/chromium/extensions/common/api/events.json @@ -34,7 +34,7 @@ "actions": { "type": "array", "items": {"type": "any"}, - "description": "List of actions that are triggered if one of the condtions is fulfilled." + "description": "List of actions that are triggered if one of the conditions is fulfilled." }, "priority": { "type": "integer", diff --git a/chromium/extensions/common/api/networking_onc.idl b/chromium/extensions/common/api/networking_onc.idl new file mode 100644 index 00000000000..960c7a90cc4 --- /dev/null +++ b/chromium/extensions/common/api/networking_onc.idl @@ -0,0 +1,1017 @@ +// Copyright 2017 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. + +// <p> +// The <code>chrome.networking.onc</code> API is used for configuring +// network connections (Cellular, Ethernet, VPN, WiFi or WiMAX). +// This API is available in Chrome OS kiosk sessions. +// </p> +// <p> +// Network connection configurations are specified following +// <a href="https://chromium.googlesource.com/chromium/src/+/master/components/onc/docs/onc_spec.md"> +// Open Network Configuration (ONC)</a> specification. +// </p> +// <p> +// <b>NOTE</b>: Most dictionary properties and enum values use UpperCamelCase +// to match the ONC specification instead of the JavaScript lowerCamelCase +// convention. +// </p> +namespace networking.onc { + enum ActivationStateType { + Activated, Activating, NotActivated, PartiallyActivated + }; + + enum CaptivePortalStatus { + Unknown, Offline, Online, Portal, ProxyAuthRequired + }; + + enum ConnectionStateType { + Connected, Connecting, NotConnected + }; + + enum DeviceStateType { + // Device is available but not initialized. + Uninitialized, + // Device is initialized but not enabled. + Disabled, + // Enabled state has been requested but has not completed. + Enabling, + // Device is enabled. + Enabled, + // Device is prohibited. + Prohibited + }; + + enum IPConfigType { + DHCP, Static + }; + + enum NetworkType { + All, Cellular, Ethernet, VPN, Wireless, WiFi, WiMAX + }; + + enum ProxySettingsType { + Direct, Manual, PAC, WPAD + }; + + enum ClientCertificateType { + Ref, Pattern + }; + + dictionary ManagedBoolean { + // The active value currently used by the network configuration manager + // (e.g. Shill). + boolean? Active; + // The source from which the effective property value was determined. + DOMString? Effective; + // The property value provided by the user policy. + boolean? UserPolicy; + // The property value provided by the device policy. + boolean? DevicePolicy; + // The property value set by the logged in user. Only provided if + // |UserEditable| is <code>true</code>. + boolean? UserSetting; + // The value set for all users of the device. Only provided if + // |DeviceEditiable| is <code>true</code>. + boolean? SharedSetting; + // Whether a UserPolicy for the property exists and allows the property to + // be edited (i.e. the policy set recommended property value). + // Defaults to <code>false</code>. + boolean? UserEditable; + // Whether a DevicePolicy for the property exists and allows the property to + // be edited (i.e. the policy set recommended property value). + // Defaults to <code>false</code>. + boolean? DeviceEditable; + }; + + dictionary ManagedLong { + // The active value currently used by the network configuration manager + // (e.g. Shill). + long? Active; + // The source from which the effective property value was determined. + DOMString? Effective; + // The property value provided by the user policy. + long? UserPolicy; + // The property value provided by the device policy. + long? DevicePolicy; + // The property value set by the logged in user. Only provided if + // |UserEditable| is <code>true</code>. + long? UserSetting; + // The value set for all users of the device. Only provided if + // |DeviceEditiable| is <code>true</code>. + long? SharedSetting; + // Whether a UserPolicy for the property exists and allows the property to + // be edited (i.e. the policy set recommended property value). + // Defaults to <code>false</code>. + boolean? UserEditable; + // Whether a DevicePolicy for the property exists and allows the property to + // be edited (i.e. the policy set recommended property value). + // Defaults to <code>false</code>. + boolean? DeviceEditable; + }; + + dictionary ManagedDOMString { + // The active value currently used by the network configuration manager + // (e.g. Shill). + DOMString? Active; + // The source from which the effective property value was determined. + DOMString? Effective; + // The property value provided by the user policy. + DOMString? UserPolicy; + // The property value provided by the device policy. + DOMString? DevicePolicy; + // The property value set by the logged in user. Only provided if + // |UserEditable| is <code>true</code>. + DOMString? UserSetting; + // The value set for all users of the device. Only provided if + // |DeviceEditiable| is <code>true</code>. + DOMString? SharedSetting; + // Whether a UserPolicy for the property exists and allows the property to + // be edited (i.e. the policy set recommended property value). + // Defaults to <code>false</code>. + boolean? UserEditable; + // Whether a DevicePolicy for the property exists and allows the property to + // be edited (i.e. the policy set recommended property value). + // Defaults to <code>false</code>. + boolean? DeviceEditable; + }; + + dictionary ManagedDOMStringList { + // The active value currently used by the network configuration manager + // (e.g. Shill). + DOMString[]? Active; + // The source from which the effective property value was determined. + DOMString? Effective; + // The property value provided by the user policy. + DOMString[]? UserPolicy; + // The property value provided by the device policy. + DOMString[]? DevicePolicy; + // The property value set by the logged in user. Only provided if + // |UserEditable| is <code>true</code>. + DOMString[]? UserSetting; + // The value set for all users of the device. Only provided if + // |DeviceEditiable| is <code>true</code>. + DOMString[]? SharedSetting; + // Whether a UserPolicy for the property exists and allows the property to + // be edited (i.e. the policy set recommended property value). + // Defaults to <code>false</code>. + boolean? UserEditable; + // Whether a DevicePolicy for the property exists and allows the property to + // be edited (i.e. the policy set recommended property value). + // Defaults to <code>false</code>. + boolean? DeviceEditable; + }; + + dictionary ManagedIPConfigType { + // The active value currently used by the network configuration manager + // (e.g. Shill). + IPConfigType? Active; + // The source from which the effective property value was determined. + DOMString? Effective; + // The property value provided by the user policy. + IPConfigType? UserPolicy; + // The property value provided by the device policy. + IPConfigType? DevicePolicy; + // The property value set by the logged in user. Only provided if + // |UserEditable| is <code>true</code>. + IPConfigType? UserSetting; + // The value set for all users of the device. Only provided if + // |DeviceEditiable| is <code>true</code>. + IPConfigType? SharedSetting; + // Whether a UserPolicy for the property exists and allows the property to + // be edited (i.e. the policy set recommended property value). + // Defaults to <code>false</code>. + boolean? UserEditable; + // Whether a DevicePolicy for the property exists and allows the property to + // be edited (i.e. the policy set recommended property value). + // Defaults to <code>false</code>. + boolean? DeviceEditable; + }; + + dictionary ManagedProxySettingsType { + // The active value currently used by the network configuration manager + // (e.g. Shill). + ProxySettingsType? Active; + // The source from which the effective property value was determined. + DOMString? Effective; + // The property value provided by the user policy. + ProxySettingsType? UserPolicy; + // The property value provided by the device policy. + ProxySettingsType? DevicePolicy; + // The property value set by the logged in user. Only provided if + // |UserEditable| is <code>true</code>. + ProxySettingsType? UserSetting; + // The value set for all users of the device. Only provided if + // |DeviceEditiable| is <code>true</code>. + ProxySettingsType? SharedSetting; + // Whether a UserPolicy for the property exists and allows the property to + // be edited (i.e. the policy set recommended property value). + // Defaults to <code>false</code>. + boolean? UserEditable; + // Whether a DevicePolicy for the property exists and allows the property to + // be edited (i.e. the policy set recommended property value). + // Defaults to <code>false</code>. + boolean? DeviceEditable; + }; + + // Sub-dictionary types. + + dictionary CellularProviderProperties { + // The operator name. + DOMString Name; + // Cellular network ID as a simple concatenation of the network's + // MCC (Mobile Country Code) and MNC (Mobile Network Code). + DOMString Code; + // The two-letter country code. + DOMString? Country; + }; + + dictionary IssuerSubjectPattern { + // If set, the value against which to match the certificate subject's + // common name. + DOMString? CommonName; + // If set, the value against which to match the certificate subject's + // common location. + DOMString? Locality; + // If set, the value against which to match the certificate subject's + // organizations. At least one organization should match the value. + DOMString? Organization; + // 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; + }; + + dictionary CertificatePattern { + // List of URIs to which the user can be directed in case no certificates + // that match this pattern are found. + DOMString[]? EnrollmentURI; + // If set, pattern against which X.509 issuer settings should be matched. + IssuerSubjectPattern? Issuer; + // List of certificate issuer CA certificates. A certificate must be signed + // by one of them in order to match this pattern. + DOMString[]? IssuerCARef; + // If set, pattern against which X.509 subject settings should be matched. + IssuerSubjectPattern? Subject; + }; + + dictionary EAPProperties { + DOMString? AnonymousIdentity; + CertificatePattern? ClientCertPattern; + DOMString? ClientCertRef; + ClientCertificateType ClientCertType; + DOMString? Identity; + DOMString? Inner; + // The outer EAP type. Required by ONC, but may not be provided when + // translating from Shill. + DOMString? Outer; + DOMString? Password; + boolean? SaveCredentials; + DOMString[]? ServerCAPEMs; + DOMString[]? ServerCARefs; + boolean? UseProactiveKeyCaching; + boolean? UseSystemCAs; + }; + + dictionary FoundNetworkProperties { + // Network availability. + DOMString Status; + // Network ID. + DOMString NetworkId; + // Access technology used by the network. + DOMString Technology; + // The network operator's short-format name. + DOMString? ShortName; + // The network operator's long-format name. + DOMString? LongName; + }; + + dictionary IPConfigProperties { + // Gateway address used for the IP configuration. + DOMString? Gateway; + // The IP address for a connection. Can be IPv4 or IPv6 address, depending + // on value of <code>Type</code>. + DOMString? IPAddress; + // Array of addresses used for name servers. + DOMString[]? NameServers; + // The routing prefix. + long? RoutingPrefix; + // The IP configuration type. Can be <code>IPv4</code> or <code>IPv6</code>. + DOMString? Type; + // The URL for WEb Proxy Auto-Discovery, as reported over DHCP. + DOMString? WebProxyAutoDiscoveryUrl; + }; + + dictionary ManagedIPConfigProperties { + // See $(ref:IPConfigProperties.Gateway). + ManagedDOMString? Gateway; + // See $(ref:IPConfigProperties.IPAddress). + ManagedDOMString? IPAddress; + // See $(ref:IPConfigProperties.NameServers). + ManagedDOMStringList? NameServers; + // See $(ref:IPConfigProperties.RoutingPrefix). + ManagedLong? RoutingPrefix; + // See $(ref:IPConfigProperties.Type). + ManagedDOMString? Type; + // See $(ref:IPConfigProperties.WebProxyAutoDiscoveryUrl). + ManagedDOMString? WebProxyAutoDiscoveryUrl; + }; + + dictionary PaymentPortal { + // The HTTP method to use for the payment portal. + DOMString Method; + // The post data to send to the payment portal. Ignored unless + // <code>Method</code> is <code>POST</code>. + DOMString? PostData; + // The payment portal URL. + DOMString? Url; + }; + + dictionary ProxyLocation { + // The proxy IP address host. + DOMString Host; + // The port to use for the proxy. + long Port; + }; + + dictionary ManagedProxyLocation { + // See $(ref:ProxyLocation.Host). + ManagedDOMString Host; + // See $(ref:ProxyLocation.Port). + ManagedLong Port; + }; + + [noinline_doc] dictionary ManualProxySettings { + // Settings for HTTP proxy. + ProxyLocation? HTTPProxy; + // Settings for secure HTTP proxy. + ProxyLocation? SecureHTTPProxy; + // Settings for FTP proxy. + ProxyLocation? FTPProxy; + // Settings for SOCKS proxy. + ProxyLocation? SOCKS; + }; + + dictionary ManagedManualProxySettings { + // See $(ref:ManualProxySettings.HTTPProxy). + ManagedProxyLocation? HTTPProxy; + // See $(ref:ManualProxySettings.SecureHTTPProxy). + ManagedProxyLocation? SecureHTTPProxy; + // See $(ref:ManualProxySettings.FTPProxy). + ManagedProxyLocation? FTPProxy; + // See $(ref:ManualProxySettings.SOCKS). + ManagedProxyLocation? SOCKS; + }; + + [noinline_doc] dictionary ProxySettings { + // The type of proxy settings. + ProxySettingsType Type; + // Manual proxy settings - used only for <code>Manual</code> proxy settings. + ManualProxySettings? Manual; + // Domains and hosts for which manual proxy settings are excluded. + DOMString[]? ExcludeDomains; + // URL for proxy auto-configuration file. + DOMString? PAC; + }; + + dictionary ManagedProxySettings { + // See $(ref:ProxySettings.Type). + ManagedProxySettingsType Type; + // See $(ref:ProxySettings.Manual). + ManagedManualProxySettings? Manual; + // See $(ref:ProxySettings.ExcludeDomains). + ManagedDOMStringList? ExcludeDomains; + // See $(ref:ProxySettings.PAC). + ManagedDOMString? PAC; + }; + + dictionary SIMLockStatus { + // The status of SIM lock - possible values are <code>'sim-pin'</code>, + // <code>'sim-puk'</code> and <code>''</code>. + DOMString LockType; + // Whether SIM lock is enabled. + boolean LockEnabled; + // Number of PIN lock tries allowed before PUK is required to unlock the + // SIM. + long? RetriesLeft; + }; + + dictionary ThirdPartyVPNProperties { + // ID of the third-party VPN provider extension. + DOMString ExtensionID; + // The VPN provider name. + DOMString? ProviderName; + }; + + dictionary ManagedThirdPartyVPNProperties { + // See $(ref:ThirdPartyVPNProperties.ExtensionID). + ManagedDOMString ExtensionID; + // See $(ref:ThirdPartyVPNProperties.ProviderName). + DOMString? ProviderName; + }; + + // Network type dictionary types. + + [noinline_doc] dictionary CellularProperties { + // Whether the cellular network should be connected automatically (when + // in range). + boolean? AutoConnect; + // The cellular network activation type. + DOMString? ActivationType; + // Carrier account activation state. + ActivationStateType? ActivationState; + // Whether roaming is allowed for the network. + boolean? AllowRoaming; + // The name of the carrier for which the cellular device is configured. + DOMString? Carrier; + // Cellular device technology family - <code>CDMA</code> or + // <code>GSM</code>. + DOMString? Family; + // The firmware revision loaded in the cellular modem. + DOMString? FirmwareRevision; + // The list of networks found during the most recent network scan. + FoundNetworkProperties[]? FoundNetworks; + // The cellular modem hardware revision. + DOMString? HardwareRevision; + // Information about the operator that issued the SIM card currently + // installed in the modem. + CellularProviderProperties? HomeProvider; + // The cellular modem manufacturer. + DOMString? Manufacturer; + // The cellular modem model ID. + DOMString? ModelID; + // If the modem is registered on a network, the network technology + // currently in use. + DOMString? NetworkTechnology; + // Online payment portal a user can use to sign-up for or modify a mobile + // data plan. + PaymentPortal? PaymentPortal; + // The revision of the Preferred Roaming List loaded in the modem. + long? PRLVersion; + // The roaming state of the cellular modem on the current network. + DOMString? RoamingState; + // Information about the operator on whose network the modem is currently + // registered. + CellularProviderProperties? ServingOperator; + // The state of SIM lock for GSM family networks. + SIMLockStatus? SIMLockStatus; + // Whether a SIM card is present. + boolean? SIMPresent; + // The current network signal strength. + long? SignalStrength; + // Whether the cellular network supports scanning. + boolean? SupportNetworkScan; + // A list of supported carriers. + DOMString[]? SupportedCarriers; + }; + + dictionary ManagedCellularProperties { + // See $(ref:CellularProperties.AutoConnect). + ManagedBoolean? AutoConnect; + // See $(ref:CellularProperties.ActivationType). + DOMString? ActivationType; + // See $(ref:CellularProperties.ActivationState). + ActivationStateType? ActivationState; + // See $(ref:CellularProperties.AllowRoaming). + boolean? AllowRoaming; + // See $(ref:CellularProperties.Carrier). + ManagedDOMString? Carrier; + // See $(ref:CellularProperties.Family). + DOMString? Family; + // See $(ref:CellularProperties.FirmwareRevision). + DOMString? FirmwareRevision; + // See $(ref:CellularProperties.FoundNetworks). + FoundNetworkProperties[]? FoundNetworks; + // See $(ref:CellularProperties.HardwareRevision). + DOMString? HardwareRevision; + // See $(ref:CellularProperties.HomeProvider). + CellularProviderProperties[]? HomeProvider; + // See $(ref:CellularProperties.Manufacturer). + DOMString? Manufacturer; + // See $(ref:CellularProperties.ModelID). + DOMString? ModelID; + // See $(ref:CellularProperties.NetworkTechnology). + DOMString? NetworkTechnology; + // See $(ref:CellularProperties.PaymentPortal). + PaymentPortal? PaymentPortal; + // See $(ref:CellularProperties.PRLVersion). + long? PRLVersion; + // See $(ref:CellularProperties.RoamingState). + DOMString? RoamingState; + // See $(ref:CellularProperties.ServingOperator). + CellularProviderProperties? ServingOperator; + // See $(ref:CellularProperties.SIMLockStatus). + SIMLockStatus? SIMLockStatus; + // See $(ref:CellularProperties.SIMPresent). + boolean? SIMPresent; + // See $(ref:CellularProperties.SignalStrength). + long? SignalStrength; + // See $(ref:CellularProperties.SupportNetworkScan). + boolean? SupportNetworkScan; + // See $(ref:CellularProperties.SupportedCarriers). + DOMString[]? SupportedCarriers; + }; + + dictionary CellularStateProperties { + // See $(ref:CellularProperties.ActivationState). + ActivationStateType? ActivationState; + // See $(ref:CellularProperties.NetworkTechnology). + DOMString? NetworkTechnology; + // See $(ref:CellularProperties.RoamingState). + DOMString? RoamingState; + // See $(ref:CellularProperties.SIMPresent). + boolean? SIMPresent; + // See $(ref:CellularProperties.SignalStrength). + long? SignalStrength; + }; + + dictionary EthernetProperties { + // 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>. + DOMString? Authentication; + // Network's EAP settings. Required for 8021X authentication. + EAPProperties? EAP; + }; + + dictionary ManagedEthernetProperties { + // See $(ref:EthernetProperties.AutoConnect). + ManagedBoolean? AutoConnect; + // See $(ref:EthernetProperties.Authentication). + ManagedDOMString? Authentication; + }; + + dictionary EthernetStateProperties { + // See $(ref:EthernetProperties.Authentication). + DOMString Authentication; + }; + + dictionary VPNProperties { + // Whether the VPN network should be connected automatically. + boolean? AutoConnect; + // The VPN host. + DOMString? Host; + // The VPN type. + DOMString? Type; + }; + + dictionary ManagedVPNProperties { + // See $(ref:VPNProperties.AutoConnect). + ManagedBoolean? AutoConnect; + // See $(ref:VPNProperties.Host). + ManagedDOMString? Host; + // See $(ref:VPNProperties.Type). + ManagedDOMString Type; + }; + + dictionary VPNStateProperties { + // See $(ref:VPNProperties.Type). + DOMString Type; + }; + + [noinline_doc] dictionary WiFiProperties { + // Whether ARP polling of default gateway is allowed. Defaults to true. + boolean? AllowGatewayARPPolling; + // Whether the WiFi network should be connected automatically when in range. + boolean? AutoConnect; + // The BSSID of the associated access point.. + DOMString? BSSID; + // The network EAP properties. Required for <code>WEP-8021X</code> and + // <code>WPA-EAP</code> networks. + EAPProperties? EAP; + // The WiFi service operating frequency in MHz. For connected networks, the + // current frequency on which the network is connected. Otherwise, the + // frequency of the best available BSS. + long? Frequency; + // Contains all operating frequency recently seen for the WiFi network. + long[]? FrequencyList; + // HEX-encoded copy of the network SSID. + DOMString? HexSSID; + // Whether the network SSID will be broadcast. + boolean? HiddenSSID; + // Signal-to-noise value (in dB) below which roaming to a new network + // should be attempted. + long? RoamThreshold; + // The network SSID. + DOMString? SSID; + // The network security type. + DOMString? Security; + // The network signal strength. + long? SignalStrength; + }; + + dictionary ManagedWiFiProperties { + // See $(ref:WiFiProperties.AllowGatewayARPPolling). + ManagedBoolean? AllowGatewayARPPolling; + // See $(ref:WiFiProperties.AutoConnect). + ManagedBoolean? AutoConnect; + // See $(ref:WiFiProperties.BSSID). + DOMString? BSSID; + // See $(ref:WiFiProperties.Frequency). + long? Frequency; + // See $(ref:WiFiProperties.FrequencyList). + long[]? FrequencyList; + // See $(ref:WiFiProperties.HexSSID). + ManagedDOMString? HexSSID; + // See $(ref:WiFiProperties.HiddenSSID). + ManagedBoolean? HiddenSSID; + // See $(ref:WiFiProperties.RoamThreshold). + ManagedLong? RoamThreshold; + // See $(ref:WiFiProperties.SSID). + ManagedDOMString? SSID; + // See $(ref:WiFiProperties.Security). + ManagedDOMString Security; + // See $(ref:WiFiProperties.SignalStrength). + long? SignalStrength; + }; + + dictionary WiFiStateProperties { + // See $(ref:WiFiProperties.BSSID). + DOMString? BSSID; + // See $(ref:WiFiProperties.Frequency). + long? Frequency; + // See $(ref:WiFiProperties.Security). + DOMString Security; + // See $(ref:WiFiProperties.SignalStrength). + long? SignalStrength; + }; + + dictionary WiMAXProperties { + // Whether the network should be connected automatically. + boolean? AutoConnect; + // The network EAP properties. + EAPProperties? EAP; + // The network signal strength. + long? SignalStrength; + }; + + dictionary ManagedWiMAXProperties { + // See $(ref:WiMAXProperties.AutoConnect). + ManagedBoolean? AutoConnect; + // See $(ref:WiMAXProperties.SignalStrength). + long? SignalStrength; + }; + + dictionary WiMAXStateProperties { + // See $(ref:WiMAXProperties.SignalStrength). + long? SignalStrength; + }; + + dictionary NetworkConfigProperties { + // See $(ref:NetworkProperties.Cellular). + CellularProperties? Cellular; + // See $(ref:NetworkProperties.Ethernet). + EthernetProperties? Ethernet; + // See $(ref:NetworkProperties.GUID). + DOMString? GUID; + // See $(ref:NetworkProperties.IPAddressConfigType). + IPConfigType? IPAddressConfigType; + // See $(ref:NetworkProperties.Name). + DOMString? Name; + // See $(ref:NetworkProperties.NameServersConfigType). + IPConfigType? NameServersConfigType; + // See $(ref:NetworkProperties.Priority). + long? Priority; + // See $(ref:NetworkProperties.Type). + NetworkType? Type; + // See $(ref:NetworkProperties.VPN). + VPNProperties? VPN; + // See $(ref:NetworkProperties.WiFi). + WiFiProperties? WiFi; + // See $(ref:NetworkProperties.WiMAX). + WiMAXProperties? WiMAX; + }; + + [noinline_doc] + dictionary NetworkProperties { + // For cellular networks, cellular network properties. + CellularProperties? Cellular; + // Whether the network is connectable. + boolean? Connectable; + // The network's current connection state. + ConnectionStateType? ConnectionState; + // The last recorded network error state. + DOMString? ErrorState; + // For Ethernet networks, the Ethernet network properties. + EthernetProperties? Ethernet; + // The network GUID. + DOMString GUID; + // The network's IP address configuration type. + IPConfigType? IPAddressConfigType; + // The network's IP configuration. + IPConfigProperties[]? IPConfigs; + // The network's MAC address. + DOMString? MacAddress; + // A user friendly network name. + DOMString? Name; + // The IP configuration type for the name servers used by the network. + IPConfigType? NameServersConfigType; + // The network priority. + long? Priority; + // The network's proxy settings. + ProxySettings? ProxySettings; + // For a connected network, whether the network connectivity to the + // Internet is limited, e.g. if the network is behind a portal, or a + // cellular network is not activated. + boolean? RestrictedConnectivity; + // The network's static IP configuration. + IPConfigProperties? StaticIPConfig; + // IP configuration that was received from the DHCP server before applying + // static IP configuration. + IPConfigProperties? SavedIPConfig; + // Indicates whether and how the network is configured. + DOMString? Source; + // The network type. + NetworkType Type; + // For VPN networks, the network VPN properties. + VPNProperties? VPN; + // For WiFi networks, the network WiFi properties. + WiFiProperties? WiFi; + // For WiMAX networks, the network WiMAX properties. + WiMAXProperties? WiMAX; + }; + + [noinline_doc] + dictionary ManagedProperties { + // See $(ref:NetworkProperties.Cellular). + ManagedCellularProperties? Cellular; + // See $(ref:NetworkProperties.Connectable). + boolean? Connectable; + // See $(ref:NetworkProperties.ConnectionState). + ConnectionStateType? ConnectionState; + // See $(ref:NetworkProperties.ErrorState). + DOMString? ErrorState; + // See $(ref:NetworkProperties.Ethernet). + ManagedEthernetProperties? Ethernet; + // See $(ref:NetworkProperties.GUID). + DOMString GUID; + // See $(ref:NetworkProperties.IPAddressConfigType). + ManagedIPConfigType? IPAddressConfigType; + // See $(ref:NetworkProperties.IPConfigs). + IPConfigProperties[]? IPConfigs; + // See $(ref:NetworkProperties.MacAddress). + DOMString? MacAddress; + // See $(ref:NetworkProperties.Name). + ManagedDOMString? Name; + // See $(ref:NetworkProperties.NameServersConfigType). + ManagedIPConfigType? NameServersConfigType; + // See $(ref:NetworkProperties.Priority). + ManagedLong? Priority; + // See $(ref:NetworkProperties.ProxySettings). + ManagedProxySettings? ProxySettings; + // See $(ref:NetworkProperties.RestrictedConnectivity). + boolean? RestrictedConnectivity; + // See $(ref:NetworkProperties.StaticIPConfig). + ManagedIPConfigProperties? StaticIPConfig; + // See $(ref:NetworkProperties.SavedIPConfig). + IPConfigProperties? SavedIPConfig; + // See $(ref:NetworkProperties.Source). + DOMString? Source; + // See $(ref:NetworkProperties.Type). + NetworkType Type; + // See $(ref:NetworkProperties.VPN). + ManagedVPNProperties? VPN; + // See $(ref:NetworkProperties.WiFi). + ManagedWiFiProperties? WiFi; + // See $(ref:NetworkProperties.WiMAX). + ManagedWiMAXProperties? WiMAX; + }; + + dictionary NetworkStateProperties { + // See $(ref:NetworkProperties.Cellular). + CellularStateProperties? Cellular; + // See $(ref:NetworkProperties.Connectable). + boolean? Connectable; + // See $(ref:NetworkProperties.ConnectionState). + ConnectionStateType? ConnectionState; + // See $(ref:NetworkProperties.Ethernet). + EthernetStateProperties? Ethernet; + // See $(ref:NetworkProperties.ErrorState). + DOMString? ErrorState; + // See $(ref:NetworkProperties.GUID). + DOMString GUID; + // See $(ref:NetworkProperties.Name). + DOMString? Name; + // See $(ref:NetworkProperties.Priority). + long? Priority; + // See $(ref:NetworkProperties.Source). + DOMString? Source; + // See $(ref:NetworkProperties.Type). + NetworkType Type; + // See $(ref:NetworkProperties.VPN). + VPNStateProperties? VPN; + // See $(ref:NetworkProperties.WiFi). + WiFiStateProperties? WiFi; + // See $(ref:NetworkProperties.WiMAX). + WiMAXStateProperties? WiMAX; + }; + + dictionary DeviceStateProperties { + // Set if the device is enabled. True if the device is currently scanning. + boolean? Scanning; + + // Set to the SIM lock type if the device type is Cellular and the device + // is locked. + DOMString? SimLockType; + + // Set to the SIM present state if the device type is Cellular. + boolean? SimPresent; + + // The current state of the device. + DeviceStateType State; + + // The network type associated with the device (Cellular, Ethernet, WiFi, or + // WiMAX). + NetworkType Type; + }; + + dictionary NetworkFilter { + // The type of networks to return. + NetworkType networkType; + + // If true, only include visible (physically connected or in-range) + // networks. Defaults to 'false'. + boolean? visible; + + // If true, only include configured (saved) networks. Defaults to 'false'. + boolean? configured; + + // Maximum number of networks to return. Defaults to 1000 if unspecified. + // Use 0 for no limit. + long? limit; + }; + + dictionary GlobalPolicy { + // If true, only policy networks may auto connect. Defaults to false. + boolean? AllowOnlyPolicyNetworksToAutoconnect; + + // If true, only policy networks may be connected to and no new networks may + // be added or configured. Defaults to false. + boolean? AllowOnlyPolicyNetworksToConnect; + }; + + callback VoidCallback = void(); + callback BooleanCallback = void(boolean result); + callback StringCallback = void(DOMString result); + callback GetPropertiesCallback = void(NetworkProperties result); + callback GetManagedPropertiesCallback = void(ManagedProperties result); + callback GetStatePropertiesCallback = void(NetworkStateProperties result); + callback GetNetworksCallback = void(NetworkStateProperties[] result); + callback GetDeviceStatesCallback = void(DeviceStateProperties[] result); + callback GetEnabledNetworkTypesCallback = void(NetworkType[] result); + callback CaptivePortalStatusCallback = void(CaptivePortalStatus result); + callback GetGlobalPolicyCallback = void(GlobalPolicy result); + + interface Functions { + // Gets all the properties of the network with id networkGuid. Includes all + // properties of the network (read-only and read/write values). + // |networkGuid|: The GUID of the network to get properties for. + // |callback|: Called with the network properties when received. + static void getProperties(DOMString networkGuid, + GetPropertiesCallback callback); + + // Gets the merged properties of the network with id networkGuid from the + // sources: User settings, shared settings, user policy, device policy and + // the currently active settings. + // |networkGuid|: The GUID of the network to get properties for. + // |callback|: Called with the managed network properties when received. + static void getManagedProperties(DOMString networkGuid, + GetManagedPropertiesCallback callback); + + // Gets the cached read-only properties of the network with id networkGuid. + // This is meant to be a higher performance function than + // $(ref:getProperties), which requires a round trip to query the networking + // subsystem. The following properties are returned for all networks: GUID, + // Type, Name, WiFi.Security. Additional properties are provided for visible + // networks: ConnectionState, ErrorState, WiFi.SignalStrength, + // Cellular.NetworkTechnology, Cellular.ActivationState, + // Cellular.RoamingState. + // |networkGuid|: The GUID of the network to get properties for. + // |callback|: Called immediately with the network state properties. + static void getState(DOMString networkGuid, + GetStatePropertiesCallback callback); + + // Sets the properties of the network with id networkGuid. + // <b> + // In kiosk sessions, calling this method on a shared network will fail. + // </b> + // |networkGuid|: The GUID of the network to set properties for. + // |properties|: The properties to set. + // |callback|: Called when the operation has completed. + static void setProperties(DOMString networkGuid, + NetworkConfigProperties properties, + optional VoidCallback callback); + + // Creates a new network configuration from properties. If a matching + // configured network already exists, this will fail. Otherwise returns the + // GUID of the new network. + // |shared|: <p> + // If <code>true</code>, share this network configuration with + // other users. + // </p> + // <p> + // <b>This option is exposed only to Chrome's Web UI.</b> + // When called by apps, <code>false</code> is the only allowed value. + // </p> + // |properties|: The properties to configure the new network with. + // |callback|: Called with the GUID for the new network configuration once + // the network has been created. + static void createNetwork(boolean shared, + NetworkConfigProperties properties, + optional StringCallback callback); + + // <p> + // Forgets a network configuration by clearing any configured properties + // for the network with GUID <code>networkGuid</code>. This may also + // include any other networks with matching identifiers (e.g. WiFi SSID + // and Security). If no such configuration exists, an error will be set + // and the operation will fail. + // </p> + // <p> + // <b>In kiosk sessions, this method will not be able to forget shared + // network configurations.</b> + // </p> + // |networkGuid|: The GUID of the network to forget. + // |callback|: Called when the operation has completed. + static void forgetNetwork(DOMString networkGuid, + optional VoidCallback callback); + + // Returns a list of network objects with the same properties provided by + // $(ref:getState). A filter is provided to specify the + // type of networks returned and to limit the number of networks. Networks + // are ordered by the system based on their priority, with connected or + // connecting networks listed first. + // |filter|: Describes which networks to return. + // |callback|: Called with a dictionary of networks and their state + // properties when received. + static void getNetworks(NetworkFilter filter, + GetNetworksCallback callback); + + // Returns states of available networking devices. + // |callback|: Called with a list of devices and their state. + static void getDeviceStates(GetDeviceStatesCallback callback); + + // Enables any devices matching the specified network type. Note, the type + // might represent multiple network types (e.g. 'Wireless'). + // |networkType|: The type of network to enable. + static void enableNetworkType(NetworkType networkType); + + // Disables any devices matching the specified network type. See note for + // $(ref:enableNetworkType). + // |networkType|: The type of network to disable. + static void disableNetworkType(NetworkType networkType); + + // Requests that the networking subsystem scan for new networks and + // update the list returned by $(ref:getNetworks). This is only a + // request: the network subsystem can choose to ignore it. If the list + // is updated, then the $(ref:onNetworkListChanged) event will be fired. + static void requestNetworkScan(); + + // Starts a connection to the network with networkGuid. + // |networkGuid|: The GUID of the network to connect to. + // |callback|: Called when the connect request has been sent. Note: the + // connection may not have completed. Observe $(ref:onNetworksChanged) + // to be notified when a network state changes. + static void startConnect(DOMString networkGuid, + optional VoidCallback callback); + + // Starts a disconnect from the network with networkGuid. + // |networkGuid|: The GUID of the network to disconnect from. + // |callback|: Called when the disconnect request has been sent. See note + // for $(ref:startConnect). + static void startDisconnect(DOMString networkGuid, + optional VoidCallback callback); + + // Returns captive portal status for the network matching 'networkGuid'. + // |networkGuid|: The GUID of the network to get captive portal status for. + // |callback|: A callback function that returns the results of the query for + // network captive portal status. + static void getCaptivePortalStatus(DOMString networkGuid, + CaptivePortalStatusCallback callback); + + // Gets the global policy properties. These properties are not expected to + // change during a session. + static void getGlobalPolicy(GetGlobalPolicyCallback callback); + }; + + interface Events { + // Fired when the properties change on any of the networks. Sends a list of + // GUIDs for networks whose properties have changed. + static void onNetworksChanged(DOMString[] changes); + + // Fired when the list of networks has changed. Sends a complete list of + // GUIDs for all the current networks. + static void onNetworkListChanged(DOMString[] changes); + + // Fired when the list of devices has changed or any device state properties + // have changed. + static void onDeviceStateListChanged(); + + // Fired when a portal detection for a network completes. Sends the GUID of + // the network and the corresponding captive portal status. + static void onPortalDetectionCompleted(DOMString networkGuid, + CaptivePortalStatus status); + }; +}; diff --git a/chromium/extensions/common/api/networking_private.idl b/chromium/extensions/common/api/networking_private.idl index 6bbe0863984..d42db08d6e9 100644 --- a/chromium/extensions/common/api/networking_private.idl +++ b/chromium/extensions/common/api/networking_private.idl @@ -233,9 +233,12 @@ namespace networkingPrivate { DOMString? ClientCertType; DOMString? Identity; DOMString? Inner; - DOMString Outer; + // The outer EAP type. Required by ONC, but may not be provided when + // translating from Shill. + DOMString? Outer; DOMString? Password; boolean? SaveCredentials; + DOMString[]? ServerCAPEMs; DOMString[]? ServerCARefs; boolean? UseProactiveKeyCaching; boolean? UseSystemCAs; @@ -248,9 +251,12 @@ namespace networkingPrivate { ManagedDOMString? ClientCertType; ManagedDOMString? Identity; ManagedDOMString? Inner; - ManagedDOMString Outer; + // The outer EAP type. Required by ONC, but may not be provided when + // translating from Shill. + ManagedDOMString? Outer; ManagedDOMString? Password; ManagedBoolean? SaveCredentials; + ManagedDOMStringList? ServerCAPEMs; ManagedDOMStringList? ServerCARefs; ManagedBoolean? UseProactiveKeyCaching; ManagedBoolean? UseSystemCAs; @@ -961,6 +967,7 @@ namespace networkingPrivate { // is a trusted device. // |callback|: A callback function that indicates whether or not the device // is a trusted device. + [nodoc, deprecated = "Use networking.castPrivate API."] static void verifyDestination(VerificationProperties properties, BooleanCallback callback); @@ -971,6 +978,7 @@ namespace networkingPrivate { // |networkGuid|: The GUID of the Cellular network to activate. // |callback|: A callback function that receives base64-encoded encrypted // credential data to send to a trusted device. + [nodoc, deprecated = "Use networking.castPrivate API."] static void verifyAndEncryptCredentials(VerificationProperties properties, DOMString networkGuid, StringCallback callback); @@ -982,6 +990,7 @@ namespace networkingPrivate { // |data|: A string containing the base64-encoded data to encrypt. // |callback|: A callback function that receives base64-encoded encrypted // data to send to a trusted device. + [nodoc, deprecated = "Use networking.castPrivate API."] static void verifyAndEncryptData(VerificationProperties properties, DOMString data, StringCallback callback); @@ -995,6 +1004,7 @@ namespace networkingPrivate { // (e.g. MAC address lookup failed). 'Timeout' indicates that the lookup // timed out. Otherwise a valid status is returned (see // $(ref:getWifiTDLSStatus)). + [nodoc, deprecated = "Use networking.castPrivate API."] static void setWifiTDLSEnabledState(DOMString ip_or_mac_address, boolean enabled, optional StringCallback callback); @@ -1004,6 +1014,7 @@ namespace networkingPrivate { // |callback|: A callback function that receives a string with the current // TDLS status which can be 'Connected', 'Disabled', 'Disconnected', // 'Nonexistent', or 'Unknown'. + [nodoc, deprecated = "Use networking.castPrivate API."] static void getWifiTDLSStatus(DOMString ip_or_mac_address, StringCallback callback); diff --git a/chromium/extensions/common/api/printer_provider/usb_printer_manifest_data.cc b/chromium/extensions/common/api/printer_provider/usb_printer_manifest_data.cc index c34a349e786..fc5c46606f4 100644 --- a/chromium/extensions/common/api/printer_provider/usb_printer_manifest_data.cc +++ b/chromium/extensions/common/api/printer_provider/usb_printer_manifest_data.cc @@ -4,6 +4,8 @@ #include "extensions/common/api/printer_provider/usb_printer_manifest_data.h" +#include <memory> + #include "base/memory/ptr_util.h" #include "base/strings/utf_string_conversions.h" #include "device/usb/usb_device.h" @@ -69,7 +71,7 @@ std::unique_ptr<UsbPrinterManifestData> UsbPrinterManifestData::FromValue( bool UsbPrinterManifestData::SupportsDevice( const scoped_refptr<device::UsbDevice>& device) const { for (const auto& filter : filters_) { - if (filter.Matches(device)) + if (filter.Matches(*device)) return true; } diff --git a/chromium/extensions/common/api/system_display.idl b/chromium/extensions/common/api/system_display.idl index 6a1a921e853..1674d1b1f00 100644 --- a/chromium/extensions/common/api/system_display.idl +++ b/chromium/extensions/common/api/system_display.idl @@ -129,6 +129,10 @@ namespace system.display { // True if this display is enabled. boolean isEnabled; + // True for all displays when in unified desktop mode. See documentation + // for $(ref:enableUnifiedDesktop). + boolean isUnified; + // The number of pixels per inch along the x-axis. double dpiX; @@ -163,6 +167,13 @@ namespace system.display { }; dictionary DisplayProperties { + // Chrome OS only. If set to true, changes the display mode to unified + // desktop (see $(ref:enableUnifiedDesktop) for details). If set to false, + // unified desktop mode will be disabled. This is only valid for the + // primary display. If provided, mirroringSourceId must not be provided and + // other properties may not apply. This is has no effect if not provided. + boolean? isUnified; + // Chrome OS only. If set and not empty, enables mirroring for this display. // Otherwise disables mirroring for this display. This value should indicate // the id of the source display to mirror, which must not be the same as the @@ -203,6 +214,13 @@ namespace system.display { DisplayMode? displayMode; }; + dictionary GetInfoFlags { + // If set to true, only a single $(ref:DisplayUnitInfo) will be returned + // by $(ref:getInfo) when in unified desktop mode (see + // $(ref:enableUnifiedDesktop)). Defaults to false. + boolean? singleUnified; + }; + callback DisplayInfoCallback = void (DisplayUnitInfo[] displayInfo); callback DisplayLayoutCallback = void (DisplayLayout[] layouts); callback SetDisplayUnitInfoCallback = void(); @@ -210,11 +228,15 @@ namespace system.display { callback NativeTouchCalibrationCallback = void(boolean success); interface Functions { - // Get the information of all attached display devices. - static void getInfo(DisplayInfoCallback callback); + // Requests the information for all attached display devices. + // |flags|: Options affecting how the information is returned. + // |callback|: The callback to invoke with the results. + static void getInfo(optional GetInfoFlags flags, + DisplayInfoCallback callback); - // Get the layout info for all displays. + // Requests the layout info for all displays. // NOTE: This is only available to Chrome OS Kiosk apps and Web UI. + // |callback|: The callback to invoke with the results. static void getDisplayLayout(DisplayLayoutCallback callback); // Updates the properties for the display specified by |id|, according to diff --git a/chromium/extensions/common/common_manifest_handlers.cc b/chromium/extensions/common/common_manifest_handlers.cc index a40be154d5e..b4e4cc8f171 100644 --- a/chromium/extensions/common/common_manifest_handlers.cc +++ b/chromium/extensions/common/common_manifest_handlers.cc @@ -23,6 +23,8 @@ #include "extensions/common/manifest_handlers/nacl_modules_handler.h" #include "extensions/common/manifest_handlers/oauth2_manifest_handler.h" #include "extensions/common/manifest_handlers/offline_enabled_info.h" +#include "extensions/common/manifest_handlers/plugins_handler.h" +#include "extensions/common/manifest_handlers/requirements_info.h" #include "extensions/common/manifest_handlers/sandboxed_page_info.h" #include "extensions/common/manifest_handlers/shared_module_info.h" #include "extensions/common/manifest_handlers/web_accessible_resources_info.h" @@ -58,6 +60,8 @@ void RegisterCommonManifestHandlers() { #endif (new OAuth2ManifestHandler)->Register(); (new OfflineEnabledHandler)->Register(); + (new PluginsHandler)->Register(); + (new RequirementsHandler)->Register(); // Depends on plugins. (new SandboxedPageHandler)->Register(); (new SharedModuleHandler)->Register(); (new SocketsManifestHandler)->Register(); diff --git a/chromium/extensions/common/constants.cc b/chromium/extensions/common/constants.cc index 948655d0715..c569a2dc3a0 100644 --- a/chromium/extensions/common/constants.cc +++ b/chromium/extensions/common/constants.cc @@ -80,7 +80,7 @@ const uint8_t kWebstoreSignaturesPublicKey[] = { 0x58, 0x34, 0xc8, 0x22, 0x2d, 0x2a, 0x65, 0x75, 0xa7, 0xd9, 0x08, 0x62, 0xcd, 0x02, 0x03, 0x01, 0x00, 0x01}; -const int kWebstoreSignaturesPublicKeySize = +const size_t kWebstoreSignaturesPublicKeySize = arraysize(kWebstoreSignaturesPublicKey); const char kMimeTypeJpeg[] = "image/jpeg"; diff --git a/chromium/extensions/common/constants.h b/chromium/extensions/common/constants.h index 4bf94c940e4..587299fb1f6 100644 --- a/chromium/extensions/common/constants.h +++ b/chromium/extensions/common/constants.h @@ -111,7 +111,7 @@ extern const char kWebStoreAppId[]; // The key used for signing some pieces of data from the webstore. extern const uint8_t kWebstoreSignaturesPublicKey[]; -extern const int kWebstoreSignaturesPublicKeySize; +extern const size_t kWebstoreSignaturesPublicKeySize; // Enumeration of possible app launch sources. // This should be kept in sync with LaunchSource in diff --git a/chromium/extensions/common/csp_validator.cc b/chromium/extensions/common/csp_validator.cc index 1dc9128f524..86f38cc17e7 100644 --- a/chromium/extensions/common/csp_validator.cc +++ b/chromium/extensions/common/csp_validator.cc @@ -12,6 +12,7 @@ #include "base/bind.h" #include "base/callback.h" #include "base/macros.h" +#include "base/strings/string_piece.h" #include "base/strings/string_split.h" #include "base/strings/string_tokenizer.h" #include "base/strings/string_util.h" @@ -197,7 +198,7 @@ std::string GetSecureDirectiveValues( const std::string& directive_name, const std::vector<base::StringPiece>& directive_values, std::vector<InstallWarning>* warnings) { - std::vector<std::string> sane_csp_parts(1, directive_name); + std::vector<base::StringPiece> sane_csp_parts{directive_name}; for (base::StringPiece source_literal : directive_values) { std::string source_lower = base::ToLowerASCII(source_literal); bool is_secure_csp_token = false; @@ -231,7 +232,7 @@ std::string GetSecureDirectiveValues( } if (is_secure_csp_token) { - sane_csp_parts.push_back(source_literal.as_string()); + sane_csp_parts.push_back(source_literal); } else if (warnings) { warnings->push_back(CSPInstallWarning(ErrorUtils::FormatErrorMessage( manifest_errors::kInvalidCSPInsecureValue, source_literal.as_string(), @@ -241,7 +242,9 @@ std::string GetSecureDirectiveValues( // End of CSP directive that was started at the beginning of this method. If // none of the values are secure, the policy will be empty and default to // 'none', which is secure. - sane_csp_parts.back().push_back(kDirectiveSeparator); + std::string last_part = sane_csp_parts.back().as_string(); + last_part.push_back(kDirectiveSeparator); + sane_csp_parts.back() = last_part; return base::JoinString(sane_csp_parts, " "); } @@ -253,7 +256,7 @@ std::string GetAppSandboxSecureDirectiveValues( const std::string& directive_name, const std::vector<base::StringPiece>& directive_values, std::vector<InstallWarning>* warnings) { - std::vector<std::string> sane_csp_parts(1, directive_name); + std::vector<std::string> sane_csp_parts{directive_name}; bool seen_self_or_none = false; for (base::StringPiece source_literal : directive_values) { std::string source_lower = base::ToLowerASCII(source_literal); diff --git a/chromium/extensions/common/event_filter.cc b/chromium/extensions/common/event_filter.cc index 7130238c902..260416ee8f8 100644 --- a/chromium/extensions/common/event_filter.cc +++ b/chromium/extensions/common/event_filter.cc @@ -22,9 +22,11 @@ EventFilter::EventMatcherEntry::EventMatcherEntry( URLMatcher* url_matcher, const URLMatcherConditionSet::Vector& condition_sets) : event_matcher_(std::move(event_matcher)), url_matcher_(url_matcher) { - for (URLMatcherConditionSet::Vector::const_iterator it = - condition_sets.begin(); it != condition_sets.end(); it++) - condition_set_ids_.push_back((*it)->id()); + condition_set_ids_.reserve(condition_sets.size()); + for (const scoped_refptr<URLMatcherConditionSet>& condition_set : + condition_sets) { + condition_set_ids_.push_back(condition_set->id()); + } url_matcher_->AddConditionSets(condition_sets); } @@ -62,10 +64,10 @@ EventFilter::MatcherID EventFilter::AddEventMatcher( return -1; MatcherID id = next_id_++; - for (URLMatcherConditionSet::Vector::iterator it = condition_sets.begin(); - it != condition_sets.end(); it++) { + for (const scoped_refptr<URLMatcherConditionSet>& condition_set : + condition_sets) { condition_set_id_to_event_matcher_id_.insert( - std::make_pair((*it)->id(), id)); + std::make_pair(condition_set->id(), id)); } id_to_event_name_[id] = event_name; event_matchers_[event_name][id] = base::MakeUnique<EventMatcherEntry>( @@ -143,7 +145,8 @@ std::set<EventFilter::MatcherID> EventFilter::MatchEvent( return matchers; EventMatcherMap& matcher_map = it->second; - GURL url_to_match_against = event_info.has_url() ? event_info.url() : GURL(); + const GURL& url_to_match_against = + event_info.has_url() ? event_info.url() : GURL::EmptyGURL(); std::set<URLMatcherConditionSet::ID> matching_condition_set_ids = url_matcher_.MatchURL(url_to_match_against); for (std::set<URLMatcherConditionSet::ID>::iterator it = diff --git a/chromium/extensions/common/event_filter_unittest.cc b/chromium/extensions/common/event_filter_unittest.cc index 6e96c991c14..d51e16333f7 100644 --- a/chromium/extensions/common/event_filter_unittest.cc +++ b/chromium/extensions/common/event_filter_unittest.cc @@ -33,7 +33,7 @@ class EventFilterUnittest : public testing::Test { protected: std::unique_ptr<base::Value> HostSuffixDict(const std::string& host_suffix) { std::unique_ptr<base::DictionaryValue> dict(new DictionaryValue()); - dict->Set("hostSuffix", new base::StringValue(host_suffix)); + dict->Set("hostSuffix", new base::Value(host_suffix)); return std::unique_ptr<base::Value>(dict.release()); } diff --git a/chromium/extensions/common/event_filtering_info.cc b/chromium/extensions/common/event_filtering_info.cc index 4770d9e9522..b8040e9c2cd 100644 --- a/chromium/extensions/common/event_filtering_info.cc +++ b/chromium/extensions/common/event_filtering_info.cc @@ -12,6 +12,15 @@ namespace extensions { +namespace { + +const char kInstanceId[] = "instanceId"; +const char kServiceType[] = "serviceType"; +const char kWindowType[] = "windowType"; +const char kWindowExposedByDefault[] = "windowExposedByDefault"; + +} + EventFilteringInfo::EventFilteringInfo() : has_url_(false), has_instance_id_(false), @@ -19,6 +28,24 @@ EventFilteringInfo::EventFilteringInfo() has_window_type_(false), has_window_exposed_by_default_(false) {} +EventFilteringInfo::EventFilteringInfo(const base::DictionaryValue& dict) + : EventFilteringInfo() { + std::string url; + if (dict.GetString("url", &url)) { + GURL maybe_url(url); + if (maybe_url.is_valid()) { + has_url_ = true; + url_.Swap(&maybe_url); + } + } + + has_instance_id_ = dict.GetInteger(kInstanceId, &instance_id_); + dict.GetString(kServiceType, &service_type_); + has_window_type_ = dict.GetString(kWindowType, &window_type_); + has_window_exposed_by_default_ = + dict.GetBoolean(kWindowExposedByDefault, &window_exposed_by_default_); +} + EventFilteringInfo::EventFilteringInfo(const EventFilteringInfo& other) = default; @@ -51,16 +78,16 @@ std::unique_ptr<base::DictionaryValue> EventFilteringInfo::AsValue() const { result->SetString("url", url_.spec()); if (has_instance_id_) - result->SetInteger("instanceId", instance_id_); + result->SetInteger(kInstanceId, instance_id_); if (!service_type_.empty()) - result->SetString("serviceType", service_type_); + result->SetString(kServiceType, service_type_); if (has_window_type_) - result->SetString("windowType", window_type_); + result->SetString(kWindowType, window_type_); if (has_window_exposed_by_default_) - result->SetBoolean("windowExposedByDefault", window_exposed_by_default_); + result->SetBoolean(kWindowExposedByDefault, window_exposed_by_default_); return result; } diff --git a/chromium/extensions/common/event_filtering_info.h b/chromium/extensions/common/event_filtering_info.h index e6b7f9f7d6b..ea7596cabb1 100644 --- a/chromium/extensions/common/event_filtering_info.h +++ b/chromium/extensions/common/event_filtering_info.h @@ -26,6 +26,7 @@ namespace extensions { class EventFilteringInfo { public: EventFilteringInfo(); + explicit EventFilteringInfo(const base::DictionaryValue& dict); EventFilteringInfo(const EventFilteringInfo& other); ~EventFilteringInfo(); void SetWindowExposedByDefault(bool exposed); diff --git a/chromium/extensions/common/extension_l10n_util.cc b/chromium/extensions/common/extension_l10n_util.cc index bf0194a4f6c..4422ca344d2 100644 --- a/chromium/extensions/common/extension_l10n_util.cc +++ b/chromium/extensions/common/extension_l10n_util.cc @@ -92,7 +92,7 @@ bool LocalizeManifestListValue(const std::string& key, std::string result; if (list->GetString(i, &result)) { if (messages.ReplaceMessages(&result, error)) - list->Set(i, new base::StringValue(result)); + list->Set(i, new base::Value(result)); else ret = false; } diff --git a/chromium/extensions/common/extension_l10n_util_unittest.cc b/chromium/extensions/common/extension_l10n_util_unittest.cc index 3caba365958..abe80f2cc92 100644 --- a/chromium/extensions/common/extension_l10n_util_unittest.cc +++ b/chromium/extensions/common/extension_l10n_util_unittest.cc @@ -39,7 +39,8 @@ TEST(ExtensionL10nUtil, ValidateLocalesWithBadLocale) { base::FilePath messages_file = locale.Append(kMessagesFilename); std::string data = "{ \"name\":"; - ASSERT_TRUE(base::WriteFile(messages_file, data.c_str(), data.length())); + ASSERT_EQ(static_cast<int>(data.length()), + base::WriteFile(messages_file, data.c_str(), data.length())); base::DictionaryValue manifest; manifest.SetString(keys::kDefaultLocale, "en"); @@ -92,8 +93,9 @@ TEST(ExtensionL10nUtil, GetValidLocalesWithUnsupportedLocale) { base::FilePath locale_1 = src_path.AppendASCII("sr"); ASSERT_TRUE(base::CreateDirectory(locale_1)); std::string data("whatever"); - ASSERT_TRUE(base::WriteFile( - locale_1.Append(kMessagesFilename), data.c_str(), data.length())); + ASSERT_EQ(static_cast<int>(data.length()), + base::WriteFile(locale_1.Append(kMessagesFilename), data.c_str(), + data.length())); // Unsupported locale. ASSERT_TRUE(base::CreateDirectory(src_path.AppendASCII("xxx_yyy"))); @@ -165,7 +167,8 @@ TEST(ExtensionL10nUtil, LoadMessageCatalogsBadJSONFormat) { std::string data = "{ \"name\":"; base::FilePath messages_file = locale.Append(kMessagesFilename); - ASSERT_TRUE(base::WriteFile(messages_file, data.c_str(), data.length())); + ASSERT_EQ(static_cast<int>(data.length()), + base::WriteFile(messages_file, data.c_str(), data.length())); std::string error; EXPECT_TRUE(NULL == extension_l10n_util::LoadMessageCatalogs( @@ -190,14 +193,16 @@ TEST(ExtensionL10nUtil, LoadMessageCatalogsDuplicateKeys) { std::string data = "{ \"name\": { \"message\": \"something\" }, " "\"name\": { \"message\": \"something else\" } }"; - ASSERT_TRUE(base::WriteFile( - locale_1.Append(kMessagesFilename), data.c_str(), data.length())); + ASSERT_EQ(static_cast<int>(data.length()), + base::WriteFile(locale_1.Append(kMessagesFilename), data.c_str(), + data.length())); base::FilePath locale_2 = src_path.AppendASCII("sr"); ASSERT_TRUE(base::CreateDirectory(locale_2)); - ASSERT_TRUE(base::WriteFile( - locale_2.Append(kMessagesFilename), data.c_str(), data.length())); + ASSERT_EQ(static_cast<int>(data.length()), + base::WriteFile(locale_2.Append(kMessagesFilename), data.c_str(), + data.length())); std::string error; // JSON parser hides duplicates. We are going to get only one key/value @@ -428,8 +433,9 @@ TEST(ExtensionL10nUtil, LocalizeManifestWithNameDescriptionFileHandlerTitle) { manifest.SetString(keys::kDescription, "__MSG_description__"); base::ListValue* handlers = new base::ListValue(); manifest.Set(keys::kFileBrowserHandlers, handlers); - base::DictionaryValue* handler = new base::DictionaryValue(); - handlers->Append(base::WrapUnique(handler)); + handlers->Append(base::MakeUnique<base::DictionaryValue>()); + base::DictionaryValue* handler = nullptr; + handlers->GetDictionary(0, &handler); handler->SetString(keys::kPageActionDefaultTitle, "__MSG_file_handler_title__"); diff --git a/chromium/extensions/common/extension_message_generator.h b/chromium/extensions/common/extension_message_generator.h index b2c61f18826..6607293348b 100644 --- a/chromium/extensions/common/extension_message_generator.h +++ b/chromium/extensions/common/extension_message_generator.h @@ -5,5 +5,4 @@ // Multiply-included file, hence no include guard. #include "extensions/common/extension_messages.h" -#include "extensions/common/extension_utility_messages.h" #include "extensions/common/guest_view/extensions_guest_view_messages.h" diff --git a/chromium/extensions/common/extension_messages.cc b/chromium/extensions/common/extension_messages.cc index 34b15ed8987..8e56f09da38 100644 --- a/chromium/extensions/common/extension_messages.cc +++ b/chromium/extensions/common/extension_messages.cc @@ -13,6 +13,7 @@ #include "extensions/common/extension.h" #include "extensions/common/manifest.h" #include "extensions/common/manifest_handler.h" +#include "extensions/common/manifest_location_param_traits.h" #include "extensions/common/permissions/permissions_data.h" #include "extensions/common/permissions/permissions_info.h" @@ -101,29 +102,6 @@ scoped_refptr<Extension> ExtensionMsg_Loaded_Params::ConvertToExtension( namespace IPC { -template <> -struct ParamTraits<Manifest::Location> { - typedef Manifest::Location param_type; - static void Write(base::Pickle* m, const param_type& p) { - int val = static_cast<int>(p); - WriteParam(m, val); - } - static bool Read(const base::Pickle* m, - base::PickleIterator* iter, - param_type* p) { - int val = 0; - if (!ReadParam(m, iter, &val) || - val < Manifest::INVALID_LOCATION || - val >= Manifest::NUM_LOCATIONS) - return false; - *p = static_cast<param_type>(val); - return true; - } - static void Log(const param_type& p, std::string* l) { - ParamTraits<int>::Log(static_cast<int>(p), l); - } -}; - void ParamTraits<URLPattern>::GetSize(base::PickleSizer* s, const param_type& p) { GetParamSize(s, p.valid_schemes()); diff --git a/chromium/extensions/common/extension_resource_unittest.cc b/chromium/extensions/common/extension_resource_unittest.cc index 27bd56c6d67..659d7f1d4d8 100644 --- a/chromium/extensions/common/extension_resource_unittest.cc +++ b/chromium/extensions/common/extension_resource_unittest.cc @@ -58,8 +58,8 @@ TEST(ExtensionResourceTest, ResourcesOutsideOfPath) { ASSERT_TRUE(base::CreateDirectory(sub_dir)); base::FilePath inner_file = inner_dir.AppendASCII("inner"); base::FilePath outer_file = temp.GetPath().AppendASCII("outer"); - ASSERT_TRUE(base::WriteFile(outer_file, "X", 1)); - ASSERT_TRUE(base::WriteFile(inner_file, "X", 1)); + ASSERT_EQ(1, base::WriteFile(outer_file, "X", 1)); + ASSERT_EQ(1, base::WriteFile(inner_file, "X", 1)); std::string extension_id = crx_file::id_util::GenerateId("test"); #if defined(OS_POSIX) @@ -126,7 +126,8 @@ TEST(ExtensionResourceTest, CreateWithAllResourcesOnDisk) { const char* filename = "res.ico"; base::FilePath root_resource = temp.GetPath().AppendASCII(filename); std::string data = "some foo"; - ASSERT_TRUE(base::WriteFile(root_resource, data.c_str(), data.length())); + ASSERT_EQ(static_cast<int>(data.length()), + base::WriteFile(root_resource, data.c_str(), data.length())); // Create l10n resources (for current locale and its parents). base::FilePath l10n_path = temp.GetPath().Append(kLocaleFolder); @@ -140,8 +141,9 @@ TEST(ExtensionResourceTest, CreateWithAllResourcesOnDisk) { base::FilePath make_path; make_path = l10n_path.AppendASCII(locales[i]); ASSERT_TRUE(base::CreateDirectory(make_path)); - ASSERT_TRUE(base::WriteFile(make_path.AppendASCII(filename), - data.c_str(), data.length())); + ASSERT_EQ(static_cast<int>(data.length()), + base::WriteFile(make_path.AppendASCII(filename), data.c_str(), + data.length())); } base::FilePath path; diff --git a/chromium/extensions/common/extension_unpacker.mojom b/chromium/extensions/common/extension_unpacker.mojom new file mode 100644 index 00000000000..c2321c54388 --- /dev/null +++ b/chromium/extensions/common/extension_unpacker.mojom @@ -0,0 +1,36 @@ +// Copyright 2017 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. + +// Safe chrome extension unpacker service provided by the utility process +// and exposed by mojo policy to the chrome browser process. + +module extensions.mojom; + +import "mojo/common/file_path.mojom"; +import "mojo/common/string16.mojom"; +import "mojo/common/values.mojom"; + +interface ExtensionUnpacker { + // Unzip |file| into the directory |path|. + Unzip(mojo.common.mojom.FilePath file, + mojo.common.mojom.FilePath path) => (bool success); + + // Unpack and sanitize the extension in directory |path|, and return its + // parsed manifest.json file in |manifest|. The supplied |location|, and + // and the |creation_flags| defined by Extension::InitFromValueFlags are + // passed into Extension::Create() when unpacking the extension. Decoded + // image and message catalog data from the extension is written to files + // kDecodedImagesFilename and kDecodedMessageCatalogsFilename in |path|. + // If Unpack() fails for any reason, |error| contains a user-displayable + // explanation of what went wrong. + Unpack(mojo.common.mojom.FilePath path, + string extension_id, + ManifestLocation location, + int32 creation_flags) + => (mojo.common.mojom.String16 error, + mojo.common.mojom.DictionaryValue? manifest); +}; + +[Native] +enum ManifestLocation; diff --git a/chromium/extensions/common/extension_utility_messages.h b/chromium/extensions/common/extension_utility_messages.h deleted file mode 100644 index 363392f729f..00000000000 --- a/chromium/extensions/common/extension_utility_messages.h +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright 2014 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. - -// Multiply-included message file, so no include guard. - -#include <string> -#include <tuple> - -#include "extensions/common/update_manifest.h" -#include "ipc/ipc_message_macros.h" -#include "third_party/skia/include/core/SkBitmap.h" -#include "ui/gfx/ipc/skia/gfx_skia_param_traits.h" -#include "url/ipc/url_param_traits.h" - -#define IPC_MESSAGE_START ExtensionUtilityMsgStart - -#ifndef EXTENSIONS_COMMON_EXTENSION_UTILITY_MESSAGES_H_ -#define EXTENSIONS_COMMON_EXTENSION_UTILITY_MESSAGES_H_ - -using DecodedImages = std::vector<std::tuple<SkBitmap, base::FilePath>>; - -#endif // EXTENSIONS_COMMON_EXTENSION_UTILITY_MESSAGES_H_ - -IPC_STRUCT_TRAITS_BEGIN(UpdateManifest::Result) - IPC_STRUCT_TRAITS_MEMBER(extension_id) - IPC_STRUCT_TRAITS_MEMBER(version) - IPC_STRUCT_TRAITS_MEMBER(browser_min_version) - IPC_STRUCT_TRAITS_MEMBER(package_hash) - IPC_STRUCT_TRAITS_MEMBER(crx_url) -IPC_STRUCT_TRAITS_END() - -IPC_STRUCT_TRAITS_BEGIN(UpdateManifest::Results) - IPC_STRUCT_TRAITS_MEMBER(list) - IPC_STRUCT_TRAITS_MEMBER(daystart_elapsed_seconds) -IPC_STRUCT_TRAITS_END() - -//------------------------------------------------------------------------------ -// Utility process messages: -// These are messages from the browser to the utility process. - -// Tell the utility process to parse the given xml document. -IPC_MESSAGE_CONTROL1(ExtensionUtilityMsg_ParseUpdateManifest, - std::string /* xml document contents */) - -// Tell the utility process to unzip the zipfile at a given path into a -// directory at the second given path. -IPC_MESSAGE_CONTROL2(ExtensionUtilityMsg_UnzipToDir, - base::FilePath /* zip_file */, - base::FilePath /* dir */) - -// Tells the utility process to validate and sanitize the extension in a -// directory. -IPC_MESSAGE_CONTROL4(ExtensionUtilityMsg_UnpackExtension, - base::FilePath /* directory_path */, - std::string /* extension_id */, - int /* Manifest::Location */, - int /* InitFromValue flags */) - -//------------------------------------------------------------------------------ -// Utility process host messages: -// These are messages from the utility process to the browser. - -// Reply when the utility process has succeeded in parsing an update manifest -// xml document. -IPC_MESSAGE_CONTROL1(ExtensionUtilityHostMsg_ParseUpdateManifest_Succeeded, - UpdateManifest::Results /* updates */) - -// Reply when an error occurred parsing the update manifest. |error_message| -// is a description of what went wrong suitable for logging. -IPC_MESSAGE_CONTROL1(ExtensionUtilityHostMsg_ParseUpdateManifest_Failed, - std::string /* error_message, if any */) - -// Reply when the utility process is done unzipping a file. |unpacked_path| -// is the directory which contains the unzipped contents. -IPC_MESSAGE_CONTROL1(ExtensionUtilityHostMsg_UnzipToDir_Succeeded, - base::FilePath /* unpacked_path */) - -// Reply when the utility process failed to unzip a file. |error| contains -// an error string to be reported to the user. -IPC_MESSAGE_CONTROL1(ExtensionUtilityHostMsg_UnzipToDir_Failed, - std::string /* error */) - -// Reply when the utility process is done unpacking an extension. |manifest| -// is the parsed manifest.json file. -// The unpacker should also have written out files containing the decoded -// images and message catalogs from the extension. The data is written into a -// DecodedImages struct into a file named kDecodedImagesFilename in the -// directory that was passed in. This is done because the data is too large to -// pass over IPC. -IPC_MESSAGE_CONTROL1(ExtensionUtilityHostMsg_UnpackExtension_Succeeded, - base::DictionaryValue /* manifest */) - -// Reply when the utility process has failed while unpacking an extension. -// |error_message| is a user-displayable explanation of what went wrong. -IPC_MESSAGE_CONTROL1(ExtensionUtilityHostMsg_UnpackExtension_Failed, - base::string16 /* error_message, if any */) diff --git a/chromium/extensions/common/extension_utility_types.h b/chromium/extensions/common/extension_utility_types.h new file mode 100644 index 00000000000..941a33835f2 --- /dev/null +++ b/chromium/extensions/common/extension_utility_types.h @@ -0,0 +1,25 @@ +// Copyright 2017 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 EXTENSIONS_COMMON_EXTENSION_UTILITY_TYPES_H_ +#define EXTENSIONS_COMMON_EXTENSION_UTILITY_TYPES_H_ + +#include <tuple> +#include <vector> + +#include "ui/gfx/ipc/skia/gfx_skia_param_traits.h" + +class SkBitmap; + +namespace base { +class FilePath; +} + +namespace extensions { + +using DecodedImages = std::vector<std::tuple<SkBitmap, base::FilePath>>; + +} // namespace extensions + +#endif // EXTENSIONS_COMMON_EXTENSION_UTILITY_TYPES_H_ diff --git a/chromium/extensions/common/feature_switch.cc b/chromium/extensions/common/feature_switch.cc index 6567ba9b422..5868f02869b 100644 --- a/chromium/extensions/common/feature_switch.cc +++ b/chromium/extensions/common/feature_switch.cc @@ -20,6 +20,9 @@ namespace { const char kLoadMediaRouterComponentExtensionFlag[] = "load-media-router-component-extension"; +const char kYieldBetweenContentScriptRunsFieldTrial[] = + "YieldBetweenContentScriptRuns"; + class CommonSwitches { public: CommonSwitches() @@ -54,7 +57,11 @@ class CommonSwitches { FeatureSwitch::DEFAULT_DISABLED), #endif // defined(GOOGLE_CHROME_BUILD) native_crx_bindings(switches::kNativeCrxBindings, - FeatureSwitch::DEFAULT_DISABLED) { + FeatureSwitch::DEFAULT_DISABLED), + yield_between_content_script_runs( + switches::kYieldBetweenContentScriptRuns, + kYieldBetweenContentScriptRunsFieldTrial, + FeatureSwitch::DEFAULT_DISABLED) { } FeatureSwitch force_dev_mode_highlighting; @@ -71,9 +78,10 @@ class CommonSwitches { FeatureSwitch trace_app_source; FeatureSwitch load_media_router_component_extension; FeatureSwitch native_crx_bindings; + FeatureSwitch yield_between_content_script_runs; }; -base::LazyInstance<CommonSwitches> g_common_switches = +base::LazyInstance<CommonSwitches>::DestructorAtExit g_common_switches = LAZY_INSTANCE_INITIALIZER; } // namespace @@ -108,6 +116,9 @@ FeatureSwitch* FeatureSwitch::load_media_router_component_extension() { FeatureSwitch* FeatureSwitch::native_crx_bindings() { return &g_common_switches.Get().native_crx_bindings; } +FeatureSwitch* FeatureSwitch::yield_between_content_script_runs() { + return &g_common_switches.Get().yield_between_content_script_runs; +} FeatureSwitch::ScopedOverride::ScopedOverride(FeatureSwitch* feature, bool override_value) @@ -153,7 +164,12 @@ FeatureSwitch::FeatureSwitch(const base::CommandLine* command_line, bool FeatureSwitch::IsEnabled() const { if (override_value_ != OVERRIDE_NONE) return override_value_ == OVERRIDE_ENABLED; + if (!cached_value_.has_value()) + cached_value_ = ComputeValue(); + return cached_value_.value(); +} +bool FeatureSwitch::ComputeValue() const { if (!switch_name_) return default_value_; diff --git a/chromium/extensions/common/feature_switch.h b/chromium/extensions/common/feature_switch.h index 6e2f8e7abad..df10bd5db56 100644 --- a/chromium/extensions/common/feature_switch.h +++ b/chromium/extensions/common/feature_switch.h @@ -8,6 +8,7 @@ #include <string> #include "base/macros.h" +#include "base/optional.h" namespace base { class CommandLine; @@ -41,6 +42,7 @@ class FeatureSwitch { static FeatureSwitch* trace_app_source(); static FeatureSwitch* load_media_router_component_extension(); static FeatureSwitch* native_crx_bindings(); + static FeatureSwitch* yield_between_content_script_runs(); enum DefaultValue { DEFAULT_ENABLED, @@ -88,12 +90,14 @@ class FeatureSwitch { private: std::string GetLegacyEnableFlag() const; std::string GetLegacyDisableFlag() const; + bool ComputeValue() const; const base::CommandLine* command_line_; const char* switch_name_; const char* field_trial_name_; bool default_value_; OverrideValue override_value_; + mutable base::Optional<bool> cached_value_; DISALLOW_COPY_AND_ASSIGN(FeatureSwitch); }; diff --git a/chromium/extensions/common/features/complex_feature.cc b/chromium/extensions/common/features/complex_feature.cc index ed129da1e64..b5ea0ff01ff 100644 --- a/chromium/extensions/common/features/complex_feature.cc +++ b/chromium/extensions/common/features/complex_feature.cc @@ -7,7 +7,7 @@ namespace extensions { ComplexFeature::ComplexFeature(std::vector<Feature*>* features) { - DCHECK_GT(features->size(), 0UL); + DCHECK_GT(features->size(), 1UL); for (Feature* f : *features) features_.push_back(std::unique_ptr<Feature>(f)); features->clear(); diff --git a/chromium/extensions/common/features/feature_provider.cc b/chromium/extensions/common/features/feature_provider.cc index 3c7b6a53c39..99213c7ff53 100644 --- a/chromium/extensions/common/features/feature_provider.cc +++ b/chromium/extensions/common/features/feature_provider.cc @@ -140,7 +140,7 @@ Feature* FeatureProvider::GetParent(Feature* feature) const { if (feature->no_parent()) return nullptr; - std::vector<std::string> split = base::SplitString( + std::vector<base::StringPiece> split = base::SplitStringPiece( feature->name(), ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); if (split.size() < 2) return nullptr; diff --git a/chromium/extensions/common/features/simple_feature.cc b/chromium/extensions/common/features/simple_feature.cc index d901cd9a70c..bb5aa6a8295 100644 --- a/chromium/extensions/common/features/simple_feature.cc +++ b/chromium/extensions/common/features/simple_feature.cc @@ -164,8 +164,8 @@ std::string ListDisplayNames(const std::vector<EnumType>& enum_types) { return display_name_list; } -bool IsCommandLineSwitchEnabled(const std::string& switch_name) { - base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); +bool IsCommandLineSwitchEnabled(base::CommandLine* command_line, + const std::string& switch_name) { if (command_line->HasSwitch(switch_name + "=1")) return true; if (command_line->HasSwitch(std::string("enable-") + switch_name)) @@ -215,55 +215,15 @@ Feature::Availability SimpleFeature::IsAvailableToManifest( Manifest::Location location, int manifest_version, Platform platform) const { - // Check extension type first to avoid granting platform app permissions - // to component extensions. - // HACK(kalman): user script -> extension. Solve this in a more generic way - // when we compile feature files. - Manifest::Type type_to_check = (type == Manifest::TYPE_USER_SCRIPT) ? - Manifest::TYPE_EXTENSION : type; - if (!extension_types_.empty() && - !base::ContainsValue(extension_types_, type_to_check)) { - return CreateAvailability(INVALID_TYPE, type); - } - - if (IsIdInBlacklist(extension_id)) - return CreateAvailability(FOUND_IN_BLACKLIST, type); - - // TODO(benwells): don't grant all component extensions. - // See http://crbug.com/370375 for more details. - // Component extensions can access any feature. - // NOTE: Deliberately does not match EXTERNAL_COMPONENT. - if (component_extensions_auto_granted_ && location == Manifest::COMPONENT) - return CreateAvailability(IS_AVAILABLE, type); - - if (!whitelist_.empty() && !IsIdInWhitelist(extension_id) && - !IsWhitelistedForTest(extension_id)) { - return CreateAvailability(NOT_FOUND_IN_WHITELIST, type); - } - - if (!MatchesManifestLocation(location)) - return CreateAvailability(INVALID_LOCATION, type); - - if (!platforms_.empty() && !base::ContainsValue(platforms_, platform)) - return CreateAvailability(INVALID_PLATFORM, type); - - if (min_manifest_version_ != 0 && manifest_version < min_manifest_version_) - return CreateAvailability(INVALID_MIN_MANIFEST_VERSION, type); - - if (max_manifest_version_ != 0 && manifest_version > max_manifest_version_) - return CreateAvailability(INVALID_MAX_MANIFEST_VERSION, type); - - if (!command_line_switch_.empty() && - !IsCommandLineSwitchEnabled(command_line_switch_)) { - return CreateAvailability(MISSING_COMMAND_LINE_SWITCH, type); - } - - if (channel_ && *channel_ < GetCurrentChannel()) - return CreateAvailability(UNSUPPORTED_CHANNEL, *channel_); - - const FeatureSessionType session_type = GetCurrentFeatureSessionType(); - if (!MatchesSessionTypes(session_type)) - return CreateAvailability(INVALID_SESSION_TYPE, session_type); + Availability environment_availability = GetEnvironmentAvailability( + platform, GetCurrentChannel(), GetCurrentFeatureSessionType(), + base::CommandLine::ForCurrentProcess()); + if (!environment_availability.is_available()) + return environment_availability; + Availability manifest_availability = + GetManifestAvailability(extension_id, type, location, manifest_version); + if (!manifest_availability.is_available()) + return manifest_availability; return CheckDependencies(base::Bind(&IsAvailableToManifestForBind, extension_id, @@ -277,36 +237,24 @@ Feature::Availability SimpleFeature::IsAvailableToContext( const Extension* extension, Feature::Context context, const GURL& url, - SimpleFeature::Platform platform) const { - if (extension) { - Availability result = IsAvailableToManifest(extension->id(), - extension->GetType(), - extension->location(), - extension->manifest_version(), - platform); - if (!result.is_available()) - return result; - } - - // TODO(lazyboy): This isn't quite right for Extension Service Worker - // extension API calls, since there's no guarantee that the extension is - // "active" in current renderer process when the API permission check is - // done. - if (!contexts_.empty() && !base::ContainsValue(contexts_, context)) - return CreateAvailability(INVALID_CONTEXT, context); + Platform platform) const { + Availability environment_availability = GetEnvironmentAvailability( + platform, GetCurrentChannel(), GetCurrentFeatureSessionType(), + base::CommandLine::ForCurrentProcess()); + if (!environment_availability.is_available()) + return environment_availability; - // TODO(kalman): Consider checking |matches_| regardless of context type. - // Fewer surprises, and if the feature configuration wants to isolate - // "matches" from say "blessed_extension" then they can use complex features. - if ((context == WEB_PAGE_CONTEXT || context == WEBUI_CONTEXT) && - !matches_.MatchesURL(url)) { - return CreateAvailability(INVALID_URL, url); + if (extension) { + Availability manifest_availability = GetManifestAvailability( + extension->id(), extension->GetType(), extension->location(), + extension->manifest_version()); + if (!manifest_availability.is_available()) + return manifest_availability; } - const FeatureSessionType session_type = GetCurrentFeatureSessionType(); - if (!MatchesSessionTypes(session_type)) { - return CreateAvailability(INVALID_SESSION_TYPE, session_type); - } + Availability context_availability = GetContextAvailability(context, url); + if (!context_availability.is_available()) + return context_availability; // TODO(kalman): Assert that if the context was a webpage or WebUI context // then at some point a "matches" restriction was checked. @@ -579,4 +527,90 @@ void SimpleFeature::set_whitelist( whitelist_.assign(whitelist.begin(), whitelist.end()); } +Feature::Availability SimpleFeature::GetEnvironmentAvailability( + Platform platform, + version_info::Channel channel, + FeatureSessionType session_type, + base::CommandLine* command_line) const { + if (!platforms_.empty() && !base::ContainsValue(platforms_, platform)) + return CreateAvailability(INVALID_PLATFORM); + + if (channel_ && *channel_ < GetCurrentChannel()) + return CreateAvailability(UNSUPPORTED_CHANNEL, *channel_); + + if (!command_line_switch_.empty() && + !IsCommandLineSwitchEnabled(command_line, command_line_switch_)) { + return CreateAvailability(MISSING_COMMAND_LINE_SWITCH); + } + + if (!MatchesSessionTypes(session_type)) + return CreateAvailability(INVALID_SESSION_TYPE, session_type); + + return CreateAvailability(IS_AVAILABLE); +} + +Feature::Availability SimpleFeature::GetManifestAvailability( + const std::string& extension_id, + Manifest::Type type, + Manifest::Location location, + int manifest_version) const { + // Check extension type first to avoid granting platform app permissions + // to component extensions. + // HACK(kalman): user script -> extension. Solve this in a more generic way + // when we compile feature files. + Manifest::Type type_to_check = + (type == Manifest::TYPE_USER_SCRIPT) ? Manifest::TYPE_EXTENSION : type; + if (!extension_types_.empty() && + !base::ContainsValue(extension_types_, type_to_check)) { + return CreateAvailability(INVALID_TYPE, type); + } + + if (IsIdInBlacklist(extension_id)) + return CreateAvailability(FOUND_IN_BLACKLIST); + + // TODO(benwells): don't grant all component extensions. + // See http://crbug.com/370375 for more details. + // Component extensions can access any feature. + // NOTE: Deliberately does not match EXTERNAL_COMPONENT. + if (component_extensions_auto_granted_ && location == Manifest::COMPONENT) + return CreateAvailability(IS_AVAILABLE); + + if (!whitelist_.empty() && !IsIdInWhitelist(extension_id) && + !IsWhitelistedForTest(extension_id)) { + return CreateAvailability(NOT_FOUND_IN_WHITELIST); + } + + if (!MatchesManifestLocation(location)) + return CreateAvailability(INVALID_LOCATION); + + if (min_manifest_version_ != 0 && manifest_version < min_manifest_version_) + return CreateAvailability(INVALID_MIN_MANIFEST_VERSION); + + if (max_manifest_version_ != 0 && manifest_version > max_manifest_version_) + return CreateAvailability(INVALID_MAX_MANIFEST_VERSION); + + return CreateAvailability(IS_AVAILABLE); +} + +Feature::Availability SimpleFeature::GetContextAvailability( + Feature::Context context, + const GURL& url) const { + // TODO(lazyboy): This isn't quite right for Extension Service Worker + // extension API calls, since there's no guarantee that the extension is + // "active" in current renderer process when the API permission check is + // done. + if (!contexts_.empty() && !base::ContainsValue(contexts_, context)) + return CreateAvailability(INVALID_CONTEXT, context); + + // TODO(kalman): Consider checking |matches_| regardless of context type. + // Fewer surprises, and if the feature configuration wants to isolate + // "matches" from say "blessed_extension" then they can use complex features. + if ((context == WEB_PAGE_CONTEXT || context == WEBUI_CONTEXT) && + !matches_.MatchesURL(url)) { + return CreateAvailability(INVALID_URL, url); + } + + return CreateAvailability(IS_AVAILABLE); +} + } // namespace extensions diff --git a/chromium/extensions/common/features/simple_feature.h b/chromium/extensions/common/features/simple_feature.h index 343282e88b5..13199e867d4 100644 --- a/chromium/extensions/common/features/simple_feature.h +++ b/chromium/extensions/common/features/simple_feature.h @@ -24,6 +24,10 @@ #include "extensions/common/features/feature_session_type.h" #include "extensions/common/manifest.h" +namespace base { +class CommandLine; +} + namespace extensions { class FeatureProviderTest; @@ -215,6 +219,24 @@ class SimpleFeature : public Feature { static bool IsValidExtensionId(const std::string& extension_id); + // Returns the availability of the feature with respect to the basic + // environment Chrome is running in. + Availability GetEnvironmentAvailability( + Platform platform, + version_info::Channel channel, + FeatureSessionType session_type, + base::CommandLine* command_line) const; + + // Returns the availability of the feature with respect to a given extension's + // properties. + Availability GetManifestAvailability(const std::string& extension_id, + Manifest::Type type, + Manifest::Location location, + int manifest_version) const; + + // Returns the availability of the feature with respect to a given context. + Availability GetContextAvailability(Context context, const GURL& url) const; + // For clarity and consistency, we handle the default value of each of these // members the same way: it matches everything. It is up to the higher level // code that reads Features out of static data to validate that data and set diff --git a/chromium/extensions/common/features/simple_feature_unittest.cc b/chromium/extensions/common/features/simple_feature_unittest.cc index a5702489221..f446042f5fd 100644 --- a/chromium/extensions/common/features/simple_feature_unittest.cc +++ b/chromium/extensions/common/features/simple_feature_unittest.cc @@ -860,4 +860,34 @@ TEST_F(SimpleFeatureTest, ComplexFeatureAvailability) { } } +TEST(SimpleFeatureUnitTest, TestChannelsWithoutExtension) { + // Create a webui feature available on trunk. + SimpleFeature feature; + feature.set_contexts({Feature::WEBUI_CONTEXT}); + feature.set_matches({"chrome://settings/*"}); + feature.set_channel(version_info::Channel::UNKNOWN); + + const GURL kWhitelistedUrl("chrome://settings/foo"); + const GURL kOtherUrl("https://example.com"); + + { + // It should be available on trunk. + ScopedCurrentChannel current_channel(Channel::UNKNOWN); + EXPECT_EQ(Feature::IS_AVAILABLE, + feature + .IsAvailableToContext(nullptr, Feature::WEBUI_CONTEXT, + kWhitelistedUrl) + .result()); + } + { + // It should be unavailable on beta. + ScopedCurrentChannel current_channel(Channel::BETA); + EXPECT_EQ(Feature::UNSUPPORTED_CHANNEL, + feature + .IsAvailableToContext(nullptr, Feature::WEBUI_CONTEXT, + kWhitelistedUrl) + .result()); + } +} + } // namespace extensions diff --git a/chromium/extensions/common/file_util_unittest.cc b/chromium/extensions/common/file_util_unittest.cc index 4aea12c4740..c1bba333774 100644 --- a/chromium/extensions/common/file_util_unittest.cc +++ b/chromium/extensions/common/file_util_unittest.cc @@ -152,8 +152,9 @@ TEST_F(FileUtilTest, CheckIllegalFilenamesNoUnderscores) { ASSERT_TRUE(base::CreateDirectory(src_path)); std::string data = "{ \"name\": { \"message\": \"foobar\" } }"; - ASSERT_TRUE(base::WriteFile( - src_path.AppendASCII("some_file.txt"), data.c_str(), data.length())); + ASSERT_EQ(static_cast<int>(data.length()), + base::WriteFile(src_path.AppendASCII("some_file.txt"), data.c_str(), + data.length())); std::string error; EXPECT_TRUE(file_util::CheckForIllegalFilenames(temp.GetPath(), &error)); } @@ -213,8 +214,9 @@ TEST_F(FileUtilTest, ASSERT_TRUE(base::CreateDirectory(src_path)); std::string data = "{ \"name\": { \"message\": \"foobar\" } }"; - ASSERT_TRUE(base::WriteFile(src_path.AppendASCII("lpt1.txt"), data.c_str(), - data.length())); + ASSERT_EQ(static_cast<int>(data.length()), + base::WriteFile(src_path.AppendASCII("lpt1.txt"), data.c_str(), + data.length())); std::string error; EXPECT_FALSE( @@ -350,19 +352,20 @@ TEST_F(FileUtilTest, FindPrivateKeyFiles) { base::FilePath src_path = temp.GetPath().AppendASCII("some_dir"); ASSERT_TRUE(base::CreateDirectory(src_path)); - ASSERT_TRUE(base::WriteFile( - src_path.AppendASCII("a_key.pem"), private_key, arraysize(private_key))); - ASSERT_TRUE(base::WriteFile(src_path.AppendASCII("second_key.pem"), - private_key, - arraysize(private_key))); + ASSERT_EQ(static_cast<int>(arraysize(private_key)), + base::WriteFile(src_path.AppendASCII("a_key.pem"), private_key, + arraysize(private_key))); + ASSERT_EQ(static_cast<int>(arraysize(private_key)), + base::WriteFile(src_path.AppendASCII("second_key.pem"), private_key, + arraysize(private_key))); // Shouldn't find a key with a different extension. - ASSERT_TRUE(base::WriteFile(src_path.AppendASCII("key.diff_ext"), - private_key, - arraysize(private_key))); + ASSERT_EQ(static_cast<int>(arraysize(private_key)), + base::WriteFile(src_path.AppendASCII("key.diff_ext"), private_key, + arraysize(private_key))); // Shouldn't find a key that isn't parsable. - ASSERT_TRUE(base::WriteFile(src_path.AppendASCII("unparsable_key.pem"), - private_key, - arraysize(private_key) - 30)); + ASSERT_EQ(static_cast<int>(arraysize(private_key)) - 30, + base::WriteFile(src_path.AppendASCII("unparsable_key.pem"), + private_key, arraysize(private_key) - 30)); std::vector<base::FilePath> private_keys = file_util::FindPrivateKeyFiles(temp.GetPath()); EXPECT_EQ(2U, private_keys.size()); @@ -386,10 +389,12 @@ TEST_F(FileUtilTest, WarnOnPrivateKey) { " \"manifest_version\": 2,\n" " \"description\": \"The first extension that I made.\"\n" "}\n"; - ASSERT_TRUE(base::WriteFile( - ext_path.AppendASCII("manifest.json"), manifest, strlen(manifest))); - ASSERT_TRUE(base::WriteFile( - ext_path.AppendASCII("a_key.pem"), private_key, strlen(private_key))); + ASSERT_EQ(static_cast<int>(strlen(manifest)), + base::WriteFile(ext_path.AppendASCII("manifest.json"), manifest, + strlen(manifest))); + ASSERT_EQ(static_cast<int>(strlen(private_key)), + base::WriteFile(ext_path.AppendASCII("a_key.pem"), private_key, + strlen(private_key))); std::string error; scoped_refptr<Extension> extension( diff --git a/chromium/extensions/common/manifest.h b/chromium/extensions/common/manifest.h index 5455cc6a7ac..f21713ad7dd 100644 --- a/chromium/extensions/common/manifest.h +++ b/chromium/extensions/common/manifest.h @@ -110,6 +110,10 @@ class Manifest { return location == COMPONENT || location == EXTERNAL_COMPONENT; } + static inline bool IsValidLocation(Location location) { + return location > INVALID_LOCATION && location < NUM_LOCATIONS; + } + // Unpacked extensions start off with file access since they are a developer // feature. static inline bool ShouldAlwaysAllowFileAccess(Location location) { diff --git a/chromium/extensions/common/manifest_handler.cc b/chromium/extensions/common/manifest_handler.cc index 537bb9a1f8b..24ab931e30d 100644 --- a/chromium/extensions/common/manifest_handler.cc +++ b/chromium/extensions/common/manifest_handler.cc @@ -18,8 +18,8 @@ namespace extensions { namespace { -static base::LazyInstance<ManifestHandlerRegistry> g_registry = - LAZY_INSTANCE_INITIALIZER; +static base::LazyInstance<ManifestHandlerRegistry>::DestructorAtExit + g_registry = LAZY_INSTANCE_INITIALIZER; static ManifestHandlerRegistry* g_registry_override = NULL; ManifestHandlerRegistry* GetRegistry() { diff --git a/chromium/extensions/common/manifest_handler.h b/chromium/extensions/common/manifest_handler.h index 4c7da31eee0..d1cf4648925 100644 --- a/chromium/extensions/common/manifest_handler.h +++ b/chromium/extensions/common/manifest_handler.h @@ -123,7 +123,7 @@ class ManifestHandlerRegistry { private: friend class ManifestHandler; friend class ScopedTestingManifestHandlerRegistry; - friend struct base::DefaultLazyInstanceTraits<ManifestHandlerRegistry>; + friend struct base::LazyInstanceTraitsBase<ManifestHandlerRegistry>; ManifestHandlerRegistry(); ~ManifestHandlerRegistry(); diff --git a/chromium/extensions/common/manifest_handlers/action_handlers_handler.cc b/chromium/extensions/common/manifest_handlers/action_handlers_handler.cc index 2d303181183..c5ac38d6f72 100644 --- a/chromium/extensions/common/manifest_handlers/action_handlers_handler.cc +++ b/chromium/extensions/common/manifest_handlers/action_handlers_handler.cc @@ -42,9 +42,9 @@ bool ActionHandlersHandler::Parse(Extension* extension, base::string16* error) { } auto info = base::MakeUnique<ActionHandlersInfo>(); - for (const std::unique_ptr<base::Value>& wrapped_value : *entries) { + for (const base::Value& wrapped_value : *entries) { std::string value; - if (!wrapped_value->GetAsString(&value)) { + if (!wrapped_value.GetAsString(&value)) { *error = base::ASCIIToUTF16(errors::kInvalidActionHandlersType); return false; } diff --git a/chromium/extensions/common/manifest_handlers/background_info.cc b/chromium/extensions/common/manifest_handlers/background_info.cc index 0466dcd513b..eb8912757ae 100644 --- a/chromium/extensions/common/manifest_handlers/background_info.cc +++ b/chromium/extensions/common/manifest_handlers/background_info.cc @@ -37,8 +37,8 @@ namespace { const char kBackground[] = "background"; -static base::LazyInstance<BackgroundInfo> g_empty_background_info = - LAZY_INSTANCE_INITIALIZER; +static base::LazyInstance<BackgroundInfo>::DestructorAtExit + g_empty_background_info = LAZY_INSTANCE_INITIALIZER; const BackgroundInfo& GetBackgroundInfo(const Extension* extension) { BackgroundInfo* info = static_cast<BackgroundInfo*>( diff --git a/chromium/extensions/common/manifest_handlers/content_capabilities_handler.cc b/chromium/extensions/common/manifest_handlers/content_capabilities_handler.cc index c994dea36af..03d84d57017 100644 --- a/chromium/extensions/common/manifest_handlers/content_capabilities_handler.cc +++ b/chromium/extensions/common/manifest_handlers/content_capabilities_handler.cc @@ -32,8 +32,8 @@ ContentCapabilitiesInfo::ContentCapabilitiesInfo() { ContentCapabilitiesInfo::~ContentCapabilitiesInfo() { } -static base::LazyInstance<ContentCapabilitiesInfo> -g_empty_content_capabilities_info = LAZY_INSTANCE_INITIALIZER; +static base::LazyInstance<ContentCapabilitiesInfo>::DestructorAtExit + g_empty_content_capabilities_info = LAZY_INSTANCE_INITIALIZER; // static const ContentCapabilitiesInfo& ContentCapabilitiesInfo::Get( diff --git a/chromium/extensions/common/manifest_handlers/icons_handler.cc b/chromium/extensions/common/manifest_handlers/icons_handler.cc index 90cdbddb16c..2825ae917b7 100644 --- a/chromium/extensions/common/manifest_handlers/icons_handler.cc +++ b/chromium/extensions/common/manifest_handlers/icons_handler.cc @@ -23,7 +23,7 @@ namespace extensions { namespace keys = manifest_keys; -static base::LazyInstance<ExtensionIconSet> g_empty_icon_set = +static base::LazyInstance<ExtensionIconSet>::DestructorAtExit g_empty_icon_set = LAZY_INSTANCE_INITIALIZER; // static diff --git a/chromium/extensions/common/manifest_handlers/kiosk_mode_info.cc b/chromium/extensions/common/manifest_handlers/kiosk_mode_info.cc index b9947e28ce3..13bb071cba7 100644 --- a/chromium/extensions/common/manifest_handlers/kiosk_mode_info.cc +++ b/chromium/extensions/common/manifest_handlers/kiosk_mode_info.cc @@ -119,7 +119,7 @@ bool KioskModeHandler::Parse(Extension* extension, base::string16* error) { for (const auto& value : *list) { std::unique_ptr<KioskSecondaryAppsType> app = - KioskSecondaryAppsType::FromValue(*value, error); + KioskSecondaryAppsType::FromValue(value, error); if (!app) { *error = base::ASCIIToUTF16( manifest_errors::kInvalidKioskSecondaryAppsBadAppId); diff --git a/chromium/extensions/common/manifest_handlers/oauth2_manifest_handler.cc b/chromium/extensions/common/manifest_handlers/oauth2_manifest_handler.cc index 2e99bf25379..c6b77666c3e 100644 --- a/chromium/extensions/common/manifest_handlers/oauth2_manifest_handler.cc +++ b/chromium/extensions/common/manifest_handlers/oauth2_manifest_handler.cc @@ -31,7 +31,7 @@ namespace errors = manifest_errors; OAuth2Info::OAuth2Info() : auto_approve(false) {} OAuth2Info::~OAuth2Info() {} -static base::LazyInstance<OAuth2Info> g_empty_oauth2_info = +static base::LazyInstance<OAuth2Info>::DestructorAtExit g_empty_oauth2_info = LAZY_INSTANCE_INITIALIZER; // static diff --git a/chromium/extensions/common/manifest_handlers/plugins_handler.cc b/chromium/extensions/common/manifest_handlers/plugins_handler.cc new file mode 100644 index 00000000000..d89fdbe434c --- /dev/null +++ b/chromium/extensions/common/manifest_handlers/plugins_handler.cc @@ -0,0 +1,141 @@ +// Copyright (c) 2013 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 "extensions/common/manifest_handlers/plugins_handler.h" + +#include <stddef.h> + +#include <memory> + +#include "base/files/file_util.h" +#include "base/strings/string_number_conversions.h" +#include "base/strings/utf_string_conversions.h" +#include "base/values.h" +#include "build/build_config.h" +#include "extensions/common/error_utils.h" +#include "extensions/common/manifest.h" +#include "extensions/common/manifest_constants.h" +#include "extensions/common/manifest_handlers/permissions_parser.h" +#include "extensions/common/permissions/api_permission.h" +#include "extensions/common/permissions/api_permission_set.h" +#include "extensions/strings/grit/extensions_strings.h" +#include "ui/base/l10n/l10n_util.h" + +namespace extensions { + +namespace keys = manifest_keys; + +namespace { + +struct PluginManifestData : Extension::ManifestData { + // Optional list of NPAPI plugins and associated properties for an extension. + PluginInfo::PluginVector plugins; +}; + +} // namespace + +PluginInfo::PluginInfo(const base::FilePath& plugin_path, bool plugin_is_public) + : path(plugin_path), is_public(plugin_is_public) {} + +PluginInfo::~PluginInfo() {} + +// static +const PluginInfo::PluginVector* PluginInfo::GetPlugins( + const Extension* extension) { + PluginManifestData* data = static_cast<PluginManifestData*>( + extension->GetManifestData(keys::kPlugins)); + return data ? &data->plugins : NULL; +} + +// static +bool PluginInfo::HasPlugins(const Extension* extension) { + PluginManifestData* data = static_cast<PluginManifestData*>( + extension->GetManifestData(keys::kPlugins)); + return data && !data->plugins.empty() ? true : false; +} + +PluginsHandler::PluginsHandler() {} + +PluginsHandler::~PluginsHandler() {} + +const std::vector<std::string> PluginsHandler::Keys() const { + return SingleKey(keys::kPlugins); +} + +bool PluginsHandler::Parse(Extension* extension, base::string16* error) { + const base::ListValue* list_value = NULL; + if (!extension->manifest()->GetList(keys::kPlugins, &list_value)) { + *error = base::ASCIIToUTF16(manifest_errors::kInvalidPlugins); + return false; + } + + std::unique_ptr<PluginManifestData> plugins_data(new PluginManifestData); + + for (size_t i = 0; i < list_value->GetSize(); ++i) { + const base::DictionaryValue* plugin_value = NULL; + if (!list_value->GetDictionary(i, &plugin_value)) { + *error = base::ASCIIToUTF16(manifest_errors::kInvalidPlugins); + return false; + } + // Get plugins[i].path. + std::string path_str; + if (!plugin_value->GetString(keys::kPluginsPath, &path_str)) { + *error = ErrorUtils::FormatErrorMessageUTF16( + manifest_errors::kInvalidPluginsPath, base::SizeTToString(i)); + return false; + } + + // Get plugins[i].content (optional). + bool is_public = false; + if (plugin_value->HasKey(keys::kPluginsPublic)) { + if (!plugin_value->GetBoolean(keys::kPluginsPublic, &is_public)) { + *error = ErrorUtils::FormatErrorMessageUTF16( + manifest_errors::kInvalidPluginsPublic, base::SizeTToString(i)); + return false; + } + } + +// We don't allow extensions to load NPAPI plugins on Chrome OS, but still +// parse the entries to display consistent error messages. If the extension +// actually requires the plugins then LoadRequirements will prevent it +// loading. +#if defined(OS_CHROMEOS) + continue; +#endif // defined(OS_CHROMEOS). + plugins_data->plugins.push_back(PluginInfo( + extension->path().Append(base::FilePath::FromUTF8Unsafe(path_str)), + is_public)); + } + + if (!plugins_data->plugins.empty()) { + extension->SetManifestData(keys::kPlugins, std::move(plugins_data)); + PermissionsParser::AddAPIPermission(extension, APIPermission::kPlugin); + } + + return true; +} + +bool PluginsHandler::Validate(const Extension* extension, + std::string* error, + std::vector<InstallWarning>* warnings) const { + // Validate claimed plugin paths. + if (extensions::PluginInfo::HasPlugins(extension)) { + const extensions::PluginInfo::PluginVector* plugins = + extensions::PluginInfo::GetPlugins(extension); + CHECK(plugins); + for (std::vector<extensions::PluginInfo>::const_iterator plugin = + plugins->begin(); + plugin != plugins->end(); ++plugin) { + if (!base::PathExists(plugin->path)) { + *error = + l10n_util::GetStringFUTF8(IDS_EXTENSION_LOAD_PLUGIN_PATH_FAILED, + plugin->path.LossyDisplayName()); + return false; + } + } + } + return true; +} + +} // namespace extensions diff --git a/chromium/extensions/common/manifest_handlers/plugins_handler.h b/chromium/extensions/common/manifest_handlers/plugins_handler.h new file mode 100644 index 00000000000..c2a58009622 --- /dev/null +++ b/chromium/extensions/common/manifest_handlers/plugins_handler.h @@ -0,0 +1,53 @@ +// Copyright (c) 2013 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 EXTENSIONS_COMMON_MANIFEST_HANDLERS_PLUGINS_HANDLER_H_ +#define EXTENSIONS_COMMON_MANIFEST_HANDLERS_PLUGINS_HANDLER_H_ + +#include <memory> +#include <string> + +#include "base/macros.h" +#include "extensions/common/extension.h" +#include "extensions/common/manifest_handler.h" + +namespace extensions { + +// An NPAPI plugin included in the extension. +struct PluginInfo { + typedef std::vector<PluginInfo> PluginVector; + + PluginInfo(const base::FilePath& plugin_path, bool plugin_is_public); + ~PluginInfo(); + + base::FilePath path; // Path to the plugin. + bool is_public; // False if only this extension can load this plugin. + + // Return the plugins for a given |extensions|, or NULL if none exist. + static const PluginVector* GetPlugins(const Extension* extension); + + // Return true if the given |extension| has plugins, and false otherwise. + static bool HasPlugins(const Extension* extension); +}; + +// Parses the "plugins" manifest key. +class PluginsHandler : public ManifestHandler { + public: + PluginsHandler(); + ~PluginsHandler() override; + + bool Parse(Extension* extension, base::string16* error) override; + bool Validate(const Extension* extension, + std::string* error, + std::vector<InstallWarning>* warnings) const override; + + private: + const std::vector<std::string> Keys() const override; + + DISALLOW_COPY_AND_ASSIGN(PluginsHandler); +}; + +} // namespace extensions + +#endif // EXTENSIONS_COMMON_MANIFEST_HANDLERS_PLUGINS_HANDLER_H_ diff --git a/chromium/extensions/common/manifest_handlers/requirements_info.cc b/chromium/extensions/common/manifest_handlers/requirements_info.cc index d73af89c090..0acbf7baddc 100644 --- a/chromium/extensions/common/manifest_handlers/requirements_info.cc +++ b/chromium/extensions/common/manifest_handlers/requirements_info.cc @@ -117,7 +117,7 @@ bool RequirementsHandler::Parse(Extension* extension, base::string16* error) { for (base::ListValue::const_iterator feature_iter = features->begin(); feature_iter != features->end(); ++feature_iter) { std::string feature; - if ((*feature_iter)->GetAsString(&feature)) { + if (feature_iter->GetAsString(&feature)) { if (feature == "webgl") { requirements->webgl = true; } else if (feature == "css3d") { diff --git a/chromium/extensions/common/manifest_handlers/sandboxed_page_info.cc b/chromium/extensions/common/manifest_handlers/sandboxed_page_info.cc index 11d97dc7736..73b23a6b5a5 100644 --- a/chromium/extensions/common/manifest_handlers/sandboxed_page_info.cc +++ b/chromium/extensions/common/manifest_handlers/sandboxed_page_info.cc @@ -28,8 +28,8 @@ const char kDefaultSandboxedPageContentSecurityPolicy[] = "sandbox allow-scripts allow-forms allow-popups allow-modals; " "script-src 'self' 'unsafe-inline' 'unsafe-eval'; child-src 'self';"; -static base::LazyInstance<SandboxedPageInfo> g_empty_sandboxed_info = - LAZY_INSTANCE_INITIALIZER; +static base::LazyInstance<SandboxedPageInfo>::DestructorAtExit + g_empty_sandboxed_info = LAZY_INSTANCE_INITIALIZER; const SandboxedPageInfo& GetSandboxedPageInfo(const Extension* extension) { SandboxedPageInfo* info = static_cast<SandboxedPageInfo*>( diff --git a/chromium/extensions/common/manifest_handlers/shared_module_info.cc b/chromium/extensions/common/manifest_handlers/shared_module_info.cc index 90280e8564f..73f25d592c6 100644 --- a/chromium/extensions/common/manifest_handlers/shared_module_info.cc +++ b/chromium/extensions/common/manifest_handlers/shared_module_info.cc @@ -32,8 +32,8 @@ namespace { const char kSharedModule[] = "shared_module"; -static base::LazyInstance<SharedModuleInfo> g_empty_shared_module_info = - LAZY_INSTANCE_INITIALIZER; +static base::LazyInstance<SharedModuleInfo>::DestructorAtExit + g_empty_shared_module_info = LAZY_INSTANCE_INITIALIZER; const SharedModuleInfo& GetSharedModuleInfo(const Extension* extension) { SharedModuleInfo* info = static_cast<SharedModuleInfo*>( diff --git a/chromium/extensions/common/manifest_location.typemap b/chromium/extensions/common/manifest_location.typemap new file mode 100644 index 00000000000..b4c1da533df --- /dev/null +++ b/chromium/extensions/common/manifest_location.typemap @@ -0,0 +1,12 @@ +# Copyright 2017 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. + +mojom = "//extensions/common/extension_unpacker.mojom" + +public_headers = [ "//extensions/common/manifest.h" ] + +traits_headers = [ "//extensions/common/manifest_location_param_traits.h" ] + +type_mappings = + [ "extensions.mojom.ManifestLocation=extensions::Manifest::Location" ] diff --git a/chromium/extensions/common/manifest_location_param_traits.cc b/chromium/extensions/common/manifest_location_param_traits.cc new file mode 100644 index 00000000000..047461e9f5a --- /dev/null +++ b/chromium/extensions/common/manifest_location_param_traits.cc @@ -0,0 +1,32 @@ +// Copyright 2017 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 "extensions/common/manifest_location_param_traits.h" + +// Auto-generate IPC::ParamTraits<> code specializations for sending and +// receiving enum extensions::Manifest::Location over IPC. + +#include "ipc/param_traits_size_macros.h" +namespace IPC { +#undef EXTENSIONS_COMMON_MANIFEST_LOCATION_PARAM_TRAITS_H_ +#include "extensions/common/manifest_location_param_traits.h" +} // namespace IPC + +#include "ipc/param_traits_write_macros.h" +namespace IPC { +#undef EXTENSIONS_COMMON_MANIFEST_LOCATION_PARAM_TRAITS_H_ +#include "extensions/common/manifest_location_param_traits.h" +} // namespace IPC + +#include "ipc/param_traits_read_macros.h" +namespace IPC { +#undef EXTENSIONS_COMMON_MANIFEST_LOCATION_PARAM_TRAITS_H_ +#include "extensions/common/manifest_location_param_traits.h" +} // namespace IPC + +#include "ipc/param_traits_log_macros.h" +namespace IPC { +#undef EXTENSIONS_COMMON_MANIFEST_LOCATION_PARAM_TRAITS_H_ +#include "extensions/common/manifest_location_param_traits.h" +} // namespace IPC diff --git a/chromium/extensions/common/manifest_location_param_traits.h b/chromium/extensions/common/manifest_location_param_traits.h new file mode 100644 index 00000000000..15f7dde941a --- /dev/null +++ b/chromium/extensions/common/manifest_location_param_traits.h @@ -0,0 +1,16 @@ +// Copyright 2017 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 EXTENSIONS_COMMON_MANIFEST_LOCATION_PARAM_TRAITS_H_ +#define EXTENSIONS_COMMON_MANIFEST_LOCATION_PARAM_TRAITS_H_ + +#include "extensions/common/manifest.h" +#include "ipc/ipc_message_macros.h" +#include "ipc/param_traits_macros.h" + +IPC_ENUM_TRAITS_MIN_MAX_VALUE(extensions::Manifest::Location, + extensions::Manifest::INVALID_LOCATION, + extensions::Manifest::NUM_LOCATIONS - 1) + +#endif // EXTENSIONS_COMMON_MANIFEST_LOCATION_PARAM_TRAITS_H_ diff --git a/chromium/extensions/common/manifest_parser.mojom b/chromium/extensions/common/manifest_parser.mojom new file mode 100644 index 00000000000..be0aa7894b1 --- /dev/null +++ b/chromium/extensions/common/manifest_parser.mojom @@ -0,0 +1,36 @@ +// Copyright 2017 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. + +// Secure chrome extension update manifest parser provided by the utility +// process and exposed by mojo policy to the chrome browser process. + +module extensions.mojom; + +import "url/mojo/url.mojom"; + +interface ManifestParser { + // Parse an extensions update manifest |xml| document and return the + // |results|, or null if parsing fails. + Parse(string xml) => (UpdateManifestResults? results); +}; + +struct UpdateManifestResults { + array<UpdateManifestResult> list; + int32 daystart_elapsed_seconds; +}; + +struct UpdateManifestResult { + string extension_id; + string version; + string browser_min_version; + + url.mojom.Url crx_url; + string package_hash; + int32 size; + string package_fingerprint; + + url.mojom.Url diff_crx_url; + string diff_package_hash; + int32 diff_size; +}; diff --git a/chromium/extensions/common/manifest_parser.typemap b/chromium/extensions/common/manifest_parser.typemap new file mode 100644 index 00000000000..82cb2b06ec1 --- /dev/null +++ b/chromium/extensions/common/manifest_parser.typemap @@ -0,0 +1,18 @@ +# Copyright 2017 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. + +mojom = "//extensions/common/manifest_parser.mojom" + +public_headers = [ "//extensions/common/update_manifest.h" ] + +traits_headers = [ "//extensions/common/manifest_parser_struct_traits.h" ] + +sources = [ + "//extensions/common/manifest_parser_struct_traits.cc", +] + +type_mappings = [ + "extensions.mojom.UpdateManifestResults=::UpdateManifest::Results", + "extensions.mojom.UpdateManifestResult=::UpdateManifest::Result", +] diff --git a/chromium/extensions/common/manifest_parser_struct_traits.cc b/chromium/extensions/common/manifest_parser_struct_traits.cc new file mode 100644 index 00000000000..ddce9a53a37 --- /dev/null +++ b/chromium/extensions/common/manifest_parser_struct_traits.cc @@ -0,0 +1,47 @@ +// Copyright 2017 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 "extensions/common/manifest_parser_struct_traits.h" +#include "url/mojo/url_gurl_struct_traits.h" + +namespace mojo { + +// static +bool StructTraits<::extensions::mojom::UpdateManifestResults::DataView, + ::UpdateManifest::Results>:: + Read(::extensions::mojom::UpdateManifestResults::DataView input, + ::UpdateManifest::Results* output) { + if (!input.ReadList(&output->list)) + return false; + output->daystart_elapsed_seconds = input.daystart_elapsed_seconds(); + return true; +} + +// static +bool StructTraits<::extensions::mojom::UpdateManifestResult::DataView, + ::UpdateManifest::Result>:: + Read(::extensions::mojom::UpdateManifestResult::DataView input, + ::UpdateManifest::Result* output) { + if (!input.ReadExtensionId(&output->extension_id)) + return false; + if (!input.ReadVersion(&output->version)) + return false; + if (!input.ReadBrowserMinVersion(&output->browser_min_version)) + return false; + if (!input.ReadCrxUrl(&output->crx_url)) + return false; + if (!input.ReadPackageHash(&output->package_hash)) + return false; + output->size = input.size(); + if (!input.ReadPackageFingerprint(&output->package_fingerprint)) + return false; + if (!input.ReadDiffCrxUrl(&output->diff_crx_url)) + return false; + if (!input.ReadDiffPackageHash(&output->diff_package_hash)) + return false; + output->diff_size = input.diff_size(); + return true; +} + +} // namespace mojo diff --git a/chromium/extensions/common/manifest_parser_struct_traits.h b/chromium/extensions/common/manifest_parser_struct_traits.h new file mode 100644 index 00000000000..abe4c651626 --- /dev/null +++ b/chromium/extensions/common/manifest_parser_struct_traits.h @@ -0,0 +1,81 @@ +// Copyright 2017 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 EXTENSIONS_COMMON_MANIFEST_PARSER_STRUCT_TRAITS_H +#define EXTENSIONS_COMMON_MANIFEST_PARSER_STRUCT_TRAITS_H + +#include "extensions/common/manifest_parser.mojom.h" +#include "extensions/common/update_manifest.h" + +namespace mojo { + +template <> +struct StructTraits<::extensions::mojom::UpdateManifestResults::DataView, + ::UpdateManifest::Results> { + static const std::vector<::UpdateManifest::Result>& list( + const ::UpdateManifest::Results& input) { + return input.list; + } + + static int daystart_elapsed_seconds(const ::UpdateManifest::Results& input) { + return input.daystart_elapsed_seconds; + } + + static bool Read(::extensions::mojom::UpdateManifestResults::DataView input, + ::UpdateManifest::Results* output); +}; + +template <> +struct StructTraits<::extensions::mojom::UpdateManifestResult::DataView, + ::UpdateManifest::Result> { + static const std::string& extension_id( + const ::UpdateManifest::Result& input) { + return input.extension_id; + } + + static const std::string& version(const ::UpdateManifest::Result& input) { + return input.version; + } + + static const std::string& browser_min_version( + const ::UpdateManifest::Result& input) { + return input.browser_min_version; + } + + static const GURL& crx_url(const ::UpdateManifest::Result& input) { + return input.crx_url; + } + + static const std::string& package_hash( + const ::UpdateManifest::Result& input) { + return input.package_hash; + } + + static int size(const ::UpdateManifest::Result& input) { return input.size; } + + static const std::string& package_fingerprint( + const ::UpdateManifest::Result& input) { + return input.package_fingerprint; + } + + static const GURL& diff_crx_url(const ::UpdateManifest::Result& input) { + return input.diff_crx_url; + } + + static const std::string& diff_package_hash( + const ::UpdateManifest::Result& input) { + return input.diff_package_hash; + } + + static int diff_size(const ::UpdateManifest::Result& input) { + return input.diff_size; + } + + static bool Read(::extensions::mojom::UpdateManifestResult::DataView input, + ::UpdateManifest::Result* output); +}; + +} // namespace mojo + +#endif // EXTENSIONS_COMMON_MANIFEST_PARSER_STRUCT_TRAITS_H diff --git a/chromium/extensions/common/message_bundle.cc b/chromium/extensions/common/message_bundle.cc index 3fa75c0c343..f75472b8d62 100644 --- a/chromium/extensions/common/message_bundle.cc +++ b/chromium/extensions/common/message_bundle.cc @@ -318,8 +318,8 @@ struct ExtensionToMessagesMap { ExtensionToL10nMessagesMap messages_map; }; -static base::LazyInstance<ExtensionToMessagesMap> g_extension_to_messages_map = - LAZY_INSTANCE_INITIALIZER; +static base::LazyInstance<ExtensionToMessagesMap>::DestructorAtExit + g_extension_to_messages_map = LAZY_INSTANCE_INITIALIZER; ExtensionToMessagesMap::ExtensionToMessagesMap() {} diff --git a/chromium/extensions/common/mojo/app_window.mojom b/chromium/extensions/common/mojo/app_window.mojom new file mode 100644 index 00000000000..ffa6a4d8755 --- /dev/null +++ b/chromium/extensions/common/mojo/app_window.mojom @@ -0,0 +1,9 @@ +// Copyright 2017 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. + +module extensions.mojom; + +interface AppWindow { + SetVisuallyDeemphasized(bool deemphasized); +}; diff --git a/chromium/extensions/common/permissions/api_permission.h b/chromium/extensions/common/permissions/api_permission.h index 5c6f0694cd4..267ad255c08 100644 --- a/chromium/extensions/common/permissions/api_permission.h +++ b/chromium/extensions/common/permissions/api_permission.h @@ -243,6 +243,7 @@ class APIPermission { kClipboard, kNetworkingOnc, kVirtualKeyboard, + kNetworkingCastPrivate, // 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/manifest_permission_set_unittest.cc b/chromium/extensions/common/permissions/manifest_permission_set_unittest.cc index e0da1af8a07..bc20772b7a7 100644 --- a/chromium/extensions/common/permissions/manifest_permission_set_unittest.cc +++ b/chromium/extensions/common/permissions/manifest_permission_set_unittest.cc @@ -2,10 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "extensions/common/permissions/manifest_permission_set.h" + +#include "base/memory/ptr_util.h" #include "base/pickle.h" #include "base/values.h" #include "extensions/common/permissions/manifest_permission.h" -#include "extensions/common/permissions/manifest_permission_set.h" #include "ipc/ipc_message.h" #include "testing/gtest/include/gtest/gtest.h" @@ -26,7 +28,7 @@ class MockManifestPermission : public ManifestPermission { bool FromValue(const base::Value* value) override { return true; } std::unique_ptr<base::Value> ToValue() const override { - return base::Value::CreateNullValue(); + return base::MakeUnique<base::Value>(); } ManifestPermission* Diff(const ManifestPermission* rhs) const override { diff --git a/chromium/extensions/common/permissions/media_galleries_permission_data.cc b/chromium/extensions/common/permissions/media_galleries_permission_data.cc index 13f7d93d38c..330923de942 100644 --- a/chromium/extensions/common/permissions/media_galleries_permission_data.cc +++ b/chromium/extensions/common/permissions/media_galleries_permission_data.cc @@ -24,7 +24,7 @@ bool MediaGalleriesPermissionData::Check( } std::unique_ptr<base::Value> MediaGalleriesPermissionData::ToValue() const { - return std::unique_ptr<base::Value>(new base::StringValue(permission_)); + return std::unique_ptr<base::Value>(new base::Value(permission_)); } bool MediaGalleriesPermissionData::FromValue(const base::Value* value) { diff --git a/chromium/extensions/common/permissions/permissions_info.h b/chromium/extensions/common/permissions/permissions_info.h index 7834594584b..197f549c97a 100644 --- a/chromium/extensions/common/permissions/permissions_info.h +++ b/chromium/extensions/common/permissions/permissions_info.h @@ -56,7 +56,7 @@ class PermissionsInfo { size_t get_permission_count() const { return permission_count_; } private: - friend struct base::DefaultLazyInstanceTraits<PermissionsInfo>; + friend struct base::LazyInstanceTraitsBase<PermissionsInfo>; PermissionsInfo(); diff --git a/chromium/extensions/common/permissions/settings_override_permission.cc b/chromium/extensions/common/permissions/settings_override_permission.cc index df5b0733ec1..55f6a17d744 100644 --- a/chromium/extensions/common/permissions/settings_override_permission.cc +++ b/chromium/extensions/common/permissions/settings_override_permission.cc @@ -62,7 +62,7 @@ bool SettingsOverrideAPIPermission::FromValue( } std::unique_ptr<base::Value> SettingsOverrideAPIPermission::ToValue() const { - return base::MakeUnique<base::StringValue>(setting_value_); + return base::MakeUnique<base::Value>(setting_value_); } APIPermission* SettingsOverrideAPIPermission::Clone() const { diff --git a/chromium/extensions/common/permissions/socket_permission_data.cc b/chromium/extensions/common/permissions/socket_permission_data.cc index e4dbbdcc560..1616a1032a5 100644 --- a/chromium/extensions/common/permissions/socket_permission_data.cc +++ b/chromium/extensions/common/permissions/socket_permission_data.cc @@ -103,7 +103,7 @@ bool SocketPermissionData::Check(const APIPermission::CheckParam* param) const { } std::unique_ptr<base::Value> SocketPermissionData::ToValue() const { - return std::unique_ptr<base::Value>(new base::StringValue(GetAsString())); + return std::unique_ptr<base::Value>(new base::Value(GetAsString())); } bool SocketPermissionData::FromValue(const base::Value* value) { diff --git a/chromium/extensions/common/permissions/socket_permission_entry.cc b/chromium/extensions/common/permissions/socket_permission_entry.cc index 0bc963ea103..dbe3254e77a 100644 --- a/chromium/extensions/common/permissions/socket_permission_entry.cc +++ b/chromium/extensions/common/permissions/socket_permission_entry.cc @@ -14,6 +14,7 @@ #include "base/logging.h" #include "base/strings/string_number_conversions.h" +#include "base/strings/string_piece.h" #include "base/strings/string_split.h" #include "base/strings/string_util.h" #include "extensions/common/permissions/api_permission.h" @@ -158,9 +159,9 @@ bool SocketPermissionEntry::ParseHostPattern( result.pattern_.host = base::ToLowerASCII(result.pattern_.host); // The first component can optionally be '*' to match all subdomains. - std::vector<std::string> host_components = - base::SplitString(result.pattern_.host, std::string(1, kDot), - base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); + std::vector<base::StringPiece> host_components = + base::SplitStringPiece(result.pattern_.host, std::string{kDot}, + base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); DCHECK(!host_components.empty()); if (host_components[0] == kWildcard || host_components[0].empty()) { diff --git a/chromium/extensions/common/switches.cc b/chromium/extensions/common/switches.cc index 3a5bc085678..750089ffb06 100644 --- a/chromium/extensions/common/switches.cc +++ b/chromium/extensions/common/switches.cc @@ -97,6 +97,10 @@ const char kNativeCrxBindings[] = "native-crx-bindings"; // the one received from update manifest. const char kEnableCrxHashCheck[] = "enable-crx-hash-check"; +// Whether to split content script injections into multiple tasks. +const char kYieldBetweenContentScriptRuns[] = + "yield-between-content-script-runs"; + } // namespace switches } // namespace extensions diff --git a/chromium/extensions/common/switches.h b/chromium/extensions/common/switches.h index 90a142fd7b6..c8207b66a60 100644 --- a/chromium/extensions/common/switches.h +++ b/chromium/extensions/common/switches.h @@ -36,6 +36,7 @@ extern const char kTraceAppSource[]; extern const char kNativeCrxBindings[]; extern const char kWhitelistedExtensionID[]; extern const char kEnableCrxHashCheck[]; +extern const char kYieldBetweenContentScriptRuns[]; } // namespace switches diff --git a/chromium/extensions/common/typemaps.gni b/chromium/extensions/common/typemaps.gni new file mode 100644 index 00000000000..15eaa269299 --- /dev/null +++ b/chromium/extensions/common/typemaps.gni @@ -0,0 +1,8 @@ +# Copyright 2017 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. + +typemaps = [ + "//extensions/common/manifest_location.typemap", + "//extensions/common/manifest_parser.typemap", +] diff --git a/chromium/extensions/common/update_manifest.cc b/chromium/extensions/common/update_manifest.cc index adb7c3174f6..22c36746c91 100644 --- a/chromium/extensions/common/update_manifest.cc +++ b/chromium/extensions/common/update_manifest.cc @@ -19,22 +19,24 @@ static const char* kExpectedGupdateProtocol = "2.0"; static const char* kExpectedGupdateXmlns = "http://www.google.com/update2/response"; -UpdateManifest::Result::Result() - : size(0), - diff_size(0) {} +UpdateManifest::Result::Result() : size(0), diff_size(0) {} UpdateManifest::Result::Result(const Result& other) = default; -UpdateManifest::Result::~Result() {} +UpdateManifest::Result::~Result() = default; UpdateManifest::Results::Results() : daystart_elapsed_seconds(kNoDaystart) {} -UpdateManifest::Results::~Results() {} +UpdateManifest::Results::Results(const Results& other) = default; -UpdateManifest::UpdateManifest() { -} +UpdateManifest::Results& UpdateManifest::Results::operator=( + const Results& other) = default; + +UpdateManifest::Results::~Results() = default; + +UpdateManifest::UpdateManifest() = default; -UpdateManifest::~UpdateManifest() {} +UpdateManifest::~UpdateManifest() = default; void UpdateManifest::ParseError(const char* details, ...) { va_list args; diff --git a/chromium/extensions/common/update_manifest.h b/chromium/extensions/common/update_manifest.h index 6761a399e8d..d98586e2cf0 100644 --- a/chromium/extensions/common/update_manifest.h +++ b/chromium/extensions/common/update_manifest.h @@ -40,6 +40,10 @@ class UpdateManifest { // a differential update is specified in the response. // The result of parsing one <app> tag in an xml update check manifest. + // TODO(crbug.com/692120): consider removing struct Result and Results and + // using the corresponding mojo type instead. This would also remove the + // need for the Mojo struct traits that are currently defined / used to + // cart these Result/Results structs over Mojo IPC. struct Result { Result(); Result(const Result& other); @@ -64,6 +68,8 @@ class UpdateManifest { static const int kNoDaystart = -1; struct Results { Results(); + Results(const Results& other); + Results& operator=(const Results& other); ~Results(); std::vector<Result> list; diff --git a/chromium/extensions/common/url_pattern.cc b/chromium/extensions/common/url_pattern.cc index 0b318d95ea2..5677fbc8367 100644 --- a/chromium/extensions/common/url_pattern.cc +++ b/chromium/extensions/common/url_pattern.cc @@ -11,7 +11,6 @@ #include "base/macros.h" #include "base/strings/pattern.h" #include "base/strings/string_number_conversions.h" -#include "base/strings/string_piece.h" #include "base/strings/string_split.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" @@ -130,6 +129,14 @@ bool URLPattern::IsValidSchemeForExtensions(base::StringPiece scheme) { return false; } +// static +int URLPattern::GetValidSchemeMaskForExtensions() { + int result = 0; + for (size_t i = 0; i < arraysize(kValidSchemeMasks); ++i) + result |= kValidSchemeMasks[i]; + return result; +} + URLPattern::URLPattern() : valid_schemes_(SCHEME_NONE), match_all_urls_(false), @@ -247,7 +254,7 @@ URLPattern::ParseResult URLPattern::Parse(base::StringPiece pattern) { .CopyToString(&host_); // The first component can optionally be '*' to match all subdomains. - std::vector<std::string> host_components = base::SplitString( + std::vector<base::StringPiece> host_components = base::SplitStringPiece( host_, ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); // Could be empty if the host only consists of whitespace characters. diff --git a/chromium/extensions/common/url_pattern.h b/chromium/extensions/common/url_pattern.h index 574a00c9a7e..23f0687845c 100644 --- a/chromium/extensions/common/url_pattern.h +++ b/chromium/extensions/common/url_pattern.h @@ -87,6 +87,9 @@ class URLPattern { // Returns true if the given |scheme| is considered valid for extensions. static bool IsValidSchemeForExtensions(base::StringPiece scheme); + // Returns the mask for all schemes considered valid for extensions. + static int GetValidSchemeMaskForExtensions(); + explicit URLPattern(int valid_schemes); // Convenience to construct a URLPattern from a string. If the string is not diff --git a/chromium/extensions/common/url_pattern_set.cc b/chromium/extensions/common/url_pattern_set.cc index 56860926fb4..28c8cf70a5f 100644 --- a/chromium/extensions/common/url_pattern_set.cc +++ b/chromium/extensions/common/url_pattern_set.cc @@ -233,8 +233,7 @@ std::unique_ptr<base::ListValue> URLPatternSet::ToValue() const { std::unique_ptr<base::ListValue> value(new base::ListValue); for (URLPatternSet::const_iterator i = patterns_.begin(); i != patterns_.end(); ++i) - value->AppendIfNotPresent( - base::MakeUnique<base::StringValue>(i->GetAsString())); + value->AppendIfNotPresent(base::MakeUnique<base::Value>(i->GetAsString())); return value; } diff --git a/chromium/extensions/common/value_builder.cc b/chromium/extensions/common/value_builder.cc index 08bb7de1e1e..7f2a177e4db 100644 --- a/chromium/extensions/common/value_builder.cc +++ b/chromium/extensions/common/value_builder.cc @@ -42,15 +42,13 @@ DictionaryBuilder& DictionaryBuilder::Set(const std::string& path, DictionaryBuilder& DictionaryBuilder::Set(const std::string& path, const std::string& in_value) { - dict_->SetWithoutPathExpansion(path, - base::MakeUnique<base::StringValue>(in_value)); + dict_->SetWithoutPathExpansion(path, base::MakeUnique<base::Value>(in_value)); return *this; } DictionaryBuilder& DictionaryBuilder::Set(const std::string& path, const base::string16& in_value) { - dict_->SetWithoutPathExpansion(path, - base::MakeUnique<base::StringValue>(in_value)); + dict_->SetWithoutPathExpansion(path, base::MakeUnique<base::Value>(in_value)); return *this; } |
