Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1303)

Side by Side Diff: chrome/browser/ui/webui/local_discovery/local_discovery_ui.cc

Issue 338423005: Add back button to chrome://devices (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/resources/local_discovery/local_discovery.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/local_discovery/local_discovery_ui.h" 5 #include "chrome/browser/ui/webui/local_discovery/local_discovery_ui.h"
6 6
7 #include "chrome/browser/profiles/profile.h" 7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_finder.h"
8 #include "chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h" 10 #include "chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h"
9 #include "chrome/browser/ui/webui/metrics_handler.h" 11 #include "chrome/browser/ui/webui/metrics_handler.h"
10 #include "chrome/common/pref_names.h" 12 #include "chrome/common/pref_names.h"
11 #include "chrome/common/url_constants.h" 13 #include "chrome/common/url_constants.h"
14 #include "content/public/browser/web_contents.h"
12 #include "content/public/browser/web_ui.h" 15 #include "content/public/browser/web_ui.h"
13 #include "content/public/browser/web_ui_data_source.h" 16 #include "content/public/browser/web_ui_data_source.h"
14 #include "grit/browser_resources.h" 17 #include "grit/browser_resources.h"
15 #include "grit/generated_resources.h" 18 #include "grit/generated_resources.h"
16 19
17 namespace { 20 namespace {
18 21
19 content::WebUIDataSource* CreateLocalDiscoveryHTMLSource() { 22 content::WebUIDataSource* CreateLocalDiscoveryHTMLSource() {
20 content::WebUIDataSource* source = 23 content::WebUIDataSource* source =
21 content::WebUIDataSource::Create(chrome::kChromeUIDevicesHost); 24 content::WebUIDataSource::Create(chrome::kChromeUIDevicesHost);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 source->AddLocalizedString("cloudDevicesNeedLogin", 80 source->AddLocalizedString("cloudDevicesNeedLogin",
78 IDS_LOCAL_DISCOVERY_CLOUD_DEVICES_NEED_LOGIN); 81 IDS_LOCAL_DISCOVERY_CLOUD_DEVICES_NEED_LOGIN);
79 source->AddLocalizedString("cloudDevicesLogin", 82 source->AddLocalizedString("cloudDevicesLogin",
80 IDS_LOCAL_DISCOVERY_CLOUD_DEVICES_LOGIN); 83 IDS_LOCAL_DISCOVERY_CLOUD_DEVICES_LOGIN);
81 source->AddLocalizedString("registerNeedLogin", 84 source->AddLocalizedString("registerNeedLogin",
82 IDS_LOCAL_DISCOVERY_REGISTER_NEED_LOGIN); 85 IDS_LOCAL_DISCOVERY_REGISTER_NEED_LOGIN);
83 source->AddLocalizedString("availableDevicesTitle", 86 source->AddLocalizedString("availableDevicesTitle",
84 IDS_LOCAL_DISCOVERY_AVAILABLE_DEVICES); 87 IDS_LOCAL_DISCOVERY_AVAILABLE_DEVICES);
85 source->AddLocalizedString("myDevicesTitle", 88 source->AddLocalizedString("myDevicesTitle",
86 IDS_LOCAL_DISCOVERY_MY_DEVICES); 89 IDS_LOCAL_DISCOVERY_MY_DEVICES);
87 90 source->AddLocalizedString("backButton", IDS_SETTINGS_TITLE);
88 91
89 // Cloud print connector-related strings. 92 // Cloud print connector-related strings.
90 #if defined(ENABLE_FULL_PRINTING) && !defined(OS_CHROMEOS) 93 #if defined(ENABLE_FULL_PRINTING) && !defined(OS_CHROMEOS)
91 source->AddLocalizedString("cloudPrintConnectorEnablingButton", 94 source->AddLocalizedString("cloudPrintConnectorEnablingButton",
92 IDS_OPTIONS_CLOUD_PRINT_CONNECTOR_ENABLING_BUTTON); 95 IDS_OPTIONS_CLOUD_PRINT_CONNECTOR_ENABLING_BUTTON);
93 source->AddLocalizedString("cloudPrintConnectorDisabledButton", 96 source->AddLocalizedString("cloudPrintConnectorDisabledButton",
94 IDS_OPTIONS_CLOUD_PRINT_CONNECTOR_DISABLED_BUTTON); 97 IDS_OPTIONS_CLOUD_PRINT_CONNECTOR_DISABLED_BUTTON);
95 source->AddLocalizedString("cloudPrintConnectorEnabledButton", 98 source->AddLocalizedString("cloudPrintConnectorEnabledButton",
96 IDS_OPTIONS_CLOUD_PRINT_CONNECTOR_ENABLED_BUTTON); 99 IDS_OPTIONS_CLOUD_PRINT_CONNECTOR_ENABLED_BUTTON);
97 source->AddLocalizedString("cloudPrintName", 100 source->AddLocalizedString("cloudPrintName",
98 IDS_GOOGLE_CLOUD_PRINT); 101 IDS_GOOGLE_CLOUD_PRINT);
99 source->AddLocalizedString("titleConnector", 102 source->AddLocalizedString("titleConnector",
100 IDS_LOCAL_DISCOVERY_CONNECTOR_SECTION); 103 IDS_LOCAL_DISCOVERY_CONNECTOR_SECTION);
101 #endif 104 #endif
102 105
103 source->SetJsonPath("strings.js"); 106 source->SetJsonPath("strings.js");
104 107
105 source->DisableDenyXFrameOptions(); 108 source->DisableDenyXFrameOptions();
106 109
107 return source; 110 return source;
108 } 111 }
109 112
110 } // namespace 113 } // namespace
111 114
112 LocalDiscoveryUI::LocalDiscoveryUI(content::WebUI* web_ui) 115 LocalDiscoveryUI::LocalDiscoveryUI(content::WebUI* web_ui)
113 : WebUIController(web_ui) { 116 : WebUIController(web_ui) {
114 // Set up the chrome://devices/ source. 117 // Set up the chrome://devices/ source.
115 Profile* profile = Profile::FromWebUI(web_ui); 118 content::WebUIDataSource* source = CreateLocalDiscoveryHTMLSource();
116 content::WebUIDataSource::Add(profile, CreateLocalDiscoveryHTMLSource()); 119 Browser* browser =
120 chrome::FindBrowserWithWebContents(web_ui->GetWebContents());
121 // Missing location bar probably means we came from settings in a window.
122 // Show a back button pointing to Settings, since there's no address bar.
123 if (browser &&
124 !browser->CanSupportWindowFeature(Browser::FEATURE_LOCATIONBAR)) {
stevenjb 2014/06/18 17:40:00 You should be able to test browser->is_trusted_sou
michaelpg 2014/06/18 18:56:37 Yes, that's better.
125 source->AddString("backButtonURL", chrome::kChromeUISettingsURL);
126 }
127 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source);
117 128
118 // TODO(gene): Use LocalDiscoveryUIHandler to send updated to the devices 129 // TODO(gene): Use LocalDiscoveryUIHandler to send updated to the devices
119 // page. For example 130 // page. For example
120 web_ui->AddMessageHandler(new local_discovery::LocalDiscoveryUIHandler()); 131 web_ui->AddMessageHandler(new local_discovery::LocalDiscoveryUIHandler());
121 web_ui->AddMessageHandler(new MetricsHandler()); 132 web_ui->AddMessageHandler(new MetricsHandler());
122 } 133 }
123 134
124 void LocalDiscoveryUI::RegisterProfilePrefs( 135 void LocalDiscoveryUI::RegisterProfilePrefs(
125 user_prefs::PrefRegistrySyncable* registry) { 136 user_prefs::PrefRegistrySyncable* registry) {
126 registry->RegisterBooleanPref( 137 registry->RegisterBooleanPref(
127 prefs::kLocalDiscoveryNotificationsEnabled, 138 prefs::kLocalDiscoveryNotificationsEnabled,
128 #if defined(OS_WIN) 139 #if defined(OS_WIN)
129 false, 140 false,
130 #else 141 #else
131 true, 142 true,
132 #endif 143 #endif
133 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); 144 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
134 } 145 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/local_discovery/local_discovery.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698