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

Unified Diff: chrome/renderer/searchbox/searchbox_extension.cc

Issue 11413217: Instant API: tell page whether the browser is capturing key strokes. (Closed) Base URL: http://git.chromium.org/chromium/src.git@focus
Patch Set: Finish renaming. Created 8 years, 1 month 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
Index: chrome/renderer/searchbox/searchbox_extension.cc
diff --git a/chrome/renderer/searchbox/searchbox_extension.cc b/chrome/renderer/searchbox/searchbox_extension.cc
index ee3f47af81115f30dee407c4742e29f9a6957bf5..a99d4a94c8697c66840adb901377563b6cdd47aa 100644
--- a/chrome/renderer/searchbox/searchbox_extension.cc
+++ b/chrome/renderer/searchbox/searchbox_extension.cc
@@ -131,6 +131,15 @@ static const char kDispatchUpOrDownKeyPressEventScript[] =
" true;"
"}";
+static const char kDispatchKeyCaptureChangeScript[] =
+ "if (window.chrome &&"
+ " window.chrome.searchBox &&"
+ " window.chrome.searchBox.onkeycapturechange &&"
+ " typeof window.chrome.searchBox.onkeycapturechange == 'function') {"
+ " window.chrome.searchBox.onkeycapturechange();"
+ " true;"
+ "}";
+
static const char kDispatchContextChangeEventScript[] =
"if (window.chrome &&"
" window.chrome.searchBox &&"
@@ -220,6 +229,9 @@ class SearchBoxExtensionWrapper : public v8::Extension {
// "top".
static v8::Handle<v8::Value> GetThemeAreaHeight(const v8::Arguments& args);
+ // Gets whether the browser is capturing key strokes.
+ static v8::Handle<v8::Value> IsKeyCaptureEnabled(const v8::Arguments& args);
+
// Navigates the window to a URL represented by either a URL string or a
// restricted ID.
static v8::Handle<v8::Value> NavigateContentWindow(const v8::Arguments& args);
@@ -287,6 +299,8 @@ v8::Handle<v8::FunctionTemplate> SearchBoxExtensionWrapper::GetNativeFunction(
return v8::FunctionTemplate::New(GetThemeBackgroundInfo);
if (name->Equals(v8::String::New("GetThemeAreaHeight")))
return v8::FunctionTemplate::New(GetThemeAreaHeight);
+ if (name->Equals(v8::String::New("IsKeyCaptureEnabled")))
+ return v8::FunctionTemplate::New(IsKeyCaptureEnabled);
if (name->Equals(v8::String::New("NavigateContentWindow")))
return v8::FunctionTemplate::New(NavigateContentWindow);
if (name->Equals(v8::String::New("SetSuggestions")))
@@ -427,6 +441,16 @@ v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetAutocompleteResults(
}
// static
+v8::Handle<v8::Value> SearchBoxExtensionWrapper::IsKeyCaptureEnabled(
+ const v8::Arguments& args) {
+ content::RenderView* render_view = GetRenderView();
+ if (!render_view) return v8::Undefined();
+
+ return v8::Boolean::New(SearchBox::Get(render_view)->
+ is_key_capture_enabled());
+}
+
+// static
v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetContext(
const v8::Arguments& args) {
content::RenderView* render_view = GetRenderView();
@@ -805,6 +829,12 @@ void SearchBoxExtension::DispatchUpOrDownKeyPress(WebKit::WebFrame* frame,
}
// static
+void SearchBoxExtension::DispatchKeyCaptureChange(WebKit::WebFrame* frame) {
+ DVLOG(1) << "DispatchKeyCaptureChange";
+ Dispatch(frame, kDispatchKeyCaptureChangeScript);
+}
+
+// static
void SearchBoxExtension::DispatchContextChange(WebKit::WebFrame* frame) {
DVLOG(1) << "DispatchContextChange";
Dispatch(frame, kDispatchContextChangeEventScript);
« chrome/renderer/searchbox/searchbox.cc ('K') | « chrome/renderer/searchbox/searchbox_extension.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698