OLD | NEW |
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" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 if (!url.is_valid()) | 47 if (!url.is_valid()) |
48 return string16(); | 48 return string16(); |
49 } | 49 } |
50 | 50 |
51 // Don't autogenerate keywords for referrers that are anything other than HTTP | 51 // Don't autogenerate keywords for referrers that are anything other than HTTP |
52 // or have a path. | 52 // or have a path. |
53 // | 53 // |
54 // If we relax the path constraint, we need to be sure to sanitize the path | 54 // If we relax the path constraint, we need to be sure to sanitize the path |
55 // elements and update AutocompletePopup to look for keywords using the path. | 55 // elements and update AutocompletePopup to look for keywords using the path. |
56 // See http://b/issue?id=863583. | 56 // See http://b/issue?id=863583. |
57 if (!url.SchemeIs(chrome::kHttpScheme) || (url.path().length() > 1)) | 57 if (!url.SchemeIs(content::kHttpScheme) || (url.path().length() > 1)) |
58 return string16(); | 58 return string16(); |
59 | 59 |
60 return TemplateURLService::GenerateKeyword(url); | 60 return TemplateURLService::GenerateKeyword(url); |
61 } | 61 } |
62 | 62 |
63 } // namespace | 63 } // namespace |
64 | 64 |
65 SearchEngineTabHelper::~SearchEngineTabHelper() { | 65 SearchEngineTabHelper::~SearchEngineTabHelper() { |
66 } | 66 } |
67 | 67 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 // the favicon url wasn't obtained before the load started. This assumes the | 195 // the favicon url wasn't obtained before the load started. This assumes the |
196 // latter. | 196 // latter. |
197 // TODO(sky): Need a way to set the favicon that doesn't involve generating | 197 // TODO(sky): Need a way to set the favicon that doesn't involve generating |
198 // its url. | 198 // its url. |
199 data.favicon_url = current_favicon.is_valid() ? | 199 data.favicon_url = current_favicon.is_valid() ? |
200 current_favicon : TemplateURL::GenerateFaviconURL(params.referrer.url); | 200 current_favicon : TemplateURL::GenerateFaviconURL(params.referrer.url); |
201 data.safe_for_autoreplace = true; | 201 data.safe_for_autoreplace = true; |
202 data.input_encodings.push_back(params.searchable_form_encoding); | 202 data.input_encodings.push_back(params.searchable_form_encoding); |
203 url_service->Add(new TemplateURL(profile, data)); | 203 url_service->Add(new TemplateURL(profile, data)); |
204 } | 204 } |
OLD | NEW |