OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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.h" | 5 #include "chrome/renderer/searchbox.h" |
6 | 6 |
7 #include "chrome/common/render_messages.h" | 7 #include "chrome/common/render_messages.h" |
8 #include "chrome/renderer/searchbox_extension.h" | 8 #include "chrome/renderer/searchbox_extension.h" |
9 #include "content/public/renderer/render_view.h" | 9 #include "content/public/renderer/render_view.h" |
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
11 | 11 |
12 using WebKit::WebView; | 12 using WebKit::WebView; |
13 | 13 |
14 SearchBox::SearchBox(content::RenderView* render_view) | 14 SearchBox::SearchBox(content::RenderView* render_view) |
15 : content::RenderViewObserver(render_view), | 15 : content::RenderViewObserver(render_view), |
16 content::RenderViewObserverTracker<SearchBox>(render_view), | 16 content::RenderViewObserverTracker<SearchBox>(render_view), |
17 verbatim_(false), | 17 verbatim_(false), |
18 selection_start_(0), | 18 selection_start_(0), |
19 selection_end_(0) { | 19 selection_end_(0) { |
20 } | 20 } |
21 | 21 |
22 SearchBox::~SearchBox() { | 22 SearchBox::~SearchBox() { |
23 } | 23 } |
24 | 24 |
25 void SearchBox::SetSuggestions(const std::vector<std::string>& suggestions, | 25 void SearchBox::SetSuggestions(const std::vector<std::string>& suggestions, |
26 InstantCompleteBehavior behavior) { | 26 InstantCompleteBehavior behavior) { |
27 // Explicitly allow empty vector to be sent to the browser. | 27 // Explicitly allow empty vector to be sent to the browser. |
28 render_view()->Send(new ChromeViewHostMsg_SetSuggestions( | 28 render_view()->Send(new ChromeViewHostMsg_SetSuggestions( |
29 render_view()->GetRoutingId(), render_view()->GetPageId(), suggestions, | 29 render_view()->GetRoutingID(), render_view()->GetPageId(), suggestions, |
30 behavior)); | 30 behavior)); |
31 } | 31 } |
32 | 32 |
33 gfx::Rect SearchBox::GetRect() { | 33 gfx::Rect SearchBox::GetRect() { |
34 // Need to adjust for scale. | 34 // Need to adjust for scale. |
35 if (rect_.IsEmpty()) | 35 if (rect_.IsEmpty()) |
36 return rect_; | 36 return rect_; |
37 WebView* web_view = render_view()->GetWebView(); | 37 WebView* web_view = render_view()->GetWebView(); |
38 if (!web_view) | 38 if (!web_view) |
39 return rect_; | 39 return rect_; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 bool verbatim, | 105 bool verbatim, |
106 int selection_start, | 106 int selection_start, |
107 int selection_end) { | 107 int selection_end) { |
108 value_ = value; | 108 value_ = value; |
109 verbatim_ = verbatim; | 109 verbatim_ = verbatim; |
110 selection_start_ = selection_start; | 110 selection_start_ = selection_start; |
111 selection_end_ = selection_end; | 111 selection_end_ = selection_end; |
112 bool result = extensions_v8::SearchBoxExtension::PageSupportsInstant( | 112 bool result = extensions_v8::SearchBoxExtension::PageSupportsInstant( |
113 render_view()->GetWebView()->mainFrame()); | 113 render_view()->GetWebView()->mainFrame()); |
114 render_view()->Send(new ChromeViewHostMsg_InstantSupportDetermined( | 114 render_view()->Send(new ChromeViewHostMsg_InstantSupportDetermined( |
115 render_view()->GetRoutingId(), render_view()->GetPageId(), result)); | 115 render_view()->GetRoutingID(), render_view()->GetPageId(), result)); |
116 } | 116 } |
117 | 117 |
118 void SearchBox::Reset() { | 118 void SearchBox::Reset() { |
119 verbatim_ = false; | 119 verbatim_ = false; |
120 value_ = string16(); | 120 value_ = string16(); |
121 selection_start_ = selection_end_ = 0; | 121 selection_start_ = selection_end_ = 0; |
122 rect_ = gfx::Rect(); | 122 rect_ = gfx::Rect(); |
123 } | 123 } |
OLD | NEW |