| 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 "chrome/browser/chromeos/accessibility_util.h" | 7 #include "chrome/browser/chromeos/accessibility_util.h" |
| 8 #include "chrome/browser/chromeos/login/proxy_settings_dialog.h" | 8 #include "chrome/browser/chromeos/login/proxy_settings_dialog.h" |
| 9 #include "chrome/browser/chromeos/login/webui_login_display.h" | 9 #include "chrome/browser/chromeos/login/webui_login_display.h" |
| 10 #include "chrome/browser/chromeos/status/clock_menu_button.h" | 10 #include "chrome/browser/chromeos/status/clock_menu_button.h" |
| 11 #include "chrome/browser/chromeos/status/input_method_menu_button.h" | 11 #include "chrome/browser/chromeos/status/input_method_menu_button.h" |
| 12 #include "chrome/browser/chromeos/status/network_menu_button.h" | 12 #include "chrome/browser/chromeos/status/network_menu_button.h" |
| 13 #include "chrome/browser/chromeos/status/status_area_view.h" | 13 #include "chrome/browser/chromeos/status/status_area_view.h" |
| 14 #include "chrome/browser/chromeos/wm_ipc.h" | 14 #include "chrome/browser/chromeos/wm_ipc.h" |
| 15 #include "chrome/browser/profiles/profile_manager.h" | 15 #include "chrome/browser/profiles/profile_manager.h" |
| 16 #include "chrome/browser/ui/views/dom_view.h" | 16 #include "chrome/browser/ui/views/dom_view.h" |
| 17 #include "content/browser/tab_contents/tab_contents.h" | 17 #include "content/browser/tab_contents/tab_contents.h" |
| 18 #include "ui/gfx/rect.h" | 18 #include "ui/gfx/rect.h" |
| 19 #include "ui/gfx/size.h" | 19 #include "ui/gfx/size.h" |
| 20 #include "views/widget/native_widget_gtk.h" |
| 20 #include "views/widget/widget.h" | 21 #include "views/widget/widget.h" |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| 24 const char kViewClassName[] = "browser/chromeos/login/WebUILoginView"; | 25 const char kViewClassName[] = "browser/chromeos/login/WebUILoginView"; |
| 25 | 26 |
| 26 // These strings must be kept in sync with handleAccelerator() in oobe.js. | 27 // These strings must be kept in sync with handleAccelerator() in oobe.js. |
| 27 const char kAccelNameAccessibility[] = "accessibility"; | 28 const char kAccelNameAccessibility[] = "accessibility"; |
| 28 const char kAccelNameEnrollment[] = "enrollment"; | 29 const char kAccelNameEnrollment[] = "enrollment"; |
| 29 | 30 |
| 30 } // namespace | 31 } // namespace |
| 31 | 32 |
| 32 namespace chromeos { | 33 namespace chromeos { |
| 33 | 34 |
| 34 // static | 35 // static |
| 35 const int WebUILoginView::kStatusAreaCornerPadding = 5; | 36 const int WebUILoginView::kStatusAreaCornerPadding = 5; |
| 36 | 37 |
| 37 // WebUILoginView public: ------------------------------------------------------ | 38 // WebUILoginView public: ------------------------------------------------------ |
| 38 | 39 |
| 39 WebUILoginView::WebUILoginView() | 40 WebUILoginView::WebUILoginView() |
| 40 : status_area_(NULL), | 41 : status_area_(NULL), |
| 41 profile_(NULL), | 42 profile_(NULL), |
| 42 webui_login_(NULL), | 43 webui_login_(NULL), |
| 43 status_window_(NULL) { | 44 status_window_(NULL), |
| 45 host_window_frozen_(false) { |
| 44 accel_map_[views::Accelerator(ui::VKEY_Z, false, true, true)] = | 46 accel_map_[views::Accelerator(ui::VKEY_Z, false, true, true)] = |
| 45 kAccelNameAccessibility; | 47 kAccelNameAccessibility; |
| 46 accel_map_[views::Accelerator(ui::VKEY_E, false, true, true)] = | 48 accel_map_[views::Accelerator(ui::VKEY_E, false, true, true)] = |
| 47 kAccelNameEnrollment; | 49 kAccelNameEnrollment; |
| 48 | 50 |
| 49 for (AccelMap::iterator i(accel_map_.begin()); i != accel_map_.end(); ++i) | 51 for (AccelMap::iterator i(accel_map_.begin()); i != accel_map_.end(); ++i) |
| 50 AddAccelerator(i->first); | 52 AddAccelerator(i->first); |
| 51 } | 53 } |
| 52 | 54 |
| 53 WebUILoginView::~WebUILoginView() { | 55 WebUILoginView::~WebUILoginView() { |
| 54 if (status_window_) | 56 if (status_window_) |
| 55 status_window_->Close(); | 57 status_window_->Close(); |
| 56 status_window_ = NULL; | 58 status_window_ = NULL; |
| 57 } | 59 } |
| 58 | 60 |
| 59 void WebUILoginView::Init() { | 61 void WebUILoginView::Init() { |
| 60 profile_ = ProfileManager::GetDefaultProfile(); | 62 profile_ = ProfileManager::GetDefaultProfile(); |
| 61 | 63 |
| 62 webui_login_ = new DOMView(); | 64 webui_login_ = new DOMView(); |
| 63 AddChildView(webui_login_); | 65 AddChildView(webui_login_); |
| 64 webui_login_->Init(profile_, NULL); | 66 webui_login_->Init(profile_, NULL); |
| 65 webui_login_->SetVisible(true); | 67 webui_login_->SetVisible(true); |
| 66 webui_login_->tab_contents()->set_delegate(this); | 68 webui_login_->tab_contents()->set_delegate(this); |
| 69 |
| 70 tab_watcher_.reset(new TabFirstRenderWatcher(webui_login_->tab_contents(), |
| 71 this)); |
| 67 } | 72 } |
| 68 | 73 |
| 69 std::string WebUILoginView::GetClassName() const { | 74 std::string WebUILoginView::GetClassName() const { |
| 70 return kViewClassName; | 75 return kViewClassName; |
| 71 } | 76 } |
| 72 | 77 |
| 73 bool WebUILoginView::AcceleratorPressed( | 78 bool WebUILoginView::AcceleratorPressed( |
| 74 const views::Accelerator& accelerator) { | 79 const views::Accelerator& accelerator) { |
| 75 AccelMap::const_iterator entry = accel_map_.find(accelerator); | 80 AccelMap::const_iterator entry = accel_map_.find(accelerator); |
| 76 if (entry == accel_map_.end()) | 81 if (entry == accel_map_.end()) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 87 } | 92 } |
| 88 | 93 |
| 89 return true; | 94 return true; |
| 90 } | 95 } |
| 91 | 96 |
| 92 gfx::NativeWindow WebUILoginView::GetNativeWindow() const { | 97 gfx::NativeWindow WebUILoginView::GetNativeWindow() const { |
| 93 return GetWidget()->GetNativeWindow(); | 98 return GetWidget()->GetNativeWindow(); |
| 94 } | 99 } |
| 95 | 100 |
| 96 void WebUILoginView::OnWindowCreated() { | 101 void WebUILoginView::OnWindowCreated() { |
| 97 InitStatusArea(); | 102 // Freezes host window update until the tab is rendered. |
| 103 host_window_frozen_ = static_cast<views::NativeWidgetGtk*>( |
| 104 GetWidget()->native_widget())->SuppressFreezeUpdates(); |
| 98 } | 105 } |
| 99 | 106 |
| 100 void WebUILoginView::UpdateWindowType() { | 107 void WebUILoginView::UpdateWindowType() { |
| 101 std::vector<int> params; | 108 std::vector<int> params; |
| 102 WmIpc::instance()->SetWindowType( | 109 WmIpc::instance()->SetWindowType( |
| 103 GTK_WIDGET(GetNativeWindow()), | 110 GTK_WIDGET(GetNativeWindow()), |
| 104 WM_IPC_WINDOW_LOGIN_WEBUI, | 111 WM_IPC_WINDOW_LOGIN_WEBUI, |
| 105 ¶ms); | 112 ¶ms); |
| 106 } | 113 } |
| 107 | 114 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 | 186 |
| 180 void WebUILoginView::OnDialogClosed() { | 187 void WebUILoginView::OnDialogClosed() { |
| 181 } | 188 } |
| 182 | 189 |
| 183 void WebUILoginView::OnLocaleChanged() { | 190 void WebUILoginView::OnLocaleChanged() { |
| 184 // Proxy settings dialog contains localized strings. | 191 // Proxy settings dialog contains localized strings. |
| 185 proxy_settings_dialog_.reset(); | 192 proxy_settings_dialog_.reset(); |
| 186 SchedulePaint(); | 193 SchedulePaint(); |
| 187 } | 194 } |
| 188 | 195 |
| 196 void WebUILoginView::OnTabMainFrameLoaded() { |
| 197 } |
| 198 |
| 199 void WebUILoginView::OnTabMainFrameFirstRender() { |
| 200 InitStatusArea(); |
| 201 |
| 202 if (host_window_frozen_) { |
| 203 host_window_frozen_ = false; |
| 204 |
| 205 // Unfreezes the host window since tab is rendereed now. |
| 206 views::NativeWidgetGtk::UpdateFreezeUpdatesProperty( |
| 207 GetNativeWindow(), false); |
| 208 } |
| 209 } |
| 210 |
| 189 void WebUILoginView::InitStatusArea() { | 211 void WebUILoginView::InitStatusArea() { |
| 190 DCHECK(status_area_ == NULL); | 212 DCHECK(status_area_ == NULL); |
| 191 DCHECK(status_window_ == NULL); | 213 DCHECK(status_window_ == NULL); |
| 192 status_area_ = new StatusAreaView(this); | 214 status_area_ = new StatusAreaView(this); |
| 193 status_area_->Init(); | 215 status_area_->Init(); |
| 194 | 216 |
| 195 views::Widget* login_window = WebUILoginDisplay::GetLoginWindow(); | 217 views::Widget* login_window = WebUILoginDisplay::GetLoginWindow(); |
| 196 gfx::Size size = status_area_->GetPreferredSize(); | 218 gfx::Size size = status_area_->GetPreferredSize(); |
| 197 gfx::Rect bounds(width() - size.width() - kStatusAreaCornerPadding, | 219 gfx::Rect bounds(width() - size.width() - kStatusAreaCornerPadding, |
| 198 kStatusAreaCornerPadding, | 220 kStatusAreaCornerPadding, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 webui_login_->tab_contents()->FocusThroughTabTraversal(reverse); | 253 webui_login_->tab_contents()->FocusThroughTabTraversal(reverse); |
| 232 return true; | 254 return true; |
| 233 } | 255 } |
| 234 | 256 |
| 235 void WebUILoginView::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { | 257 void WebUILoginView::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { |
| 236 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event, | 258 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event, |
| 237 GetFocusManager()); | 259 GetFocusManager()); |
| 238 } | 260 } |
| 239 | 261 |
| 240 } // namespace chromeos | 262 } // namespace chromeos |
| OLD | NEW |