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

Side by Side Diff: chrome/browser/chromeos/net/network_portal_notification_controller.cc

Issue 818433003: ChromeOS: Implement CaptivePortalAuthenticationIgnoresProxy policy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/net/network_portal_notification_controller.h" 5 #include "chrome/browser/chromeos/net/network_portal_notification_controller.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/system/system_notifier.h" 8 #include "ash/system/system_notifier.h"
9 #include "ash/system/tray/system_tray_notifier.h" 9 #include "ash/system/tray/system_tray_notifier.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/prefs/pref_service.h"
16 #include "base/strings/string16.h" 17 #include "base/strings/string16.h"
17 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
19 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/chromeos/mobile/mobile_activator.h" 20 #include "chrome/browser/chromeos/mobile/mobile_activator.h"
21 #include "chrome/browser/chromeos/net/captive_portal_ignore_proxy_policy_values. h"
19 #include "chrome/browser/chromeos/net/network_portal_web_dialog.h" 22 #include "chrome/browser/chromeos/net/network_portal_web_dialog.h"
23 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
24 #include "chrome/browser/chromeos/policy/consumer_management_service.h"
20 #include "chrome/browser/chromeos/profiles/profile_helper.h" 25 #include "chrome/browser/chromeos/profiles/profile_helper.h"
21 #include "chrome/browser/profiles/profile_manager.h" 26 #include "chrome/browser/profiles/profile_manager.h"
22 #include "chrome/browser/ui/browser_dialogs.h" 27 #include "chrome/browser/ui/browser_dialogs.h"
23 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" 28 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
24 #include "chrome/browser/ui/singleton_tabs.h" 29 #include "chrome/browser/ui/singleton_tabs.h"
30 #include "chrome/common/pref_names.h"
25 #include "chrome/grit/generated_resources.h" 31 #include "chrome/grit/generated_resources.h"
26 #include "chrome/grit/theme_resources.h" 32 #include "chrome/grit/theme_resources.h"
27 #include "chromeos/chromeos_switches.h" 33 #include "chromeos/chromeos_switches.h"
28 #include "chromeos/network/network_state.h" 34 #include "chromeos/network/network_state.h"
29 #include "components/captive_portal/captive_portal_detector.h" 35 #include "components/captive_portal/captive_portal_detector.h"
30 #include "ui/base/l10n/l10n_util.h" 36 #include "ui/base/l10n/l10n_util.h"
31 #include "ui/base/resource/resource_bundle.h" 37 #include "ui/base/resource/resource_bundle.h"
32 #include "ui/message_center/message_center.h" 38 #include "ui/message_center/message_center.h"
33 #include "ui/message_center/notification.h" 39 #include "ui/message_center/notification.h"
34 #include "ui/message_center/notification_types.h" 40 #include "ui/message_center/notification_types.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 NetworkPortalNotificationController::USER_ACTION_METRIC_COUNT); 100 NetworkPortalNotificationController::USER_ACTION_METRIC_COUNT);
95 } 101 }
96 102
97 void NetworkPortalNotificationControllerDelegate::Click() { 103 void NetworkPortalNotificationControllerDelegate::Click() {
98 clicked_ = true; 104 clicked_ = true;
99 UMA_HISTOGRAM_ENUMERATION( 105 UMA_HISTOGRAM_ENUMERATION(
100 NetworkPortalNotificationController::kUserActionMetric, 106 NetworkPortalNotificationController::kUserActionMetric,
101 NetworkPortalNotificationController::USER_ACTION_METRIC_CLICKED, 107 NetworkPortalNotificationController::USER_ACTION_METRIC_CLICKED,
102 NetworkPortalNotificationController::USER_ACTION_METRIC_COUNT); 108 NetworkPortalNotificationController::USER_ACTION_METRIC_COUNT);
103 109
104 if (CommandLine::ForCurrentProcess()->HasSwitch( 110 Profile* profile = ProfileManager::GetActiveUserProfile();
105 chromeos::switches::kEnableCaptivePortalBypassProxy)) { 111
112 const bool command_line_switch_present =
113 CommandLine::ForCurrentProcess()->HasSwitch(
114 chromeos::switches::kEnableCaptivePortalBypassProxy);
115 bool use_incognito_profile = command_line_switch_present;
116
117 if (profile &&
118 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.
119 prefs::kCaptivePortalAuthenticationIgnoresProxy)) {
120 const int policy = profile->GetPrefs()->GetInteger(
121 prefs::kCaptivePortalAuthenticationIgnoresProxy);
122 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.
123 use_incognito_profile = true;
124 } else if (policy == CAPTIVE_PORTAL_AUTH_IGNORE_PROXY_FALSE) {
125 use_incognito_profile = false;
126 } else {
127 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.
128 }
129 } 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.
130 ->browser_policy_connector_chromeos()
131 ->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.)
132 g_browser_process->platform_part()
133 ->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
134 ->GetConsumerManagementService()
135 ->GetStatus() ==
136 policy::ConsumerManagementService::STATUS_ENROLLED) {
137 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.
138 }
139
140 if (use_incognito_profile) {
106 if (controller_) 141 if (controller_)
107 controller_->ShowDialog(); 142 controller_->ShowDialog();
108 } else { 143 } else {
109 Profile* profile = ProfileManager::GetActiveUserProfile();
110 if (!profile) 144 if (!profile)
111 return; 145 return;
112 chrome::ScopedTabbedBrowserDisplayer displayer( 146 chrome::ScopedTabbedBrowserDisplayer displayer(
113 profile, chrome::HOST_DESKTOP_TYPE_ASH); 147 profile, chrome::HOST_DESKTOP_TYPE_ASH);
114 GURL url(captive_portal::CaptivePortalDetector::kDefaultURL); 148 GURL url(captive_portal::CaptivePortalDetector::kDefaultURL);
115 chrome::ShowSingletonTab(displayer.browser(), url); 149 chrome::ShowSingletonTab(displayer.browser(), url);
116 } 150 }
117 CloseNotification(); 151 CloseNotification();
118 } 152 }
119 153
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 235
202 void NetworkPortalNotificationController::OnDialogDestroyed( 236 void NetworkPortalNotificationController::OnDialogDestroyed(
203 const NetworkPortalWebDialog* dialog) { 237 const NetworkPortalWebDialog* dialog) {
204 if (dialog == dialog_) { 238 if (dialog == dialog_) {
205 dialog_ = nullptr; 239 dialog_ = nullptr;
206 ProfileHelper::Get()->ClearSigninProfile(base::Closure()); 240 ProfileHelper::Get()->ClearSigninProfile(base::Closure());
207 } 241 }
208 } 242 }
209 243
210 } // namespace chromeos 244 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698