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/captive_portal/captive_portal_tab_reloader.h" | 5 #include "chrome/browser/captive_portal/captive_portal_tab_reloader.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/location.h" |
| 10 #include "base/single_thread_task_runner.h" |
| 11 #include "base/thread_task_runner_handle.h" |
10 #include "chrome/browser/captive_portal/captive_portal_service.h" | 12 #include "chrome/browser/captive_portal/captive_portal_service.h" |
11 #include "chrome/browser/captive_portal/captive_portal_service_factory.h" | 13 #include "chrome/browser/captive_portal/captive_portal_service_factory.h" |
12 #include "content/public/browser/interstitial_page.h" | 14 #include "content/public/browser/interstitial_page.h" |
13 #include "content/public/browser/navigation_controller.h" | 15 #include "content/public/browser/navigation_controller.h" |
14 #include "content/public/browser/navigation_entry.h" | 16 #include "content/public/browser/navigation_entry.h" |
15 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
16 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
17 | 19 |
18 using captive_portal::CaptivePortalResult; | 20 using captive_portal::CaptivePortalResult; |
19 | 21 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 // The page returned an error out before the timer triggered. Go ahead and | 95 // The page returned an error out before the timer triggered. Go ahead and |
94 // try to detect a portal now, rather than waiting for the timer. | 96 // try to detect a portal now, rather than waiting for the timer. |
95 if (state_ == STATE_TIMER_RUNNING) { | 97 if (state_ == STATE_TIMER_RUNNING) { |
96 OnSlowSSLConnect(); | 98 OnSlowSSLConnect(); |
97 return; | 99 return; |
98 } | 100 } |
99 | 101 |
100 // If the tab needs to reload, do so asynchronously, to avoid reentrancy | 102 // If the tab needs to reload, do so asynchronously, to avoid reentrancy |
101 // issues. | 103 // issues. |
102 if (state_ == STATE_NEEDS_RELOAD) { | 104 if (state_ == STATE_NEEDS_RELOAD) { |
103 base::MessageLoop::current()->PostTask( | 105 base::ThreadTaskRunnerHandle::Get()->PostTask( |
104 FROM_HERE, | 106 FROM_HERE, base::Bind(&CaptivePortalTabReloader::ReloadTabIfNeeded, |
105 base::Bind(&CaptivePortalTabReloader::ReloadTabIfNeeded, | 107 weak_factory_.GetWeakPtr())); |
106 weak_factory_.GetWeakPtr())); | |
107 } | 108 } |
108 } | 109 } |
109 | 110 |
110 void CaptivePortalTabReloader::OnAbort() { | 111 void CaptivePortalTabReloader::OnAbort() { |
111 provisional_main_frame_load_ = false; | 112 provisional_main_frame_load_ = false; |
112 ssl_url_in_redirect_chain_ = false; | 113 ssl_url_in_redirect_chain_ = false; |
113 | 114 |
114 SetState(STATE_NONE); | 115 SetState(STATE_NONE); |
115 } | 116 } |
116 | 117 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 void CaptivePortalTabReloader::MaybeOpenCaptivePortalLoginTab() { | 273 void CaptivePortalTabReloader::MaybeOpenCaptivePortalLoginTab() { |
273 open_login_tab_callback_.Run(); | 274 open_login_tab_callback_.Run(); |
274 } | 275 } |
275 | 276 |
276 void CaptivePortalTabReloader::CheckForCaptivePortal() { | 277 void CaptivePortalTabReloader::CheckForCaptivePortal() { |
277 CaptivePortalService* service = | 278 CaptivePortalService* service = |
278 CaptivePortalServiceFactory::GetForProfile(profile_); | 279 CaptivePortalServiceFactory::GetForProfile(profile_); |
279 if (service) | 280 if (service) |
280 service->DetectCaptivePortal(); | 281 service->DetectCaptivePortal(); |
281 } | 282 } |
OLD | NEW |