Chromium Code Reviews| 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..c887aff29ea9367a1bc385ecef9346f178704664 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" |
| @@ -24,20 +25,24 @@ |
| #include "net/base/net_errors.h" |
| #include "net/base/ssl_info.h" |
| +int captive_portal::CaptivePortalTabHelper::kUserDataKey; |
|
mmenke
2012/09/19 16:11:30
You can remove the captive_portal:: prefix and mov
Avi (use Gerrit)
2012/09/19 16:41:27
OK.
|
| + |
| namespace captive_portal { |
| 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); |
|
mmenke
2012/09/19 16:11:30
nit: We're in the captive_portal namespace, so no
|
| + 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()); |
|
mmenke
2012/09/19 16:11:30
nit: We're in the captive_portal namespace, so no
|
| + captive_portal_tab_helper->SetIsLoginTab(); |
| } |
| } // namespace captive_portal |