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

Unified Diff: chrome/browser/ui/webui/interstitials/interstitial_ui.cc

Issue 1189413003: Added CaptivePortal Interstitial to chrome://interstitials (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Some style changes Created 5 years, 6 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/ui/webui/interstitials/interstitial_ui.cc
diff --git a/chrome/browser/ui/webui/interstitials/interstitial_ui.cc b/chrome/browser/ui/webui/interstitials/interstitial_ui.cc
index f71f025747404ed21965cd4bf4d3ea24f05d87ff..d41c2cec13f005f573c53412f86f4e80ed63f881 100644
--- a/chrome/browser/ui/webui/interstitials/interstitial_ui.cc
+++ b/chrome/browser/ui/webui/interstitials/interstitial_ui.cc
@@ -7,9 +7,11 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/captive_portal/captive_portal_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h"
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
+#include "chrome/browser/ssl/captive_portal_blocking_page.h"
#include "chrome/browser/ssl/ssl_blocking_page.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/browser_resources.h"
@@ -46,6 +48,22 @@ class InterstitialHTMLSource : public content::URLDataSource {
DISALLOW_COPY_AND_ASSIGN(InterstitialHTMLSource);
};
+class FakeConnectionInfoDelegate : public CaptivePortalBlockingPage::Delegate {
+ public:
+ FakeConnectionInfoDelegate(bool is_wifi_connection, std::string wifi_ssid)
+ : is_wifi_connection_(is_wifi_connection), wifi_ssid_(wifi_ssid) {}
+ ~FakeConnectionInfoDelegate() override {}
+
+ bool IsWifiConnection() const override { return is_wifi_connection_; }
+ std::string GetWiFiSSID() const override { return wifi_ssid_; }
+
+ private:
+ bool is_wifi_connection_;
+ const std::string wifi_ssid_;
+
+ DISALLOW_COPY_AND_ASSIGN(FakeConnectionInfoDelegate);
+};
+
SSLBlockingPage* CreateSSLBlockingPage(content::WebContents* web_contents) {
// Random parameters for SSL blocking page.
int cert_error = net::ERR_CERT_CONTAINS_ERRORS;
@@ -139,6 +157,49 @@ SafeBrowsingBlockingPage* CreateSafeBrowsingBlockingPage(
resource);
}
+CaptivePortalBlockingPage* CreateCaptivePortalBlockingPage(
+ content::WebContents* web_contents) {
+ bool is_wifi_connection = false;
+ GURL landing_url("https://captive.portal/login");
+ GURL request_url("https://google.com");
+ // Not initialized to a default value, since non-empty wifi_ssid is
+ // considered a wifi connection, even if is_wifi_connection is false
meacer 2015/06/19 22:50:37 nit: Period at the end of the comment.
Bhanu Dev 2015/06/19 23:21:33 Done.
+ std::string wifi_ssid;
+
+ std::string request_url_param;
+ if (net::GetValueForKeyInQuery(web_contents->GetURL(), "url",
+ &request_url_param)) {
+ if (GURL(request_url_param).is_valid())
+ request_url = GURL(request_url_param);
+ }
+ std::string landing_url_param;
+ if (net::GetValueForKeyInQuery(web_contents->GetURL(), "landing_page",
+ &landing_url_param)) {
+ if (GURL(landing_url_param).is_valid())
+ landing_url = GURL(landing_url_param);
+ }
+ std::string wifi_connection_param;
+ if (net::GetValueForKeyInQuery(web_contents->GetURL(), "is_wifi",
+ &wifi_connection_param)) {
+ is_wifi_connection = wifi_connection_param == "1";
+ }
+ std::string wifi_ssid_param;
+ if (net::GetValueForKeyInQuery(web_contents->GetURL(), "wifi_name",
+ &wifi_ssid_param)) {
+ wifi_ssid = wifi_ssid_param;
+ }
+ FakeConnectionInfoDelegate* delegate =
+ new FakeConnectionInfoDelegate(is_wifi_connection, wifi_ssid);
+ net::SSLInfo ssl_info;
+ ssl_info.cert = new net::X509Certificate(
+ request_url.host(), "CA", base::Time::Max(), base::Time::Max());
+ CaptivePortalBlockingPage* blocking_page = new CaptivePortalBlockingPage(
+ web_contents, request_url, landing_url, nullptr, ssl_info,
+ base::Callback<void(bool)>());
+ blocking_page->SetDelegate(delegate);
+ return blocking_page;
+}
+
} // namespace
InterstitialUI::InterstitialUI(content::WebUI* web_ui)
@@ -186,6 +247,8 @@ void InterstitialHTMLSource::StartDataRequest(
interstitial_delegate.reset(CreateSSLBlockingPage(web_contents_));
} else if (StartsWithASCII(path, "safebrowsing", true)) {
interstitial_delegate.reset(CreateSafeBrowsingBlockingPage(web_contents_));
+ } else if (StartsWithASCII(path, "captiveportal", true)) {
+ interstitial_delegate.reset(CreateCaptivePortalBlockingPage(web_contents_));
}
std::string html;

Powered by Google App Engine
This is Rietveld 408576698