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

Side by Side Diff: chrome/browser/ui/webui/chromeos/network_ui.cc

Issue 2067153002: ChromeOS: Implement Network Selection screen of material design OOBE. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reverted change to web_ui_browser_test.cc that was moved to another CL. Created 4 years, 5 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
« no previous file with comments | « chrome/browser/ui/webui/chromeos/network_ui.h ('k') | extensions/common/api/_api_features.json » ('j') | 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/chromeos/network_ui.h" 5 #include "chrome/browser/ui/webui/chromeos/network_ui.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/extensions/tab_helper.h" 12 #include "chrome/browser/extensions/tab_helper.h"
13 #include "chrome/common/url_constants.h" 13 #include "chrome/common/url_constants.h"
14 #include "chrome/grit/generated_resources.h" 14 #include "chrome/grit/generated_resources.h"
15 #include "chromeos/network/device_state.h" 15 #include "chromeos/network/device_state.h"
16 #include "chromeos/network/network_configuration_handler.h" 16 #include "chromeos/network/network_configuration_handler.h"
17 #include "chromeos/network/network_state.h" 17 #include "chromeos/network/network_state.h"
18 #include "chromeos/network/network_state_handler.h" 18 #include "chromeos/network/network_state_handler.h"
19 #include "components/device_event_log/device_event_log.h" 19 #include "components/device_event_log/device_event_log.h"
20 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
21 #include "content/public/browser/web_ui.h" 21 #include "content/public/browser/web_ui.h"
22 #include "content/public/browser/web_ui_data_source.h" 22 #include "content/public/browser/web_ui_data_source.h"
23 #include "content/public/browser/web_ui_message_handler.h" 23 #include "content/public/browser/web_ui_message_handler.h"
24 #include "grit/browser_resources.h" 24 #include "grit/browser_resources.h"
25 #include "third_party/cros_system_api/dbus/service_constants.h" 25 #include "third_party/cros_system_api/dbus/service_constants.h"
26 #include "ui/base/l10n/l10n_util.h"
26 #include "ui/chromeos/strings/grit/ui_chromeos_strings.h" 27 #include "ui/chromeos/strings/grit/ui_chromeos_strings.h"
27 28
28 namespace chromeos { 29 namespace chromeos {
29 30
30 namespace { 31 namespace {
31 32
32 bool GetServicePathFromGuid(const std::string& guid, 33 bool GetServicePathFromGuid(const std::string& guid,
33 std::string* service_path) { 34 std::string* service_path) {
34 const NetworkState* network = 35 const NetworkState* network =
35 NetworkHandler::Get()->network_state_handler()->GetNetworkStateFromGuid( 36 NetworkHandler::Get()->network_state_handler()->GetNetworkStateFromGuid(
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 return_arg_list); 131 return_arg_list);
131 } 132 }
132 133
133 base::WeakPtrFactory<NetworkConfigMessageHandler> weak_ptr_factory_; 134 base::WeakPtrFactory<NetworkConfigMessageHandler> weak_ptr_factory_;
134 135
135 DISALLOW_COPY_AND_ASSIGN(NetworkConfigMessageHandler); 136 DISALLOW_COPY_AND_ASSIGN(NetworkConfigMessageHandler);
136 }; 137 };
137 138
138 } // namespace 139 } // namespace
139 140
141 // static
142 void NetworkUI::GetLocalizedStrings(base::DictionaryValue* localized_strings) {
143 localized_strings->SetString("titleText",
144 l10n_util::GetStringUTF16(IDS_NETWORK_UI_TITLE));
145
146 localized_strings->SetString("titleText",
147 l10n_util::GetStringUTF16(IDS_NETWORK_UI_TITLE));
148 localized_strings->SetString(
149 "autoRefreshText",
150 l10n_util::GetStringUTF16(IDS_NETWORK_UI_AUTO_REFRESH));
151 localized_strings->SetString(
152 "deviceLogLinkText", l10n_util::GetStringUTF16(IDS_DEVICE_LOG_LINK_TEXT));
153 localized_strings->SetString(
154 "networkRefreshText", l10n_util::GetStringUTF16(IDS_NETWORK_UI_REFRESH));
155 localized_strings->SetString(
156 "clickToExpandText", l10n_util::GetStringUTF16(IDS_NETWORK_UI_EXPAND));
157 localized_strings->SetString(
158 "propertyFormatText",
159 l10n_util::GetStringUTF16(IDS_NETWORK_UI_PROPERTY_FORMAT));
160
161 localized_strings->SetString(
162 "normalFormatOption",
163 l10n_util::GetStringUTF16(IDS_NETWORK_UI_FORMAT_NORMAL));
164 localized_strings->SetString(
165 "managedFormatOption",
166 l10n_util::GetStringUTF16(IDS_NETWORK_UI_FORMAT_MANAGED));
167 localized_strings->SetString(
168 "stateFormatOption",
169 l10n_util::GetStringUTF16(IDS_NETWORK_UI_FORMAT_STATE));
170 localized_strings->SetString(
171 "shillFormatOption",
172 l10n_util::GetStringUTF16(IDS_NETWORK_UI_FORMAT_SHILL));
173
174 localized_strings->SetString(
175 "visibleNetworksLabel",
176 l10n_util::GetStringUTF16(IDS_NETWORK_UI_VISIBLE_NETWORKS));
177 localized_strings->SetString(
178 "favoriteNetworksLabel",
179 l10n_util::GetStringUTF16(IDS_NETWORK_UI_FAVORITE_NETWORKS));
180
181 localized_strings->SetString(
182 "networkConnected",
183 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_NETWORK_CONNECTED));
184 localized_strings->SetString(
185 "networkConnecting",
186 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_NETWORK_CONNECTING));
187 localized_strings->SetString(
188 "networkDisabled",
189 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_NETWORK_DISABLED));
190 localized_strings->SetString(
191 "networkNotConnected",
192 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_NETWORK_NOT_CONNECTED));
193 localized_strings->SetString(
194 "OncTypeCellular", l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_CELLULAR));
195 localized_strings->SetString(
196 "OncTypeEthernet", l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_ETHERNET));
197 localized_strings->SetString("OncTypeVPN",
198 l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_VPN));
199 localized_strings->SetString(
200 "OncTypeWiFi", l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_WIFI));
201 localized_strings->SetString(
202 "OncTypeWimax", l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_WIMAX));
203 localized_strings->SetString(
204 "vpnNameTemplate",
205 l10n_util::GetStringUTF16(
206 IDS_OPTIONS_SETTINGS_SECTION_THIRD_PARTY_VPN_NAME_TEMPLATE));
207 }
208
140 NetworkUI::NetworkUI(content::WebUI* web_ui) 209 NetworkUI::NetworkUI(content::WebUI* web_ui)
141 : content::WebUIController(web_ui) { 210 : content::WebUIController(web_ui) {
142 web_ui->AddMessageHandler(new NetworkConfigMessageHandler()); 211 web_ui->AddMessageHandler(new NetworkConfigMessageHandler());
143 212
144 // Enable extension API calls in the WebUI. 213 // Enable extension API calls in the WebUI.
145 extensions::TabHelper::CreateForWebContents(web_ui->GetWebContents()); 214 extensions::TabHelper::CreateForWebContents(web_ui->GetWebContents());
146 215
216 base::DictionaryValue localized_strings;
217 GetLocalizedStrings(&localized_strings);
218
147 content::WebUIDataSource* html = 219 content::WebUIDataSource* html =
148 content::WebUIDataSource::Create(chrome::kChromeUINetworkHost); 220 content::WebUIDataSource::Create(chrome::kChromeUINetworkHost);
149 221 html->AddLocalizedStrings(localized_strings);
150 html->AddLocalizedString("titleText", IDS_NETWORK_UI_TITLE);
151 html->AddLocalizedString("autoRefreshText", IDS_NETWORK_UI_AUTO_REFRESH);
152 html->AddLocalizedString("deviceLogLinkText", IDS_DEVICE_LOG_LINK_TEXT);
153 html->AddLocalizedString("networkRefreshText", IDS_NETWORK_UI_REFRESH);
154 html->AddLocalizedString("clickToExpandText", IDS_NETWORK_UI_EXPAND);
155 html->AddLocalizedString("propertyFormatText",
156 IDS_NETWORK_UI_PROPERTY_FORMAT);
157
158 html->AddLocalizedString("normalFormatOption", IDS_NETWORK_UI_FORMAT_NORMAL);
159 html->AddLocalizedString("managedFormatOption",
160 IDS_NETWORK_UI_FORMAT_MANAGED);
161 html->AddLocalizedString("stateFormatOption", IDS_NETWORK_UI_FORMAT_STATE);
162 html->AddLocalizedString("shillFormatOption", IDS_NETWORK_UI_FORMAT_SHILL);
163
164 html->AddLocalizedString("visibleNetworksLabel",
165 IDS_NETWORK_UI_VISIBLE_NETWORKS);
166 html->AddLocalizedString("favoriteNetworksLabel",
167 IDS_NETWORK_UI_FAVORITE_NETWORKS);
168
169 html->AddLocalizedString("networkConnected",
170 IDS_ASH_STATUS_TRAY_NETWORK_CONNECTED);
171 html->AddLocalizedString("networkConnecting",
172 IDS_ASH_STATUS_TRAY_NETWORK_CONNECTING);
173 html->AddLocalizedString("networkDisabled",
174 IDS_OPTIONS_SETTINGS_NETWORK_DISABLED);
175 html->AddLocalizedString("networkNotConnected",
176 IDS_ASH_STATUS_TRAY_NETWORK_NOT_CONNECTED);
177 html->AddLocalizedString("OncTypeCellular", IDS_NETWORK_TYPE_CELLULAR);
178 html->AddLocalizedString("OncTypeEthernet", IDS_NETWORK_TYPE_ETHERNET);
179 html->AddLocalizedString("OncTypeVPN", IDS_NETWORK_TYPE_VPN);
180 html->AddLocalizedString("OncTypeWiFi", IDS_NETWORK_TYPE_WIFI);
181 html->AddLocalizedString("OncTypeWimax", IDS_NETWORK_TYPE_WIMAX);
182 html->AddLocalizedString(
183 "vpnNameTemplate",
184 IDS_OPTIONS_SETTINGS_SECTION_THIRD_PARTY_VPN_NAME_TEMPLATE);
185 222
186 html->SetJsonPath("strings.js"); 223 html->SetJsonPath("strings.js");
187 html->AddResourcePath("network_ui.css", IDR_NETWORK_UI_CSS); 224 html->AddResourcePath("network_ui.css", IDR_NETWORK_UI_CSS);
188 html->AddResourcePath("network_ui.js", IDR_NETWORK_UI_JS); 225 html->AddResourcePath("network_ui.js", IDR_NETWORK_UI_JS);
189 html->SetDefaultResource(IDR_NETWORK_UI_HTML); 226 html->SetDefaultResource(IDR_NETWORK_UI_HTML);
190 227
191 content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(), 228 content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(),
192 html); 229 html);
193 } 230 }
194 231
195 NetworkUI::~NetworkUI() { 232 NetworkUI::~NetworkUI() {
196 } 233 }
197 234
198 } // namespace chromeos 235 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/chromeos/network_ui.h ('k') | extensions/common/api/_api_features.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698