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

Unified Diff: chrome/browser/chromeos/net/network_portal_notification_controller.cc

Issue 750153002: ChromeOS: bypass proxy for captive portal authorization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 6 years, 1 month 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/chromeos/net/network_portal_notification_controller.cc
diff --git a/chrome/browser/chromeos/net/network_portal_notification_controller.cc b/chrome/browser/chromeos/net/network_portal_notification_controller.cc
index 17ad3559ba1da68cc749bb1557051dd739856ecd..137c3f2eb61074e657213ec38ca235ad2107ddea 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

Powered by Google App Engine
This is Rietveld 408576698