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

Unified Diff: chrome/common/extensions/api/extension_action/browser_action_handler.cc

Issue 11644057: Move BrowserAction out of Extension (Closed) Base URL: http://git.chromium.org/chromium/src.git@dc_ungoop_extension_action
Patch Set: Created 8 years 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/extension_action/browser_action_handler.cc
diff --git a/chrome/common/extensions/api/extension_action/browser_action_handler.cc b/chrome/common/extensions/api/extension_action/browser_action_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8afebca285d9a12c6704e0087a29ea86e6903e7f
--- /dev/null
+++ b/chrome/common/extensions/api/extension_action/browser_action_handler.cc
@@ -0,0 +1,60 @@
+// Copyright (c) 2012 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/extension_action/browser_action_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_handler_helpers.h"
+#include "chrome/common/extensions/extension.h"
+#include "chrome/common/extensions/extension_constants.h"
+#include "chrome/common/extensions/extension_manifest_constants.h"
+#include "chrome/common/extensions/feature_switch.h"
+
+namespace errors = extension_manifest_errors;
+
+namespace extensions {
+
+BrowserActionInfo::BrowserActionInfo(ActionInfo* action_info)
+ : browser_action_info(action_info) {
+}
+
+BrowserActionInfo::~BrowserActionInfo() {
+}
+
+// static
+const ActionInfo* BrowserActionInfo::GetBrowserAction(
+ const Extension* extension) {
+ BrowserActionInfo* info = static_cast<BrowserActionInfo*>(
+ extension->GetManifestData(extension_manifest_keys::kBrowserAction));
+ return info ? info->browser_action_info.get() : NULL;
+}
+
+BrowserActionHandler::BrowserActionHandler() {
+}
+
+BrowserActionHandler::~BrowserActionHandler() {
+}
+
+bool BrowserActionHandler::Parse(const base::Value* value,
+ Extension* extension,
+ string16* error) {
+ const DictionaryValue* dict = NULL;
+ if (!value->GetAsDictionary(&dict)) {
+ *error = ASCIIToUTF16(errors::kInvalidBrowserAction);
+ return false;
+ }
+
+ scoped_ptr<ActionInfo> action_info = LoadActionInfo(extension, dict, error);
+ if (!action_info.get())
+ return false; // Failed to parse browser action definition.
+
+ extension->SetManifestData(extension_manifest_keys::kBrowserAction,
+ new BrowserActionInfo(action_info.release()));
+
+ return true;
+}
+
+} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698