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

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

Issue 12319108: Prevent querying of restricted query values. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months 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 | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/searchbox/searchbox.h ('k') | chrome/renderer/searchbox/searchbox_extension.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.h" 5 #include "chrome/renderer/searchbox/searchbox.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/common/render_messages.h" 8 #include "chrome/common/render_messages.h"
9 #include "chrome/common/url_constants.h" 9 #include "chrome/common/url_constants.h"
10 #include "chrome/renderer/searchbox/searchbox_extension.h" 10 #include "chrome/renderer/searchbox/searchbox_extension.h"
11 #include "content/public/renderer/render_view.h" 11 #include "content/public/renderer/render_view.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
14 14
15 SearchBox::SearchBox(content::RenderView* render_view) 15 SearchBox::SearchBox(content::RenderView* render_view)
16 : content::RenderViewObserver(render_view), 16 : content::RenderViewObserver(render_view),
17 content::RenderViewObserverTracker<SearchBox>(render_view), 17 content::RenderViewObserverTracker<SearchBox>(render_view),
18 verbatim_(false), 18 verbatim_(false),
19 selection_start_(0), 19 selection_start_(0),
20 selection_end_(0), 20 selection_end_(0),
21 results_base_(0), 21 results_base_(0),
22 start_margin_(0), 22 start_margin_(0),
23 last_results_base_(0), 23 last_results_base_(0),
24 is_key_capture_enabled_(false), 24 is_key_capture_enabled_(false),
25 display_instant_results_(false), 25 display_instant_results_(false),
26 omnibox_font_size_(0) { 26 omnibox_font_size_(0),
27 last_restricted_id_(0) {
27 } 28 }
28 29
29 SearchBox::~SearchBox() { 30 SearchBox::~SearchBox() {
30 } 31 }
31 32
32 void SearchBox::SetSuggestions( 33 void SearchBox::SetSuggestions(
33 const std::vector<InstantSuggestion>& suggestions) { 34 const std::vector<InstantSuggestion>& suggestions) {
34 if (!suggestions.empty() && 35 if (!suggestions.empty() &&
35 suggestions[0].behavior == INSTANT_COMPLETE_REPLACE) { 36 suggestions[0].behavior == INSTANT_COMPLETE_REPLACE) {
36 query_ = suggestions[0].text; 37 query_ = suggestions[0].text;
37 verbatim_ = true; 38 verbatim_ = true;
38 selection_start_ = selection_end_ = query_.size(); 39 selection_start_ = selection_end_ = query_.size();
39 } 40 }
40 // Explicitly allow empty vector to be sent to the browser. 41 // Explicitly allow empty vector to be sent to the browser.
41 render_view()->Send(new ChromeViewHostMsg_SetSuggestions( 42 render_view()->Send(new ChromeViewHostMsg_SetSuggestions(
42 render_view()->GetRoutingID(), render_view()->GetPageId(), suggestions)); 43 render_view()->GetRoutingID(), render_view()->GetPageId(), suggestions));
43 } 44 }
44 45
46 void SearchBox::ClearQuery() {
47 query_.clear();
48 }
49
45 void SearchBox::ShowInstantOverlay(InstantShownReason reason, 50 void SearchBox::ShowInstantOverlay(InstantShownReason reason,
46 int height, 51 int height,
47 InstantSizeUnits units) { 52 InstantSizeUnits units) {
48 render_view()->Send(new ChromeViewHostMsg_ShowInstantOverlay( 53 render_view()->Send(new ChromeViewHostMsg_ShowInstantOverlay(
49 render_view()->GetRoutingID(), render_view()->GetPageId(), reason, 54 render_view()->GetRoutingID(), render_view()->GetPageId(), reason,
50 height, units)); 55 height, units));
51 } 56 }
52 57
53 void SearchBox::FocusOmnibox() { 58 void SearchBox::FocusOmnibox() {
54 render_view()->Send(new ChromeViewHostMsg_FocusOmnibox( 59 render_view()->Send(new ChromeViewHostMsg_FocusOmnibox(
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { 351 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) {
347 extensions_v8::SearchBoxExtension::DispatchMostVisitedChanged( 352 extensions_v8::SearchBoxExtension::DispatchMostVisitedChanged(
348 render_view()->GetWebView()->mainFrame()); 353 render_view()->GetWebView()->mainFrame());
349 } 354 }
350 } 355 }
351 356
352 const std::vector<InstantMostVisitedItem>& 357 const std::vector<InstantMostVisitedItem>&
353 SearchBox::GetMostVisitedItems() const { 358 SearchBox::GetMostVisitedItems() const {
354 return most_visited_items_; 359 return most_visited_items_;
355 } 360 }
OLDNEW
« no previous file with comments | « chrome/renderer/searchbox/searchbox.h ('k') | chrome/renderer/searchbox/searchbox_extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698