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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/common/extensions/api/omnibox/omnibox_handler.h"
6
7 #include "base/memory/scoped_ptr.h"
8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h"
10 #include "base/values.h"
11 #include "chrome/common/extensions/extension.h"
12 #include "chrome/common/extensions/extension_manifest_constants.h"
13
14 namespace extensions {
15
16 namespace {
17
18 // Manifest keys.
19 const char kKeyword[] = "keyword";
20
21 } // namespace
22
23 // static
24 const std::string& OmniboxInfo::GetKeyword(const Extension* extension) {
25 OmniboxInfo* info = static_cast<OmniboxInfo*>(
26 extension->GetManifestData(extension_manifest_keys::kOmnibox));
27 return info ? info->keyword : EmptyString();
28 }
29
30 // static
31 bool OmniboxInfo::IsVerboseInstallMessage(const Extension* extension) {
32 return !GetKeyword(extension).empty() ||
33 extension->browser_action_info() ||
34 (extension->page_action_info() &&
35 (extension->page_action_command() ||
36 !extension->page_action_info()->default_icon.empty()));
37 }
38
39 OmniboxHandler::OmniboxHandler() {
40 }
41
42 OmniboxHandler::~OmniboxHandler() {
43 }
44
45 bool OmniboxHandler::Parse(const base::Value* value,
46 Extension* extension,
47 string16* error) {
48 scoped_ptr<OmniboxInfo> info(new OmniboxInfo);
49 const DictionaryValue* dict = NULL;
50 if (!value->GetAsDictionary(&dict) ||
51 !dict->GetString(kKeyword, &info->keyword) ||
52 info->keyword.empty()) {
53 *error = ASCIIToUTF16(extension_manifest_errors::kInvalidOmniboxKeyword);
54 return false;
55 }
56 extension->SetManifestData(extension_manifest_keys::kOmnibox, info.release());
57 return true;
58 }
59
60 } // namespace extensions
OLDNEW
« 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