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

Unified Diff: chrome/browser/ui/search/search_tab_helper.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: indent 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/search/search_tab_helper.cc
diff --git a/chrome/browser/ui/search/search_tab_helper.cc b/chrome/browser/ui/search/search_tab_helper.cc
index 6b46fd73ec85d5d80e4576fbce15c79706d20139..7aa0866db5e62b4454d22cf8c5e60788e7d592dd 100644
--- a/chrome/browser/ui/search/search_tab_helper.cc
+++ b/chrome/browser/ui/search/search_tab_helper.cc
@@ -6,6 +6,8 @@
#include "chrome/browser/google/google_util.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/search/search.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/navigation_controller.h"
@@ -99,6 +101,23 @@ void SearchTabHelper::Observe(
!is_initial_navigation_commit_);
}
is_initial_navigation_commit_ = false;
+
+ // Update the extracted search terms (if any) in the model.
+ if (web_contents()) {
sky 2012/12/12 22:41:57 Do you really need this if?
Mathieu 2012/12/12 23:37:24 It comes from SearchModel and it is marked as "wea
sky 2012/12/13 00:48:18 From WebContentsUserData: // A base class for cla
+ const content::NavigationController* navigation_controller =
+ &web_contents()->GetController();
+ if (navigation_controller) {
sky 2012/12/12 22:41:57 There is always a NavigationController.
Mathieu 2012/12/12 23:37:24 Done.
+ content::NavigationEntry* entry = navigation_controller->GetActiveEntry();
sky 2012/12/12 22:41:57 Use committed_details->entry
Mathieu 2012/12/12 23:37:24 Done.
+ Profile* profile =
+ Profile::FromBrowserContext(web_contents()->GetBrowserContext());
+ TemplateURLService* template_url_service =
+ TemplateURLServiceFactory::GetForProfile(profile);
+ string16 search_terms =
+ template_url_service->TryToExtractSearchTermsFromURL(entry->GetURL());
+ if (!search_terms.empty())
+ entry->SetSearchTerms(search_terms);
+ }
+ }
}
void SearchTabHelper::UpdateModelBasedOnURL(const GURL& url, bool animate) {

Powered by Google App Engine
This is Rietveld 408576698