Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2285)

Unified Diff: chrome/browser/captive_portal/captive_portal_tab_helper.cc

Issue 10946011: Switch CaptivePortalTabHelper to use WebContentsUserData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698