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

Unified Diff: chrome/browser/resource_request_allowed_notifier.cc

Issue 10917120: Activate the VariationsService for ChromeOS and ensure that it does not ping the server until the E… (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Refactored to use ResourceRequestAllowedNotifier Created 8 years, 3 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resource_request_allowed_notifier.cc
diff --git a/chrome/browser/resource_request_allowed_notifier.cc b/chrome/browser/resource_request_allowed_notifier.cc
new file mode 100644
index 0000000000000000000000000000000000000000..96095812b91f027a8b5445b88eeceeb4747fd1e2
--- /dev/null
+++ b/chrome/browser/resource_request_allowed_notifier.cc
@@ -0,0 +1,58 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/resource_request_allowed_notifier.h"
+#include "chrome/common/chrome_notification_types.h"
+
+#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/login/wizard_controller.h"
+#endif
+
+ResourceRequestAllowedNotifier::ResourceRequestAllowedNotifier() {
+ net::NetworkChangeNotifier::AddConnectionTypeObserver(this);
+}
+
+ResourceRequestAllowedNotifier::~ResourceRequestAllowedNotifier() {
+ net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this);
+}
+
+void ResourceRequestAllowedNotifier::AddObserver(Observer* observer) {
+ observer_list_.AddObserver(observer);
+}
+
+void ResourceRequestAllowedNotifier::RemoveObserver(Observer* observer) {
+ observer_list_.RemoveObserver(observer);
+}
+
+// static
+bool ResourceRequestAllowedNotifier::IsNetworkOffline() {
+ return net::NetworkChangeNotifier::IsOffline();
+}
+
+#if defined(OS_CHROMEOS)
+// static
+bool ResourceRequestAllowedNotifier::IsEulaAccepted() {
+ return chromeos::WizardController::IsEulaAccepted();
+}
+
+void ResourceRequestAllowedNotifier::Observe(
+ int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ DCHECK(type == chrome::NOTIFICATION_WIZARD_EULA_ACCEPTED);
+
+ // Pass the message on to the observers.
+ FOR_EACH_OBSERVER(Observer, observer_list_, OnEulaAccepted());
+}
+#endif
+
+// net::NetworkChangeNotifier::ConnectionTypeObserver implementation.
+void ResourceRequestAllowedNotifier::OnConnectionTypeChanged(
+ net::NetworkChangeNotifier::ConnectionType type) {
+ if (type != net::NetworkChangeNotifier::CONNECTION_NONE) {
+ FOR_EACH_OBSERVER(Observer,
+ observer_list_,
+ OnNetworkChangedToActiveConnection());
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698