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

Unified Diff: extensions/common/features/feature_session_type.cc

Issue 2241203003: Pass user session type to extension feature checks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Pass user session type to extension renderer Created 4 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
« no previous file with comments | « extensions/common/features/feature_session_type.h ('k') | extensions/renderer/dispatcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/common/features/feature_session_type.cc
diff --git a/extensions/common/features/feature_session_type.cc b/extensions/common/features/feature_session_type.cc
new file mode 100644
index 0000000000000000000000000000000000000000..10f2af7a6123912f474978cc57d4fce3879a314c
--- /dev/null
+++ b/extensions/common/features/feature_session_type.cc
@@ -0,0 +1,39 @@
+// Copyright 2016 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 "extensions/common/features/feature_session_type.h"
+
+#include "base/logging.h"
+#include "base/memory/ptr_util.h"
+
+namespace extensions {
+
+namespace {
+
+const FeatureSessionType kDefaultSessionType = FeatureSessionType::INITIAL;
+FeatureSessionType g_current_session_type = kDefaultSessionType;
+
+} // namespace
+
+FeatureSessionType GetCurrentFeatureSessionType() {
+ return g_current_session_type;
+}
+
+void SetCurrentFeatureSessionType(FeatureSessionType session_type) {
+ // Make sure that session type stays constant after it's been initialized.
+ // Note that this requirement can be bypassed in tests by using
+ // |ScopedCurrentFeatureSessionType|.
+ CHECK(g_current_session_type == kDefaultSessionType ||
+ session_type == g_current_session_type);
+ g_current_session_type = session_type;
+}
+
+std::unique_ptr<base::AutoReset<FeatureSessionType>>
+ScopedCurrentFeatureSessionType(FeatureSessionType type) {
+ CHECK_EQ(g_current_session_type, kDefaultSessionType);
+ return base::MakeUnique<base::AutoReset<FeatureSessionType>>(
+ &g_current_session_type, type);
+}
+
+} // namespace extensions
« no previous file with comments | « extensions/common/features/feature_session_type.h ('k') | extensions/renderer/dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698