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

Unified Diff: chrome/browser/chromeos/tether/tether_service.h

Issue 2819713002: Create TetherService, a TetherAllowed pref, and use DependencyManager for RegisterProfilePrefs call… (Closed)
Patch Set: Move TetherService[Factory] from chrome/browser to chrome/browser/chromeos. Created 3 years, 8 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/chromeos/tether/tether_service.h
diff --git a/chrome/browser/chromeos/tether/tether_service.h b/chrome/browser/chromeos/tether/tether_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..bfd2a72e495dce769b3e49413e84814bb83c60de
--- /dev/null
+++ b/chrome/browser/chromeos/tether/tether_service.h
@@ -0,0 +1,55 @@
+// Copyright 2017 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.
+
+#ifndef CHROME_BROWSER_CHROMEOS_TETHER_TETHER_SERVICE_H_
+#define CHROME_BROWSER_CHROMEOS_TETHER_TETHER_SERVICE_H_
+
+#include <memory>
+
+#include "base/macros.h"
+#include "components/keyed_service/core/keyed_service.h"
+#include "components/prefs/pref_change_registrar.h"
+
+namespace user_prefs {
+class PrefRegistrySyncable;
+}
+
+class Profile;
+
+class TetherService : public KeyedService {
+ public:
+ explicit TetherService(Profile* profile);
+ ~TetherService() override;
+
+ // Gets TetherService instance.
+ static TetherService* Get(Profile* profile);
+
+ static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
+
+ // Start the Tether module. Should only be called once a user is logged in.
+ void StartTether();
+
+ // Whether Tether is allowed to be used. If the controlling preference
+ // is set (from policy), this returns the preference value. Otherwise, it is
+ // permitted if the flag is enabled. Virtual to allow override for testing.
+ virtual bool IsAllowed() const;
+
+ protected:
+ // KeyedService
+ void Shutdown() override;
+
+ private:
+ // Callback when the controlling pref changes.
+ void OnPrefsChanged();
+
+ Profile* profile_;
+ PrefChangeRegistrar registrar_;
+
+ // Whether the service has been shut down.
+ bool shut_down_;
+
+ DISALLOW_COPY_AND_ASSIGN(TetherService);
+};
+
+#endif // CHROME_BROWSER_CHROMEOS_TETHER_TETHER_SERVICE_H_

Powered by Google App Engine
This is Rietveld 408576698