OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ui/webui_login_view.h" | 5 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/system/tray/system_tray.h" | 8 #include "ash/system/tray/system_tray.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 | 156 |
157 for (AccelMap::iterator i(accel_map_.begin()); i != accel_map_.end(); ++i) | 157 for (AccelMap::iterator i(accel_map_.begin()); i != accel_map_.end(); ++i) |
158 AddAccelerator(i->first); | 158 AddAccelerator(i->first); |
159 } | 159 } |
160 | 160 |
161 WebUILoginView::~WebUILoginView() { | 161 WebUILoginView::~WebUILoginView() { |
162 FOR_EACH_OBSERVER(web_modal::ModalDialogHostObserver, | 162 FOR_EACH_OBSERVER(web_modal::ModalDialogHostObserver, |
163 observer_list_, | 163 observer_list_, |
164 OnHostDestroying()); | 164 OnHostDestroying()); |
165 | 165 |
166 if (ash::Shell::GetInstance()->HasPrimaryStatusArea()) { | 166 if (ash::Shell::HasInstance() && |
| 167 ash::Shell::GetInstance()->HasPrimaryStatusArea()) { |
167 ash::Shell::GetInstance()->GetPrimarySystemTray()-> | 168 ash::Shell::GetInstance()->GetPrimarySystemTray()-> |
168 SetNextFocusableView(NULL); | 169 SetNextFocusableView(NULL); |
169 } | 170 } |
170 } | 171 } |
171 | 172 |
172 void WebUILoginView::Init() { | 173 void WebUILoginView::Init() { |
173 Profile* signin_profile = ProfileHelper::GetSigninProfile(); | 174 Profile* signin_profile = ProfileHelper::GetSigninProfile(); |
174 auth_extension_.reset(new ScopedGaiaAuthExtension(signin_profile)); | 175 auth_extension_.reset(new ScopedGaiaAuthExtension(signin_profile)); |
175 webui_login_ = new views::WebView(signin_profile); | 176 webui_login_ = new views::WebView(signin_profile); |
176 webui_login_->set_allow_accelerators(true); | 177 webui_login_->set_allow_accelerators(true); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 *network, NULL, GetNativeWindow()); | 297 *network, NULL, GetNativeWindow()); |
297 dialog->Show(); | 298 dialog->Show(); |
298 } | 299 } |
299 | 300 |
300 void WebUILoginView::OnPostponedShow() { | 301 void WebUILoginView::OnPostponedShow() { |
301 set_is_hidden(false); | 302 set_is_hidden(false); |
302 OnLoginPromptVisible(); | 303 OnLoginPromptVisible(); |
303 } | 304 } |
304 | 305 |
305 void WebUILoginView::SetStatusAreaVisible(bool visible) { | 306 void WebUILoginView::SetStatusAreaVisible(bool visible) { |
306 if (ash::Shell::GetInstance()->HasPrimaryStatusArea()) { | 307 if (ash::Shell::HasInstance() && |
| 308 ash::Shell::GetInstance()->HasPrimaryStatusArea()) { |
307 ash::SystemTray* tray = ash::Shell::GetInstance()->GetPrimarySystemTray(); | 309 ash::SystemTray* tray = ash::Shell::GetInstance()->GetPrimarySystemTray(); |
308 if (visible) { | 310 if (visible) { |
309 // Tray may have been initialized being hidden. | 311 // Tray may have been initialized being hidden. |
310 tray->SetVisible(visible); | 312 tray->SetVisible(visible); |
311 tray->GetWidget()->Show(); | 313 tray->GetWidget()->Show(); |
312 } else { | 314 } else { |
313 tray->GetWidget()->Hide(); | 315 tray->GetWidget()->Hide(); |
314 } | 316 } |
315 } | 317 } |
316 } | 318 } |
317 | 319 |
318 void WebUILoginView::SetUIEnabled(bool enabled) { | 320 void WebUILoginView::SetUIEnabled(bool enabled) { |
319 forward_keyboard_event_ = enabled; | 321 forward_keyboard_event_ = enabled; |
320 ash::Shell::GetInstance()->GetPrimarySystemTray()->SetEnabled(enabled); | 322 if (ash::Shell::HasInstance()) |
| 323 ash::Shell::GetInstance()->GetPrimarySystemTray()->SetEnabled(enabled); |
321 } | 324 } |
322 | 325 |
323 void WebUILoginView::AddFrameObserver(FrameObserver* frame_observer) { | 326 void WebUILoginView::AddFrameObserver(FrameObserver* frame_observer) { |
324 DCHECK(frame_observer); | 327 DCHECK(frame_observer); |
325 DCHECK(!frame_observer_list_.HasObserver(frame_observer)); | 328 DCHECK(!frame_observer_list_.HasObserver(frame_observer)); |
326 frame_observer_list_.AddObserver(frame_observer); | 329 frame_observer_list_.AddObserver(frame_observer); |
327 } | 330 } |
328 | 331 |
329 void WebUILoginView::RemoveFrameObserver(FrameObserver* frame_observer) { | 332 void WebUILoginView::RemoveFrameObserver(FrameObserver* frame_observer) { |
330 DCHECK(frame_observer); | 333 DCHECK(frame_observer); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 bool WebUILoginView::IsPopupOrPanel(const WebContents* source) const { | 412 bool WebUILoginView::IsPopupOrPanel(const WebContents* source) const { |
410 return true; | 413 return true; |
411 } | 414 } |
412 | 415 |
413 bool WebUILoginView::TakeFocus(content::WebContents* source, bool reverse) { | 416 bool WebUILoginView::TakeFocus(content::WebContents* source, bool reverse) { |
414 // In case of blocked UI (ex.: sign in is in progress) | 417 // In case of blocked UI (ex.: sign in is in progress) |
415 // we should not process focus change events. | 418 // we should not process focus change events. |
416 if (!forward_keyboard_event_) | 419 if (!forward_keyboard_event_) |
417 return false; | 420 return false; |
418 | 421 |
419 ash::SystemTray* tray = ash::Shell::GetInstance()->GetPrimarySystemTray(); | 422 if (ash::Shell::HasInstance()) { |
420 if (tray && tray->GetWidget()->IsVisible()) { | 423 ash::SystemTray* tray = ash::Shell::GetInstance()->GetPrimarySystemTray(); |
421 tray->SetNextFocusableView(this); | 424 if (tray && tray->GetWidget()->IsVisible()) { |
422 ash::Shell::GetInstance()->RotateFocus(reverse ? ash::Shell::BACKWARD : | 425 tray->SetNextFocusableView(this); |
423 ash::Shell::FORWARD); | 426 ash::Shell::GetInstance()->RotateFocus(reverse ? ash::Shell::BACKWARD : |
| 427 ash::Shell::FORWARD); |
| 428 } |
424 } | 429 } |
425 | 430 |
426 return true; | 431 return true; |
427 } | 432 } |
428 | 433 |
429 void WebUILoginView::RequestMediaAccessPermission( | 434 void WebUILoginView::RequestMediaAccessPermission( |
430 WebContents* web_contents, | 435 WebContents* web_contents, |
431 const content::MediaStreamRequest& request, | 436 const content::MediaStreamRequest& request, |
432 const content::MediaResponseCallback& callback) { | 437 const content::MediaResponseCallback& callback) { |
433 if (MediaStreamInfoBarDelegate::Create(web_contents, request, callback)) | 438 if (MediaStreamInfoBarDelegate::Create(web_contents, request, callback)) |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 webui_visible_ = true; | 480 webui_visible_ = true; |
476 } | 481 } |
477 | 482 |
478 void WebUILoginView::ReturnFocus(bool reverse) { | 483 void WebUILoginView::ReturnFocus(bool reverse) { |
479 // Return the focus to the web contents. | 484 // Return the focus to the web contents. |
480 webui_login_->web_contents()->FocusThroughTabTraversal(reverse); | 485 webui_login_->web_contents()->FocusThroughTabTraversal(reverse); |
481 GetWidget()->Activate(); | 486 GetWidget()->Activate(); |
482 } | 487 } |
483 | 488 |
484 } // namespace chromeos | 489 } // namespace chromeos |
OLD | NEW |