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

Unified Diff: chrome/common/extensions/api/omnibox/omnibox_handler.cc

Issue 11446034: SupportsUserData and manifest handlers for Extension; use them for the Omnibox API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase + manifestdata 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
« no previous file with comments | « chrome/common/extensions/api/omnibox/omnibox_handler.h ('k') | chrome/common/extensions/extension.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/api/omnibox/omnibox_handler.cc
diff --git a/chrome/common/extensions/api/omnibox/omnibox_handler.cc b/chrome/common/extensions/api/omnibox/omnibox_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..941bdd329fee3bd008a27513068caf6d563279c4
--- /dev/null
+++ b/chrome/common/extensions/api/omnibox/omnibox_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/omnibox/omnibox_handler.h"
+
+#include "base/memory/scoped_ptr.h"
+#include "base/string_util.h"
+#include "base/utf_string_conversions.h"
+#include "base/values.h"
+#include "chrome/common/extensions/extension.h"
+#include "chrome/common/extensions/extension_manifest_constants.h"
+
+namespace extensions {
+
+namespace {
+
+// Manifest keys.
+const char kKeyword[] = "keyword";
+
+} // namespace
+
+// static
+const std::string& OmniboxInfo::GetKeyword(const Extension* extension) {
+ OmniboxInfo* info = static_cast<OmniboxInfo*>(
+ extension->GetManifestData(extension_manifest_keys::kOmnibox));
+ return info ? info->keyword : EmptyString();
+}
+
+// static
+bool OmniboxInfo::IsVerboseInstallMessage(const Extension* extension) {
+ return !GetKeyword(extension).empty() ||
+ extension->browser_action_info() ||
+ (extension->page_action_info() &&
+ (extension->page_action_command() ||
+ !extension->page_action_info()->default_icon.empty()));
+}
+
+OmniboxHandler::OmniboxHandler() {
+}
+
+OmniboxHandler::~OmniboxHandler() {
+}
+
+bool OmniboxHandler::Parse(const base::Value* value,
+ Extension* extension,
+ string16* error) {
+ scoped_ptr<OmniboxInfo> info(new OmniboxInfo);
+ const DictionaryValue* dict = NULL;
+ if (!value->GetAsDictionary(&dict) ||
+ !dict->GetString(kKeyword, &info->keyword) ||
+ info->keyword.empty()) {
+ *error = ASCIIToUTF16(extension_manifest_errors::kInvalidOmniboxKeyword);
+ return false;
+ }
+ extension->SetManifestData(extension_manifest_keys::kOmnibox, info.release());
+ return true;
+}
+
+} // namespace extensions
« no previous file with comments | « chrome/common/extensions/api/omnibox/omnibox_handler.h ('k') | chrome/common/extensions/extension.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698