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..90c527ef77e1325741d13a2c49029ebecb889b58 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/chromeos/mobile/mobile_activator.h" |
| +#include "chrome/browser/chromeos/net/captive_portal_ignore_proxy_policy_values.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,40 @@ 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 command_line_switch_present = |
| + CommandLine::ForCurrentProcess()->HasSwitch( |
| + chromeos::switches::kEnableCaptivePortalBypassProxy); |
| + bool use_incognito_profile = command_line_switch_present; |
| + |
| + if (profile && |
| + profile->GetPrefs()->IsManagedPreference( |
|
bartfab (slow)
2014/12/19 12:08:53
You do not really need to check if this is a manag
Alexander Alekseev
2014/12/22 22:20:10
Done.
|
| + prefs::kCaptivePortalAuthenticationIgnoresProxy)) { |
| + const int policy = profile->GetPrefs()->GetInteger( |
| + prefs::kCaptivePortalAuthenticationIgnoresProxy); |
| + if (policy == CAPTIVE_PORTAL_AUTH_IGNORE_PROXY_TRUE) { |
|
bartfab (slow)
2014/12/19 12:08:54
This would probably be cleaner as a switch stateme
Alexander Alekseev
2014/12/22 22:20:11
Done.
|
| + use_incognito_profile = true; |
| + } else if (policy == CAPTIVE_PORTAL_AUTH_IGNORE_PROXY_FALSE) { |
| + use_incognito_profile = false; |
| + } else { |
| + DCHECK(policy == CAPTIVE_PORTAL_AUTH_IGNORE_PROXY_USER_CONFIGURABLE); |
|
bartfab (slow)
2014/12/19 12:08:53
Nit: Use DCHECK_EQ.
Alexander Alekseev
2014/12/22 22:20:10
Done.
|
| + } |
| + } else if (g_browser_process->platform_part() |
|
bartfab (slow)
2014/12/19 12:08:53
Nit: #include "chrome/browser/browser_process_plat
Alexander Alekseev
2014/12/22 22:20:11
Done.
|
| + ->browser_policy_connector_chromeos() |
| + ->GetConsumerManagementService() && |
|
bartfab (slow)
2014/12/19 12:08:53
Can the consumer management service not exist?
Alexander Alekseev
2014/12/22 22:20:10
In tests. (Added comment on this.)
|
| + g_browser_process->platform_part() |
| + ->browser_policy_connector_chromeos() |
|
bartfab (slow)
2014/12/19 12:08:53
Nit: This is indented 4 spaces too many.
Alexander Alekseev
2014/12/22 22:20:11
Done.
(BTW, this the exact result of clang-format
|
| + ->GetConsumerManagementService() |
| + ->GetStatus() == |
| + policy::ConsumerManagementService::STATUS_ENROLLED) { |
| + use_incognito_profile = false; |
|
bartfab (slow)
2014/12/19 12:08:53
What is this case? Please document it.
Alexander Alekseev
2014/12/22 22:20:11
Done.
|
| + } |
| + |
| + if (use_incognito_profile) { |
| if (controller_) |
| controller_->ShowDialog(); |
| } else { |
| - Profile* profile = ProfileManager::GetActiveUserProfile(); |
| if (!profile) |
| return; |
| chrome::ScopedTabbedBrowserDisplayer displayer( |