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

Unified Diff: chrome/common/extensions/api/sockets/sockets_manifest_handler.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_handler.cc
diff --git a/chrome/common/extensions/api/sockets/sockets_manifest_handler.cc b/chrome/common/extensions/api/sockets/sockets_manifest_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ad406f004962b64fabd384a0cdd3ff6082377c00
--- /dev/null
+++ b/chrome/common/extensions/api/sockets/sockets_manifest_handler.cc
@@ -0,0 +1,51 @@
+// 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_handler.h"
+
+#include "chrome/common/extensions/api/sockets/sockets_manifest_data.h"
+#include "chrome/common/extensions/api/sockets/sockets_manifest_permission.h"
+#include "chrome/common/extensions/extension.h"
+#include "extensions/common/manifest_constants.h"
+
+namespace extensions {
+
+SocketsManifestHandler::SocketsManifestHandler() {}
+
+SocketsManifestHandler::~SocketsManifestHandler() {}
+
+bool SocketsManifestHandler::Parse(Extension* extension, string16* error) {
+ const base::Value* sockets = NULL;
+ CHECK(extension->manifest()->Get(manifest_keys::kSockets, &sockets));
+ std::vector<InstallWarning> install_warnings;
+ scoped_ptr<SocketsManifestData> data =
+ SocketsManifestData::FromValue(*sockets,
+ &install_warnings,
+ error);
+ if (!data)
+ return false;
+
+ extension->AddInstallWarnings(install_warnings);
+ extension->SetManifestData(manifest_keys::kSockets, data.release());
+ return true;
+}
+
+ManifestPermission* SocketsManifestHandler::CreatePermission() {
+ return new SocketsManifestPermission();
+}
+
+ManifestPermission* SocketsManifestHandler::CreateInitialRequiredPermission(
+ const Extension* extension) {
+ SocketsManifestData* data = SocketsManifestData::Get(extension);
+ if (data) {
Yoyo Zhou 2013/11/14 00:26:55 nit: don't need braces here
+ return data->permission()->Clone();
+ }
+ return new SocketsManifestPermission();
+}
+
+const std::vector<std::string> SocketsManifestHandler::Keys() const {
+ return SingleKey(manifest_keys::kSockets);
+}
+
+} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698