OLD | NEW |
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" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "chrome/browser/chromeos/policy/consumer_management_service.h" | 22 #include "chrome/browser/chromeos/policy/consumer_management_service.h" |
23 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 23 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
24 #include "chrome/browser/profiles/profile_manager.h" | 24 #include "chrome/browser/profiles/profile_manager.h" |
25 #include "chrome/browser/ui/browser_dialogs.h" | 25 #include "chrome/browser/ui/browser_dialogs.h" |
26 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 26 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
27 #include "chrome/browser/ui/singleton_tabs.h" | 27 #include "chrome/browser/ui/singleton_tabs.h" |
28 #include "chrome/grit/generated_resources.h" | 28 #include "chrome/grit/generated_resources.h" |
29 #include "chrome/grit/theme_resources.h" | 29 #include "chrome/grit/theme_resources.h" |
30 #include "chromeos/chromeos_switches.h" | 30 #include "chromeos/chromeos_switches.h" |
31 #include "chromeos/network/network_state.h" | 31 #include "chromeos/network/network_state.h" |
| 32 #include "chromeos/network/network_type_pattern.h" |
32 #include "components/captive_portal/captive_portal_detector.h" | 33 #include "components/captive_portal/captive_portal_detector.h" |
33 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
34 #include "ui/base/resource/resource_bundle.h" | 35 #include "ui/base/resource/resource_bundle.h" |
35 #include "ui/message_center/message_center.h" | 36 #include "ui/message_center/message_center.h" |
36 #include "ui/message_center/notification.h" | 37 #include "ui/message_center/notification.h" |
37 #include "ui/message_center/notification_types.h" | 38 #include "ui/message_center/notification_types.h" |
38 #include "ui/message_center/notifier_settings.h" | 39 #include "ui/message_center/notifier_settings.h" |
39 #include "ui/views/widget/widget.h" | 40 #include "ui/views/widget/widget.h" |
40 | 41 |
41 using message_center::Notification; | 42 using message_center::Notification; |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 if (network->path() == last_network_path_) | 177 if (network->path() == last_network_path_) |
177 return; | 178 return; |
178 last_network_path_ = network->path(); | 179 last_network_path_ = network->path(); |
179 | 180 |
180 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 181 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
181 gfx::Image& icon = bundle.GetImageNamed(IDR_PORTAL_DETECTION_ALERT); | 182 gfx::Image& icon = bundle.GetImageNamed(IDR_PORTAL_DETECTION_ALERT); |
182 message_center::NotifierId notifier_id( | 183 message_center::NotifierId notifier_id( |
183 message_center::NotifierId::SYSTEM_COMPONENT, | 184 message_center::NotifierId::SYSTEM_COMPONENT, |
184 ash::system_notifier::kNotifierNetworkPortalDetector); | 185 ash::system_notifier::kNotifierNetworkPortalDetector); |
185 | 186 |
| 187 bool is_wifi = NetworkTypePattern::WiFi().MatchesType(network->type()); |
186 scoped_ptr<Notification> notification(new Notification( | 188 scoped_ptr<Notification> notification(new Notification( |
187 message_center::NOTIFICATION_TYPE_SIMPLE, kNotificationId, | 189 message_center::NOTIFICATION_TYPE_SIMPLE, kNotificationId, |
188 l10n_util::GetStringUTF16(IDS_PORTAL_DETECTION_NOTIFICATION_TITLE), | 190 l10n_util::GetStringUTF16( |
189 l10n_util::GetStringFUTF16(IDS_PORTAL_DETECTION_NOTIFICATION_MESSAGE, | 191 is_wifi ? |
190 base::UTF8ToUTF16(network->name())), | 192 IDS_PORTAL_DETECTION_NOTIFICATION_TITLE_WIFI : |
| 193 IDS_PORTAL_DETECTION_NOTIFICATION_TITLE_WIRED), |
| 194 l10n_util::GetStringFUTF16( |
| 195 is_wifi ? |
| 196 IDS_PORTAL_DETECTION_NOTIFICATION_MESSAGE_WIFI : |
| 197 IDS_PORTAL_DETECTION_NOTIFICATION_MESSAGE_WIRED, |
| 198 base::UTF8ToUTF16(network->name())), |
191 icon, base::string16() /* display_source */, notifier_id, | 199 icon, base::string16() /* display_source */, notifier_id, |
192 message_center::RichNotificationData(), | 200 message_center::RichNotificationData(), |
193 new NetworkPortalNotificationControllerDelegate(AsWeakPtr()))); | 201 new NetworkPortalNotificationControllerDelegate(AsWeakPtr()))); |
194 notification->SetSystemPriority(); | 202 notification->SetSystemPriority(); |
195 | 203 |
196 if (ash::Shell::HasInstance()) { | 204 if (ash::Shell::HasInstance()) { |
197 ash::Shell::GetInstance() | 205 ash::Shell::GetInstance() |
198 ->system_tray_notifier() | 206 ->system_tray_notifier() |
199 ->NotifyOnCaptivePortalDetected(network->path()); | 207 ->NotifyOnCaptivePortalDetected(network->path()); |
200 } | 208 } |
(...skipping 13 matching lines...) Expand all Loading... |
214 | 222 |
215 void NetworkPortalNotificationController::OnDialogDestroyed( | 223 void NetworkPortalNotificationController::OnDialogDestroyed( |
216 const NetworkPortalWebDialog* dialog) { | 224 const NetworkPortalWebDialog* dialog) { |
217 if (dialog == dialog_) { | 225 if (dialog == dialog_) { |
218 dialog_ = nullptr; | 226 dialog_ = nullptr; |
219 ProfileHelper::Get()->ClearSigninProfile(base::Closure()); | 227 ProfileHelper::Get()->ClearSigninProfile(base::Closure()); |
220 } | 228 } |
221 } | 229 } |
222 | 230 |
223 } // namespace chromeos | 231 } // namespace chromeos |
OLD | NEW |