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

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

Issue 12047107: Change the SearchBox API from using the start/end margins of the location bar to using the start ma… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync to r180728 Created 7 years, 10 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
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 "chrome/common/render_messages.h" 7 #include "chrome/common/render_messages.h"
8 #include "chrome/renderer/searchbox/searchbox_extension.h" 8 #include "chrome/renderer/searchbox/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 SearchBox::SearchBox(content::RenderView* render_view) 12 SearchBox::SearchBox(content::RenderView* render_view)
13 : content::RenderViewObserver(render_view), 13 : content::RenderViewObserver(render_view),
14 content::RenderViewObserverTracker<SearchBox>(render_view), 14 content::RenderViewObserverTracker<SearchBox>(render_view),
15 verbatim_(false), 15 verbatim_(false),
16 selection_start_(0), 16 selection_start_(0),
17 selection_end_(0), 17 selection_end_(0),
18 results_base_(0), 18 results_base_(0),
19 start_margin_(0), 19 location_bar_margin_(0),
20 end_margin_(0), 20 location_bar_width_(0),
21 last_results_base_(0), 21 last_results_base_(0),
22 is_key_capture_enabled_(false), 22 is_key_capture_enabled_(false),
23 theme_area_height_(0), 23 theme_area_height_(0),
24 display_instant_results_(false), 24 display_instant_results_(false),
25 omnibox_font_size_(0) { 25 omnibox_font_size_(0) {
26 } 26 }
27 27
28 SearchBox::~SearchBox() { 28 SearchBox::~SearchBox() {
29 } 29 }
30 30
(...skipping 28 matching lines...) Expand all
59 render_view()->GetRoutingID(), render_view()->GetPageId())); 59 render_view()->GetRoutingID(), render_view()->GetPageId()));
60 } 60 }
61 61
62 void SearchBox::NavigateToURL(const GURL& url, 62 void SearchBox::NavigateToURL(const GURL& url,
63 content::PageTransition transition) { 63 content::PageTransition transition) {
64 render_view()->Send(new ChromeViewHostMsg_SearchBoxNavigate( 64 render_view()->Send(new ChromeViewHostMsg_SearchBoxNavigate(
65 render_view()->GetRoutingID(), render_view()->GetPageId(), 65 render_view()->GetRoutingID(), render_view()->GetPageId(),
66 url, transition)); 66 url, transition));
67 } 67 }
68 68
69 int SearchBox::GetStartMargin() const { 69 int SearchBox::GetLocationBarMargin() const {
70 return static_cast<int>(start_margin_ / GetZoom()); 70 return static_cast<int>(location_bar_margin_ / GetZoom());
71 } 71 }
72 72
73 int SearchBox::GetEndMargin() const { 73 int SearchBox::GetLocationBarWidth() const {
74 return static_cast<int>(end_margin_ / GetZoom()); 74 return static_cast<int>(location_bar_width_ / GetZoom());
75 } 75 }
76 76
77 gfx::Rect SearchBox::GetPopupBounds() const { 77 gfx::Rect SearchBox::GetPopupBounds() const {
78 double zoom = GetZoom(); 78 double zoom = GetZoom();
79 return gfx::Rect(static_cast<int>(popup_bounds_.x() / zoom), 79 return gfx::Rect(static_cast<int>(popup_bounds_.x() / zoom),
80 static_cast<int>(popup_bounds_.y() / zoom), 80 static_cast<int>(popup_bounds_.y() / zoom),
81 static_cast<int>(popup_bounds_.width() / zoom), 81 static_cast<int>(popup_bounds_.width() / zoom),
82 static_cast<int>(popup_bounds_.height() / zoom)); 82 static_cast<int>(popup_bounds_.height() / zoom));
83 } 83 }
84 84
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 184
185 void SearchBox::OnPopupResize(const gfx::Rect& bounds) { 185 void SearchBox::OnPopupResize(const gfx::Rect& bounds) {
186 popup_bounds_ = bounds; 186 popup_bounds_ = bounds;
187 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { 187 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) {
188 DVLOG(1) << render_view() << " OnPopupResize"; 188 DVLOG(1) << render_view() << " OnPopupResize";
189 extensions_v8::SearchBoxExtension::DispatchResize( 189 extensions_v8::SearchBoxExtension::DispatchResize(
190 render_view()->GetWebView()->mainFrame()); 190 render_view()->GetWebView()->mainFrame());
191 } 191 }
192 } 192 }
193 193
194 void SearchBox::OnMarginChange(int start, int end) { 194 void SearchBox::OnMarginChange(int margin, int width) {
195 start_margin_ = start; 195 location_bar_margin_ = margin;
196 end_margin_ = end; 196 location_bar_width_ = width;
197 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { 197 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) {
198 extensions_v8::SearchBoxExtension::DispatchMarginChange( 198 extensions_v8::SearchBoxExtension::DispatchMarginChange(
199 render_view()->GetWebView()->mainFrame()); 199 render_view()->GetWebView()->mainFrame());
200 } 200 }
201 } 201 }
202 202
203 void SearchBox::OnDetermineIfPageSupportsInstant() { 203 void SearchBox::OnDetermineIfPageSupportsInstant() {
204 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { 204 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) {
205 bool result = extensions_v8::SearchBoxExtension::PageSupportsInstant( 205 bool result = extensions_v8::SearchBoxExtension::PageSupportsInstant(
206 render_view()->GetWebView()->mainFrame()); 206 render_view()->GetWebView()->mainFrame());
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 omnibox_font_size_ = omnibox_font_size; 284 omnibox_font_size_ = omnibox_font_size;
285 } 285 }
286 286
287 void SearchBox::Reset() { 287 void SearchBox::Reset() {
288 query_.clear(); 288 query_.clear();
289 verbatim_ = false; 289 verbatim_ = false;
290 selection_start_ = 0; 290 selection_start_ = 0;
291 selection_end_ = 0; 291 selection_end_ = 0;
292 results_base_ = 0; 292 results_base_ = 0;
293 popup_bounds_ = gfx::Rect(); 293 popup_bounds_ = gfx::Rect();
294 start_margin_ = 0; 294 location_bar_margin_ = 0;
295 end_margin_ = 0; 295 location_bar_width_ = 0;
296 autocomplete_results_.clear(); 296 autocomplete_results_.clear();
297 is_key_capture_enabled_ = false; 297 is_key_capture_enabled_ = false;
298 mode_ = chrome::search::Mode(); 298 mode_ = chrome::search::Mode();
299 theme_info_ = ThemeBackgroundInfo(); 299 theme_info_ = ThemeBackgroundInfo();
300 theme_area_height_ = 0; 300 theme_area_height_ = 0;
301 // Don't reset display_instant_results_ to prevent clearing it on committed 301 // Don't reset display_instant_results_ to prevent clearing it on committed
302 // results pages in extended mode. Otherwise resetting it is a no-op because 302 // results pages in extended mode. Otherwise resetting it is a no-op because
303 // a new loader is created when it changes; see crbug.com/164662. 303 // a new loader is created when it changes; see crbug.com/164662.
304 // Also don't reset omnibox_font_ or omnibox_font_size_ since it never 304 // Also don't reset omnibox_font_ or omnibox_font_size_ since it never
305 // changes. 305 // changes.
306 } 306 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698