Add back button to chrome://devices

When settings in a window is enabled, add a back button to the devices
page. This helps because the window has no address bar. See bug for
screenshot.

Longer-term, the devices page should show as an overlay in Settings
rather than load as a new page.

RTL is not enabled for this page; see issue 386020.

BUG=384333
R=noamsml@chromium.org,oshima@chromium.org

+oshima@ for icon. Oshima, is theme_resources the right place for this?
+stevenjb@ for browser shenanigans in local_discovery_ui.cc.

Review URL: https://codereview.chromium.org/338423005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278376 0039d316-1c4b-4281-b951-d872f2087c98
parent ac793992
......@@ -140,6 +140,7 @@
<structure type="chrome_scaled_image" name="IDR_BROWSER_ACTIONS_OVERFLOW" file="common/browser_actions_overflow_normal.png" />
<structure type="chrome_scaled_image" name="IDR_BROWSER_ACTIONS_OVERFLOW_H" file="common/browser_actions_overflow_hover.png" />
<structure type="chrome_scaled_image" name="IDR_BROWSER_ACTIONS_OVERFLOW_P" file="common/browser_actions_overflow_pressed.png" />
<structure type="chrome_scaled_image" name="IDR_CHEVRON_LEFT" file="common/chevron_left.png" />
<structure type="chrome_scaled_image" name="IDR_CLOSE_BUTTON_MASK" file="common/close_button_mask.png" />
<if expr="is_win">
<structure type="chrome_scaled_image" name="IDR_CONFLICT_FAVICON" file="common/favicon_conflicts.png" />
......
......@@ -113,3 +113,19 @@ section {
.dialog-contents {
padding-left: 17px;
}
#back-button {
background: url('chrome://theme/IDR_CHEVRON_LEFT') left no-repeat;
margin-bottom: 25px;
margin-top: 6px;
padding-left: 23px;
}
html[dir='rtl'] #back-button {
transform: scaleX(-1);
}
html[dir='rtl'] #back-button span {
display: inline-block;
transform: scaleX(-1);
}
......@@ -78,6 +78,9 @@
</div>
<header>
<button id="back-button" class="link-button" hidden>
<span i18n-content="backButton"></span>
</button>
<h1 i18n-content="devicesTitle"></h1>
</header>
......
......@@ -605,6 +605,13 @@ cr.define('local_discovery', function() {
'click',
registerOverlayLoginButtonClicked);
if (loadTimeData.valueExists('backButtonURL')) {
$('back-button').hidden = false;
$('back-button').addEventListener('click', function() {
window.location.href = loadTimeData.getString('backButtonURL');
});
}
updateVisibility();
document.addEventListener('visibilitychange', updateVisibility, false);
......
......@@ -5,10 +5,13 @@
#include "chrome/browser/ui/webui/local_discovery/local_discovery_ui.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h"
#include "chrome/browser/ui/webui/metrics_handler.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
#include "grit/browser_resources.h"
......@@ -84,7 +87,7 @@ content::WebUIDataSource* CreateLocalDiscoveryHTMLSource() {
IDS_LOCAL_DISCOVERY_AVAILABLE_DEVICES);
source->AddLocalizedString("myDevicesTitle",
IDS_LOCAL_DISCOVERY_MY_DEVICES);
source->AddLocalizedString("backButton", IDS_SETTINGS_TITLE);
// Cloud print connector-related strings.
#if defined(ENABLE_FULL_PRINTING) && !defined(OS_CHROMEOS)
......@@ -112,8 +115,13 @@ content::WebUIDataSource* CreateLocalDiscoveryHTMLSource() {
LocalDiscoveryUI::LocalDiscoveryUI(content::WebUI* web_ui)
: WebUIController(web_ui) {
// Set up the chrome://devices/ source.
Profile* profile = Profile::FromWebUI(web_ui);
content::WebUIDataSource::Add(profile, CreateLocalDiscoveryHTMLSource());
content::WebUIDataSource* source = CreateLocalDiscoveryHTMLSource();
Browser* browser =
chrome::FindBrowserWithWebContents(web_ui->GetWebContents());
// Show a back button pointing to Settings if the browser has no location bar.
if (browser && browser->is_trusted_source())
source->AddString("backButtonURL", chrome::kChromeUISettingsURL);
content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source);
// TODO(gene): Use LocalDiscoveryUIHandler to send updated to the devices
// page. For example
......
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