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

Unified Diff: chrome/common/extensions/api/system_indicator/system_indicator_handler.cc

Issue 12618009: Move SystemIndicator parsing out of Extension class (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 9 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/common/extensions/api/system_indicator/system_indicator_handler.cc
diff --git a/chrome/common/extensions/api/system_indicator/system_indicator_handler.cc b/chrome/common/extensions/api/system_indicator/system_indicator_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..638b53940945659ef76a43fb0b0a72316b4f6b76
--- /dev/null
+++ b/chrome/common/extensions/api/system_indicator/system_indicator_handler.cc
@@ -0,0 +1,49 @@
+// Copyright (c) 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/system_indicator/system_indicator_handler.h"
+
+#include "base/memory/scoped_ptr.h"
+#include "base/utf_string_conversions.h"
+#include "base/values.h"
+#include "chrome/common/extensions/api/extension_action/action_info.h"
+#include "chrome/common/extensions/extension.h"
+#include "chrome/common/extensions/extension_manifest_constants.h"
+#include "chrome/common/extensions/permissions/api_permission_set.h"
+
+namespace extensions {
+
+SystemIndicatorHandler::SystemIndicatorHandler() {
+}
+
+SystemIndicatorHandler::~SystemIndicatorHandler() {
+}
+
+bool SystemIndicatorHandler::Parse(Extension* extension, string16* error) {
+ const DictionaryValue* system_indicator_value = NULL;
+ if (!extension->manifest()->GetDictionary(
+ extension_manifest_keys::kSystemIndicator, &system_indicator_value)) {
+ *error = ASCIIToUTF16(extension_manifest_errors::kInvalidSystemIndicator);
+ return false;
+ }
+
+ scoped_ptr<ActionInfo> action_info = ActionInfo::Load(
+ extension, system_indicator_value, error);
+
+ if (!action_info.get())
+ return false;
+
+ // Because the manifest was successfully parsed, auto-grant the permission.
+ // TODO(dewittj) Add this for all extension action APIs.
+ extension->initial_api_permissions()->insert(APIPermission::kSystemIndicator);
+
+ ActionInfo::SetSystemIndicatorInfo(extension, action_info.release());
+ return true;
+}
+
+const std::vector<std::string> SystemIndicatorHandler::Keys() const {
+ return SingleKey(extension_manifest_keys::kSystemIndicator);
+}
+
+} // namespace extensions
« no previous file with comments | « chrome/common/extensions/api/system_indicator/system_indicator_handler.h ('k') | chrome/common/extensions/extension.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698