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

Unified Diff: chrome/browser/extensions/extension_omnibox_api.cc

Issue 2807033: Add support for omnibox.onInputStarted and onInputCancelled. (Closed)
Patch Set: fix Stop Created 10 years, 6 months 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/browser/extensions/extension_omnibox_api.h ('k') | chrome/browser/extensions/extensions_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_omnibox_api.cc
diff --git a/chrome/browser/extensions/extension_omnibox_api.cc b/chrome/browser/extensions/extension_omnibox_api.cc
index 5c046a37dd7f8629679e4b88a98aac1b74803808..2f3f8f1061c9244c379bcd4059136f560711c164 100644
--- a/chrome/browser/extensions/extension_omnibox_api.cc
+++ b/chrome/browser/extensions/extension_omnibox_api.cc
@@ -12,8 +12,10 @@
#include "chrome/common/notification_service.h"
namespace events {
-const char kOnInputChanged[] = "experimental.omnibox.onInputChanged/";
-const char kOnInputEntered[] = "experimental.omnibox.onInputEntered/";
+const char kOnInputStarted[] = "experimental.omnibox.onInputStarted";
+const char kOnInputChanged[] = "experimental.omnibox.onInputChanged";
+const char kOnInputEntered[] = "experimental.omnibox.onInputEntered";
+const char kOnInputCancelled[] = "experimental.omnibox.onInputCancelled";
}; // namespace events
namespace {
@@ -31,10 +33,19 @@ const wchar_t kDescriptionStylesOffset[] = L"offset";
}; // namespace
// static
+void ExtensionOmniboxEventRouter::OnInputStarted(
+ Profile* profile, const std::string& extension_id) {
+ profile->GetExtensionMessageService()->DispatchEventToExtension(
+ extension_id, events::kOnInputStarted, "[]", profile->IsOffTheRecord(),
+ GURL());
+}
+
+// static
bool ExtensionOmniboxEventRouter::OnInputChanged(
Profile* profile, const std::string& extension_id,
const std::string& input, int suggest_id) {
- std::string event_name = events::kOnInputChanged + extension_id;
+ std::string event_name = ExtensionMessageService::GetPerExtensionEventName(
+ events::kOnInputChanged, extension_id);
if (!profile->GetExtensionMessageService()->HasEventListener(event_name))
return false;
@@ -44,8 +55,9 @@ bool ExtensionOmniboxEventRouter::OnInputChanged(
std::string json_args;
base::JSONWriter::Write(&args, false, &json_args);
- profile->GetExtensionMessageService()->DispatchEventToRenderers(
- event_name, json_args, profile->IsOffTheRecord(), GURL());
+ profile->GetExtensionMessageService()->DispatchEventToExtension(
+ extension_id, events::kOnInputChanged, json_args,
+ profile->IsOffTheRecord(), GURL());
return true;
}
@@ -60,8 +72,21 @@ void ExtensionOmniboxEventRouter::OnInputEntered(
std::string json_args;
base::JSONWriter::Write(&args, false, &json_args);
- profile->GetExtensionMessageService()->DispatchEventToRenderers(
- event_name, json_args, profile->IsOffTheRecord(), GURL());
+ profile->GetExtensionMessageService()->DispatchEventToExtension(
+ extension_id, events::kOnInputEntered, json_args,
+ profile->IsOffTheRecord(), GURL());
+
+ NotificationService::current()->Notify(
+ NotificationType::EXTENSION_OMNIBOX_INPUT_ENTERED,
+ Source<Profile>(profile), NotificationService::NoDetails());
+}
+
+// static
+void ExtensionOmniboxEventRouter::OnInputCancelled(
+ Profile* profile, const std::string& extension_id) {
+ profile->GetExtensionMessageService()->DispatchEventToExtension(
+ extension_id, events::kOnInputCancelled, "[]", profile->IsOffTheRecord(),
+ GURL());
}
bool OmniboxSendSuggestionsFunction::RunImpl() {
« no previous file with comments | « chrome/browser/extensions/extension_omnibox_api.h ('k') | chrome/browser/extensions/extensions_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698