| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/renderer/render_view.h" | 9 #include "content/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(RenderView* render_view) | 14 SearchBox::SearchBox(RenderView* render_view) |
| 15 : RenderViewObserver(render_view), | 15 : RenderViewObserver(render_view), |
| 16 RenderViewObserverTracker<SearchBox>(render_view), | 16 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 ViewHostMsg_SetSuggestions( | 28 render_view()->Send(new ChromeViewHostMsg_SetSuggestions( |
| 29 render_view()->routing_id(), render_view()->page_id(), suggestions, | 29 render_view()->routing_id(), render_view()->page_id(), suggestions, |
| 30 behavior)); | 30 behavior)); |
| 31 } | 31 } |
| 32 | 32 |
| 33 bool SearchBox::OnMessageReceived(const IPC::Message& message) { | 33 bool SearchBox::OnMessageReceived(const IPC::Message& message) { |
| 34 bool handled = true; | 34 bool handled = true; |
| 35 IPC_BEGIN_MESSAGE_MAP(SearchBox, message) | 35 IPC_BEGIN_MESSAGE_MAP(SearchBox, message) |
| 36 IPC_MESSAGE_HANDLER(ViewMsg_SearchBoxChange, OnChange) | 36 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxChange, OnChange) |
| 37 IPC_MESSAGE_HANDLER(ViewMsg_SearchBoxSubmit, OnSubmit) | 37 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSubmit, OnSubmit) |
| 38 IPC_MESSAGE_HANDLER(ViewMsg_SearchBoxCancel, OnCancel) | 38 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxCancel, OnCancel) |
| 39 IPC_MESSAGE_HANDLER(ViewMsg_SearchBoxResize, OnResize) | 39 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxResize, OnResize) |
| 40 IPC_MESSAGE_HANDLER(ViewMsg_DetermineIfPageSupportsInstant, | 40 IPC_MESSAGE_HANDLER(ChromeViewMsg_DetermineIfPageSupportsInstant, |
| 41 OnDetermineIfPageSupportsInstant) | 41 OnDetermineIfPageSupportsInstant) |
| 42 IPC_MESSAGE_UNHANDLED(handled = false) | 42 IPC_MESSAGE_UNHANDLED(handled = false) |
| 43 IPC_END_MESSAGE_MAP() | 43 IPC_END_MESSAGE_MAP() |
| 44 return handled; | 44 return handled; |
| 45 } | 45 } |
| 46 | 46 |
| 47 void SearchBox::OnChange(const string16& value, | 47 void SearchBox::OnChange(const string16& value, |
| 48 bool verbatim, | 48 bool verbatim, |
| 49 int selection_start, | 49 int selection_start, |
| 50 int selection_end) { | 50 int selection_end) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 void SearchBox::OnDetermineIfPageSupportsInstant(const string16& value, | 88 void SearchBox::OnDetermineIfPageSupportsInstant(const string16& value, |
| 89 bool verbatim, | 89 bool verbatim, |
| 90 int selection_start, | 90 int selection_start, |
| 91 int selection_end) { | 91 int selection_end) { |
| 92 value_ = value; | 92 value_ = value; |
| 93 verbatim_ = verbatim; | 93 verbatim_ = verbatim; |
| 94 selection_start_ = selection_start; | 94 selection_start_ = selection_start; |
| 95 selection_end_ = selection_end; | 95 selection_end_ = selection_end; |
| 96 bool result = extensions_v8::SearchBoxExtension::PageSupportsInstant( | 96 bool result = extensions_v8::SearchBoxExtension::PageSupportsInstant( |
| 97 render_view()->webview()->mainFrame()); | 97 render_view()->webview()->mainFrame()); |
| 98 render_view()->Send(new ViewHostMsg_InstantSupportDetermined( | 98 render_view()->Send(new ChromeViewHostMsg_InstantSupportDetermined( |
| 99 render_view()->routing_id(), render_view()->page_id(), result)); | 99 render_view()->routing_id(), render_view()->page_id(), result)); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void SearchBox::Reset() { | 102 void SearchBox::Reset() { |
| 103 verbatim_ = false; | 103 verbatim_ = false; |
| 104 value_ = string16(); | 104 value_ = string16(); |
| 105 selection_start_ = selection_end_ = 0; | 105 selection_start_ = selection_end_ = 0; |
| 106 rect_ = gfx::Rect(); | 106 rect_ = gfx::Rect(); |
| 107 } | 107 } |
| OLD | NEW |