| 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/login/error_screen_handler.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/error_screen_handler.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 DCHECK(network_state_informer_.get()); | 46 DCHECK(network_state_informer_.get()); |
| 47 } | 47 } |
| 48 | 48 |
| 49 ErrorScreenHandler::~ErrorScreenHandler() {} | 49 ErrorScreenHandler::~ErrorScreenHandler() {} |
| 50 | 50 |
| 51 void ErrorScreenHandler::SetDelegate(ErrorScreenActorDelegate* delegate) { | 51 void ErrorScreenHandler::SetDelegate(ErrorScreenActorDelegate* delegate) { |
| 52 delegate_ = delegate; | 52 delegate_ = delegate; |
| 53 } | 53 } |
| 54 | 54 |
| 55 void ErrorScreenHandler::Show(OobeDisplay::Screen parent_screen, | 55 void ErrorScreenHandler::Show(OobeDisplay::Screen parent_screen, |
| 56 base::DictionaryValue* params) { | 56 base::DictionaryValue* params, |
| 57 const base::Closure& hide_closure) { |
| 57 if (!page_is_ready()) { | 58 if (!page_is_ready()) { |
| 58 show_on_init_ = true; | 59 show_on_init_ = true; |
| 59 return; | 60 return; |
| 60 } | 61 } |
| 61 parent_screen_ = parent_screen; | 62 parent_screen_ = parent_screen; |
| 63 hide_closure_.reset(new base::Closure(hide_closure)); |
| 62 ShowScreen(OobeUI::kScreenErrorMessage, params); | 64 ShowScreen(OobeUI::kScreenErrorMessage, params); |
| 63 NetworkErrorShown(); | 65 NetworkErrorShown(); |
| 64 NetworkPortalDetector::Get()->SetStrategy( | 66 NetworkPortalDetector::Get()->SetStrategy( |
| 65 PortalDetectorStrategy::STRATEGY_ID_ERROR_SCREEN); | 67 PortalDetectorStrategy::STRATEGY_ID_ERROR_SCREEN); |
| 66 if (delegate_) | 68 if (delegate_) |
| 67 delegate_->OnErrorShow(); | 69 delegate_->OnErrorShow(); |
| 68 LOG(WARNING) << "Offline message is displayed"; | 70 LOG(WARNING) << "Offline message is displayed"; |
| 69 } | 71 } |
| 70 | 72 |
| 73 void ErrorScreenHandler::CheckAndShowScreen() { |
| 74 std::string screen_name; |
| 75 if (GetScreenName(parent_screen(), &screen_name)) |
| 76 ShowScreen(screen_name.c_str(), NULL); |
| 77 } |
| 78 |
| 79 void ErrorScreenHandler::Show(OobeDisplay::Screen parent_screen, |
| 80 base::DictionaryValue* params) { |
| 81 Show(parent_screen, |
| 82 params, |
| 83 base::Bind(&ErrorScreenHandler::CheckAndShowScreen, |
| 84 base::Unretained(this))); |
| 85 } |
| 86 |
| 71 void ErrorScreenHandler::Hide() { | 87 void ErrorScreenHandler::Hide() { |
| 72 if (parent_screen_ == OobeUI::SCREEN_UNKNOWN) | 88 if (parent_screen_ == OobeUI::SCREEN_UNKNOWN) |
| 73 return; | 89 return; |
| 74 std::string screen_name; | 90 if (hide_closure_.get()) |
| 75 if (GetScreenName(parent_screen_, &screen_name)) | 91 hide_closure_->Run(); |
| 76 ShowScreen(screen_name.c_str(), NULL); | |
| 77 NetworkPortalDetector::Get()->SetStrategy( | 92 NetworkPortalDetector::Get()->SetStrategy( |
| 78 PortalDetectorStrategy::STRATEGY_ID_LOGIN_SCREEN); | 93 PortalDetectorStrategy::STRATEGY_ID_LOGIN_SCREEN); |
| 79 if (delegate_) | 94 if (delegate_) |
| 80 delegate_->OnErrorHide(); | 95 delegate_->OnErrorHide(); |
| 81 LOG(WARNING) << "Offline message is hidden"; | 96 LOG(WARNING) << "Offline message is hidden"; |
| 82 } | 97 } |
| 83 | 98 |
| 84 void ErrorScreenHandler::FixCaptivePortal() { | 99 void ErrorScreenHandler::FixCaptivePortal() { |
| 85 if (!captive_portal_window_proxy_.get()) { | 100 if (!captive_portal_window_proxy_.get()) { |
| 86 content::WebContents* web_contents = | 101 content::WebContents* web_contents = |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 params.SetString("network", network_); | 286 params.SetString("network", network_); |
| 272 params.SetBoolean("guestSigninAllowed", guest_signin_allowed_); | 287 params.SetBoolean("guestSigninAllowed", guest_signin_allowed_); |
| 273 params.SetBoolean("offlineLoginAllowed", offline_login_allowed_); | 288 params.SetBoolean("offlineLoginAllowed", offline_login_allowed_); |
| 274 params.SetBoolean("showConnectingIndicator", show_connecting_indicator_); | 289 params.SetBoolean("showConnectingIndicator", show_connecting_indicator_); |
| 275 Show(parent_screen_, ¶ms); | 290 Show(parent_screen_, ¶ms); |
| 276 show_on_init_ = false; | 291 show_on_init_ = false; |
| 277 } | 292 } |
| 278 } | 293 } |
| 279 | 294 |
| 280 } // namespace chromeos | 295 } // namespace chromeos |
| OLD | NEW |