| Index: chrome/browser/captive_portal/captive_portal_tab_helper.cc
|
| diff --git a/chrome/browser/captive_portal/captive_portal_tab_helper.cc b/chrome/browser/captive_portal/captive_portal_tab_helper.cc
|
| index 7f6ff240157e9b03fd5c88dfdab3cb4ae133de46..4108f12b2ee01fc8293021a1d421bfbcb19285bc 100644
|
| --- a/chrome/browser/captive_portal/captive_portal_tab_helper.cc
|
| +++ b/chrome/browser/captive_portal/captive_portal_tab_helper.cc
|
| @@ -8,6 +8,7 @@
|
| #include "chrome/browser/captive_portal/captive_portal_login_detector.h"
|
| #include "chrome/browser/captive_portal/captive_portal_tab_reloader.h"
|
| #include "chrome/browser/captive_portal/captive_portal_service_factory.h"
|
| +#include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/ui/browser.h"
|
| #include "chrome/browser/ui/browser_finder.h"
|
| #include "chrome/browser/ui/browser_tabstrip.h"
|
| @@ -26,18 +27,22 @@
|
|
|
| namespace captive_portal {
|
|
|
| +int CaptivePortalTabHelper::kUserDataKey;
|
| +
|
| CaptivePortalTabHelper::CaptivePortalTabHelper(
|
| - Profile* profile,
|
| content::WebContents* web_contents)
|
| : content::WebContentsObserver(web_contents),
|
| + // web_contents is NULL in unit tests.
|
| + profile_(web_contents ? Profile::FromBrowserContext(
|
| + web_contents->GetBrowserContext())
|
| + : NULL),
|
| tab_reloader_(
|
| new CaptivePortalTabReloader(
|
| - profile,
|
| + profile_,
|
| web_contents,
|
| base::Bind(&CaptivePortalTabHelper::OpenLoginTab,
|
| base::Unretained(this)))),
|
| - login_detector_(new CaptivePortalLoginDetector(profile)),
|
| - profile_(profile),
|
| + login_detector_(new CaptivePortalLoginDetector(profile_)),
|
| pending_error_code_(net::OK),
|
| provisional_render_view_host_(NULL) {
|
| registrar_.Add(this,
|
| @@ -243,8 +248,10 @@ void CaptivePortalTabHelper::OpenLoginTab() {
|
| // TODO(mmenke): Consider focusing that tab, at least if this is the tab
|
| // helper for the currently active tab for the profile.
|
| for (int i = 0; i < browser->tab_count(); ++i) {
|
| - TabContents* tab_contents = chrome::GetTabContentsAt(browser, i);
|
| - if (tab_contents->captive_portal_tab_helper()->IsLoginTab())
|
| + content::WebContents* web_contents = chrome::GetWebContentsAt(browser, i);
|
| + captive_portal::CaptivePortalTabHelper* captive_portal_tab_helper =
|
| + captive_portal::CaptivePortalTabHelper::FromWebContents(web_contents);
|
| + if (captive_portal_tab_helper->IsLoginTab())
|
| return;
|
| }
|
|
|
| @@ -254,7 +261,10 @@ void CaptivePortalTabHelper::OpenLoginTab() {
|
| browser,
|
| CaptivePortalServiceFactory::GetForProfile(profile_)->test_url(),
|
| content::PAGE_TRANSITION_TYPED);
|
| - tab_contents->captive_portal_tab_helper()->SetIsLoginTab();
|
| + captive_portal::CaptivePortalTabHelper* captive_portal_tab_helper =
|
| + captive_portal::CaptivePortalTabHelper::FromWebContents(
|
| + tab_contents->web_contents());
|
| + captive_portal_tab_helper->SetIsLoginTab();
|
| }
|
|
|
| } // namespace captive_portal
|
|
|