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/chromeos/login/webui_login_view.h" | 5 #include "chrome/browser/chromeos/login/webui_login_view.h" |
6 | 6 |
| 7 #include "base/utf_string_conversions.h" |
| 8 #include "base/values.h" |
7 #include "chrome/browser/chromeos/accessibility_util.h" | 9 #include "chrome/browser/chromeos/accessibility_util.h" |
8 #include "chrome/browser/chromeos/login/proxy_settings_dialog.h" | 10 #include "chrome/browser/chromeos/login/proxy_settings_dialog.h" |
9 #include "chrome/browser/chromeos/login/webui_login_display.h" | 11 #include "chrome/browser/chromeos/login/webui_login_display.h" |
10 #include "chrome/browser/chromeos/status/clock_menu_button.h" | 12 #include "chrome/browser/chromeos/status/clock_menu_button.h" |
11 #include "chrome/browser/chromeos/status/input_method_menu_button.h" | 13 #include "chrome/browser/chromeos/status/input_method_menu_button.h" |
12 #include "chrome/browser/chromeos/status/network_menu_button.h" | 14 #include "chrome/browser/chromeos/status/network_menu_button.h" |
13 #include "chrome/browser/chromeos/status/status_area_view.h" | 15 #include "chrome/browser/chromeos/status/status_area_view.h" |
14 #include "chrome/browser/chromeos/wm_ipc.h" | 16 #include "chrome/browser/chromeos/wm_ipc.h" |
15 #include "chrome/browser/profiles/profile_manager.h" | 17 #include "chrome/browser/profiles/profile_manager.h" |
16 #include "chrome/browser/ui/views/dom_view.h" | 18 #include "chrome/browser/ui/views/dom_view.h" |
| 19 #include "content/browser/renderer_host/render_view_host_observer.h" |
17 #include "content/browser/tab_contents/tab_contents.h" | 20 #include "content/browser/tab_contents/tab_contents.h" |
| 21 #include "content/common/view_messages.h" |
18 #include "ui/gfx/rect.h" | 22 #include "ui/gfx/rect.h" |
19 #include "ui/gfx/size.h" | 23 #include "ui/gfx/size.h" |
20 #include "views/widget/native_widget_gtk.h" | 24 #include "views/widget/native_widget_gtk.h" |
21 #include "views/widget/widget.h" | 25 #include "views/widget/widget.h" |
22 | 26 |
23 #if defined(TOUCH_UI) | 27 #if defined(TOUCH_UI) |
24 #include "chrome/browser/ui/touch/keyboard/keyboard_manager.h" | 28 #include "chrome/browser/ui/touch/keyboard/keyboard_manager.h" |
25 #endif | 29 #endif |
26 | 30 |
27 namespace { | 31 namespace { |
28 | 32 |
29 const char kViewClassName[] = "browser/chromeos/login/WebUILoginView"; | 33 const char kViewClassName[] = "browser/chromeos/login/WebUILoginView"; |
30 | 34 |
31 // These strings must be kept in sync with handleAccelerator() in oobe.js. | 35 // These strings must be kept in sync with handleAccelerator() in oobe.js. |
32 const char kAccelNameAccessibility[] = "accessibility"; | 36 const char kAccelNameAccessibility[] = "accessibility"; |
33 const char kAccelNameEnrollment[] = "enrollment"; | 37 const char kAccelNameEnrollment[] = "enrollment"; |
34 | 38 |
| 39 // Observes IPC messages from the FrameSniffer and notifies JS if error |
| 40 // appears. |
| 41 class SnifferObserver : public RenderViewHostObserver { |
| 42 public: |
| 43 SnifferObserver(RenderViewHost* host, WebUI* webui) |
| 44 : RenderViewHostObserver(host), webui_(webui) { |
| 45 DCHECK(webui_); |
| 46 Send(new ViewMsg_StartFrameSniffer(routing_id(), |
| 47 UTF8ToUTF16("gaia-frame"))); |
| 48 } |
| 49 |
| 50 virtual ~SnifferObserver() {} |
| 51 |
| 52 // IPC::Channel::Listener implementation. |
| 53 virtual bool OnMessageReceived(const IPC::Message& message) { |
| 54 bool handled = true; |
| 55 IPC_BEGIN_MESSAGE_MAP(SnifferObserver, message) |
| 56 IPC_MESSAGE_HANDLER(ViewHostMsg_FrameLoadingError, OnError) |
| 57 IPC_MESSAGE_UNHANDLED(handled = false) |
| 58 IPC_END_MESSAGE_MAP() |
| 59 return handled; |
| 60 } |
| 61 |
| 62 private: |
| 63 void OnError(int error) { |
| 64 base::FundamentalValue error_value(error); |
| 65 webui_->CallJavascriptFunction("login.OfflineMessageScreen.onFrameError", |
| 66 error_value); |
| 67 } |
| 68 |
| 69 WebUI* webui_; |
| 70 }; |
| 71 |
35 } // namespace | 72 } // namespace |
36 | 73 |
37 namespace chromeos { | 74 namespace chromeos { |
38 | 75 |
39 // static | 76 // static |
40 const int WebUILoginView::kStatusAreaCornerPadding = 5; | 77 const int WebUILoginView::kStatusAreaCornerPadding = 5; |
41 | 78 |
42 // WebUILoginView public: ------------------------------------------------------ | 79 // WebUILoginView public: ------------------------------------------------------ |
43 | 80 |
44 WebUILoginView::WebUILoginView() | 81 WebUILoginView::WebUILoginView() |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 | 234 |
198 void WebUILoginView::OnDialogClosed() { | 235 void WebUILoginView::OnDialogClosed() { |
199 } | 236 } |
200 | 237 |
201 void WebUILoginView::OnLocaleChanged() { | 238 void WebUILoginView::OnLocaleChanged() { |
202 // Proxy settings dialog contains localized strings. | 239 // Proxy settings dialog contains localized strings. |
203 proxy_settings_dialog_.reset(); | 240 proxy_settings_dialog_.reset(); |
204 SchedulePaint(); | 241 SchedulePaint(); |
205 } | 242 } |
206 | 243 |
| 244 void WebUILoginView::OnRenderHostCreated(RenderViewHost* host) { |
| 245 new SnifferObserver(host, GetWebUI()); |
| 246 } |
| 247 |
207 void WebUILoginView::OnTabMainFrameLoaded() { | 248 void WebUILoginView::OnTabMainFrameLoaded() { |
208 } | 249 } |
209 | 250 |
210 void WebUILoginView::OnTabMainFrameFirstRender() { | 251 void WebUILoginView::OnTabMainFrameFirstRender() { |
211 InitStatusArea(); | 252 InitStatusArea(); |
212 | 253 |
213 if (host_window_frozen_) { | 254 if (host_window_frozen_) { |
214 host_window_frozen_ = false; | 255 host_window_frozen_ = false; |
215 | 256 |
216 // Unfreezes the host window since tab is rendereed now. | 257 // Unfreezes the host window since tab is rendereed now. |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 GetFocusManager()); | 316 GetFocusManager()); |
276 | 317 |
277 // Make sure error bubble is cleared on keyboard event. This is needed | 318 // Make sure error bubble is cleared on keyboard event. This is needed |
278 // when the focus is inside an iframe. | 319 // when the focus is inside an iframe. |
279 WebUI* web_ui = GetWebUI(); | 320 WebUI* web_ui = GetWebUI(); |
280 if (web_ui) | 321 if (web_ui) |
281 web_ui->CallJavascriptFunction("cr.ui.Oobe.clearErrors"); | 322 web_ui->CallJavascriptFunction("cr.ui.Oobe.clearErrors"); |
282 } | 323 } |
283 | 324 |
284 } // namespace chromeos | 325 } // namespace chromeos |
OLD | NEW |