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/keyboard_overlay_ui.h" | 5 #include "chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 10 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 DictionaryValue localized_strings; | 220 DictionaryValue localized_strings; |
221 for (size_t i = 0; i < arraysize(kI18nContentToMessage); ++i) { | 221 for (size_t i = 0; i < arraysize(kI18nContentToMessage); ++i) { |
222 localized_strings.SetString( | 222 localized_strings.SetString( |
223 kI18nContentToMessage[i].i18n_content, | 223 kI18nContentToMessage[i].i18n_content, |
224 l10n_util::GetStringUTF16(kI18nContentToMessage[i].message)); | 224 l10n_util::GetStringUTF16(kI18nContentToMessage[i].message)); |
225 } | 225 } |
226 | 226 |
227 static const base::StringPiece keyboard_overlay_html( | 227 static const base::StringPiece keyboard_overlay_html( |
228 ResourceBundle::GetSharedInstance().GetRawDataResource( | 228 ResourceBundle::GetSharedInstance().GetRawDataResource( |
229 IDR_KEYBOARD_OVERLAY_HTML)); | 229 IDR_KEYBOARD_OVERLAY_HTML)); |
230 const std::string full_html = jstemplate_builder::GetI18nTemplateHtml( | 230 std::string full_html = jstemplate_builder::GetI18nTemplateHtml( |
231 keyboard_overlay_html, &localized_strings); | 231 keyboard_overlay_html, &localized_strings); |
232 | 232 |
233 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); | 233 SendResponse(request_id, base::RefCountedString::TakeString(&full_html)); |
234 html_bytes->data.resize(full_html.size()); | |
235 std::copy(full_html.begin(), full_html.end(), html_bytes->data.begin()); | |
236 | |
237 SendResponse(request_id, html_bytes); | |
238 } | 234 } |
239 | 235 |
240 //////////////////////////////////////////////////////////////////////////////// | 236 //////////////////////////////////////////////////////////////////////////////// |
241 // | 237 // |
242 // KeyboardOverlayHandler | 238 // KeyboardOverlayHandler |
243 // | 239 // |
244 //////////////////////////////////////////////////////////////////////////////// | 240 //////////////////////////////////////////////////////////////////////////////// |
245 KeyboardOverlayHandler::KeyboardOverlayHandler(Profile* profile) | 241 KeyboardOverlayHandler::KeyboardOverlayHandler(Profile* profile) |
246 : profile_(profile) { | 242 : profile_(profile) { |
247 } | 243 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 KeyboardOverlayUI::KeyboardOverlayUI(TabContents* contents) | 297 KeyboardOverlayUI::KeyboardOverlayUI(TabContents* contents) |
302 : HtmlDialogUI(contents) { | 298 : HtmlDialogUI(contents) { |
303 KeyboardOverlayHandler* handler = | 299 KeyboardOverlayHandler* handler = |
304 new KeyboardOverlayHandler(contents->profile()); | 300 new KeyboardOverlayHandler(contents->profile()); |
305 AddMessageHandler((handler)->Attach(this)); | 301 AddMessageHandler((handler)->Attach(this)); |
306 KeyboardOverlayUIHTMLSource* html_source = new KeyboardOverlayUIHTMLSource(); | 302 KeyboardOverlayUIHTMLSource* html_source = new KeyboardOverlayUIHTMLSource(); |
307 | 303 |
308 // Set up the chrome://keyboardoverlay/ source. | 304 // Set up the chrome://keyboardoverlay/ source. |
309 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); | 305 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); |
310 } | 306 } |
OLD | NEW |