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

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

Issue 10908226: Introduces a search term extraction mechanism working for arbitrary search providers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed dominich comments. Created 8 years, 3 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/ui/toolbar/toolbar_model.h" 5 #include "chrome/browser/ui/toolbar/toolbar_model.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/autocomplete/autocomplete_input.h" 8 #include "chrome/browser/autocomplete/autocomplete_input.h"
9 #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"
11 #include "chrome/browser/search_engines/template_url_service.h"
12 #include "chrome/browser/search_engines/template_url_service_factory.h"
12 #include "chrome/browser/ssl/ssl_error_info.h" 13 #include "chrome/browser/ssl/ssl_error_info.h"
13 #include "chrome/browser/ui/search/search.h" 14 #include "chrome/browser/ui/search/search.h"
14 #include "chrome/browser/ui/toolbar/toolbar_model_delegate.h" 15 #include "chrome/browser/ui/toolbar/toolbar_model_delegate.h"
15 #include "chrome/common/chrome_constants.h" 16 #include "chrome/common/chrome_constants.h"
16 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
17 #include "chrome/common/url_constants.h" 18 #include "chrome/common/url_constants.h"
18 #include "content/public/browser/cert_store.h" 19 #include "content/public/browser/cert_store.h"
19 #include "content/public/browser/navigation_controller.h" 20 #include "content/public/browser/navigation_controller.h"
20 #include "content/public/browser/navigation_entry.h" 21 #include "content/public/browser/navigation_entry.h"
21 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 NavigationController* ToolbarModel::GetNavigationController() const { 192 NavigationController* ToolbarModel::GetNavigationController() const {
192 // This |current_tab| can be NULL during the initialization of the 193 // This |current_tab| can be NULL during the initialization of the
193 // toolbar during window creation (i.e. before any tabs have been added 194 // toolbar during window creation (i.e. before any tabs have been added
194 // to the window). 195 // to the window).
195 WebContents* current_tab = delegate_->GetActiveWebContents(); 196 WebContents* current_tab = delegate_->GetActiveWebContents();
196 return current_tab ? &current_tab->GetController() : NULL; 197 return current_tab ? &current_tab->GetController() : NULL;
197 } 198 }
198 199
199 string16 ToolbarModel::TryToExtractSearchTermsFromURL(const GURL& url) const { 200 string16 ToolbarModel::TryToExtractSearchTermsFromURL(const GURL& url) const {
200 Profile* profile = GetProfile(); 201 Profile* profile = GetProfile();
201 if (profile && 202
202 chrome::search::IsInstantExtendedAPIEnabled(profile) && 203 if (!profile || !chrome::search::IsInstantExtendedAPIEnabled(profile))
dominich 2012/09/14 21:34:04 One more thought (from a discussion with dcblack):
beaudoin 2012/09/22 06:55:45 From the discussion it looks like we should only r
203 google_util::IsInstantExtendedAPIGoogleSearchUrl(url.spec())) { 204 return string16();
204 // TODO(dominich): http://crbug.com/135106 - Replace this with whatever the 205
205 // final solution is as per http://crbug.com/139176. 206 TemplateURLService* template_url_service =
206 return google_util::GetSearchTermsFromGoogleSearchURL(url.spec()); 207 TemplateURLServiceFactory::GetForProfile(profile);
207 } 208
208 return string16(); 209 if (!template_url_service)
210 return string16();
211
212 TemplateURL *template_url = template_url_service->GetDefaultSearchProvider();
213 if (!template_url)
214 return string16();
215
216 return template_url->ExtractSearchTermsFromURL(url);
dominich 2012/09/13 18:30:30 is this checking for espv=1 in the query component
beaudoin 2012/09/22 06:55:45 Done.
209 } 217 }
210 218
211 Profile* ToolbarModel::GetProfile() const { 219 Profile* ToolbarModel::GetProfile() const {
212 NavigationController* navigation_controller = GetNavigationController(); 220 NavigationController* navigation_controller = GetNavigationController();
213 return navigation_controller ? 221 return navigation_controller ?
214 Profile::FromBrowserContext(navigation_controller->GetBrowserContext()) : 222 Profile::FromBrowserContext(navigation_controller->GetBrowserContext()) :
215 NULL; 223 NULL;
216 } 224 }
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/template_url_unittest.cc ('k') | chrome/browser/ui/toolbar/toolbar_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698