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

Side by Side Diff: chrome/browser/omnibox_search_hint.cc

Issue 10810062: Moving common code into OmniboxView from OmniboxView* (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix final nits Created 8 years, 4 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/browser/omnibox_search_hint.h" 5 #include "chrome/browser/omnibox_search_hint.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 void OmniboxSearchHint::ShowEnteringQuery() { 214 void OmniboxSearchHint::ShowEnteringQuery() {
215 LocationBar* location_bar = browser::FindBrowserWithWebContents( 215 LocationBar* location_bar = browser::FindBrowserWithWebContents(
216 tab_->web_contents())->window()->GetLocationBar(); 216 tab_->web_contents())->window()->GetLocationBar();
217 OmniboxView* omnibox_view = location_bar->GetLocationEntry(); 217 OmniboxView* omnibox_view = location_bar->GetLocationEntry();
218 location_bar->FocusLocation(true); 218 location_bar->FocusLocation(true);
219 omnibox_view->SetUserText( 219 omnibox_view->SetUserText(
220 l10n_util::GetStringUTF16(IDS_OMNIBOX_SEARCH_HINT_OMNIBOX_TEXT)); 220 l10n_util::GetStringUTF16(IDS_OMNIBOX_SEARCH_HINT_OMNIBOX_TEXT));
221 omnibox_view->SelectAll(false); 221 omnibox_view->SelectAll(false);
222 // Entering text in the omnibox view triggers the suggestion popup that we 222 // Entering text in the omnibox view triggers the suggestion popup that we
223 // don't want to show in this case. 223 // don't want to show in this case.
224 omnibox_view->ClosePopup(); 224 omnibox_view->CloseOmniboxPopup();
225 } 225 }
226 226
227 void OmniboxSearchHint::DisableHint() { 227 void OmniboxSearchHint::DisableHint() {
228 // The NAV_ENTRY_COMMITTED notification was needed to show the infobar, the 228 // The NAV_ENTRY_COMMITTED notification was needed to show the infobar, the
229 // OMNIBOX_OPENED_URL notification was there to set the kShowOmniboxSearchHint 229 // OMNIBOX_OPENED_URL notification was there to set the kShowOmniboxSearchHint
230 // prefs to false, none of them are needed anymore. 230 // prefs to false, none of them are needed anymore.
231 notification_registrar_.RemoveAll(); 231 notification_registrar_.RemoveAll();
232 tab_->profile()->GetPrefs()->SetBoolean(prefs::kShowOmniboxSearchHint, 232 tab_->profile()->GetPrefs()->SetBoolean(prefs::kShowOmniboxSearchHint,
233 false); 233 false);
234 } 234 }
235 235
236 // static 236 // static
237 bool OmniboxSearchHint::IsEnabled(Profile* profile) { 237 bool OmniboxSearchHint::IsEnabled(Profile* profile) {
238 // The infobar can only be shown if the correct switch has been provided and 238 // The infobar can only be shown if the correct switch has been provided and
239 // the user did not dismiss the infobar before. 239 // the user did not dismiss the infobar before.
240 return profile->GetPrefs()->GetBoolean(prefs::kShowOmniboxSearchHint) && 240 return profile->GetPrefs()->GetBoolean(prefs::kShowOmniboxSearchHint) &&
241 CommandLine::ForCurrentProcess()->HasSwitch( 241 CommandLine::ForCurrentProcess()->HasSwitch(
242 switches::kSearchInOmniboxHint); 242 switches::kSearchInOmniboxHint);
243 } 243 }
OLDNEW
« no previous file with comments | « chrome/browser/automation/testing_automation_provider.cc ('k') | chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698