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

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

Issue 6051012: Revert 70271 - Remove wstring from l10n_util. Part 3.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 12 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/task.h" 11 #include "base/task.h"
12 // TODO(avi): remove when conversions not needed any more
13 #include "base/utf_string_conversions.h"
14 #include "chrome/browser/autocomplete/autocomplete.h" 12 #include "chrome/browser/autocomplete/autocomplete.h"
15 #include "chrome/browser/autocomplete/autocomplete_edit.h" 13 #include "chrome/browser/autocomplete/autocomplete_edit.h"
16 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" 14 #include "chrome/browser/autocomplete/autocomplete_edit_view.h"
17 #include "chrome/browser/autocomplete/autocomplete_match.h" 15 #include "chrome/browser/autocomplete/autocomplete_match.h"
18 #include "chrome/browser/browser_list.h" 16 #include "chrome/browser/browser_list.h"
19 #include "chrome/browser/browser_window.h" 17 #include "chrome/browser/browser_window.h"
20 #include "chrome/browser/prefs/pref_service.h" 18 #include "chrome/browser/prefs/pref_service.h"
21 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/search_engines/template_url.h" 20 #include "chrome/browser/search_engines/template_url.h"
23 #include "chrome/browser/search_engines/template_url_model.h" 21 #include "chrome/browser/search_engines/template_url_model.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 176
179 void OmniboxSearchHint::ShowInfoBar() { 177 void OmniboxSearchHint::ShowInfoBar() {
180 tab_->AddInfoBar(new HintInfoBar(this)); 178 tab_->AddInfoBar(new HintInfoBar(this));
181 } 179 }
182 180
183 void OmniboxSearchHint::ShowEnteringQuery() { 181 void OmniboxSearchHint::ShowEnteringQuery() {
184 LocationBar* location_bar = BrowserList::GetLastActive()->window()-> 182 LocationBar* location_bar = BrowserList::GetLastActive()->window()->
185 GetLocationBar(); 183 GetLocationBar();
186 AutocompleteEditView* edit_view = location_bar->location_entry(); 184 AutocompleteEditView* edit_view = location_bar->location_entry();
187 location_bar->FocusLocation(true); 185 location_bar->FocusLocation(true);
188 edit_view->SetUserText(UTF16ToWideHack( 186 edit_view->SetUserText(
189 l10n_util::GetStringUTF16(IDS_OMNIBOX_SEARCH_HINT_OMNIBOX_TEXT))); 187 l10n_util::GetString(IDS_OMNIBOX_SEARCH_HINT_OMNIBOX_TEXT));
190 edit_view->SelectAll(false); 188 edit_view->SelectAll(false);
191 // Entering text in the autocomplete edit view triggers the suggestion popup 189 // Entering text in the autocomplete edit view triggers the suggestion popup
192 // that we don't want to show in this case. 190 // that we don't want to show in this case.
193 edit_view->ClosePopup(); 191 edit_view->ClosePopup();
194 } 192 }
195 193
196 void OmniboxSearchHint::DisableHint() { 194 void OmniboxSearchHint::DisableHint() {
197 // The NAV_ENTRY_COMMITTED notification was needed to show the infobar, the 195 // The NAV_ENTRY_COMMITTED notification was needed to show the infobar, the
198 // OMNIBOX_OPENED_URL notification was there to set the kShowOmniboxSearchHint 196 // OMNIBOX_OPENED_URL notification was there to set the kShowOmniboxSearchHint
199 // prefs to false, none of them are needed anymore. 197 // prefs to false, none of them are needed anymore.
200 notification_registrar_.RemoveAll(); 198 notification_registrar_.RemoveAll();
201 tab_->profile()->GetPrefs()->SetBoolean(prefs::kShowOmniboxSearchHint, 199 tab_->profile()->GetPrefs()->SetBoolean(prefs::kShowOmniboxSearchHint,
202 false); 200 false);
203 } 201 }
204 202
205 // static 203 // static
206 bool OmniboxSearchHint::IsEnabled(Profile* profile) { 204 bool OmniboxSearchHint::IsEnabled(Profile* profile) {
207 // The infobar can only be shown if the correct switch has been provided and 205 // The infobar can only be shown if the correct switch has been provided and
208 // the user did not dismiss the infobar before. 206 // the user did not dismiss the infobar before.
209 return profile->GetPrefs()->GetBoolean(prefs::kShowOmniboxSearchHint) && 207 return profile->GetPrefs()->GetBoolean(prefs::kShowOmniboxSearchHint) &&
210 CommandLine::ForCurrentProcess()->HasSwitch( 208 CommandLine::ForCurrentProcess()->HasSwitch(
211 switches::kSearchInOmniboxHint); 209 switches::kSearchInOmniboxHint);
212 } 210 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698