Index: chrome/renderer/searchbox/searchbox_extension.cc |
diff --git a/chrome/renderer/searchbox/searchbox_extension.cc b/chrome/renderer/searchbox/searchbox_extension.cc |
index affffd80e3398df765e95ca66bc0754365975457..cec0a3e59c2e1920487405d5a84d2c0cbbf4adbb 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(); |
@@ -800,6 +824,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); |