OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/display/display_manager.h" | |
8 #include "ash/shell.h" | |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 11 #include "base/command_line.h" |
10 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
11 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
12 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
13 #include "base/values.h" | 15 #include "base/values.h" |
14 #include "chrome/browser/chromeos/input_method/input_method_configuration.h" | 16 #include "chrome/browser/chromeos/input_method/input_method_configuration.h" |
15 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 17 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
16 #include "chrome/browser/chromeos/input_method/xkeyboard.h" | 18 #include "chrome/browser/chromeos/input_method/xkeyboard.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
185 { "keyboardOverlayPreviousWord", IDS_KEYBOARD_OVERLAY_PREVIOUS_WORD }, | 187 { "keyboardOverlayPreviousWord", IDS_KEYBOARD_OVERLAY_PREVIOUS_WORD }, |
186 { "keyboardOverlayPrint", IDS_KEYBOARD_OVERLAY_PRINT }, | 188 { "keyboardOverlayPrint", IDS_KEYBOARD_OVERLAY_PRINT }, |
187 { "keyboardOverlayReloadCurrentPage", | 189 { "keyboardOverlayReloadCurrentPage", |
188 IDS_KEYBOARD_OVERLAY_RELOAD_CURRENT_PAGE }, | 190 IDS_KEYBOARD_OVERLAY_RELOAD_CURRENT_PAGE }, |
189 { "keyboardOverlayReloadIgnoringCache", | 191 { "keyboardOverlayReloadIgnoringCache", |
190 IDS_KEYBOARD_OVERLAY_RELOAD_IGNORING_CACHE }, | 192 IDS_KEYBOARD_OVERLAY_RELOAD_IGNORING_CACHE }, |
191 { "keyboardOverlayReopenLastClosedTab", | 193 { "keyboardOverlayReopenLastClosedTab", |
192 IDS_KEYBOARD_OVERLAY_REOPEN_LAST_CLOSED_TAB }, | 194 IDS_KEYBOARD_OVERLAY_REOPEN_LAST_CLOSED_TAB }, |
193 { "keyboardOverlayReportIssue", IDS_KEYBOARD_OVERLAY_REPORT_ISSUE }, | 195 { "keyboardOverlayReportIssue", IDS_KEYBOARD_OVERLAY_REPORT_ISSUE }, |
194 { "keyboardOverlayResetZoom", IDS_KEYBOARD_OVERLAY_RESET_ZOOM }, | 196 { "keyboardOverlayResetZoom", IDS_KEYBOARD_OVERLAY_RESET_ZOOM }, |
197 { "keyboardOverlayRotateScreen", IDS_KEYBOARD_OVERLAY_ROTATE_SCREEN }, | |
195 { "keyboardOverlaySave", IDS_KEYBOARD_OVERLAY_SAVE }, | 198 { "keyboardOverlaySave", IDS_KEYBOARD_OVERLAY_SAVE }, |
199 { "keyboardOverlayScaleDownUi", IDS_KEYBOARD_OVERLAY_SCALE_DOWN_UI }, | |
200 { "keyboardOverlayScaleUpUi", IDS_KEYBOARD_OVERLAY_SCALE_UP_UI }, | |
196 { "keyboardOverlayScreenshotRegion", | 201 { "keyboardOverlayScreenshotRegion", |
197 IDS_KEYBOARD_OVERLAY_SCREENSHOT_REGION }, | 202 IDS_KEYBOARD_OVERLAY_SCREENSHOT_REGION }, |
198 { "keyboardOverlayScrollUpOnePage", | 203 { "keyboardOverlayScrollUpOnePage", |
199 IDS_KEYBOARD_OVERLAY_SCROLL_UP_ONE_PAGE }, | 204 IDS_KEYBOARD_OVERLAY_SCROLL_UP_ONE_PAGE }, |
200 { "keyboardOverlaySelectAll", IDS_KEYBOARD_OVERLAY_SELECT_ALL }, | 205 { "keyboardOverlaySelectAll", IDS_KEYBOARD_OVERLAY_SELECT_ALL }, |
201 { "keyboardOverlaySelectPreviousInputMethod", | 206 { "keyboardOverlaySelectPreviousInputMethod", |
202 IDS_KEYBOARD_OVERLAY_SELECT_PREVIOUS_INPUT_METHOD }, | 207 IDS_KEYBOARD_OVERLAY_SELECT_PREVIOUS_INPUT_METHOD }, |
203 { "keyboardOverlaySelectWordAtATime", | 208 { "keyboardOverlaySelectWordAtATime", |
204 IDS_KEYBOARD_OVERLAY_SELECT_WORD_AT_A_TIME }, | 209 IDS_KEYBOARD_OVERLAY_SELECT_WORD_AT_A_TIME }, |
205 { "keyboardOverlayShowMessageCenter", | 210 { "keyboardOverlayShowMessageCenter", |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
244 source->AddLocalizedString(kI18nContentToMessage[i].i18n_content, | 249 source->AddLocalizedString(kI18nContentToMessage[i].i18n_content, |
245 kI18nContentToMessage[i].message); | 250 kI18nContentToMessage[i].message); |
246 } | 251 } |
247 | 252 |
248 source->AddString("keyboardOverlayLearnMoreURL", UTF8ToUTF16(kLearnMoreURL)); | 253 source->AddString("keyboardOverlayLearnMoreURL", UTF8ToUTF16(kLearnMoreURL)); |
249 const char* has_diamond_key_value = | 254 const char* has_diamond_key_value = |
250 CommandLine::ForCurrentProcess()->HasSwitch( | 255 CommandLine::ForCurrentProcess()->HasSwitch( |
251 switches::kHasChromeOSDiamondKey) ? "true" : "false"; | 256 switches::kHasChromeOSDiamondKey) ? "true" : "false"; |
252 source->AddString("keyboardOverlayHasChromeOSDiamondKey", | 257 source->AddString("keyboardOverlayHasChromeOSDiamondKey", |
253 has_diamond_key_value); | 258 has_diamond_key_value); |
259 ash::Shell* shell = ash::Shell::GetInstance(); | |
260 if (shell) { | |
261 ash::internal::DisplayManager* display_manager = shell->display_manager(); | |
262 source->AddString("keyboardOverlayIsDisplayRotationEnabled", | |
263 display_manager->IsDisplayRotationEnabled() ? | |
264 "true" : "false"); | |
xiyuan
2013/03/23 05:49:09
nit: you could use source->AddBoolean and test tha
mazda
2013/03/23 06:28:45
Cool! Thanks.
| |
265 source->AddString("keyboardOverlayIsDisplayUIScalingEnabled", | |
266 display_manager->IsDisplayUIScalingEnabled() ? | |
267 "true" : "false"); | |
268 } | |
254 source->SetJsonPath("strings.js"); | 269 source->SetJsonPath("strings.js"); |
255 source->SetUseJsonJSFormatV2(); | 270 source->SetUseJsonJSFormatV2(); |
256 source->AddResourcePath("keyboard_overlay.js", IDR_KEYBOARD_OVERLAY_JS); | 271 source->AddResourcePath("keyboard_overlay.js", IDR_KEYBOARD_OVERLAY_JS); |
257 source->SetDefaultResource(IDR_KEYBOARD_OVERLAY_HTML); | 272 source->SetDefaultResource(IDR_KEYBOARD_OVERLAY_HTML); |
258 return source; | 273 return source; |
259 } | 274 } |
260 | 275 |
261 } // namespace | 276 } // namespace |
262 | 277 |
263 // The handler for Javascript messages related to the "keyboardoverlay" view. | 278 // The handler for Javascript messages related to the "keyboardoverlay" view. |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
362 | 377 |
363 KeyboardOverlayUI::KeyboardOverlayUI(content::WebUI* web_ui) | 378 KeyboardOverlayUI::KeyboardOverlayUI(content::WebUI* web_ui) |
364 : WebDialogUI(web_ui) { | 379 : WebDialogUI(web_ui) { |
365 Profile* profile = Profile::FromWebUI(web_ui); | 380 Profile* profile = Profile::FromWebUI(web_ui); |
366 KeyboardOverlayHandler* handler = new KeyboardOverlayHandler(profile); | 381 KeyboardOverlayHandler* handler = new KeyboardOverlayHandler(profile); |
367 web_ui->AddMessageHandler(handler); | 382 web_ui->AddMessageHandler(handler); |
368 | 383 |
369 // Set up the chrome://keyboardoverlay/ source. | 384 // Set up the chrome://keyboardoverlay/ source. |
370 content::WebUIDataSource::Add(profile, CreateKeyboardOverlayUIHTMLSource()); | 385 content::WebUIDataSource::Add(profile, CreateKeyboardOverlayUIHTMLSource()); |
371 } | 386 } |
OLD | NEW |