Chromium Code Reviews| 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..890c3432ff5112b0c7af5c0a68e97a3a6338495e 100644 |
| --- a/chrome/renderer/searchbox/searchbox_extension.cc |
| +++ b/chrome/renderer/searchbox/searchbox_extension.cc |
| @@ -131,6 +131,17 @@ static const char kDispatchUpOrDownKeyPressEventScript[] = |
| " true;" |
| "}"; |
| +static const char kDispatchKeyStrokeCapturingModeChangeScript[] = |
| + "if (window.chrome &&" |
| + " window.chrome.searchBox &&" |
| + " window.chrome.searchBox.onkeystrokecapturingmodechange &&" |
| + " typeof window.chrome.searchBox.onkeystrokecapturingmodechange == " |
| + " 'function') {" |
| + " for (var i = 0; i < %d; ++i)" |
| + " window.chrome.searchBox.onkeystrokecapturingmodechange();" |
| + " true;" |
| + "}"; |
| + |
| static const char kDispatchContextChangeEventScript[] = |
| "if (window.chrome &&" |
| " window.chrome.searchBox &&" |
| @@ -205,6 +216,10 @@ class SearchBoxExtensionWrapper : public v8::Extension { |
| static v8::Handle<v8::Value> GetAutocompleteResults( |
| const v8::Arguments& args); |
| + // Gets whether the browser is capturing key strokes. |
| + static v8::Handle<v8::Value> GetIsCapturingKeyStrokes( |
|
Jered
2012/11/28 17:50:16
GetIsCapturingKeyStrokes -> IsKeyCaptureEnabled.
samarth
2012/11/28 19:33:09
Done.
|
| + const v8::Arguments& args); |
| + |
| // Gets the current session context. |
| static v8::Handle<v8::Value> GetContext(const v8::Arguments& args); |
| @@ -281,6 +296,8 @@ v8::Handle<v8::FunctionTemplate> SearchBoxExtensionWrapper::GetNativeFunction( |
| return v8::FunctionTemplate::New(GetHeight); |
| if (name->Equals(v8::String::New("GetAutocompleteResults"))) |
| return v8::FunctionTemplate::New(GetAutocompleteResults); |
| + if (name->Equals(v8::String::New("GetIsCapturingKeyStrokes"))) |
| + return v8::FunctionTemplate::New(GetIsCapturingKeyStrokes); |
| if (name->Equals(v8::String::New("GetContext"))) |
| return v8::FunctionTemplate::New(GetContext); |
| if (name->Equals(v8::String::New("GetThemeBackgroundInfo"))) |
| @@ -427,6 +444,15 @@ v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetAutocompleteResults( |
| } |
| // static |
| +v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetIsCapturingKeyStrokes( |
| + const v8::Arguments& args) { |
| + content::RenderView* render_view = GetRenderView(); |
| + if (!render_view) return v8::Undefined(); |
| + |
| + return v8::Boolean::New(SearchBox::Get(render_view)->capturing_key_strokes()); |
| +} |
| + |
| +// static |
| v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetContext( |
| const v8::Arguments& args) { |
| content::RenderView* render_view = GetRenderView(); |
| @@ -805,6 +831,13 @@ void SearchBoxExtension::DispatchUpOrDownKeyPress(WebKit::WebFrame* frame, |
| } |
| // static |
| +void SearchBoxExtension::DispatchKeyStrokeCapturingModeChange( |
| + WebKit::WebFrame* frame) { |
| + DVLOG(1) << "DispatchKeyStrokeCapturingModeChange"; |
| + Dispatch(frame, kDispatchKeyStrokeCapturingModeChangeScript); |
| +} |
| + |
| +// static |
| void SearchBoxExtension::DispatchContextChange(WebKit::WebFrame* frame) { |
| DVLOG(1) << "DispatchContextChange"; |
| Dispatch(frame, kDispatchContextChangeEventScript); |