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

Side by Side Diff: chrome/browser/ui/search_engines/search_engine_tab_helper.cc

Issue 10381016: Remove the "autogenerate keyword" bit on TemplateURL. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 7 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/search_engines/search_engine_tab_helper.h" 5 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h"
6 6
7 #include "chrome/browser/profiles/profile.h" 7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/search_engines/template_url.h" 8 #include "chrome/browser/search_engines/template_url.h"
9 #include "chrome/browser/search_engines/template_url_fetcher.h" 9 #include "chrome/browser/search_engines/template_url_fetcher.h"
10 #include "chrome/browser/search_engines/template_url_fetcher_factory.h" 10 #include "chrome/browser/search_engines/template_url_fetcher_factory.h"
11 #include "chrome/browser/search_engines/template_url_service.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/search_engines/template_url_service_factory.h"
13 #include "chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.h" 13 #include "chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.h"
14 #include "chrome/common/render_messages.h" 14 #include "chrome/common/render_messages.h"
15 #include "chrome/common/url_constants.h"
15 #include "content/public/browser/favicon_status.h" 16 #include "content/public/browser/favicon_status.h"
16 #include "content/public/browser/navigation_controller.h" 17 #include "content/public/browser/navigation_controller.h"
17 #include "content/public/browser/navigation_entry.h" 18 #include "content/public/browser/navigation_entry.h"
18 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
19 #include "content/public/common/frame_navigate_params.h" 20 #include "content/public/common/frame_navigate_params.h"
20 21
21 using content::NavigationController; 22 using content::NavigationController;
22 using content::NavigationEntry; 23 using content::NavigationEntry;
23 using content::WebContents; 24 using content::WebContents;
24 25
(...skipping 13 matching lines...) Expand all
38 39
39 // We want to use the user typed URL if available since that represents what 40 // We want to use the user typed URL if available since that represents what
40 // the user typed to get here, and fall back on the regular URL if not. 41 // the user typed to get here, and fall back on the regular URL if not.
41 GURL url = entry->GetUserTypedURL(); 42 GURL url = entry->GetUserTypedURL();
42 if (!url.is_valid()) { 43 if (!url.is_valid()) {
43 url = entry->GetURL(); 44 url = entry->GetURL();
44 if (!url.is_valid()) 45 if (!url.is_valid())
45 return string16(); 46 return string16();
46 } 47 }
47 48
48 return TemplateURLService::GenerateKeyword(url, true); 49 // Don't autogenerate keywords for referrers that are anything other than HTTP
50 // or have a path.
51 //
52 // If we relax the path constraint, we need to be sure to sanitize the path
53 // elements and update AutocompletePopup to look for keywords using the path.
54 // See http://b/issue?id=863583.
55 if (!url.SchemeIs(chrome::kHttpScheme) || (url.path().length() > 1))
56 return string16();
57
58 return TemplateURLService::GenerateKeyword(url);
49 } 59 }
50 60
51 } // namespace 61 } // namespace
52 62
53 SearchEngineTabHelper::SearchEngineTabHelper(WebContents* web_contents) 63 SearchEngineTabHelper::SearchEngineTabHelper(WebContents* web_contents)
54 : content::WebContentsObserver(web_contents) { 64 : content::WebContentsObserver(web_contents) {
55 DCHECK(web_contents); 65 DCHECK(web_contents);
56 } 66 }
57 67
58 SearchEngineTabHelper::~SearchEngineTabHelper() { 68 SearchEngineTabHelper::~SearchEngineTabHelper() {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 // the favicon url wasn't obtained before the load started. This assumes the 192 // the favicon url wasn't obtained before the load started. This assumes the
183 // latter. 193 // latter.
184 // TODO(sky): Need a way to set the favicon that doesn't involve generating 194 // TODO(sky): Need a way to set the favicon that doesn't involve generating
185 // its url. 195 // its url.
186 data.favicon_url = current_favicon.is_valid() ? 196 data.favicon_url = current_favicon.is_valid() ?
187 current_favicon : TemplateURL::GenerateFaviconURL(params.referrer.url); 197 current_favicon : TemplateURL::GenerateFaviconURL(params.referrer.url);
188 data.safe_for_autoreplace = true; 198 data.safe_for_autoreplace = true;
189 data.input_encodings.push_back(params.searchable_form_encoding); 199 data.input_encodings.push_back(params.searchable_form_encoding);
190 url_service->Add(new TemplateURL(profile, data)); 200 url_service->Add(new TemplateURL(profile, data));
191 } 201 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698