summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/app/generated_resources.grd10
-rw-r--r--chrome/browser/about_flags.cc10
-rw-r--r--chrome/browser/chromeos/net/network_portal_notification_controller.cc66
-rw-r--r--chrome/browser/chromeos/net/network_portal_notification_controller.h14
-rw-r--r--chrome/browser/chromeos/net/network_portal_web_dialog.cc105
-rw-r--r--chrome/browser/chromeos/net/network_portal_web_dialog.h54
-rw-r--r--chrome/chrome_browser_chromeos.gypi2
-rw-r--r--chromeos/chromeos_switches.cc4
-rw-r--r--chromeos/chromeos_switches.h1
-rw-r--r--tools/metrics/histograms/histograms.xml1
10 files changed, 250 insertions, 17 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 1455c19..ff49fe6 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -14101,6 +14101,12 @@ Do you accept?
<message name="IDS_FLAGS_ENABLE_REMOTE_ASSISTANCE_DESCRIPTION" desc="Description of about::flags option to enable remote assistance on Chrome OS.">
Accepts remote assistance connections to this machine via the Chrome Remote Desktop app.
</message>
+ <message name="IDS_FLAGS_ENABLE_CAPTIVE_PORTAL_BYPASS_PROXY_NAME" desc="Name of about::flags option to enable bypass proxy for captive portal authorization on Chrome OS.">
+ Enable bypass proxy for Captive Portal Authorization
+ </message>
+ <message name="IDS_FLAGS_ENABLE_CAPTIVE_PORTAL_BYPASS_PROXY_DESCRIPTION" desc="Description of about::flags option to enable bypass proxy for captive portal authorization on Chrome OS.">
+ If proxy is configured, it usually prevents from authorization on different captive portals. This flag enables opening captive portal authorization dialog in a separate window, which ignores proxy settings.
+ </message>
</if>
<!-- Strings for controlling the minimum SSL/TLS version in about:flags. -->
@@ -15234,6 +15240,10 @@ Do you accept?
<message name="IDS_HOTWORD_OPT_IN_FINISHED_WAIT" desc="The text displayed when waiting for the voice model training to complete. ">
Processing ...
</message>
+
+ <message name="IDS_CAPTIVE_PORTAL_AUTHORIZATION_DIALOG_NAME" desc="Name of the modal Web dialog (displayed in the title) displaying captive portal login page on ChromeOS.">
+ Captive Portal Authorization
+ </message>
</messages>
</release>
</grit>
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index f866bd9..cdc0ff2 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -2032,6 +2032,16 @@ const Experiment kExperiments[] = {
kOsAndroid,
SINGLE_VALUE_TYPE(autofill::switches::kEnableCreditCardScan)
},
+#if defined(OS_CHROMEOS)
+ {
+ "enable-captive-portal-bypass-proxy",
+ IDS_FLAGS_ENABLE_CAPTIVE_PORTAL_BYPASS_PROXY_NAME,
+ IDS_FLAGS_ENABLE_CAPTIVE_PORTAL_BYPASS_PROXY_DESCRIPTION,
+ kOsCrOS,
+ SINGLE_VALUE_TYPE(chromeos::switches::kEnableCaptivePortalBypassProxy)
+ },
+#endif // defined(OS_CHROMEOS)
+
// NOTE: Adding new command-line switches requires adding corresponding
// entries to enum "LoginCustomFlags" in histograms.xml. See note in
// histograms.xml and don't forget to run AboutFlagsHistogramTest unit test.
diff --git a/chrome/browser/chromeos/net/network_portal_notification_controller.cc b/chrome/browser/chromeos/net/network_portal_notification_controller.cc
index 17ad355..137c3f2 100644
--- a/chrome/browser/chromeos/net/network_portal_notification_controller.cc
+++ b/chrome/browser/chromeos/net/network_portal_notification_controller.cc
@@ -16,7 +16,10 @@
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/chromeos/mobile/mobile_activator.h"
+#include "chrome/browser/chromeos/net/network_portal_web_dialog.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
#include "chrome/browser/ui/singleton_tabs.h"
#include "chrome/grit/generated_resources.h"
@@ -30,6 +33,7 @@
#include "ui/message_center/notification.h"
#include "ui/message_center/notification_types.h"
#include "ui/message_center/notifier_settings.h"
+#include "ui/views/widget/widget.h"
using message_center::Notification;
@@ -51,7 +55,9 @@ void CloseNotification() {
class NetworkPortalNotificationControllerDelegate
: public message_center::NotificationDelegate {
public:
- NetworkPortalNotificationControllerDelegate(): clicked_(false) {}
+ explicit NetworkPortalNotificationControllerDelegate(
+ base::WeakPtr<NetworkPortalNotificationController> controller)
+ : clicked_(false), controller_(controller) {}
// Overridden from message_center::NotificationDelegate:
virtual void Display() override;
@@ -63,6 +69,8 @@ class NetworkPortalNotificationControllerDelegate
bool clicked_;
+ base::WeakPtr<NetworkPortalNotificationController> controller_;
+
DISALLOW_COPY_AND_ASSIGN(NetworkPortalNotificationControllerDelegate);
};
@@ -93,14 +101,19 @@ void NetworkPortalNotificationControllerDelegate::Click() {
NetworkPortalNotificationController::USER_ACTION_METRIC_CLICKED,
NetworkPortalNotificationController::USER_ACTION_METRIC_COUNT);
- Profile* profile = ProfileManager::GetActiveUserProfile();
- if (!profile)
- return;
- chrome::ScopedTabbedBrowserDisplayer displayer(profile,
- chrome::HOST_DESKTOP_TYPE_ASH);
- GURL url(captive_portal::CaptivePortalDetector::kDefaultURL);
- chrome::ShowSingletonTab(displayer.browser(), url);
-
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ chromeos::switches::kEnableCaptivePortalBypassProxy)) {
+ if (controller_)
+ controller_->ShowDialog();
+ } else {
+ Profile* profile = ProfileManager::GetActiveUserProfile();
+ if (!profile)
+ return;
+ chrome::ScopedTabbedBrowserDisplayer displayer(
+ profile, chrome::HOST_DESKTOP_TYPE_ASH);
+ GURL url(captive_portal::CaptivePortalDetector::kDefaultURL);
+ chrome::ShowSingletonTab(displayer.browser(), url);
+ }
CloseNotification();
}
@@ -118,7 +131,9 @@ const char NetworkPortalNotificationController::kNotificationMetric[] =
const char NetworkPortalNotificationController::kUserActionMetric[] =
"CaptivePortal.Notification.UserAction";
-NetworkPortalNotificationController::NetworkPortalNotificationController() {}
+NetworkPortalNotificationController::NetworkPortalNotificationController()
+ : dialog_(nullptr) {
+}
NetworkPortalNotificationController::~NetworkPortalNotificationController() {}
@@ -131,6 +146,10 @@ void NetworkPortalNotificationController::OnPortalDetectionCompleted(
if (!network ||
state.status != NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL) {
last_network_path_.clear();
+
+ if (dialog_)
+ dialog_->Close();
+
CloseNotification();
return;
}
@@ -152,16 +171,13 @@ void NetworkPortalNotificationController::OnPortalDetectionCompleted(
ash::system_notifier::kNotifierNetworkPortalDetector);
scoped_ptr<Notification> notification(new Notification(
- message_center::NOTIFICATION_TYPE_SIMPLE,
- kNotificationId,
+ message_center::NOTIFICATION_TYPE_SIMPLE, kNotificationId,
l10n_util::GetStringUTF16(IDS_PORTAL_DETECTION_NOTIFICATION_TITLE),
l10n_util::GetStringFUTF16(IDS_PORTAL_DETECTION_NOTIFICATION_MESSAGE,
base::UTF8ToUTF16(network->name())),
- icon,
- base::string16() /* display_source */,
- notifier_id,
+ icon, base::string16() /* display_source */, notifier_id,
message_center::RichNotificationData(),
- new NetworkPortalNotificationControllerDelegate()));
+ new NetworkPortalNotificationControllerDelegate(AsWeakPtr())));
notification->SetSystemPriority();
if (ash::Shell::HasInstance()) {
@@ -173,4 +189,22 @@ void NetworkPortalNotificationController::OnPortalDetectionCompleted(
message_center::MessageCenter::Get()->AddNotification(notification.Pass());
}
+void NetworkPortalNotificationController::ShowDialog() {
+ if (dialog_)
+ return;
+
+ Profile* signin_profile = ProfileHelper::GetSigninProfile();
+ dialog_ = new NetworkPortalWebDialog(AsWeakPtr());
+ dialog_->SetWidget(views::Widget::GetWidgetForNativeWindow(
+ chrome::ShowWebDialog(nullptr, signin_profile, dialog_)));
+}
+
+void NetworkPortalNotificationController::OnDialogDestroyed(
+ const NetworkPortalWebDialog* dialog) {
+ if (dialog == dialog_) {
+ dialog_ = nullptr;
+ ProfileHelper::Get()->ClearSigninProfile(base::Closure());
+ }
+}
+
} // namespace chromeos
diff --git a/chrome/browser/chromeos/net/network_portal_notification_controller.h b/chrome/browser/chromeos/net/network_portal_notification_controller.h
index 3b825d4..1d279af 100644
--- a/chrome/browser/chromeos/net/network_portal_notification_controller.h
+++ b/chrome/browser/chromeos/net/network_portal_notification_controller.h
@@ -8,13 +8,16 @@
#include <string>
#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
#include "chromeos/network/portal_detector/network_portal_detector.h"
namespace chromeos {
class NetworkState;
+class NetworkPortalWebDialog;
-class NetworkPortalNotificationController {
+class NetworkPortalNotificationController
+ : public base::SupportsWeakPtr<NetworkPortalNotificationController> {
public:
// The values of these metrics are being used for UMA gathering, so it is
// important that they don't change between releases.
@@ -47,10 +50,19 @@ class NetworkPortalNotificationController {
const NetworkState* network,
const NetworkPortalDetector::CaptivePortalState& state);
+ // Creates NetworkPortalWebDialog.
+ void ShowDialog();
+
+ // NULLifies reference to the active dialog.
+ void OnDialogDestroyed(const NetworkPortalWebDialog* dialog);
+
private:
// Last network path for which notification was displayed.
std::string last_network_path_;
+ // Currently displayed authorization dialog, or NULL if none.
+ NetworkPortalWebDialog* dialog_;
+
DISALLOW_COPY_AND_ASSIGN(NetworkPortalNotificationController);
};
diff --git a/chrome/browser/chromeos/net/network_portal_web_dialog.cc b/chrome/browser/chromeos/net/network_portal_web_dialog.cc
new file mode 100644
index 0000000..28a611a
--- /dev/null
+++ b/chrome/browser/chromeos/net/network_portal_web_dialog.cc
@@ -0,0 +1,105 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/net/network_portal_web_dialog.h"
+
+#include "ash/shell.h"
+#include "chrome/grit/generated_resources.h"
+#include "components/captive_portal/captive_portal_detector.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/ui_base_types.h"
+#include "ui/gfx/display.h"
+#include "ui/gfx/size.h"
+#include "ui/views/widget/widget.h"
+#include "url/gurl.h"
+
+namespace {
+
+const float kNetworkPortalWebDialogWidthFraction = .8;
+const float kNetworkPortalWebDialogHeightFraction = .8;
+
+gfx::Size GetPortalDialogSize() {
+ const gfx::Display display = ash::Shell::GetScreen()->GetPrimaryDisplay();
+
+ gfx::Size display_size = display.size();
+
+ if (display.rotation() == gfx::Display::ROTATE_90 ||
+ display.rotation() == gfx::Display::ROTATE_270) {
+ display_size = gfx::Size(display_size.height(), display_size.width());
+ }
+
+ display_size =
+ gfx::Size(display_size.width() * kNetworkPortalWebDialogWidthFraction,
+ display_size.height() * kNetworkPortalWebDialogHeightFraction);
+
+ return display_size;
+}
+
+} // namespace
+
+namespace chromeos {
+
+NetworkPortalWebDialog::NetworkPortalWebDialog(
+ base::WeakPtr<NetworkPortalNotificationController> controller)
+ : controller_(controller), widget_(nullptr) {
+}
+
+NetworkPortalWebDialog::~NetworkPortalWebDialog() {
+ if (controller_)
+ controller_->OnDialogDestroyed(this);
+}
+
+void NetworkPortalWebDialog::Close() {
+ if (widget_)
+ widget_->Close();
+}
+
+void NetworkPortalWebDialog::SetWidget(views::Widget* widget) {
+ widget_ = widget;
+}
+
+ui::ModalType NetworkPortalWebDialog::GetDialogModalType() const {
+ return ui::MODAL_TYPE_SYSTEM;
+}
+
+base::string16 NetworkPortalWebDialog::GetDialogTitle() const {
+ return l10n_util::GetStringUTF16(
+ IDS_CAPTIVE_PORTAL_AUTHORIZATION_DIALOG_NAME);
+}
+
+GURL NetworkPortalWebDialog::GetDialogContentURL() const {
+ return GURL(captive_portal::CaptivePortalDetector::kDefaultURL);
+}
+
+void NetworkPortalWebDialog::GetWebUIMessageHandlers(
+ std::vector<content::WebUIMessageHandler*>* handlers) const {
+}
+
+void NetworkPortalWebDialog::GetDialogSize(gfx::Size* size) const {
+ *size = GetPortalDialogSize();
+}
+
+std::string NetworkPortalWebDialog::GetDialogArgs() const {
+ return std::string();
+}
+
+bool NetworkPortalWebDialog::CanResizeDialog() const {
+ return false;
+}
+
+void NetworkPortalWebDialog::OnDialogClosed(const std::string& json_retval) {
+ delete this;
+}
+
+void NetworkPortalWebDialog::OnCloseContents(content::WebContents* /* source */,
+ bool* out_close_dialog) {
+ if (out_close_dialog)
+ *out_close_dialog = true;
+}
+
+bool NetworkPortalWebDialog::ShouldShowDialogTitle() const {
+ return true;
+}
+
+} // namespace chromeos
diff --git a/chrome/browser/chromeos/net/network_portal_web_dialog.h b/chrome/browser/chromeos/net/network_portal_web_dialog.h
new file mode 100644
index 0000000..1f7f209
--- /dev/null
+++ b/chrome/browser/chromeos/net/network_portal_web_dialog.h
@@ -0,0 +1,54 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_WEB_DIALOG_H_
+#define CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_WEB_DIALOG_H_
+
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "chrome/browser/chromeos/net/network_portal_notification_controller.h"
+#include "ui/web_dialogs/web_dialog_delegate.h"
+
+namespace views {
+class Widget;
+}
+
+namespace chromeos {
+
+// This is the modal Web dialog to display captive portal login page.
+// It is automatically closed when successful authorization is detected.
+class NetworkPortalWebDialog : public ui::WebDialogDelegate {
+ public:
+ explicit NetworkPortalWebDialog(
+ base::WeakPtr<NetworkPortalNotificationController> controller);
+ virtual ~NetworkPortalWebDialog();
+
+ void SetWidget(views::Widget* widget);
+ void Close();
+
+ private:
+ // ui::WebDialogDelegate:
+ virtual ui::ModalType GetDialogModalType() const override;
+ virtual base::string16 GetDialogTitle() const override;
+ virtual GURL GetDialogContentURL() const override;
+ virtual void GetWebUIMessageHandlers(
+ std::vector<content::WebUIMessageHandler*>* handlers) const override;
+ virtual void GetDialogSize(gfx::Size* size) const override;
+ virtual std::string GetDialogArgs() const override;
+ virtual bool CanResizeDialog() const override;
+ virtual void OnDialogClosed(const std::string& json_retval) override;
+ virtual void OnCloseContents(content::WebContents* source,
+ bool* out_close_dialog) override;
+ virtual bool ShouldShowDialogTitle() const override;
+
+ base::WeakPtr<NetworkPortalNotificationController> controller_;
+
+ views::Widget* widget_;
+
+ DISALLOW_COPY_AND_ASSIGN(NetworkPortalWebDialog);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_WEB_DIALOG_H_
diff --git a/chrome/chrome_browser_chromeos.gypi b/chrome/chrome_browser_chromeos.gypi
index bbcf4e7..0bf275e 100644
--- a/chrome/chrome_browser_chromeos.gypi
+++ b/chrome/chrome_browser_chromeos.gypi
@@ -660,6 +660,8 @@
'browser/chromeos/net/network_portal_detector_test_impl.h',
'browser/chromeos/net/network_portal_notification_controller.cc',
'browser/chromeos/net/network_portal_notification_controller.h',
+ 'browser/chromeos/net/network_portal_web_dialog.cc',
+ 'browser/chromeos/net/network_portal_web_dialog.h',
'browser/chromeos/net/onc_utils.cc',
'browser/chromeos/net/onc_utils.h',
'browser/chromeos/net/proxy_config_handler.cc',
diff --git a/chromeos/chromeos_switches.cc b/chromeos/chromeos_switches.cc
index 0c3ccfe..739ca06 100644
--- a/chromeos/chromeos_switches.cc
+++ b/chromeos/chromeos_switches.cc
@@ -261,5 +261,9 @@ const char kGoldenScreenshotsDir[] = "golden-screenshots-dir";
// Screenshot testing: specifies the directoru where artifacts will be stored.
const char kArtifactsDir[] = "artifacts-dir";
+// Bypass proxy for captive portal authorization.
+const char kEnableCaptivePortalBypassProxy[] =
+ "enable-captive-portal-bypass-proxy";
+
} // namespace switches
} // namespace chromeos
diff --git a/chromeos/chromeos_switches.h b/chromeos/chromeos_switches.h
index f2f8b32..8bc5aa2 100644
--- a/chromeos/chromeos_switches.h
+++ b/chromeos/chromeos_switches.h
@@ -86,6 +86,7 @@ CHROMEOS_EXPORT extern const char kStubCrosSettings[];
CHROMEOS_EXPORT extern const char kSystemDevMode[];
CHROMEOS_EXPORT extern const char kTestAutoUpdateUI[];
CHROMEOS_EXPORT extern const char kWakeOnPackets[];
+CHROMEOS_EXPORT extern const char kEnableCaptivePortalBypassProxy[];
} // namespace switches
} // namespace chromeos
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml
index 8f20920..8d9278a 100644
--- a/tools/metrics/histograms/histograms.xml
+++ b/tools/metrics/histograms/histograms.xml
@@ -48910,6 +48910,7 @@ To add a new entry, add it with any value and run test to compute valid value.
<int value="835018878" label="disable-quic"/>
<int value="838887742" label="manual-enhanced-bookmarks"/>
<int value="851085848" label="enable-settings-window"/>
+ <int value="857445869" label="enable-captive-portal-bypass-proxy"/>
<int value="869531646" label="enable-session-crashed-bubble"/>
<int value="879699575" label="disable-gesture-tap-highlight"/>
<int value="879992337" label="disable-pull-to-refresh-effect"/>