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

Side by Side Diff: chrome/renderer/searchbox/searchbox_extension.cc

Issue 11369137: Implement {Start,Stop}CapturingKeyStrokes for Instant. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Switch order in BIC. 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 #include "chrome/renderer/searchbox/searchbox_extension.h" 5 #include "chrome/renderer/searchbox/searchbox_extension.h"
6 6
7 #include "base/string_number_conversions.h" 7 #include "base/string_number_conversions.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "chrome/common/extensions/extension.h" 9 #include "chrome/common/extensions/extension.h"
10 #include "chrome/renderer/searchbox/searchbox.h" 10 #include "chrome/renderer/searchbox/searchbox.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 // Sets the search box text, completely replacing what the user typed. 241 // Sets the search box text, completely replacing what the user typed.
242 static v8::Handle<v8::Value> SetQuery(const v8::Arguments& args); 242 static v8::Handle<v8::Value> SetQuery(const v8::Arguments& args);
243 243
244 // Like |SetQuery| but uses a restricted ID to identify the text. 244 // Like |SetQuery| but uses a restricted ID to identify the text.
245 static v8::Handle<v8::Value> SetQueryFromAutocompleteResult( 245 static v8::Handle<v8::Value> SetQueryFromAutocompleteResult(
246 const v8::Arguments& args); 246 const v8::Arguments& args);
247 247
248 // Requests the preview be shown with the specified contents and height. 248 // Requests the preview be shown with the specified contents and height.
249 static v8::Handle<v8::Value> Show(const v8::Arguments& args); 249 static v8::Handle<v8::Value> Show(const v8::Arguments& args);
250 250
251 // Start capturing user key strokes.
252 static v8::Handle<v8::Value> StartCapturingKeyStrokes(
253 const v8::Arguments& args);
254
255 // Stop capturing user key strokes.
256 static v8::Handle<v8::Value> StopCapturingKeyStrokes(
257 const v8::Arguments& args);
258
251 private: 259 private:
252 DISALLOW_COPY_AND_ASSIGN(SearchBoxExtensionWrapper); 260 DISALLOW_COPY_AND_ASSIGN(SearchBoxExtensionWrapper);
253 }; 261 };
254 262
255 SearchBoxExtensionWrapper::SearchBoxExtensionWrapper( 263 SearchBoxExtensionWrapper::SearchBoxExtensionWrapper(
256 const base::StringPiece& code) 264 const base::StringPiece& code)
257 : v8::Extension(kSearchBoxExtensionName, code.data(), 0, 0, code.size()) { 265 : v8::Extension(kSearchBoxExtensionName, code.data(), 0, 0, code.size()) {
258 } 266 }
259 267
260 v8::Handle<v8::FunctionTemplate> SearchBoxExtensionWrapper::GetNativeFunction( 268 v8::Handle<v8::FunctionTemplate> SearchBoxExtensionWrapper::GetNativeFunction(
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 if (name->Equals(v8::String::New("SetQuerySuggestion"))) 300 if (name->Equals(v8::String::New("SetQuerySuggestion")))
293 return v8::FunctionTemplate::New(SetQuerySuggestion); 301 return v8::FunctionTemplate::New(SetQuerySuggestion);
294 if (name->Equals(v8::String::New("SetQuerySuggestionFromAutocompleteResult"))) 302 if (name->Equals(v8::String::New("SetQuerySuggestionFromAutocompleteResult")))
295 return v8::FunctionTemplate::New(SetQuerySuggestionFromAutocompleteResult); 303 return v8::FunctionTemplate::New(SetQuerySuggestionFromAutocompleteResult);
296 if (name->Equals(v8::String::New("SetQuery"))) 304 if (name->Equals(v8::String::New("SetQuery")))
297 return v8::FunctionTemplate::New(SetQuery); 305 return v8::FunctionTemplate::New(SetQuery);
298 if (name->Equals(v8::String::New("SetQueryFromAutocompleteResult"))) 306 if (name->Equals(v8::String::New("SetQueryFromAutocompleteResult")))
299 return v8::FunctionTemplate::New(SetQueryFromAutocompleteResult); 307 return v8::FunctionTemplate::New(SetQueryFromAutocompleteResult);
300 if (name->Equals(v8::String::New("Show"))) 308 if (name->Equals(v8::String::New("Show")))
301 return v8::FunctionTemplate::New(Show); 309 return v8::FunctionTemplate::New(Show);
310 if (name->Equals(v8::String::New("StartCapturingKeyStrokes")))
311 return v8::FunctionTemplate::New(StartCapturingKeyStrokes);
312 if (name->Equals(v8::String::New("StopCapturingKeyStrokes")))
313 return v8::FunctionTemplate::New(StopCapturingKeyStrokes);
302 return v8::Handle<v8::FunctionTemplate>(); 314 return v8::Handle<v8::FunctionTemplate>();
303 } 315 }
304 316
305 // static 317 // static
306 content::RenderView* SearchBoxExtensionWrapper::GetRenderView() { 318 content::RenderView* SearchBoxExtensionWrapper::GetRenderView() {
307 WebKit::WebFrame* webframe = WebKit::WebFrame::frameForCurrentContext(); 319 WebKit::WebFrame* webframe = WebKit::WebFrame::frameForCurrentContext();
308 if (!webframe) return NULL; 320 if (!webframe) return NULL;
309 321
310 WebKit::WebView* webview = webframe->view(); 322 WebKit::WebView* webview = webframe->view();
311 if (!webview) return NULL; // can happen during closing 323 if (!webview) return NULL; // can happen during closing
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 height = args[1]->Int32Value(); 741 height = args[1]->Int32Value();
730 units = INSTANT_SIZE_PIXELS; 742 units = INSTANT_SIZE_PIXELS;
731 } 743 }
732 744
733 SearchBox::Get(render_view)->ShowInstantPreview(reason, height, units); 745 SearchBox::Get(render_view)->ShowInstantPreview(reason, height, units);
734 746
735 return v8::Undefined(); 747 return v8::Undefined();
736 } 748 }
737 749
738 // static 750 // static
751 v8::Handle<v8::Value> SearchBoxExtensionWrapper::StartCapturingKeyStrokes(
752 const v8::Arguments& args) {
753 content::RenderView* render_view = GetRenderView();
754 if (render_view)
755 SearchBox::Get(render_view)->StartCapturingKeyStrokes();
756 return v8::Undefined();
757 }
758
759 // static
760 v8::Handle<v8::Value> SearchBoxExtensionWrapper::StopCapturingKeyStrokes(
761 const v8::Arguments& args) {
762 content::RenderView* render_view = GetRenderView();
763 if (render_view)
764 SearchBox::Get(render_view)->StopCapturingKeyStrokes();
765 return v8::Undefined();
766 }
767
768 // static
739 void SearchBoxExtension::DispatchChange(WebKit::WebFrame* frame) { 769 void SearchBoxExtension::DispatchChange(WebKit::WebFrame* frame) {
740 DVLOG(1) << "DispatchChange"; 770 DVLOG(1) << "DispatchChange";
741 Dispatch(frame, kDispatchChangeEventScript); 771 Dispatch(frame, kDispatchChangeEventScript);
742 } 772 }
743 773
744 // static 774 // static
745 void SearchBoxExtension::DispatchSubmit(WebKit::WebFrame* frame) { 775 void SearchBoxExtension::DispatchSubmit(WebKit::WebFrame* frame) {
746 Dispatch(frame, kDispatchSubmitEventScript); 776 Dispatch(frame, kDispatchSubmitEventScript);
747 } 777 }
748 778
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 Dispatch(frame, kDispatchThemeAreaHeightChangeEventScript); 835 Dispatch(frame, kDispatchThemeAreaHeightChangeEventScript);
806 } 836 }
807 837
808 // static 838 // static
809 v8::Extension* SearchBoxExtension::Get() { 839 v8::Extension* SearchBoxExtension::Get() {
810 return new SearchBoxExtensionWrapper(ResourceBundle::GetSharedInstance(). 840 return new SearchBoxExtensionWrapper(ResourceBundle::GetSharedInstance().
811 GetRawDataResource(IDR_SEARCHBOX_API)); 841 GetRawDataResource(IDR_SEARCHBOX_API));
812 } 842 }
813 843
814 } // namespace extensions_v8 844 } // namespace extensions_v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698