| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/resource_request_allowed_notifier.h" |
| 6 #include "chrome/common/chrome_notification_types.h" |
| 7 |
| 8 #if defined(OS_CHROMEOS) |
| 9 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 10 #endif |
| 11 |
| 12 ResourceRequestAllowedNotifier::ResourceRequestAllowedNotifier() { |
| 13 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); |
| 14 } |
| 15 |
| 16 ResourceRequestAllowedNotifier::~ResourceRequestAllowedNotifier() { |
| 17 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); |
| 18 } |
| 19 |
| 20 void ResourceRequestAllowedNotifier::AddObserver(Observer* observer) { |
| 21 observer_list_.AddObserver(observer); |
| 22 } |
| 23 |
| 24 void ResourceRequestAllowedNotifier::RemoveObserver(Observer* observer) { |
| 25 observer_list_.RemoveObserver(observer); |
| 26 } |
| 27 |
| 28 // static |
| 29 bool ResourceRequestAllowedNotifier::IsNetworkOffline() { |
| 30 return net::NetworkChangeNotifier::IsOffline(); |
| 31 } |
| 32 |
| 33 #if defined(OS_CHROMEOS) |
| 34 // static |
| 35 bool ResourceRequestAllowedNotifier::IsEulaAccepted() { |
| 36 return chromeos::WizardController::IsEulaAccepted(); |
| 37 } |
| 38 |
| 39 void ResourceRequestAllowedNotifier::Observe( |
| 40 int type, |
| 41 const content::NotificationSource& source, |
| 42 const content::NotificationDetails& details) { |
| 43 DCHECK(type == chrome::NOTIFICATION_WIZARD_EULA_ACCEPTED); |
| 44 |
| 45 // Pass the message on to the observers. |
| 46 FOR_EACH_OBSERVER(Observer, observer_list_, OnEulaAccepted()); |
| 47 } |
| 48 #endif |
| 49 |
| 50 // net::NetworkChangeNotifier::ConnectionTypeObserver implementation. |
| 51 void ResourceRequestAllowedNotifier::OnConnectionTypeChanged( |
| 52 net::NetworkChangeNotifier::ConnectionType type) { |
| 53 if (type != net::NetworkChangeNotifier::CONNECTION_NONE) { |
| 54 FOR_EACH_OBSERVER(Observer, |
| 55 observer_list_, |
| 56 OnNetworkChangedToActiveConnection()); |
| 57 } |
| 58 } |
| OLD | NEW |