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_helper.h" | 5 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "chrome/browser/captive_portal/captive_portal_login_detector.h" | 8 #include "chrome/browser/captive_portal/captive_portal_login_detector.h" |
9 #include "chrome/browser/captive_portal/captive_portal_tab_reloader.h" | 9 #include "chrome/browser/captive_portal/captive_portal_tab_reloader.h" |
10 #include "chrome/browser/captive_portal/captive_portal_service.h" | 10 #include "chrome/browser/captive_portal/captive_portal_service.h" |
11 #include "chrome/browser/captive_portal/captive_portal_service_factory.h" | 11 #include "chrome/browser/captive_portal/captive_portal_service_factory.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/browser_finder.h" | 13 #include "chrome/browser/ui/browser_finder.h" |
| 14 #include "chrome/browser/ui/browser_tabstrip.h" |
14 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 15 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
15 #include "chrome/common/chrome_notification_types.h" | 16 #include "chrome/common/chrome_notification_types.h" |
16 #include "content/public/browser/notification_details.h" | 17 #include "content/public/browser/notification_details.h" |
17 #include "content/public/browser/notification_source.h" | 18 #include "content/public/browser/notification_source.h" |
18 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
19 | 20 |
20 namespace captive_portal { | 21 namespace captive_portal { |
21 | 22 |
22 CaptivePortalTabHelper::CaptivePortalTabHelper( | 23 CaptivePortalTabHelper::CaptivePortalTabHelper( |
23 Profile* profile, | 24 Profile* profile, |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 Browser* browser = browser::FindTabbedBrowser(profile_, true); | 154 Browser* browser = browser::FindTabbedBrowser(profile_, true); |
154 // If the Profile doesn't have a tabbed browser window open, do nothing. | 155 // If the Profile doesn't have a tabbed browser window open, do nothing. |
155 if (!browser) | 156 if (!browser) |
156 return; | 157 return; |
157 | 158 |
158 // Check if the Profile's topmost browser window already has a login tab. | 159 // Check if the Profile's topmost browser window already has a login tab. |
159 // If so, do nothing. | 160 // If so, do nothing. |
160 // TODO(mmenke): Consider focusing that tab, at least if this is the tab | 161 // TODO(mmenke): Consider focusing that tab, at least if this is the tab |
161 // helper for the currently active tab for the profile. | 162 // helper for the currently active tab for the profile. |
162 for (int i = 0; i < browser->tab_count(); ++i) { | 163 for (int i = 0; i < browser->tab_count(); ++i) { |
163 TabContents* tab_contents = browser->GetTabContentsAt(i); | 164 TabContents* tab_contents = chrome::GetTabContentsAt(browser, i); |
164 if (tab_contents->captive_portal_tab_helper()->IsLoginTab()) | 165 if (tab_contents->captive_portal_tab_helper()->IsLoginTab()) |
165 return; | 166 return; |
166 } | 167 } |
167 | 168 |
168 // Otherwise, open a login tab. Only end up here when a captive portal result | 169 // Otherwise, open a login tab. Only end up here when a captive portal result |
169 // was received, so it's safe to assume |profile_| has a CaptivePortalService. | 170 // was received, so it's safe to assume |profile_| has a CaptivePortalService. |
170 TabContents* tab_contents = | 171 TabContents* tab_contents = chrome::AddSelectedTabWithURL( |
171 browser->AddSelectedTabWithURL( | 172 browser, |
172 CaptivePortalServiceFactory::GetForProfile(profile_)->test_url(), | 173 CaptivePortalServiceFactory::GetForProfile(profile_)->test_url(), |
173 content::PAGE_TRANSITION_TYPED); | 174 content::PAGE_TRANSITION_TYPED); |
174 tab_contents->captive_portal_tab_helper()->SetIsLoginTab(); | 175 tab_contents->captive_portal_tab_helper()->SetIsLoginTab(); |
175 } | 176 } |
176 | 177 |
177 } // namespace captive_portal | 178 } // namespace captive_portal |
OLD | NEW |