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