OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/choose_mobile_network_ui.h" | 5 #include "chrome/browser/ui/webui/chromeos/choose_mobile_network_ui.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 l10n_util::GetStringUTF16(IDS_NETWORK_NO_MOBILE_NETWORKS)); | 115 l10n_util::GetStringUTF16(IDS_NETWORK_NO_MOBILE_NETWORKS)); |
116 strings.SetString("connect", | 116 strings.SetString("connect", |
117 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_CONNECT)); | 117 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_CONNECT)); |
118 strings.SetString("cancel", l10n_util::GetStringUTF16(IDS_CANCEL)); | 118 strings.SetString("cancel", l10n_util::GetStringUTF16(IDS_CANCEL)); |
119 SetFontAndTextDirection(&strings); | 119 SetFontAndTextDirection(&strings); |
120 | 120 |
121 static const base::StringPiece html( | 121 static const base::StringPiece html( |
122 ResourceBundle::GetSharedInstance().GetRawDataResource( | 122 ResourceBundle::GetSharedInstance().GetRawDataResource( |
123 IDR_CHOOSE_MOBILE_NETWORK_HTML)); | 123 IDR_CHOOSE_MOBILE_NETWORK_HTML)); |
124 | 124 |
125 const std::string& full_html = jstemplate_builder::GetI18nTemplateHtml( | 125 std::string full_html = jstemplate_builder::GetI18nTemplateHtml(html, |
126 html, &strings); | 126 &strings); |
127 | 127 |
128 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes()); | 128 SendResponse(request_id, base::RefCountedString::TakeString(&full_html)); |
129 html_bytes->data.resize(full_html.size()); | |
130 std::copy(full_html.begin(), full_html.end(), html_bytes->data.begin()); | |
131 | |
132 SendResponse(request_id, html_bytes); | |
133 } | 129 } |
134 | 130 |
135 // ChooseMobileNetworkHandler implementation. | 131 // ChooseMobileNetworkHandler implementation. |
136 | 132 |
137 ChooseMobileNetworkHandler::ChooseMobileNetworkHandler() | 133 ChooseMobileNetworkHandler::ChooseMobileNetworkHandler() |
138 : is_page_ready_(false), has_pending_results_(false) { | 134 : is_page_ready_(false), has_pending_results_(false) { |
139 if (!CrosLibrary::Get()->EnsureLoaded()) | 135 if (!CrosLibrary::Get()->EnsureLoaded()) |
140 return; | 136 return; |
141 | 137 |
142 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); | 138 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 : ChromeWebUI(contents) { | 249 : ChromeWebUI(contents) { |
254 ChooseMobileNetworkHandler* handler = new ChooseMobileNetworkHandler(); | 250 ChooseMobileNetworkHandler* handler = new ChooseMobileNetworkHandler(); |
255 AddMessageHandler((handler)->Attach(this)); | 251 AddMessageHandler((handler)->Attach(this)); |
256 ChooseMobileNetworkHTMLSource* html_source = | 252 ChooseMobileNetworkHTMLSource* html_source = |
257 new ChooseMobileNetworkHTMLSource(); | 253 new ChooseMobileNetworkHTMLSource(); |
258 // Set up the "chrome://choose-mobile-network" source. | 254 // Set up the "chrome://choose-mobile-network" source. |
259 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); | 255 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); |
260 } | 256 } |
261 | 257 |
262 } // namespace chromeos | 258 } // namespace chromeos |
OLD | NEW |