Index: chrome/renderer/searchbox.cc |
diff --git a/chrome/renderer/searchbox.cc b/chrome/renderer/searchbox.cc |
index fc9ee55fc5289d61af8bc23993b92feb40a73711..a662713700c73019f9d535d4aeb35e3a77104c28 100644 |
--- a/chrome/renderer/searchbox.cc |
+++ b/chrome/renderer/searchbox.cc |
@@ -9,8 +9,6 @@ |
#include "content/public/renderer/render_view.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
-using WebKit::WebView; |
- |
SearchBox::SearchBox(content::RenderView* render_view) |
: content::RenderViewObserver(render_view), |
content::RenderViewObserverTracker<SearchBox>(render_view), |
@@ -22,7 +20,7 @@ SearchBox::SearchBox(content::RenderView* render_view) |
SearchBox::~SearchBox() { |
} |
-void SearchBox::SetSuggestions(const std::vector<std::string>& suggestions, |
+void SearchBox::SetSuggestions(const std::vector<string16>& suggestions, |
InstantCompleteBehavior behavior) { |
// Explicitly allow empty vector to be sent to the browser. |
render_view()->Send(new ChromeViewHostMsg_SetSuggestions( |
@@ -34,10 +32,10 @@ gfx::Rect SearchBox::GetRect() { |
// Need to adjust for scale. |
if (rect_.IsEmpty()) |
return rect_; |
- WebView* web_view = render_view()->GetWebView(); |
+ WebKit::WebView* web_view = render_view()->GetWebView(); |
if (!web_view) |
return rect_; |
- double zoom = WebView::zoomLevelToZoomFactor(web_view->zoomLevel()); |
+ double zoom = WebKit::WebView::zoomLevelToZoomFactor(web_view->zoomLevel()); |
if (zoom == 0) |
return rect_; |
return gfx::Rect(static_cast<int>(static_cast<float>(rect_.x()) / zoom), |
@@ -62,21 +60,22 @@ bool SearchBox::OnMessageReceived(const IPC::Message& message) { |
void SearchBox::OnChange(const string16& value, |
bool verbatim, |
- int selection_start, |
- int selection_end) { |
+ size_t selection_start, |
+ size_t selection_end) { |
value_ = value; |
verbatim_ = verbatim; |
selection_start_ = selection_start; |
selection_end_ = selection_end; |
- if (!render_view()->GetWebView() || !render_view()->GetWebView()->mainFrame()) |
- return; |
- extensions_v8::SearchBoxExtension::DispatchChange( |
- render_view()->GetWebView()->mainFrame()); |
+ if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { |
+ extensions_v8::SearchBoxExtension::DispatchChange( |
+ render_view()->GetWebView()->mainFrame()); |
+ } |
} |
-void SearchBox::OnSubmit(const string16& value, bool verbatim) { |
+void SearchBox::OnSubmit(const string16& value) { |
value_ = value; |
- verbatim_ = verbatim; |
+ verbatim_ = true; |
+ selection_start_ = selection_end_ = value_.size(); |
if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { |
extensions_v8::SearchBoxExtension::DispatchSubmit( |
render_view()->GetWebView()->mainFrame()); |
@@ -84,8 +83,10 @@ void SearchBox::OnSubmit(const string16& value, bool verbatim) { |
Reset(); |
} |
-void SearchBox::OnCancel() { |
- verbatim_ = false; |
+void SearchBox::OnCancel(const string16& value) { |
+ value_ = value; |
+ verbatim_ = true; |
+ selection_start_ = selection_end_ = value_.size(); |
if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { |
extensions_v8::SearchBoxExtension::DispatchCancel( |
render_view()->GetWebView()->mainFrame()); |
@@ -95,29 +96,24 @@ void SearchBox::OnCancel() { |
void SearchBox::OnResize(const gfx::Rect& bounds) { |
rect_ = bounds; |
- if (!render_view()->GetWebView() || !render_view()->GetWebView()->mainFrame()) |
- return; |
- extensions_v8::SearchBoxExtension::DispatchResize( |
- render_view()->GetWebView()->mainFrame()); |
+ if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { |
+ extensions_v8::SearchBoxExtension::DispatchResize( |
+ render_view()->GetWebView()->mainFrame()); |
+ } |
} |
-void SearchBox::OnDetermineIfPageSupportsInstant(const string16& value, |
- bool verbatim, |
- int selection_start, |
- int selection_end) { |
- value_ = value; |
- verbatim_ = verbatim; |
- selection_start_ = selection_start; |
- selection_end_ = selection_end; |
- bool result = extensions_v8::SearchBoxExtension::PageSupportsInstant( |
- render_view()->GetWebView()->mainFrame()); |
- render_view()->Send(new ChromeViewHostMsg_InstantSupportDetermined( |
- render_view()->GetRoutingID(), render_view()->GetPageId(), result)); |
+void SearchBox::OnDetermineIfPageSupportsInstant() { |
+ if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { |
+ bool result = extensions_v8::SearchBoxExtension::PageSupportsInstant( |
+ render_view()->GetWebView()->mainFrame()); |
+ render_view()->Send(new ChromeViewHostMsg_InstantSupportDetermined( |
+ render_view()->GetRoutingID(), render_view()->GetPageId(), result)); |
+ } |
} |
void SearchBox::Reset() { |
+ value_.clear(); |
verbatim_ = false; |
- value_ = string16(); |
selection_start_ = selection_end_ = 0; |
rect_ = gfx::Rect(); |
} |