Chromium Code Reviews| 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 137c3f2eb61074e657213ec38ca235ad2107ddea..7ca3b630dd850cf18c6c20a3f223c8acc75f647b 100644 |
| --- a/chrome/browser/chromeos/net/network_portal_notification_controller.cc |
| +++ b/chrome/browser/chromeos/net/network_portal_notification_controller.cc |
| @@ -13,15 +13,21 @@ |
| #include "base/memory/scoped_ptr.h" |
| #include "base/message_loop/message_loop.h" |
| #include "base/metrics/histogram.h" |
| +#include "base/prefs/pref_service.h" |
| #include "base/strings/string16.h" |
| #include "base/strings/utf_string_conversions.h" |
| +#include "chrome/browser/browser_process.h" |
| +#include "chrome/browser/browser_process_platform_part.h" |
| #include "chrome/browser/chromeos/mobile/mobile_activator.h" |
| #include "chrome/browser/chromeos/net/network_portal_web_dialog.h" |
| +#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| +#include "chrome/browser/chromeos/policy/consumer_management_service.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/common/pref_names.h" |
| #include "chrome/grit/generated_resources.h" |
| #include "chrome/grit/theme_resources.h" |
| #include "chromeos/chromeos_switches.h" |
| @@ -101,12 +107,22 @@ void NetworkPortalNotificationControllerDelegate::Click() { |
| NetworkPortalNotificationController::USER_ACTION_METRIC_CLICKED, |
| NetworkPortalNotificationController::USER_ACTION_METRIC_COUNT); |
| - if (CommandLine::ForCurrentProcess()->HasSwitch( |
| - chromeos::switches::kEnableCaptivePortalBypassProxy)) { |
| + Profile* profile = ProfileManager::GetActiveUserProfile(); |
| + |
| + const bool bypass_proxy_switch_present = |
| + CommandLine::ForCurrentProcess()->HasSwitch( |
| + chromeos::switches::kEnableCaptivePortalBypassProxy); |
| + const bool use_incognito_profile = |
| + bypass_proxy_switch_present |
| + ? (profile && |
| + profile->GetPrefs()->GetBoolean( |
|
bartfab (slow)
2015/01/07 17:38:42
Nit: #include "base/prefs/pref_service.h"
Alexander Alekseev
2015/01/12 18:41:09
Done.
|
| + prefs::kCaptivePortalAuthenticationIgnoresProxy)) |
|
bartfab (slow)
2015/01/07 17:38:42
Nit: #include "chrome/common/pref_names.h"
Alexander Alekseev
2015/01/12 18:41:09
Done.
|
| + : false; |
| + |
| + if (use_incognito_profile) { |
| if (controller_) |
| controller_->ShowDialog(); |
| } else { |
| - Profile* profile = ProfileManager::GetActiveUserProfile(); |
| if (!profile) |
| return; |
| chrome::ScopedTabbedBrowserDisplayer displayer( |
| @@ -132,7 +148,7 @@ const char NetworkPortalNotificationController::kUserActionMetric[] = |
| "CaptivePortal.Notification.UserAction"; |
| NetworkPortalNotificationController::NetworkPortalNotificationController() |
| - : dialog_(nullptr) { |
| + : dialog_(nullptr), ignore_no_network_for_testing_(false) { |
| } |
| NetworkPortalNotificationController::~NetworkPortalNotificationController() {} |
| @@ -147,8 +163,12 @@ void NetworkPortalNotificationController::OnPortalDetectionCompleted( |
| state.status != NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL) { |
| last_network_path_.clear(); |
| - if (dialog_) |
| + // Do not close dialog in browser tests on "no network" errors. |
| + if (dialog_ && |
| + (!ignore_no_network_for_testing_ || |
|
bartfab (slow)
2015/01/07 17:38:42
This conditional makes |ignore_no_network_for_test
Alexander Alekseev
2015/01/12 18:41:09
This is intentional.
bartfab (slow)
2015/01/14 11:00:07
It does not seem to match the comment though.
Alexander Alekseev
2015/01/16 22:51:48
Done.
(The comment was really outdated, sorry.)
|
| + state.status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE)) { |
|
bartfab (slow)
2015/01/07 17:38:42
If |ignore_no_network_for_testing_| is false (the
Alexander Alekseev
2015/01/12 18:41:09
Yes.
In browser_tests we have very strange conditi
|
| dialog_->Close(); |
| + } |
| CloseNotification(); |
| return; |
| @@ -207,4 +227,13 @@ void NetworkPortalNotificationController::OnDialogDestroyed( |
| } |
| } |
| +void NetworkPortalNotificationController::SetIgnoreNoNetworkForTesting() { |
| + ignore_no_network_for_testing_ = true; |
| +} |
| + |
| +const NetworkPortalWebDialog* |
| +NetworkPortalNotificationController::GetDialogForTesting() const { |
| + return dialog_; |
| +} |
| + |
| } // namespace chromeos |