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

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

Issue 12631008: alternate ntp: implement Show/HideBars API to reduce jank when showing/hiding bars (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
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"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 string16 url = RestrictedIdToURL(restrict_id); 94 string16 url = RestrictedIdToURL(restrict_id);
95 render_view()->Send(new ChromeViewHostMsg_InstantUndoMostVisitedDeletion( 95 render_view()->Send(new ChromeViewHostMsg_InstantUndoMostVisitedDeletion(
96 render_view()->GetRoutingID(), GURL(url))); 96 render_view()->GetRoutingID(), GURL(url)));
97 } 97 }
98 98
99 void SearchBox::UndoAllMostVisitedDeletions() { 99 void SearchBox::UndoAllMostVisitedDeletions() {
100 render_view()->Send(new ChromeViewHostMsg_InstantUndoAllMostVisitedDeletions( 100 render_view()->Send(new ChromeViewHostMsg_InstantUndoAllMostVisitedDeletions(
101 render_view()->GetRoutingID())); 101 render_view()->GetRoutingID()));
102 } 102 }
103 103
104 void SearchBox::ShowBars() {
105 DVLOG(1) << render_view() << " ShowBars";
106 render_view()->Send(new ChromeViewHostMsg_SearchBoxShowBars(
107 render_view()->GetRoutingID(), render_view()->GetPageId()));
108 }
109
110 void SearchBox::HideBars() {
111 DVLOG(1) << render_view() << " HideBars";
112 render_view()->Send(new ChromeViewHostMsg_SearchBoxHideBars(
113 render_view()->GetRoutingID(), render_view()->GetPageId()));
114 }
115
104 int SearchBox::GetStartMargin() const { 116 int SearchBox::GetStartMargin() const {
105 return static_cast<int>(start_margin_ / GetZoom()); 117 return static_cast<int>(start_margin_ / GetZoom());
106 } 118 }
107 119
108 gfx::Rect SearchBox::GetPopupBounds() const { 120 gfx::Rect SearchBox::GetPopupBounds() const {
109 double zoom = GetZoom(); 121 double zoom = GetZoom();
110 return gfx::Rect(static_cast<int>(popup_bounds_.x() / zoom), 122 return gfx::Rect(static_cast<int>(popup_bounds_.x() / zoom),
111 static_cast<int>(popup_bounds_.y() / zoom), 123 static_cast<int>(popup_bounds_.y() / zoom),
112 static_cast<int>(popup_bounds_.width() / zoom), 124 static_cast<int>(popup_bounds_.width() / zoom),
113 static_cast<int>(popup_bounds_.height() / zoom)); 125 static_cast<int>(popup_bounds_.height() / zoom));
(...skipping 22 matching lines...) Expand all
136 } 148 }
137 149
138 bool SearchBox::OnMessageReceived(const IPC::Message& message) { 150 bool SearchBox::OnMessageReceived(const IPC::Message& message) {
139 bool handled = true; 151 bool handled = true;
140 IPC_BEGIN_MESSAGE_MAP(SearchBox, message) 152 IPC_BEGIN_MESSAGE_MAP(SearchBox, message)
141 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxChange, OnChange) 153 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxChange, OnChange)
142 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSubmit, OnSubmit) 154 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSubmit, OnSubmit)
143 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxCancel, OnCancel) 155 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxCancel, OnCancel)
144 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxPopupResize, OnPopupResize) 156 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxPopupResize, OnPopupResize)
145 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxMarginChange, OnMarginChange) 157 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxMarginChange, OnMarginChange)
158 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxBarsHidden, OnBarsHidden)
dhollowa 2013/03/08 00:03:32 The lack of symmetry here seems a bit strange...
kuan 2013/03/12 18:00:38 it doesn't seem to be needed, at least not yet :)
146 IPC_MESSAGE_HANDLER(ChromeViewMsg_DetermineIfPageSupportsInstant, 159 IPC_MESSAGE_HANDLER(ChromeViewMsg_DetermineIfPageSupportsInstant,
147 OnDetermineIfPageSupportsInstant) 160 OnDetermineIfPageSupportsInstant)
148 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxAutocompleteResults, 161 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxAutocompleteResults,
149 OnAutocompleteResults) 162 OnAutocompleteResults)
150 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxUpOrDownKeyPressed, 163 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxUpOrDownKeyPressed,
151 OnUpOrDownKeyPressed) 164 OnUpOrDownKeyPressed)
152 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxCancelSelection, 165 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxCancelSelection,
153 OnCancelSelection) 166 OnCancelSelection)
154 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSetDisplayInstantResults, 167 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSetDisplayInstantResults,
155 OnSetDisplayInstantResults) 168 OnSetDisplayInstantResults)
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 239
227 // Override only the width parameter of the popup bounds. 240 // Override only the width parameter of the popup bounds.
228 popup_bounds_.set_width(width); 241 popup_bounds_.set_width(width);
229 242
230 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { 243 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) {
231 extensions_v8::SearchBoxExtension::DispatchMarginChange( 244 extensions_v8::SearchBoxExtension::DispatchMarginChange(
232 render_view()->GetWebView()->mainFrame()); 245 render_view()->GetWebView()->mainFrame());
233 } 246 }
234 } 247 }
235 248
249 void SearchBox::OnBarsHidden() {
250 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) {
251 extensions_v8::SearchBoxExtension::DispatchBarsHidden(
252 render_view()->GetWebView()->mainFrame());
253 }
254 }
255
236 void SearchBox::OnDetermineIfPageSupportsInstant() { 256 void SearchBox::OnDetermineIfPageSupportsInstant() {
237 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { 257 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) {
238 bool result = extensions_v8::SearchBoxExtension::PageSupportsInstant( 258 bool result = extensions_v8::SearchBoxExtension::PageSupportsInstant(
239 render_view()->GetWebView()->mainFrame()); 259 render_view()->GetWebView()->mainFrame());
240 DVLOG(1) << render_view() << " PageSupportsInstant: " << result; 260 DVLOG(1) << render_view() << " PageSupportsInstant: " << result;
241 render_view()->Send(new ChromeViewHostMsg_InstantSupportDetermined( 261 render_view()->Send(new ChromeViewHostMsg_InstantSupportDetermined(
242 render_view()->GetRoutingID(), render_view()->GetPageId(), result)); 262 render_view()->GetRoutingID(), render_view()->GetPageId(), result));
243 } 263 }
244 } 264 }
245 265
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 GURL url = GURL(ostr.str()); 404 GURL url = GURL(ostr.str());
385 return UTF8ToUTF16(url.spec()); 405 return UTF8ToUTF16(url.spec());
386 } 406 }
387 407
388 string16 SearchBox::GenerateFaviconUrl(int id) { 408 string16 SearchBox::GenerateFaviconUrl(int id) {
389 std::ostringstream ostr; 409 std::ostringstream ostr;
390 ostr << kFaviconUrlPrefix << id; 410 ostr << kFaviconUrlPrefix << id;
391 GURL url = GURL(ostr.str()); 411 GURL url = GURL(ostr.str());
392 return UTF8ToUTF16(url.spec()); 412 return UTF8ToUTF16(url.spec());
393 } 413 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698