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

Side by Side Diff: chrome/browser/ui/toolbar/toolbar_model_impl.cc

Issue 11415292: [Search] No longer reverting omnibox text on instant search (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: session_types comment Created 8 years 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved.
sky 2012/12/07 16:29:25 Don't remove this.
Mathieu 2012/12/11 00:30:17 Done. Not sure what happened.
2 // Use of this source code is governed by a BSD-style license that can be 1 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 2 // found in the LICENSE file.
4 3
5 #include "chrome/browser/ui/toolbar/toolbar_model_impl.h" 4 #include "chrome/browser/ui/toolbar/toolbar_model_impl.h"
6 5
7 #include "base/utf_string_conversions.h" 6 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/autocomplete/autocomplete_input.h" 7 #include "chrome/browser/autocomplete/autocomplete_input.h"
9 #include "chrome/browser/google/google_util.h" 8 #include "chrome/browser/google/google_util.h"
10 #include "chrome/browser/prefs/pref_service.h" 9 #include "chrome/browser/prefs/pref_service.h"
11 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 30 matching lines...) Expand all
42 : delegate_(delegate), 41 : delegate_(delegate),
43 input_in_progress_(false) { 42 input_in_progress_(false) {
44 } 43 }
45 44
46 ToolbarModelImpl::~ToolbarModelImpl() { 45 ToolbarModelImpl::~ToolbarModelImpl() {
47 } 46 }
48 47
49 // ToolbarModelImpl Implementation. 48 // ToolbarModelImpl Implementation.
50 string16 ToolbarModelImpl::GetText( 49 string16 ToolbarModelImpl::GetText(
51 bool display_search_urls_as_search_terms) const { 50 bool display_search_urls_as_search_terms) const {
51
52 NavigationEntry* entry;
akalin 2012/12/06 23:14:46 this still isn't fixed
Mathieu 2012/12/11 00:30:17 Done. Thanks.
52 if (display_search_urls_as_search_terms) { 53 if (display_search_urls_as_search_terms) {
54 const NavigationController* navigation_controller =
55 GetNavigationController();
56 if (navigation_controller) {
57 entry = navigation_controller->GetVisibleEntry();
58 if (entry && !entry->GetSearchTerms().empty()) {
59 // Entry has existing search terms.
60 return entry->GetSearchTerms();
61 }
62 }
53 string16 search_terms = TryToExtractSearchTermsFromURL(); 63 string16 search_terms = TryToExtractSearchTermsFromURL();
sky 2012/12/07 16:29:25 If we can build this on the fly do we need to pers
Mathieu 2012/12/11 00:30:17 We would like to restore the correct search terms
sky 2012/12/11 22:59:16 Ok, but that doesn't seem to indicate we need to p
Mathieu 2012/12/12 19:37:53 Well, as I mentioned there are special cases where
sky 2012/12/12 21:18:05 Forgive my pushing back, but I want to make sure w
Mathieu 2012/12/12 21:32:02 No problem, glad to discuss. I'll refer now to the
54 if (!search_terms.empty()) 64 if (!search_terms.empty()) {
65 if (entry)
66 entry->SetSearchTerms(search_terms);
sky 2012/12/07 16:29:25 This seems like the wrong place to do this. Should
Mathieu 2012/12/11 00:30:17 I agree that it's not necessarily elegant to put s
sky 2012/12/11 22:59:16 How about SearchTabHelper.
Mathieu 2012/12/12 19:37:53 Done. Refactored TryToExtractSearchTermsFromURL to
55 return search_terms; 67 return search_terms;
68 }
56 } 69 }
57 std::string languages; // Empty if we don't have a |navigation_controller|. 70 std::string languages; // Empty if we don't have a |navigation_controller|.
58 Profile* profile = GetProfile(); 71 Profile* profile = GetProfile();
59 if (profile) 72 if (profile)
60 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages); 73 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages);
61 74
62 GURL url(GetURL()); 75 GURL url(GetURL());
63 if (url.spec().length() > content::kMaxURLDisplayChars) 76 if (url.spec().length() > content::kMaxURLDisplayChars)
64 url = url.IsStandard() ? url.GetOrigin() : GURL(url.scheme() + ":"); 77 url = url.IsStandard() ? url.GetOrigin() : GURL(url.scheme() + ":");
65 // Note that we can't unescape spaces here, because if the user copies this 78 // Note that we can't unescape spaces here, because if the user copies this
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 template_url->ExtractSearchTermsFromURL(url, &result); 245 template_url->ExtractSearchTermsFromURL(url, &result);
233 return result; 246 return result;
234 } 247 }
235 248
236 Profile* ToolbarModelImpl::GetProfile() const { 249 Profile* ToolbarModelImpl::GetProfile() const {
237 NavigationController* navigation_controller = GetNavigationController(); 250 NavigationController* navigation_controller = GetNavigationController();
238 return navigation_controller ? 251 return navigation_controller ?
239 Profile::FromBrowserContext(navigation_controller->GetBrowserContext()) : 252 Profile::FromBrowserContext(navigation_controller->GetBrowserContext()) :
240 NULL; 253 NULL;
241 } 254 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698