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

Unified Diff: chrome/browser/ssl/captive_portal_blocking_page.cc

Issue 861953002: Add login url to captive portal interstitial. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mmenke comments Created 5 years, 11 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/ssl/captive_portal_blocking_page.cc
diff --git a/chrome/browser/ssl/captive_portal_blocking_page.cc b/chrome/browser/ssl/captive_portal_blocking_page.cc
index 97d6f88c93022db59de6f9e07451e2276bfbc15c..216e6baf6c549a8ff59f9b458809994108df62a1 100644
--- a/chrome/browser/ssl/captive_portal_blocking_page.cc
+++ b/chrome/browser/ssl/captive_portal_blocking_page.cc
@@ -4,16 +4,22 @@
#include "chrome/browser/ssl/captive_portal_blocking_page.h"
+#include "base/i18n/rtl.h"
#include "base/metrics/histogram.h"
+#include "base/prefs/pref_service.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
+#include "chrome/browser/captive_portal/captive_portal_tab_helper.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/pref_names.h"
+#include "components/captive_portal/captive_portal_detector.h"
#include "content/public/browser/web_contents.h"
#include "grit/generated_resources.h"
+#include "net/base/net_util.h"
#include "ui/base/l10n/l10n_util.h"
-#if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
-#include "chrome/browser/captive_portal/captive_portal_tab_helper.h"
+#if !defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
+#error This file must be built with ENABLE_CAPTIVE_PORTAL_DETECTION flag.
felt 2015/01/22 20:05:25 presumably this is already true in the build files
meacer 2015/01/22 20:22:19 Yes it's already true. Trying to compile without t
#endif
namespace {
@@ -42,12 +48,12 @@ const void* CaptivePortalBlockingPage::kTypeForTesting =
CaptivePortalBlockingPage::CaptivePortalBlockingPage(
content::WebContents* web_contents,
const GURL& request_url,
+ const GURL& login_url,
const base::Callback<void(bool)>& callback)
: SecurityInterstitialPage(web_contents, request_url),
+ login_url_(login_url),
callback_(callback) {
-#if !defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
- NOTREACHED();
-#endif
+ DCHECK(login_url_.is_valid());
RecordUMA(SHOW_ALL);
}
@@ -79,12 +85,33 @@ void CaptivePortalBlockingPage::PopulateInterstitialStrings(
l10n_util::GetStringUTF16(IDS_CAPTIVE_PORTAL_BUTTON_OPEN_LOGIN_PAGE));
load_time_data->SetString("tabTitle",
l10n_util::GetStringUTF16(IDS_CAPTIVE_PORTAL_TITLE));
- load_time_data->SetString(
- "primaryParagraph",
- l10n_util::GetStringUTF16(IDS_CAPTIVE_PORTAL_PRIMARY_PARAGRAPH));
load_time_data->SetString("heading",
l10n_util::GetStringUTF16(IDS_CAPTIVE_PORTAL_HEADING));
+ if (login_url_.spec() == captive_portal::CaptivePortalDetector::kDefaultURL) {
+ // Captive portal may intercept requests without HTTP redirects, in which
+ // case the login url would be the same as the captive portal detection url.
+ // Don't show the login url in that case.
+ load_time_data->SetString(
+ "primaryParagraph",
+ l10n_util::GetStringUTF16(
+ IDS_CAPTIVE_PORTAL_PRIMARY_PARAGRAPH_NO_LOGIN_URL));
felt 2015/01/22 20:05:25 In the future, could we handle this case by provid
mmenke 2015/01/22 20:10:48 We already have one (Namely captive_portal::Captiv
felt 2015/01/22 20:13:24 Could we link to it even if we don't display the h
mmenke 2015/01/22 20:16:25 There's a login button elsewhere on the page. Not
meacer 2015/01/22 20:22:19 Well the button works in practive too :) We can li
mmenke 2015/01/22 20:26:57 What I was thinking of is that if the user navigat
meacer 2015/01/22 20:54:15 Just checked it, we still keep the tab as login ta
meacer 2015/01/22 20:55:12 (or navigating to an http page for that matter)
mmenke 2015/01/22 21:00:50 Thanks for investigating! Yea, if the user naviga
meacer 2015/01/22 21:26:57 Sure, I'm happy to look at this. I realized I test
+ } else {
+ std::string languages;
+ Profile* profile = Profile::FromBrowserContext(
+ web_contents()->GetBrowserContext());
+ if (profile)
+ languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages);
+
+ base::string16 login_host = net::IDNToUnicode(login_url_.host(), languages);
felt 2015/01/22 20:05:25 is it ok that |languages| might never be assigned
meacer 2015/01/22 20:22:19 If |languages| is empty, net::IDNToUnicode will de
felt 2015/01/22 22:51:34 k
+ if (base::i18n::IsRTL())
+ base::i18n::WrapStringWithLTRFormatting(&login_host);
+ load_time_data->SetString(
+ "primaryParagraph",
+ l10n_util::GetStringFUTF16(IDS_CAPTIVE_PORTAL_PRIMARY_PARAGRAPH,
felt 2015/01/22 20:13:24 It looks like this just sets the login page as tex
meacer 2015/01/22 20:22:19 As I mentioned above, the mocks didn't have the li
meacer 2015/01/22 20:23:13 And yes, the login button does that already.
felt 2015/01/22 22:51:34 ok then nevermind me i was confused, i thought the
+ login_host));
+ }
+
// Fill the empty strings to avoid getting debug warnings.
load_time_data->SetString("openDetails", base::string16());
load_time_data->SetString("closeDetails", base::string16());
@@ -96,8 +123,6 @@ void CaptivePortalBlockingPage::CommandReceived(const std::string& command) {
// The response has quotes around it.
if (command == std::string("\"") + kOpenLoginPageCommand + "\"") {
RecordUMA(OPEN_LOGIN_PAGE);
-#if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
CaptivePortalTabHelper::OpenLoginTabForWebContents(web_contents(), true);
-#endif
}
}
« no previous file with comments | « chrome/browser/ssl/captive_portal_blocking_page.h ('k') | chrome/browser/ssl/captive_portal_blocking_page_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698