Commit e1288972 authored by rbpotter's avatar rbpotter Committed by Commit Bot

SplitSettings: Replace usage of OS settings proxies in browser settings

The site settings page in browser settings was using one method from
each of two otherwise OS-settings-only proxies:
- getAndroidSmsInfo from MultideviceBrowserProxy
- requestAndroidAppsInfo from AndroidAppsBrowserProxy

This CL
- Copies these two methods to a new browser proxy for browser settings
- Removes all usage of the Multidevice and AndroidApps proxies in
browser settings
- Moves the leftover multidevice_page files to the
chromeos/multidevice_page directory
- Removes the multidevice_page/ directory, since this only existed to
hold the proxy and the constants it used.

Bug: 986596
Change-Id: Ia80ccd555fe391b6eea2e02faca1102c779a2963
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1989934Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#729619}
parent 1754d8c4
......@@ -107,7 +107,6 @@ group("closure_compile") {
if (is_chromeos) {
deps += [
"chromeos:closure_compile",
"multidevice_page:closure_compile",
"parental_controls_page:closure_compile",
]
}
......
......@@ -16,9 +16,22 @@ js_type_check("closure_compile") {
]
}
js_library("multidevice_browser_proxy") {
deps = [
":multidevice_constants",
"//ui/webui/resources/js:cr",
]
}
js_library("multidevice_constants") {
deps = [
"//ui/webui/resources/js:cr",
]
}
js_library("multidevice_feature_behavior") {
deps = [
"../../multidevice_page:multidevice_constants",
":multidevice_constants",
"//ui/webui/resources/js:cr",
"//ui/webui/resources/js:i18n_behavior",
]
......@@ -27,9 +40,9 @@ js_library("multidevice_feature_behavior") {
js_library("multidevice_feature_item") {
deps = [
":multidevice_feature_behavior",
":multidevice_page:multidevice_constants",
"../..:route",
"../..:route_origin_behavior",
"../../multidevice_page:multidevice_constants",
"../localized_link:localized_link",
"//ui/webui/resources/js:cr",
]
......@@ -37,18 +50,18 @@ js_library("multidevice_feature_item") {
js_library("multidevice_feature_toggle") {
deps = [
":multidevice_constants",
":multidevice_feature_behavior",
"../../multidevice_page:multidevice_constants",
]
}
js_library("multidevice_page") {
deps = [
":multidevice_browser_proxy",
":multidevice_constants",
":multidevice_feature_behavior",
"../..:route",
"../../controls:password_prompt_dialog",
"../../multidevice_page:multidevice_browser_proxy",
"../../multidevice_page:multidevice_constants",
"../localized_link:localized_link",
"//ui/webui/resources/js:cr",
"//ui/webui/resources/js:web_ui_listener_behavior",
......@@ -65,8 +78,8 @@ js_library("multidevice_radio_button") {
js_library("multidevice_smartlock_subpage") {
deps = [
":multidevice_constants",
":multidevice_feature_behavior",
"../../multidevice_page:multidevice_constants",
"../../prefs:prefs_behavior",
"//ui/webui/resources/cr_elements/cr_radio_button:cr_radio_button",
"//ui/webui/resources/js:cr",
......@@ -75,9 +88,9 @@ js_library("multidevice_smartlock_subpage") {
js_library("multidevice_subpage") {
deps = [
":multidevice_constants",
":multidevice_feature_behavior",
"../..:route",
"../../multidevice_page:multidevice_constants",
"//ui/webui/resources/cr_components/chromeos/network:network_listener_behavior",
]
externs_list = [ "$externs_path/networking_private.js" ]
......
<link rel="import" href="chrome://resources/html/cr.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="multidevice_constants.html">
<!-- Anyone using this behavior might be using the referenced icons. -->
<link rel="import" href="../os_icons.html">
<link rel="import" href="../../i18n_setup.html">
<link rel="import" href="../../multidevice_page/multidevice_constants.html">
<script src="multidevice_feature_behavior.js"></script>
......@@ -8,8 +8,8 @@
<link rel="import" href="../../route.html">
<link rel="import" href="../../route_origin_behavior.html">
<link rel="import" href="../../settings_shared_css.html">
<link rel="import" href="../../multidevice_page/multidevice_constants.html">
<link rel="import" href="../localized_link/localized_link.html">
<link rel="import" href="multidevice_constants.html">
<link rel="import" href="multidevice_feature_behavior.html">
<link rel="import" href="multidevice_feature_toggle.html">
......
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/cr_elements/cr_toggle/cr_toggle.html">
<link rel="import" href="../../multidevice_page/multidevice_browser_proxy.html">
<link rel="import" href="../../multidevice_page/multidevice_constants.html">
<link rel="import" href="multidevice_browser_proxy.html">
<link rel="import" href="multidevice_constants.html">
<link rel="import" href="multidevice_feature_behavior.html">
<dom-module id="settings-multidevice-feature-toggle">
......
......@@ -14,9 +14,9 @@
<link rel="import" href="../../settings_page/settings_animated_pages.html">
<link rel="import" href="../../settings_page/settings_subpage.html">
<link rel="import" href="../../settings_shared_css.html">
<link rel="import" href="../../multidevice_page/multidevice_browser_proxy.html">
<link rel="import" href="../../multidevice_page/multidevice_constants.html">
<link rel="import" href="../localized_link/localized_link.html">
<link rel="import" href="multidevice_browser_proxy.html">
<link rel="import" href="multidevice_constants.html">
<link rel="import" href="multidevice_feature_behavior.html">
<link rel="import" href="multidevice_feature_toggle.html">
<link rel="import" href="multidevice_smartlock_subpage.html">
......
......@@ -3,8 +3,8 @@
<link rel="import" href="chrome://resources/cr_elements/cr_radio_button/cr_radio_button.html">
<link rel="import" href="chrome://resources/cr_elements/cr_radio_group/cr_radio_group.html">
<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html">
<link rel="import" href="../../multidevice_page/multidevice_constants.html">
<link rel="import" href="../../multidevice_page/multidevice_browser_proxy.html">
<link rel="import" href="multidevice_browser_proxy.html">
<link rel="import" href="multidevice_constants.html">
<link rel="import" href="multidevice_feature_behavior.html">
<link rel="import" href="multidevice_feature_toggle.html">
<link rel="import" href="multidevice_radio_button.html">
......
......@@ -10,7 +10,7 @@
<link rel="import" href="../../route.html">
<link rel="import" href="../../settings_shared_css.html">
<link rel="import" href="../../settings_vars_css.html">
<link rel="import" href="../../multidevice_page/multidevice_constants.html">
<link rel="import" href="multidevice_constants.html">
<link rel="import" href="multidevice_feature_behavior.html">
<link rel="import" href="multidevice_feature_item.html">
<link rel="import" href="multidevice_feature_toggle.html">
......
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//third_party/closure_compiler/compile_js.gni")
# Note: This file is not chromeos only because multidevice_browser_proxy is
# required by site_settings:site_list.
js_type_check("closure_compile") {
deps = [
":multidevice_browser_proxy",
":multidevice_constants",
]
}
js_library("multidevice_browser_proxy") {
deps = [
":multidevice_constants",
"//ui/webui/resources/js:cr",
]
}
js_library("multidevice_constants") {
deps = [
"//ui/webui/resources/js:cr",
]
}
file://chromeos/components/multidevice/OWNERS
# COMPONENT: OS>Systems>Multidevice
......@@ -978,16 +978,16 @@
file="chromeos/internet_page/internet_subpage.js"
type="chrome_html" />
<structure name="IDR_OS_SETTINGS_MULTIDEVICE_BROWSER_PROXY_HTML"
file="multidevice_page/multidevice_browser_proxy.html"
file="chromeos/multidevice_page/multidevice_browser_proxy.html"
type="chrome_html" />
<structure name="IDR_OS_SETTINGS_MULTIDEVICE_BROWSER_PROXY_JS"
file="multidevice_page/multidevice_browser_proxy.js"
file="chromeos/multidevice_page/multidevice_browser_proxy.js"
type="chrome_html" />
<structure name="IDR_OS_SETTINGS_MULTIDEVICE_CONSTANTS_HTML"
file="multidevice_page/multidevice_constants.html"
file="chromeos/multidevice_page/multidevice_constants.html"
type="chrome_html" />
<structure name="IDR_OS_SETTINGS_MULTIDEVICE_CONSTANTS_JS"
file="multidevice_page/multidevice_constants.js"
file="chromeos/multidevice_page/multidevice_constants.js"
type="chrome_html" />
<structure name="IDR_OS_SETTINGS_MULTIDEVICE_FEATURE_BEHAVIOR_HTML"
file="chromeos/multidevice_page/multidevice_feature_behavior.html"
......
......@@ -879,6 +879,14 @@
<structure name="IDR_SETTINGS_SITE_FAVICON_JS"
file="site_favicon.js"
type="chrome_html" />
<if expr="chromeos">
<structure name="IDR_SETTINGS_ANDROID_INFO_BROWSER_PROXY_HTML"
file="site_settings/android_info_browser_proxy.html"
type="chrome_html" />
<structure name="IDR_SETTINGS_ANDROID_INFO_BROWSER_PROXY_JS"
file="site_settings/android_info_browser_proxy.js"
type="chrome_html" />
</if>
<structure name="IDR_SETTINGS_SITE_DATA_HTML"
file="site_settings/site_data.html"
type="chrome_html" />
......@@ -1056,26 +1064,6 @@
file="site_settings/zoom_levels.js"
type="chrome_html" />
<if expr="chromeos">
<structure name="IDR_SETTINGS_ANDROID_APPS_BROWSER_PROXY_JS"
file="chromeos/os_apps_page/android_apps_browser_proxy.js"
type="chrome_html"
preprocess="true" />
<structure name="IDR_SETTINGS_ANDROID_APPS_BROWSER_PROXY_HTML"
file="chromeos/os_apps_page/android_apps_browser_proxy.html"
type="chrome_html"
preprocess="true" />
<structure name="IDR_SETTINGS_MULTIDEVICE_BROWSER_PROXY_HTML"
file="multidevice_page/multidevice_browser_proxy.html"
type="chrome_html" />
<structure name="IDR_SETTINGS_MULTIDEVICE_BROWSER_PROXY_JS"
file="multidevice_page/multidevice_browser_proxy.js"
type="chrome_html" />
<structure name="IDR_SETTINGS_MULTIDEVICE_CONSTANTS_HTML"
file="multidevice_page/multidevice_constants.html"
type="chrome_html" />
<structure name="IDR_SETTINGS_MULTIDEVICE_CONSTANTS_JS"
file="multidevice_page/multidevice_constants.js"
type="chrome_html" />
<structure name="IDR_SETTINGS_PARENTAL_CONTROLS_BROWSER_PROXY_HTML"
file="parental_controls_page/parental_controls_browser_proxy.html"
type="chrome_html" />
......
......@@ -54,6 +54,13 @@ js_library("all_sites") {
externs_list = [ "$externs_path/settings_private.js" ]
}
js_library("android_info_browser_proxy") {
deps = [
"//ui/webui/resources/js:cr",
]
externs_list = [ "$externs_path/chrome_send.js" ]
}
js_library("category_default_setting") {
deps = [
":constants",
......@@ -134,7 +141,7 @@ js_library("protocol_handlers") {
":site_settings_behavior",
# Must be included on all platforms to satisfy closure compiler.
"../chromeos/os_apps_page:android_apps_browser_proxy",
":android_info_browser_proxy",
"//ui/webui/resources/cr_elements/cr_action_menu:cr_action_menu",
"//ui/webui/resources/js:web_ui_listener_behavior",
]
......@@ -223,10 +230,10 @@ js_library("site_entry") {
js_library("site_list") {
deps = [
":android_info_browser_proxy",
":constants",
":site_list_entry",
":site_settings_behavior",
"../multidevice_page:multidevice_browser_proxy",
"//ui/webui/resources/cr_elements/cr_action_menu:cr_action_menu",
"//ui/webui/resources/js:assert",
"//ui/webui/resources/js:cr",
......
<link rel="import" href="chrome://resources/html/cr.html">
<script src="android_info_browser_proxy.js"></script>
// Copyright 2019 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.
/**
* Type definition of AndroidAppsInfo entry. |playStoreEnabled| indicates that
* Play Store is enabled. |settingsAppAvailable| indicates that Android settings
* app is registered in the system.
* @typedef {{
* playStoreEnabled: boolean,
* settingsAppAvailable: boolean,
* }}
* @see chrome/browser/ui/webui/settings/chromeos/android_apps_handler.cc
*/
let AndroidAppsInfo;
cr.define('settings', function() {
/**
* An object containing messages for web permissisions origin
* and the messages multidevice feature state.
*
* @typedef {{origin: string,
* enabled: boolean}}
*/
let AndroidSmsInfo;
/** @interface */
class AndroidInfoBrowserProxy {
/**
* Returns android messages info with messages feature state
* and messages for web permissions origin.
* @return {!Promise<!settings.AndroidSmsInfo>} Android SMS Info
*/
getAndroidSmsInfo() {}
requestAndroidAppsInfo() {}
}
/**
* @implements {settings.AndroidInfoBrowserProxy}
*/
class AndroidInfoBrowserProxyImpl {
/** @override */
getAndroidSmsInfo() {
return cr.sendWithPromise('getAndroidSmsInfo');
}
/** @override */
requestAndroidAppsInfo() {
chrome.send('requestAndroidAppsInfo');
}
}
cr.addSingletonGetter(AndroidInfoBrowserProxyImpl);
return {
AndroidInfoBrowserProxy: AndroidInfoBrowserProxy,
AndroidInfoBrowserProxyImpl: AndroidInfoBrowserProxyImpl,
AndroidSmsInfo: AndroidSmsInfo,
};
});
......@@ -13,7 +13,7 @@
<link rel="import" href="site_settings_prefs_browser_proxy.html">
<if expr="chromeos">
<link rel="import" href="../chromeos/os_apps_page/android_apps_browser_proxy.html">
<link rel="import" href="android_info_browser_proxy.html">
</if>
<dom-module id="protocol-handlers">
......
......@@ -92,7 +92,7 @@ Polymer({
attached: function() {
cr.addWebUIListener(
'android-apps-info-update', this.androidAppsInfoUpdate_.bind(this));
settings.AndroidAppsBrowserProxyImpl.getInstance().requestAndroidAppsInfo();
settings.AndroidInfoBrowserProxyImpl.getInstance().requestAndroidAppsInfo();
},
// </if>
......
......@@ -19,7 +19,7 @@
<link rel="import" href="site_settings_behavior.html">
<link rel="import" href="site_settings_prefs_browser_proxy.html">
<if expr="chromeos">
<link rel="import" href="../multidevice_page/multidevice_browser_proxy.html">
<link rel="import" href="android_info_browser_proxy.html">
</if>
<dom-module id="site-list">
......
......@@ -310,9 +310,9 @@ Polymer({
loadTimeData.valueExists('multideviceAllowedByPolicy') &&
loadTimeData.getBoolean('multideviceAllowedByPolicy') &&
!this.androidSmsInfo_) {
const multideviceSetupProxy =
settings.MultiDeviceBrowserProxyImpl.getInstance();
return multideviceSetupProxy.getAndroidSmsInfo().then((info) => {
const androidInfoBrowserProxy =
settings.AndroidInfoBrowserProxyImpl.getInstance();
return androidInfoBrowserProxy.getAndroidSmsInfo().then((info) => {
this.androidSmsInfo_ = info;
});
}
......
......@@ -1293,7 +1293,7 @@ CrSettingsSiteListTest.prototype = {
'test_util.js',
'../test_util.js',
'test_site_settings_prefs_browser_proxy.js',
'chromeos/test_multidevice_browser_proxy.js',
'test_android_info_browser_proxy.js',
'site_list_tests.js',
]),
};
......
......@@ -253,7 +253,7 @@ function populateTestExceptions() {
settings.ContentSettingsTypes.NOTIFICATIONS, [
// android sms setting.
test_util.createRawSiteException(
multidevice.TEST_ANDROID_SMS_ORIGIN),
android_info.TEST_ANDROID_SMS_ORIGIN),
// Non android sms setting that should be handled as usual.
test_util.createRawSiteException('http://bar.com')
])]);
......@@ -280,10 +280,10 @@ suite('SiteList', function() {
let browserProxy = null;
/**
* Mock MultiDeviceBrowserProxy to use during test.
* @type {TestMultideviceBrowserProxy}
* Mock AndroidInfoBrowserProxy to use during test.
* @type {TestAndroidInfoBrowserProxy}
*/
let multiDeviceBrowserProxy = null;
let androidInfoBrowserProxy = null;
suiteSetup(function() {
CrSettingsPrefs.setInitialized();
......@@ -305,8 +305,8 @@ suite('SiteList', function() {
document.body.appendChild(testElement);
if (cr.isChromeOS) {
multiDeviceBrowserProxy = new multidevice.TestMultideviceBrowserProxy();
settings.MultiDeviceBrowserProxyImpl.instance_ = multiDeviceBrowserProxy;
androidInfoBrowserProxy = new android_info.TestAndroidInfoBrowserProxy();
settings.AndroidInfoBrowserProxyImpl.instance_ = androidInfoBrowserProxy;
}
});
......@@ -412,7 +412,7 @@ suite('SiteList', function() {
settings.ContentSettingsTypes.NOTIFICATIONS,
settings.ContentSetting.ALLOW, prefsAndroidSms);
assertEquals(
0, multiDeviceBrowserProxy.getCallCount('getAndroidSmsInfo'));
0, androidInfoBrowserProxy.getCallCount('getAndroidSmsInfo'));
loadTimeData.overrideValues({multideviceAllowedByPolicy: true});
setUpCategory(
......@@ -420,9 +420,9 @@ suite('SiteList', function() {
settings.ContentSetting.ALLOW, prefsAndroidSms);
// Assert 2 calls since the observer observes 2 properties.
assertEquals(
2, multiDeviceBrowserProxy.getCallCount('getAndroidSmsInfo'));
2, androidInfoBrowserProxy.getCallCount('getAndroidSmsInfo'));
return multiDeviceBrowserProxy.whenCalled('getAndroidSmsInfo')
return androidInfoBrowserProxy.whenCalled('getAndroidSmsInfo')
.then(() => browserProxy.whenCalled('getExceptionList'))
.then((contentType) => {
assertEquals(
......@@ -440,8 +440,6 @@ suite('SiteList', function() {
assertEquals(undefined, testElement.sites[1].showAndroidSmsNote);
browserProxy.resetResolver('getExceptionList');
multiDeviceBrowserProxy.setFeatureEnabledState(
settings.MultiDeviceFeature.MESSAGES, false);
return browserProxy.whenCalled('getExceptionList');
})
.then((contentType) => {
......
// Copyright 2019 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.
cr.define('android_info', function() {
/**
* Test value for messages for web permissions origin.
*/
const TEST_ANDROID_SMS_ORIGIN = 'http://foo.com';
/** @implements {settings.AndroidInfoBrowserProxy} */
class TestAndroidInfoBrowserProxy extends TestBrowserProxy {
constructor() {
super([
'getAndroidSmsInfo',
]);
this.androidSmsInfo = {origin: TEST_ANDROID_SMS_ORIGIN, enabled: true};
}
/** @override */
getAndroidSmsInfo() {
this.methodCalled('getAndroidSmsInfo');
return Promise.resolve(this.androidSmsInfo);
}
}
return {
TestAndroidInfoBrowserProxy: TestAndroidInfoBrowserProxy,
TEST_ANDROID_SMS_ORIGIN: TEST_ANDROID_SMS_ORIGIN,
};
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment