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

Side by Side Diff: chrome/browser/extensions/api/omnibox/omnibox_api.h

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: 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_OMNIBOX_OMNIBOX_API_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_OMNIBOX_OMNIBOX_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_OMNIBOX_OMNIBOX_API_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_OMNIBOX_OMNIBOX_API_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/string16.h" 12 #include "base/string16.h"
13 #include "chrome/browser/autocomplete/autocomplete_match.h" 13 #include "chrome/browser/autocomplete/autocomplete_match.h"
14 #include "chrome/browser/extensions/extension_function.h" 14 #include "chrome/browser/extensions/extension_function.h"
15 #include "chrome/browser/extensions/extension_icon_manager.h"
16 #include "chrome/browser/profiles/profile_keyed_service.h"
17 #include "content/public/browser/notification_observer.h"
18 #include "content/public/browser/notification_registrar.h"
15 19
16 class TemplateURL; 20 class TemplateURL;
17 21
18 namespace base { 22 namespace base {
19 class ListValue; 23 class ListValue;
20 } 24 }
21 25
22 namespace content { 26 namespace content {
23 class WebContents; 27 class WebContents;
24 } 28 }
25 29
30 namespace gfx {
31 class Image;
32 }
33
26 namespace extensions { 34 namespace extensions {
27 35
28 // Event router class for events related to the omnibox API. 36 // Event router class for events related to the omnibox API.
29 class ExtensionOmniboxEventRouter { 37 class ExtensionOmniboxEventRouter {
30 public: 38 public:
31 // The user has just typed the omnibox keyword. This is sent exactly once in 39 // The user has just typed the omnibox keyword. This is sent exactly once in
32 // a given input session, before any OnInputChanged events. 40 // a given input session, before any OnInputChanged events.
33 static void OnInputStarted( 41 static void OnInputStarted(
34 Profile* profile, const std::string& extension_id); 42 Profile* profile, const std::string& extension_id);
35 43
(...skipping 24 matching lines...) Expand all
60 public: 68 public:
61 DECLARE_EXTENSION_FUNCTION_NAME("omnibox.sendSuggestions"); 69 DECLARE_EXTENSION_FUNCTION_NAME("omnibox.sendSuggestions");
62 70
63 protected: 71 protected:
64 virtual ~OmniboxSendSuggestionsFunction() {} 72 virtual ~OmniboxSendSuggestionsFunction() {}
65 73
66 // ExtensionFunction: 74 // ExtensionFunction:
67 virtual bool RunImpl() OVERRIDE; 75 virtual bool RunImpl() OVERRIDE;
68 }; 76 };
69 77
78 class OmniboxAPI : public ProfileKeyedService,
79 public content::NotificationObserver {
80 public:
81 explicit OmniboxAPI(Profile* profile);
82 virtual ~OmniboxAPI();
83
84 // ProfileKeyedService implementation.
85 virtual void Shutdown() OVERRIDE;
86
87 // Convenience method to get the OmniboxAPI for a profile.
88 static OmniboxAPI* Get(Profile* profile);
89
90 // content::NotificationObserver implementation.
91 virtual void Observe(int type,
92 const content::NotificationSource& source,
93 const content::NotificationDetails& details) OVERRIDE;
94
95 // Returns the icon to display in the omnibox for the given extension.
96 gfx::Image GetOmniboxIcon(const std::string& extension_id);
97
98 // Returns the icon to display in the omnibox popup window for the given
99 // extension.
100 gfx::Image GetOmniboxPopupIcon(const std::string& extension_id);
101
102 // Returns the omnibox keyword for the extension.
103 static const std::string& GetKeyword(const Extension* extension);
104
105 // Returns true if the extension needs a verbose install message.
106 // TODO(yoz): This should be associated with page actions, not
107 // the omnibox.
108 static bool IsVerboseInstallMessage(const Extension* extension);
109
110 private:
111 content::NotificationRegistrar registrar_;
112
113 // Keeps track of favicon-sized omnibox icons for extensions.
114 ExtensionIconManager omnibox_icon_manager_;
115 ExtensionIconManager omnibox_popup_icon_manager_;
116 };
117
70 class OmniboxSetDefaultSuggestionFunction : public SyncExtensionFunction { 118 class OmniboxSetDefaultSuggestionFunction : public SyncExtensionFunction {
71 public: 119 public:
72 DECLARE_EXTENSION_FUNCTION_NAME("omnibox.setDefaultSuggestion"); 120 DECLARE_EXTENSION_FUNCTION_NAME("omnibox.setDefaultSuggestion");
73 121
74 protected: 122 protected:
75 virtual ~OmniboxSetDefaultSuggestionFunction() {} 123 virtual ~OmniboxSetDefaultSuggestionFunction() {}
76 124
77 // ExtensionFunction: 125 // ExtensionFunction:
78 virtual bool RunImpl() OVERRIDE; 126 virtual bool RunImpl() OVERRIDE;
79 }; 127 };
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 // omnibox.setDefaultSuggestion, apply that to |match|. Otherwise, do nothing. 168 // omnibox.setDefaultSuggestion, apply that to |match|. Otherwise, do nothing.
121 void ApplyDefaultSuggestionForExtensionKeyword( 169 void ApplyDefaultSuggestionForExtensionKeyword(
122 Profile* profile, 170 Profile* profile,
123 const TemplateURL* keyword, 171 const TemplateURL* keyword,
124 const string16& remaining_input, 172 const string16& remaining_input,
125 AutocompleteMatch* match); 173 AutocompleteMatch* match);
126 174
127 } // namespace extensions 175 } // namespace extensions
128 176
129 #endif // CHROME_BROWSER_EXTENSIONS_API_OMNIBOX_OMNIBOX_API_H_ 177 #endif // CHROME_BROWSER_EXTENSIONS_API_OMNIBOX_OMNIBOX_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698