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

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: 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
« no previous file with comments | « no previous file | chrome/browser/extensions/api/omnibox/omnibox_api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <set>
8 #include <string> 9 #include <string>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
12 #include "base/string16.h" 13 #include "base/string16.h"
13 #include "chrome/browser/autocomplete/autocomplete_match.h" 14 #include "chrome/browser/autocomplete/autocomplete_match.h"
14 #include "chrome/browser/extensions/extension_function.h" 15 #include "chrome/browser/extensions/extension_function.h"
16 #include "chrome/browser/extensions/extension_icon_manager.h"
17 #include "chrome/browser/profiles/profile_keyed_service.h"
18 #include "content/public/browser/notification_observer.h"
19 #include "content/public/browser/notification_registrar.h"
15 20
21 class Profile;
16 class TemplateURL; 22 class TemplateURL;
23 class TemplateURLService;
17 24
18 namespace base { 25 namespace base {
19 class ListValue; 26 class ListValue;
20 } 27 }
21 28
22 namespace content { 29 namespace content {
23 class WebContents; 30 class WebContents;
24 } 31 }
25 32
33 namespace gfx {
34 class Image;
35 }
36
26 namespace extensions { 37 namespace extensions {
27 38
28 // Event router class for events related to the omnibox API. 39 // Event router class for events related to the omnibox API.
29 class ExtensionOmniboxEventRouter { 40 class ExtensionOmniboxEventRouter {
30 public: 41 public:
31 // The user has just typed the omnibox keyword. This is sent exactly once in 42 // The user has just typed the omnibox keyword. This is sent exactly once in
32 // a given input session, before any OnInputChanged events. 43 // a given input session, before any OnInputChanged events.
33 static void OnInputStarted( 44 static void OnInputStarted(
34 Profile* profile, const std::string& extension_id); 45 Profile* profile, const std::string& extension_id);
35 46
(...skipping 24 matching lines...) Expand all
60 public: 71 public:
61 DECLARE_EXTENSION_FUNCTION_NAME("omnibox.sendSuggestions"); 72 DECLARE_EXTENSION_FUNCTION_NAME("omnibox.sendSuggestions");
62 73
63 protected: 74 protected:
64 virtual ~OmniboxSendSuggestionsFunction() {} 75 virtual ~OmniboxSendSuggestionsFunction() {}
65 76
66 // ExtensionFunction: 77 // ExtensionFunction:
67 virtual bool RunImpl() OVERRIDE; 78 virtual bool RunImpl() OVERRIDE;
68 }; 79 };
69 80
81 class OmniboxAPI : public ProfileKeyedService,
82 public content::NotificationObserver {
83 public:
84 explicit OmniboxAPI(Profile* profile);
85 virtual ~OmniboxAPI();
86
87 // ProfileKeyedService implementation.
88 virtual void Shutdown() OVERRIDE;
89
90 // Convenience method to get the OmniboxAPI for a profile.
91 static OmniboxAPI* Get(Profile* profile);
92
93 // content::NotificationObserver implementation.
94 virtual void Observe(int type,
95 const content::NotificationSource& source,
96 const content::NotificationDetails& details) OVERRIDE;
97
98 // Returns the icon to display in the omnibox for the given extension.
99 gfx::Image GetOmniboxIcon(const std::string& extension_id);
100
101 // Returns the icon to display in the omnibox popup window for the given
102 // extension.
103 gfx::Image GetOmniboxPopupIcon(const std::string& extension_id);
104
105 private:
106 typedef std::set<const Extension*> PendingExtensions;
107
108 TemplateURLService* url_service_;
109
110 // List of extensions waiting for the TemplateURLService to Load to
111 // have keywords registered.
112 PendingExtensions pending_extensions_;
113
114 content::NotificationRegistrar registrar_;
115
116 // Keeps track of favicon-sized omnibox icons for extensions.
117 ExtensionIconManager omnibox_icon_manager_;
118 ExtensionIconManager omnibox_popup_icon_manager_;
119 };
120
70 class OmniboxSetDefaultSuggestionFunction : public SyncExtensionFunction { 121 class OmniboxSetDefaultSuggestionFunction : public SyncExtensionFunction {
71 public: 122 public:
72 DECLARE_EXTENSION_FUNCTION_NAME("omnibox.setDefaultSuggestion"); 123 DECLARE_EXTENSION_FUNCTION_NAME("omnibox.setDefaultSuggestion");
73 124
74 protected: 125 protected:
75 virtual ~OmniboxSetDefaultSuggestionFunction() {} 126 virtual ~OmniboxSetDefaultSuggestionFunction() {}
76 127
77 // ExtensionFunction: 128 // ExtensionFunction:
78 virtual bool RunImpl() OVERRIDE; 129 virtual bool RunImpl() OVERRIDE;
79 }; 130 };
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 // omnibox.setDefaultSuggestion, apply that to |match|. Otherwise, do nothing. 171 // omnibox.setDefaultSuggestion, apply that to |match|. Otherwise, do nothing.
121 void ApplyDefaultSuggestionForExtensionKeyword( 172 void ApplyDefaultSuggestionForExtensionKeyword(
122 Profile* profile, 173 Profile* profile,
123 const TemplateURL* keyword, 174 const TemplateURL* keyword,
124 const string16& remaining_input, 175 const string16& remaining_input,
125 AutocompleteMatch* match); 176 AutocompleteMatch* match);
126 177
127 } // namespace extensions 178 } // namespace extensions
128 179
129 #endif // CHROME_BROWSER_EXTENSIONS_API_OMNIBOX_OMNIBOX_API_H_ 180 #endif // CHROME_BROWSER_EXTENSIONS_API_OMNIBOX_OMNIBOX_API_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/omnibox/omnibox_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698