diff options
author | dcarney@chromium.org <dcarney@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-11 15:50:24 +0000 |
---|---|---|
committer | dcarney@chromium.org <dcarney@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-11 15:50:24 +0000 |
commit | 6f7f189c213d9ce83785b22415c3e38c8e7d09d0 (patch) | |
tree | d996a3d364505a98420ba170abe9b88019c67d92 | |
parent | d83eec2aa6132c3f389a0426661dc84bdd9908b7 (diff) | |
download | chromium_src-6f7f189c213d9ce83785b22415c3e38c8e7d09d0.zip chromium_src-6f7f189c213d9ce83785b22415c3e38c8e7d09d0.tar.gz chromium_src-6f7f189c213d9ce83785b22415c3e38c8e7d09d0.tar.bz2 |
convert searchbox_extension to new style v8 callbacks
R=jochen@chromium.org
BUG=243656
Review URL: https://chromiumcodereview.appspot.com/16693007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@205553 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/renderer/searchbox/searchbox_extension.cc | 427 |
1 files changed, 211 insertions, 216 deletions
diff --git a/chrome/renderer/searchbox/searchbox_extension.cc b/chrome/renderer/searchbox/searchbox_extension.cc index 285390e..683827f6 100644 --- a/chrome/renderer/searchbox/searchbox_extension.cc +++ b/chrome/renderer/searchbox/searchbox_extension.cc @@ -484,137 +484,145 @@ class SearchBoxExtensionWrapper : public v8::Extension { static content::RenderView* GetRenderView(); // Deletes a Most Visited item. - static v8::Handle<v8::Value> DeleteMostVisitedItem(const v8::Arguments& args); + static void DeleteMostVisitedItem( + const v8::FunctionCallbackInfo<v8::Value>& args); // Gets the value of the user's search query. - static v8::Handle<v8::Value> GetQuery(const v8::Arguments& args); + static void GetQuery(const v8::FunctionCallbackInfo<v8::Value>& args); // Gets whether the |value| should be considered final -- as opposed to a // partial match. This may be set if the user clicks a suggestion, presses // forward delete, or in other cases where Chrome overrides. - static v8::Handle<v8::Value> GetVerbatim(const v8::Arguments& args); + static void GetVerbatim(const v8::FunctionCallbackInfo<v8::Value>& args); // Gets the start of the selection in the search box. - static v8::Handle<v8::Value> GetSelectionStart(const v8::Arguments& args); + static void GetSelectionStart( + const v8::FunctionCallbackInfo<v8::Value>& args); // Gets the end of the selection in the search box. - static v8::Handle<v8::Value> GetSelectionEnd(const v8::Arguments& args); + static void GetSelectionEnd(const v8::FunctionCallbackInfo<v8::Value>& args); // Gets the x coordinate (relative to |window|) of the left edge of the // region of the search box that overlaps the window. - static v8::Handle<v8::Value> GetX(const v8::Arguments& args); + static void GetX(const v8::FunctionCallbackInfo<v8::Value>& args); // Gets the y coordinate (relative to |window|) of the right edge of the // region of the search box that overlaps the window. - static v8::Handle<v8::Value> GetY(const v8::Arguments& args); + static void GetY(const v8::FunctionCallbackInfo<v8::Value>& args); // Gets the width of the region of the search box that overlaps the window, // i.e., the width of the omnibox. - static v8::Handle<v8::Value> GetWidth(const v8::Arguments& args); + static void GetWidth(const v8::FunctionCallbackInfo<v8::Value>& args); // Gets the height of the region of the search box that overlaps the window. - static v8::Handle<v8::Value> GetHeight(const v8::Arguments& args); + static void GetHeight(const v8::FunctionCallbackInfo<v8::Value>& args); // Gets Most Visited Items. - static v8::Handle<v8::Value> GetMostVisitedItems(const v8::Arguments& args); + static void GetMostVisitedItems( + const v8::FunctionCallbackInfo<v8::Value>& args); // Gets the start-edge margin to use with extended Instant. - static v8::Handle<v8::Value> GetStartMargin(const v8::Arguments& args); + static void GetStartMargin(const v8::FunctionCallbackInfo<v8::Value>& args); // Returns true if the Searchbox itself is oriented right-to-left. - static v8::Handle<v8::Value> GetRightToLeft(const v8::Arguments& args); + static void GetRightToLeft(const v8::FunctionCallbackInfo<v8::Value>& args); // Gets the autocomplete results from search box. - static v8::Handle<v8::Value> GetAutocompleteResults( - const v8::Arguments& args); + static void GetAutocompleteResults( + const v8::FunctionCallbackInfo<v8::Value>& args); // Gets whether to display Instant results. - static v8::Handle<v8::Value> GetDisplayInstantResults( - const v8::Arguments& args); + static void GetDisplayInstantResults( + const v8::FunctionCallbackInfo<v8::Value>& args); // Gets the background info of the theme currently adopted by browser. // Call only when overlay is showing NTP page. - static v8::Handle<v8::Value> GetThemeBackgroundInfo( - const v8::Arguments& args); + static void GetThemeBackgroundInfo( + const v8::FunctionCallbackInfo<v8::Value>& args); // Gets whether the browser is capturing key strokes. - static v8::Handle<v8::Value> IsKeyCaptureEnabled(const v8::Arguments& args); + static void IsKeyCaptureEnabled( + const v8::FunctionCallbackInfo<v8::Value>& args); // Gets the font family of the text in the omnibox. - static v8::Handle<v8::Value> GetFont(const v8::Arguments& args); + static void GetFont(const v8::FunctionCallbackInfo<v8::Value>& args); // Gets the font size of the text in the omnibox. - static v8::Handle<v8::Value> GetFontSize(const v8::Arguments& args); + static void GetFontSize(const v8::FunctionCallbackInfo<v8::Value>& args); // Navigates the window to a URL represented by either a URL string or a // restricted ID. The two variants handle restricted IDs in their // respective namespaces. - static v8::Handle<v8::Value> NavigateSearchBox(const v8::Arguments& args); - static v8::Handle<v8::Value> NavigateNewTabPage(const v8::Arguments& args); + static void NavigateSearchBox( + const v8::FunctionCallbackInfo<v8::Value>& args); + static void NavigateNewTabPage( + const v8::FunctionCallbackInfo<v8::Value>& args); // DEPRECATED: TODO(sreeram): Remove when google.com no longer uses this. - static v8::Handle<v8::Value> NavigateContentWindow(const v8::Arguments& args); + static void NavigateContentWindow( + const v8::FunctionCallbackInfo<v8::Value>& args); // Sets ordered suggestions. Valid for current |value|. - static v8::Handle<v8::Value> SetSuggestions(const v8::Arguments& args); + static void SetSuggestions(const v8::FunctionCallbackInfo<v8::Value>& args); // Sets the text to be autocompleted into the search box. - static v8::Handle<v8::Value> SetSuggestion(const v8::Arguments& args); + static void SetSuggestion(const v8::FunctionCallbackInfo<v8::Value>& args); // Like SetSuggestion() but uses a restricted autocomplete result ID to // identify the text. - static v8::Handle<v8::Value> SetSuggestionFromAutocompleteResult( - const v8::Arguments& args); + static void SetSuggestionFromAutocompleteResult( + const v8::FunctionCallbackInfo<v8::Value>& args); // Sets the search box text, completely replacing what the user typed. - static v8::Handle<v8::Value> SetQuery(const v8::Arguments& args); + static void SetQuery(const v8::FunctionCallbackInfo<v8::Value>& args); // Like |SetQuery| but uses a restricted autocomplete result ID to identify // the text. - static v8::Handle<v8::Value> SetQueryFromAutocompleteResult( - const v8::Arguments& args); + static void SetQueryFromAutocompleteResult( + const v8::FunctionCallbackInfo<v8::Value>& args); // Requests the overlay be shown with the specified contents and height. - static v8::Handle<v8::Value> ShowOverlay(const v8::Arguments& args); + static void ShowOverlay(const v8::FunctionCallbackInfo<v8::Value>& args); // Sets the focus to the omnibox. - static v8::Handle<v8::Value> FocusOmnibox(const v8::Arguments& args); + static void FocusOmnibox(const v8::FunctionCallbackInfo<v8::Value>& args); // Start capturing user key strokes. - static v8::Handle<v8::Value> StartCapturingKeyStrokes( - const v8::Arguments& args); + static void StartCapturingKeyStrokes( + const v8::FunctionCallbackInfo<v8::Value>& args); // Stop capturing user key strokes. - static v8::Handle<v8::Value> StopCapturingKeyStrokes( - const v8::Arguments& args); + static void StopCapturingKeyStrokes( + const v8::FunctionCallbackInfo<v8::Value>& args); // Undoes the deletion of all Most Visited itens. - static v8::Handle<v8::Value> UndoAllMostVisitedDeletions( - const v8::Arguments& args); + static void UndoAllMostVisitedDeletions( + const v8::FunctionCallbackInfo<v8::Value>& args); // Undoes the deletion of a Most Visited item. - static v8::Handle<v8::Value> UndoMostVisitedDeletion( - const v8::Arguments& args); + static void UndoMostVisitedDeletion( + const v8::FunctionCallbackInfo<v8::Value>& args); // Shows any attached bars. - static v8::Handle<v8::Value> ShowBars(const v8::Arguments& args); + static void ShowBars(const v8::FunctionCallbackInfo<v8::Value>& args); // Hides any attached bars. When the bars are hidden, the "onbarshidden" // event is fired to notify the page. - static v8::Handle<v8::Value> HideBars(const v8::Arguments& args); + static void HideBars(const v8::FunctionCallbackInfo<v8::Value>& args); // Gets the raw data for a suggestion including its content. // GetRenderViewWithCheckedOrigin() enforces that only code in the origin // chrome-search://suggestion can call this function. - static v8::Handle<v8::Value> GetSuggestionData(const v8::Arguments& args); + static void GetSuggestionData( + const v8::FunctionCallbackInfo<v8::Value>& args); // Gets the raw data for a most visited item including its raw URL. // GetRenderViewWithCheckedOrigin() enforces that only code in the origin // chrome-search://most-visited can call this function. - static v8::Handle<v8::Value> GetMostVisitedItemData( - const v8::Arguments& args); + static void GetMostVisitedItemData( + const v8::FunctionCallbackInfo<v8::Value>& args); // Gets whether the omnibox has focus or not. - static v8::Handle<v8::Value> IsFocused(const v8::Arguments& args); + static void IsFocused(const v8::FunctionCallbackInfo<v8::Value>& args); private: DISALLOW_COPY_AND_ASSIGN(SearchBoxExtensionWrapper); @@ -716,110 +724,117 @@ content::RenderView* SearchBoxExtensionWrapper::GetRenderView() { } // static -v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetQuery( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::GetQuery( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderView(); - if (!render_view) return v8::Undefined(); + if (!render_view) return; DVLOG(1) << render_view << " GetQuery request"; if (SearchBox::Get(render_view)->query_is_restricted()) { DVLOG(1) << render_view << " Query text marked as restricted."; - return v8::Undefined(); + return; } const string16& query = SearchBox::Get(render_view)->query(); if (internal::IsSensitiveInput(query)) { DVLOG(1) << render_view << " Query text is sensitive."; - return v8::Undefined(); + return; } DVLOG(1) << render_view << " GetQuery: '" << query << "'"; - return UTF16ToV8String(query); + args.GetReturnValue().Set(UTF16ToV8String(query)); } // static -v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetVerbatim( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::GetVerbatim( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderView(); - if (!render_view) return v8::Undefined(); + if (!render_view) return; DVLOG(1) << render_view << " GetVerbatim: " << SearchBox::Get(render_view)->verbatim(); - return v8::Boolean::New(SearchBox::Get(render_view)->verbatim()); + args.GetReturnValue().Set(SearchBox::Get(render_view)->verbatim()); } // static -v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetSelectionStart( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::GetSelectionStart( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderView(); - if (!render_view) return v8::Undefined(); + if (!render_view) return; - return v8::Uint32::New(SearchBox::Get(render_view)->selection_start()); + args.GetReturnValue().Set(static_cast<uint32_t>( + SearchBox::Get(render_view)->selection_start())); } // static -v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetSelectionEnd( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::GetSelectionEnd( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderView(); - if (!render_view) return v8::Undefined(); + if (!render_view) return; - return v8::Uint32::New(SearchBox::Get(render_view)->selection_end()); + args.GetReturnValue().Set(static_cast<uint32_t>( + SearchBox::Get(render_view)->selection_end())); } // static -v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetX( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::GetX( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderView(); - if (!render_view) return v8::Undefined(); + if (!render_view) return; - return v8::Int32::New(SearchBox::Get(render_view)->GetPopupBounds().x()); + args.GetReturnValue().Set(static_cast<int32_t>( + SearchBox::Get(render_view)->GetPopupBounds().x())); } // static -v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetY( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::GetY( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderView(); - if (!render_view) return v8::Undefined(); + if (!render_view) return; - return v8::Int32::New(SearchBox::Get(render_view)->GetPopupBounds().y()); + args.GetReturnValue().Set(static_cast<int32_t>( + SearchBox::Get(render_view)->GetPopupBounds().y())); } // static -v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetWidth( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::GetWidth( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderView(); - if (!render_view) return v8::Undefined(); - return v8::Int32::New(SearchBox::Get(render_view)->GetPopupBounds().width()); + if (!render_view) return; + args.GetReturnValue().Set(static_cast<int32_t>( + SearchBox::Get(render_view)->GetPopupBounds().width())); } // static -v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetHeight( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::GetHeight( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderView(); - if (!render_view) return v8::Undefined(); + if (!render_view) return; - return v8::Int32::New(SearchBox::Get(render_view)->GetPopupBounds().height()); + args.GetReturnValue().Set(static_cast<int32_t>( + SearchBox::Get(render_view)->GetPopupBounds().height())); } // static -v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetStartMargin( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::GetStartMargin( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderView(); - if (!render_view) return v8::Undefined(); - return v8::Int32::New(SearchBox::Get(render_view)->GetStartMargin()); + if (!render_view) return; + args.GetReturnValue().Set(static_cast<int32_t>( + SearchBox::Get(render_view)->GetStartMargin())); } // static -v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetRightToLeft( - const v8::Arguments& args) { - return v8::Boolean::New(base::i18n::IsRTL()); +void SearchBoxExtensionWrapper::GetRightToLeft( + const v8::FunctionCallbackInfo<v8::Value>& args) { + args.GetReturnValue().Set(base::i18n::IsRTL()); } // static -v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetAutocompleteResults( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::GetAutocompleteResults( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderView(); - if (!render_view) return v8::Undefined(); + if (!render_view) return; std::vector<InstantAutocompleteResultIDPair> results; SearchBox::Get(render_view)->GetAutocompleteResults(&results); @@ -833,37 +848,37 @@ v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetAutocompleteResults( results[i].first, results[i].second)); } - return results_array; + args.GetReturnValue().Set(results_array); } // static -v8::Handle<v8::Value> SearchBoxExtensionWrapper::IsKeyCaptureEnabled( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::IsKeyCaptureEnabled( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderView(); - if (!render_view) return v8::Undefined(); + if (!render_view) return; - return v8::Boolean::New(SearchBox::Get(render_view)-> - is_key_capture_enabled()); + args.GetReturnValue().Set(SearchBox::Get(render_view)-> + is_key_capture_enabled()); } // static -v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetDisplayInstantResults( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::GetDisplayInstantResults( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderView(); - if (!render_view) return v8::Undefined(); + if (!render_view) return; bool display_instant_results = SearchBox::Get(render_view)->display_instant_results(); DVLOG(1) << render_view << " " << "GetDisplayInstantResults: " << display_instant_results; - return v8::Boolean::New(display_instant_results); + args.GetReturnValue().Set(display_instant_results); } // static -v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetThemeBackgroundInfo( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::GetThemeBackgroundInfo( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderView(); - if (!render_view) return v8::Undefined(); + if (!render_view) return; DVLOG(1) << render_view << " GetThemeBackgroundInfo"; const ThemeBackgroundInfo& theme_info = @@ -958,32 +973,34 @@ v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetThemeBackgroundInfo( } } - return info; + args.GetReturnValue().Set(info); } // static -v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetFont( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::GetFont( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderView(); - if (!render_view) return v8::Undefined(); + if (!render_view) return; - return UTF16ToV8String(SearchBox::Get(render_view)->omnibox_font()); + args.GetReturnValue().Set( + UTF16ToV8String(SearchBox::Get(render_view)->omnibox_font())); } // static -v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetFontSize( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::GetFontSize( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderView(); - if (!render_view) return v8::Undefined(); + if (!render_view) return; - return v8::Uint32::New(SearchBox::Get(render_view)->omnibox_font_size()); + args.GetReturnValue().Set(static_cast<uint32_t>( + SearchBox::Get(render_view)->omnibox_font_size())); } // static -v8::Handle<v8::Value> SearchBoxExtensionWrapper::NavigateSearchBox( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::NavigateSearchBox( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderView(); - if (!render_view || !args.Length()) return v8::Undefined(); + if (!render_view || !args.Length()) return; GURL destination_url; content::PageTransition transition = content::PAGE_TRANSITION_TYPED; @@ -1013,15 +1030,13 @@ v8::Handle<v8::Value> SearchBoxExtensionWrapper::NavigateSearchBox( SearchBox::Get(render_view)->NavigateToURL( destination_url, transition, disposition, is_search_type); } - - return v8::Undefined(); } // static -v8::Handle<v8::Value> SearchBoxExtensionWrapper::NavigateNewTabPage( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::NavigateNewTabPage( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderView(); - if (!render_view || !args.Length()) return v8::Undefined(); + if (!render_view || !args.Length()) return; GURL destination_url; content::PageTransition transition = content::PAGE_TRANSITION_AUTO_BOOKMARK; @@ -1048,14 +1063,13 @@ v8::Handle<v8::Value> SearchBoxExtensionWrapper::NavigateNewTabPage( SearchBox::Get(render_view)->NavigateToURL( destination_url, transition, disposition, false); } - return v8::Undefined(); } // static -v8::Handle<v8::Value> SearchBoxExtensionWrapper::NavigateContentWindow( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::NavigateContentWindow( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderView(); - if (!render_view || !args.Length()) return v8::Undefined(); + if (!render_view || !args.Length()) return; DVLOG(1) << render_view << " NavigateContentWindow; query=" << SearchBox::Get(render_view)->query(); @@ -1065,16 +1079,18 @@ v8::Handle<v8::Value> SearchBoxExtensionWrapper::NavigateContentWindow( // be non-blank, or it would be blank due to SetQueryFromAutocompleteResult() // but verbatim would be true. if (SearchBox::Get(render_view)->query().empty() && - !SearchBox::Get(render_view)->verbatim()) - return NavigateNewTabPage(args); - return NavigateSearchBox(args); + !SearchBox::Get(render_view)->verbatim()) { + NavigateNewTabPage(args); + return; + } + NavigateSearchBox(args); } // static -v8::Handle<v8::Value> SearchBoxExtensionWrapper::SetSuggestions( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::SetSuggestions( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderView(); - if (!render_view || !args.Length()) return v8::Undefined(); + if (!render_view || !args.Length()) return; SearchBox* search_box = SearchBox::Get(render_view); DVLOG(1) << render_view << " SetSuggestions"; @@ -1108,15 +1124,13 @@ v8::Handle<v8::Value> SearchBoxExtensionWrapper::SetSuggestions( } search_box->SetSuggestions(suggestions); - - return v8::Undefined(); } // static -v8::Handle<v8::Value> SearchBoxExtensionWrapper::SetSuggestion( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::SetSuggestion( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderView(); - if (!render_view || args.Length() < 2) return v8::Undefined(); + if (!render_view || args.Length() < 2) return; string16 text = V8ValueToUTF16(args[0]); DVLOG(1) << render_view << " SetSuggestion: " << text; @@ -1135,22 +1149,19 @@ v8::Handle<v8::Value> SearchBoxExtensionWrapper::SetSuggestion( InstantSuggestion(text, behavior, type, search_box->query(), kNoMatchIndex)); search_box->SetSuggestions(suggestions); - - return v8::Undefined(); } // static -v8::Handle<v8::Value> - SearchBoxExtensionWrapper::SetSuggestionFromAutocompleteResult( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::SetSuggestionFromAutocompleteResult( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderView(); - if (!render_view || !args.Length()) return v8::Undefined(); + if (!render_view || !args.Length()) return; DVLOG(1) << render_view << " SetSuggestionFromAutocompleteResult"; InstantAutocompleteResult result; if (!SearchBox::Get(render_view)->GetAutocompleteResultWithID( args[0]->IntegerValue(), &result)) { - return v8::Undefined(); + return; } // We only support selecting autocomplete results that are URLs. @@ -1164,15 +1175,13 @@ v8::Handle<v8::Value> InstantSuggestion(text, behavior, type, search_box->query(), kNoMatchIndex)); search_box->SetSuggestions(suggestions); - - return v8::Undefined(); } // static -v8::Handle<v8::Value> SearchBoxExtensionWrapper::SetQuery( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::SetQuery( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderView(); - if (!render_view || args.Length() < 2) return v8::Undefined(); + if (!render_view || args.Length() < 2) return; DVLOG(1) << render_view << " SetQuery"; string16 text = V8ValueToUTF16(args[0]); @@ -1188,21 +1197,18 @@ v8::Handle<v8::Value> SearchBoxExtensionWrapper::SetQuery( InstantSuggestion(text, behavior, type, search_box->query(), kNoMatchIndex)); search_box->SetSuggestions(suggestions); - - return v8::Undefined(); } -v8::Handle<v8::Value> - SearchBoxExtensionWrapper::SetQueryFromAutocompleteResult( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::SetQueryFromAutocompleteResult( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderView(); - if (!render_view || !args.Length()) return v8::Undefined(); + if (!render_view || !args.Length()) return; DVLOG(1) << render_view << " SetQueryFromAutocompleteResult"; InstantAutocompleteResult result; if (!SearchBox::Get(render_view)->GetAutocompleteResultWithID( args[0]->IntegerValue(), &result)) { - return v8::Undefined(); + return; } SearchBox* search_box = SearchBox::Get(render_view); @@ -1227,15 +1233,13 @@ v8::Handle<v8::Value> search_box->SetSuggestions(suggestions); search_box->MarkQueryAsRestricted(); - - return v8::Undefined(); } // static -v8::Handle<v8::Value> SearchBoxExtensionWrapper::ShowOverlay( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::ShowOverlay( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderView(); - if (!render_view || args.Length() < 1) return v8::Undefined(); + if (!render_view || args.Length() < 1) return; int height = 100; InstantSizeUnits units = INSTANT_SIZE_PERCENT; @@ -1246,16 +1250,14 @@ v8::Handle<v8::Value> SearchBoxExtensionWrapper::ShowOverlay( DVLOG(1) << render_view << " ShowOverlay: " << height << "/" << units; SearchBox::Get(render_view)->ShowInstantOverlay(height, units); - - return v8::Undefined(); } // static -v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetMostVisitedItems( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::GetMostVisitedItems( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderView(); if (!render_view) - return v8::Undefined(); + return; DVLOG(1) << render_view << " GetMostVisitedItems"; const SearchBox* search_box = SearchBox::Get(render_view); @@ -1268,74 +1270,67 @@ v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetMostVisitedItems( instant_mv_items[i].first, instant_mv_items[i].second)); } - return v8_mv_items; + args.GetReturnValue().Set(v8_mv_items); } // static -v8::Handle<v8::Value> SearchBoxExtensionWrapper::DeleteMostVisitedItem( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::DeleteMostVisitedItem( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderView(); - if (!render_view || !args.Length()) return v8::Undefined(); + if (!render_view || !args.Length()) return; DVLOG(1) << render_view << " DeleteMostVisitedItem"; SearchBox::Get(render_view)->DeleteMostVisitedItem(args[0]->IntegerValue()); - return v8::Undefined(); } // static -v8::Handle<v8::Value> SearchBoxExtensionWrapper::UndoMostVisitedDeletion( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::UndoMostVisitedDeletion( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderView(); - if (!render_view || !args.Length()) return v8::Undefined(); + if (!render_view || !args.Length()) return; DVLOG(1) << render_view << " UndoMostVisitedDeletion"; SearchBox::Get(render_view)->UndoMostVisitedDeletion(args[0]->IntegerValue()); - return v8::Undefined(); } // static -v8::Handle<v8::Value> SearchBoxExtensionWrapper::UndoAllMostVisitedDeletions( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::UndoAllMostVisitedDeletions( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderView(); - if (!render_view) return v8::Undefined(); + if (!render_view) return; DVLOG(1) << render_view << " UndoAllMostVisitedDeletions"; SearchBox::Get(render_view)->UndoAllMostVisitedDeletions(); - return v8::Undefined(); } // static -v8::Handle<v8::Value> SearchBoxExtensionWrapper::FocusOmnibox( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::FocusOmnibox( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderView(); - if (!render_view) return v8::Undefined(); + if (!render_view) return; DVLOG(1) << render_view << " FocusOmnibox"; SearchBox::Get(render_view)->FocusOmnibox(); - - return v8::Undefined(); } // static -v8::Handle<v8::Value> SearchBoxExtensionWrapper::StartCapturingKeyStrokes( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::StartCapturingKeyStrokes( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderView(); - if (!render_view) return v8::Undefined(); + if (!render_view) return; DVLOG(1) << render_view << " StartCapturingKeyStrokes"; SearchBox::Get(render_view)->StartCapturingKeyStrokes(); - return v8::Undefined(); } // static -v8::Handle<v8::Value> SearchBoxExtensionWrapper::StopCapturingKeyStrokes( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::StopCapturingKeyStrokes( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderView(); - if (!render_view) return v8::Undefined(); + if (!render_view) return; DVLOG(1) << render_view << " StopCapturingKeyStrokes"; SearchBox::Get(render_view)->StopCapturingKeyStrokes(); - return v8::Undefined(); } // static @@ -1353,80 +1348,80 @@ bool SearchBoxExtension::PageSupportsInstant(WebKit::WebFrame* frame) { return !v.IsEmpty() && v->BooleanValue(); } -v8::Handle<v8::Value> SearchBoxExtensionWrapper::ShowBars( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::ShowBars( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderView(); - if (!render_view) return v8::Undefined(); + if (!render_view) return; DVLOG(1) << render_view << " ShowBars"; SearchBox::Get(render_view)->ShowBars(); - return v8::Undefined(); } // static -v8::Handle<v8::Value> SearchBoxExtensionWrapper::HideBars( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::HideBars( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderView(); - if (!render_view) return v8::Undefined(); + if (!render_view) return; DVLOG(1) << render_view << " HideBars"; SearchBox::Get(render_view)->HideBars(); - return v8::Undefined(); } // static -v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetSuggestionData( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::GetSuggestionData( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderViewWithCheckedOrigin( GURL(chrome::kChromeSearchSuggestionUrl)); - if (!render_view) return v8::Undefined(); + if (!render_view) return; // Need an rid argument. if (args.Length() < 1 || !args[0]->IsNumber()) - return v8::Undefined(); + return; DVLOG(1) << render_view << " GetSuggestionData"; InstantRestrictedID restricted_id = args[0]->IntegerValue(); InstantAutocompleteResult result; if (!SearchBox::Get(render_view)->GetAutocompleteResultWithID( restricted_id, &result)) { - return v8::Undefined(); + return; } const string16& query = SearchBox::Get(render_view)->query(); - return GenerateNativeSuggestion(query, restricted_id, result); + args.GetReturnValue().Set( + GenerateNativeSuggestion(query, restricted_id, result)); } // static -v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetMostVisitedItemData( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::GetMostVisitedItemData( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderViewWithCheckedOrigin( GURL(chrome::kChromeSearchMostVisitedUrl)); - if (!render_view) return v8::Undefined(); + if (!render_view) return; // Need an rid argument. if (args.Length() < 1 || !args[0]->IsNumber()) - return v8::Undefined(); + return; DVLOG(1) << render_view << " GetMostVisitedItem"; InstantRestrictedID restricted_id = args[0]->IntegerValue(); InstantMostVisitedItem mv_item; if (!SearchBox::Get(render_view)->GetMostVisitedItemWithID( restricted_id, &mv_item)) { - return v8::Undefined(); + return; } - return GenerateMostVisitedItem(render_view->GetRoutingID(), restricted_id, - mv_item); + args.GetReturnValue().Set( + GenerateMostVisitedItem(render_view->GetRoutingID(), restricted_id, + mv_item)); } // static -v8::Handle<v8::Value> SearchBoxExtensionWrapper::IsFocused( - const v8::Arguments& args) { +void SearchBoxExtensionWrapper::IsFocused( + const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* render_view = GetRenderView(); - if (!render_view) return v8::Undefined(); + if (!render_view) return; bool is_focused = SearchBox::Get(render_view)->is_focused(); DVLOG(1) << render_view << " IsFocused: " << is_focused; - return v8::Boolean::New(is_focused); + args.GetReturnValue().Set(is_focused); } // static |