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

Side by Side Diff: chrome/browser/ui/search/instant_page.cc

Issue 12851023: Refactor omnibox focus API into a single method. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments. 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/browser/ui/search/instant_page.h" 5 #include "chrome/browser/ui/search/instant_page.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 "content/public/browser/web_contents.h" 9 #include "content/public/browser/web_contents.h"
10 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 154
155 bool InstantPage::OnMessageReceived(const IPC::Message& message) { 155 bool InstantPage::OnMessageReceived(const IPC::Message& message) {
156 bool handled = true; 156 bool handled = true;
157 IPC_BEGIN_MESSAGE_MAP(InstantPage, message) 157 IPC_BEGIN_MESSAGE_MAP(InstantPage, message)
158 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetSuggestions, OnSetSuggestions) 158 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetSuggestions, OnSetSuggestions)
159 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_InstantSupportDetermined, 159 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_InstantSupportDetermined,
160 OnInstantSupportDetermined) 160 OnInstantSupportDetermined)
161 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ShowInstantOverlay, 161 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ShowInstantOverlay,
162 OnShowInstantOverlay) 162 OnShowInstantOverlay)
163 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FocusOmnibox, OnFocusOmnibox) 163 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FocusOmnibox, OnFocusOmnibox)
164 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_StartCapturingKeyStrokes,
165 OnStartCapturingKeyStrokes);
166 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_StopCapturingKeyStrokes,
167 OnStopCapturingKeyStrokes);
168 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxNavigate, 164 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxNavigate,
169 OnSearchBoxNavigate); 165 OnSearchBoxNavigate);
170 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem, 166 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem,
171 OnDeleteMostVisitedItem); 167 OnDeleteMostVisitedItem);
172 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion, 168 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion,
173 OnUndoMostVisitedDeletion); 169 OnUndoMostVisitedDeletion);
174 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions, 170 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions,
175 OnUndoAllMostVisitedDeletions); 171 OnUndoAllMostVisitedDeletions);
176 IPC_MESSAGE_UNHANDLED(handled = false) 172 IPC_MESSAGE_UNHANDLED(handled = false)
177 IPC_END_MESSAGE_MAP() 173 IPC_END_MESSAGE_MAP()
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 void InstantPage::OnShowInstantOverlay(int page_id, 217 void InstantPage::OnShowInstantOverlay(int page_id,
222 int height, 218 int height,
223 InstantSizeUnits units) { 219 InstantSizeUnits units) {
224 if (contents()->IsActiveEntry(page_id)) { 220 if (contents()->IsActiveEntry(page_id)) {
225 OnInstantSupportDetermined(page_id, true); 221 OnInstantSupportDetermined(page_id, true);
226 if (ShouldProcessShowInstantOverlay()) 222 if (ShouldProcessShowInstantOverlay())
227 delegate_->ShowInstantOverlay(contents(), height, units); 223 delegate_->ShowInstantOverlay(contents(), height, units);
228 } 224 }
229 } 225 }
230 226
231 void InstantPage::OnFocusOmnibox(int page_id) { 227 void InstantPage::OnFocusOmnibox(int page_id, OmniboxFocusState state) {
232 if (contents()->IsActiveEntry(page_id)) { 228 if (contents()->IsActiveEntry(page_id)) {
233 OnInstantSupportDetermined(page_id, true); 229 OnInstantSupportDetermined(page_id, true);
234 if (ShouldProcessFocusOmnibox()) 230 delegate_->FocusOmnibox(contents(), state);
sreeram 2013/04/01 16:04:38 Keep the ShouldProcessFocusOmnibox() check, like s
kmadhusu 2013/04/02 02:06:50 Done. Removed the other Should*() functions.
235 delegate_->FocusOmnibox(contents());
236 } 231 }
237 } 232 }
238 233
239 void InstantPage::OnStartCapturingKeyStrokes(int page_id) {
240 if (contents()->IsActiveEntry(page_id)) {
241 OnInstantSupportDetermined(page_id, true);
242 if (ShouldProcessStartCapturingKeyStrokes())
243 delegate_->StartCapturingKeyStrokes(contents());
244 }
245 }
246
247 void InstantPage::OnStopCapturingKeyStrokes(int page_id) {
248 if (contents()->IsActiveEntry(page_id)) {
249 OnInstantSupportDetermined(page_id, true);
250 if (ShouldProcessStopCapturingKeyStrokes())
251 delegate_->StopCapturingKeyStrokes(contents());
252 }
253 }
254
255 void InstantPage::OnSearchBoxNavigate(int page_id, 234 void InstantPage::OnSearchBoxNavigate(int page_id,
256 const GURL& url, 235 const GURL& url,
257 content::PageTransition transition, 236 content::PageTransition transition,
258 WindowOpenDisposition disposition) { 237 WindowOpenDisposition disposition) {
259 if (contents()->IsActiveEntry(page_id)) { 238 if (contents()->IsActiveEntry(page_id)) {
260 OnInstantSupportDetermined(page_id, true); 239 OnInstantSupportDetermined(page_id, true);
261 if (ShouldProcessNavigateToURL()) 240 if (ShouldProcessNavigateToURL())
262 delegate_->NavigateToURL(contents(), url, transition, disposition); 241 delegate_->NavigateToURL(contents(), url, transition, disposition);
263 } 242 }
264 } 243 }
265 244
266 void InstantPage::OnDeleteMostVisitedItem(InstantRestrictedID restricted_id) { 245 void InstantPage::OnDeleteMostVisitedItem(InstantRestrictedID restricted_id) {
267 delegate_->DeleteMostVisitedItem(restricted_id); 246 delegate_->DeleteMostVisitedItem(restricted_id);
268 } 247 }
269 248
270 void InstantPage::OnUndoMostVisitedDeletion(InstantRestrictedID restricted_id) { 249 void InstantPage::OnUndoMostVisitedDeletion(InstantRestrictedID restricted_id) {
271 delegate_->UndoMostVisitedDeletion(restricted_id); 250 delegate_->UndoMostVisitedDeletion(restricted_id);
272 } 251 }
273 252
274 void InstantPage::OnUndoAllMostVisitedDeletions() { 253 void InstantPage::OnUndoAllMostVisitedDeletions() {
275 delegate_->UndoAllMostVisitedDeletions(); 254 delegate_->UndoAllMostVisitedDeletions();
276 } 255 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698