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

Unified Diff: chrome/common/extensions/api/sockets/sockets_manifest_data.cc

Issue 51433002: Enable permission warnings from ManifestHandlers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address code review feedback. Created 7 years, 1 month 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/common/extensions/api/sockets/sockets_manifest_data.cc
diff --git a/chrome/common/extensions/api/sockets/sockets_manifest_data.cc b/chrome/common/extensions/api/sockets/sockets_manifest_data.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d8649ae3380be8a0fa0c0908dcba2dbdd65f1405
--- /dev/null
+++ b/chrome/common/extensions/api/sockets/sockets_manifest_data.cc
@@ -0,0 +1,52 @@
+// Copyright 2013 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/common/extensions/api/sockets/sockets_manifest_data.h"
+
+#include "chrome/common/extensions/api/sockets/sockets_manifest_permission.h"
+#include "extensions/common/manifest_constants.h"
+
+namespace extensions {
+
+SocketsManifestData::SocketsManifestData(
+ scoped_ptr<SocketsManifestPermission> permission)
+ : permission_(permission.Pass()) {
+ DCHECK(permission_);
+}
+
+SocketsManifestData::~SocketsManifestData() {}
+
+// static
+SocketsManifestData* SocketsManifestData::Get(
+ const Extension* extension) {
+ return static_cast<SocketsManifestData*>(
+ extension->GetManifestData(manifest_keys::kSockets));
+}
+
+// static
+bool SocketsManifestData::CheckRequest(
+ const Extension* extension,
+ const content::SocketPermissionRequest& request) {
+ const SocketsManifestData* data = SocketsManifestData::Get(extension);
+ if (data)
+ return data->permission()->CheckRequest(extension, request);
+
+ return false;
+}
+
+// static
+scoped_ptr<SocketsManifestData> SocketsManifestData::FromValue(
+ const base::Value& value,
+ std::vector<InstallWarning>* install_warnings,
+ string16* error) {
+ scoped_ptr<SocketsManifestPermission> permission =
+ SocketsManifestPermission::FromValue(value, install_warnings, error);
+ if (!permission)
+ return scoped_ptr<SocketsManifestData>();
+
+ return scoped_ptr<SocketsManifestData>(
+ new SocketsManifestData(permission.Pass())).Pass();
+}
+
+} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698