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/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: Removed version_46.sql, committed separately. Created 8 years, 2 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.h"
12 #include "chrome/browser/search_engines/template_url_service.h"
13 #include "chrome/browser/search_engines/template_url_service_factory.h"
12 #include "chrome/browser/ssl/ssl_error_info.h" 14 #include "chrome/browser/ssl/ssl_error_info.h"
13 #include "chrome/browser/ui/search/search.h" 15 #include "chrome/browser/ui/search/search.h"
14 #include "chrome/browser/ui/toolbar/toolbar_model_delegate.h" 16 #include "chrome/browser/ui/toolbar/toolbar_model_delegate.h"
15 #include "chrome/common/chrome_constants.h" 17 #include "chrome/common/chrome_constants.h"
16 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
17 #include "chrome/common/url_constants.h" 19 #include "chrome/common/url_constants.h"
18 #include "content/public/browser/cert_store.h" 20 #include "content/public/browser/cert_store.h"
19 #include "content/public/browser/navigation_controller.h" 21 #include "content/public/browser/navigation_controller.h"
20 #include "content/public/browser/navigation_entry.h" 22 #include "content/public/browser/navigation_entry.h"
21 #include "content/public/browser/web_contents.h" 23 #include "content/public/browser/web_contents.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 NavigationController* ToolbarModel::GetNavigationController() const { 193 NavigationController* ToolbarModel::GetNavigationController() const {
192 // This |current_tab| can be NULL during the initialization of the 194 // This |current_tab| can be NULL during the initialization of the
193 // toolbar during window creation (i.e. before any tabs have been added 195 // toolbar during window creation (i.e. before any tabs have been added
194 // to the window). 196 // to the window).
195 WebContents* current_tab = delegate_->GetActiveWebContents(); 197 WebContents* current_tab = delegate_->GetActiveWebContents();
196 return current_tab ? &current_tab->GetController() : NULL; 198 return current_tab ? &current_tab->GetController() : NULL;
197 } 199 }
198 200
199 string16 ToolbarModel::TryToExtractSearchTermsFromURL(const GURL& url) const { 201 string16 ToolbarModel::TryToExtractSearchTermsFromURL(const GURL& url) const {
200 Profile* profile = GetProfile(); 202 Profile* profile = GetProfile();
201 if (profile && 203
202 chrome::search::IsInstantExtendedAPIEnabled(profile) && 204 // Ensure instant extended API is enabled.
203 google_util::IsInstantExtendedAPIGoogleSearchUrl(url.spec())) { 205 if (!profile || !chrome::search::IsInstantExtendedAPIEnabled(profile))
204 // TODO(dominich): http://crbug.com/135106 - Replace this with whatever the 206 return string16();
205 // final solution is as per http://crbug.com/139176. 207
206 return google_util::GetSearchTermsFromGoogleSearchURL(url.spec()); 208 TemplateURLService* template_url_service =
207 } 209 TemplateURLServiceFactory::GetForProfile(profile);
208 return string16(); 210
211 TemplateURL *template_url = template_url_service->GetDefaultSearchProvider();
212 if (!template_url)
213 return string16();
214
215 string16 result;
216 template_url->ExtractSearchTermsFromURL(url, &result);
217 return result;
209 } 218 }
210 219
211 Profile* ToolbarModel::GetProfile() const { 220 Profile* ToolbarModel::GetProfile() const {
212 NavigationController* navigation_controller = GetNavigationController(); 221 NavigationController* navigation_controller = GetNavigationController();
213 return navigation_controller ? 222 return navigation_controller ?
214 Profile::FromBrowserContext(navigation_controller->GetBrowserContext()) : 223 Profile::FromBrowserContext(navigation_controller->GetBrowserContext()) :
215 NULL; 224 NULL;
216 } 225 }
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