| 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" |
| 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 "chrome/common/url_constants.h" |
| 16 #include "content/public/browser/favicon_status.h" | 16 #include "content/public/browser/favicon_status.h" |
| 17 #include "content/public/browser/navigation_controller.h" | 17 #include "content/public/browser/navigation_controller.h" |
| 18 #include "content/public/browser/navigation_entry.h" | 18 #include "content/public/browser/navigation_entry.h" |
| 19 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
| 20 #include "content/public/common/frame_navigate_params.h" | 20 #include "content/public/common/frame_navigate_params.h" |
| 21 #include "net/base/url_constants.h" |
| 21 | 22 |
| 22 using content::NavigationController; | 23 using content::NavigationController; |
| 23 using content::NavigationEntry; | 24 using content::NavigationEntry; |
| 24 using content::WebContents; | 25 using content::WebContents; |
| 25 | 26 |
| 26 DEFINE_WEB_CONTENTS_USER_DATA_KEY(SearchEngineTabHelper); | 27 DEFINE_WEB_CONTENTS_USER_DATA_KEY(SearchEngineTabHelper); |
| 27 | 28 |
| 28 namespace { | 29 namespace { |
| 29 | 30 |
| 30 // Returns true if the entry's transition type is FORM_SUBMIT. | 31 // Returns true if the entry's transition type is FORM_SUBMIT. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 48 if (!url.is_valid()) | 49 if (!url.is_valid()) |
| 49 return base::string16(); | 50 return base::string16(); |
| 50 } | 51 } |
| 51 | 52 |
| 52 // Don't autogenerate keywords for referrers that are anything other than HTTP | 53 // Don't autogenerate keywords for referrers that are anything other than HTTP |
| 53 // or have a path. | 54 // or have a path. |
| 54 // | 55 // |
| 55 // If we relax the path constraint, we need to be sure to sanitize the path | 56 // If we relax the path constraint, we need to be sure to sanitize the path |
| 56 // elements and update AutocompletePopup to look for keywords using the path. | 57 // elements and update AutocompletePopup to look for keywords using the path. |
| 57 // See http://b/issue?id=863583. | 58 // See http://b/issue?id=863583. |
| 58 if (!url.SchemeIs(content::kHttpScheme) || (url.path().length() > 1)) | 59 if (!url.SchemeIs(net::kHttpScheme) || (url.path().length() > 1)) |
| 59 return base::string16(); | 60 return base::string16(); |
| 60 | 61 |
| 61 return TemplateURLService::GenerateKeyword(url); | 62 return TemplateURLService::GenerateKeyword(url); |
| 62 } | 63 } |
| 63 | 64 |
| 64 } // namespace | 65 } // namespace |
| 65 | 66 |
| 66 SearchEngineTabHelper::~SearchEngineTabHelper() { | 67 SearchEngineTabHelper::~SearchEngineTabHelper() { |
| 67 } | 68 } |
| 68 | 69 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 // the favicon url wasn't obtained before the load started. This assumes the | 197 // the favicon url wasn't obtained before the load started. This assumes the |
| 197 // latter. | 198 // latter. |
| 198 // TODO(sky): Need a way to set the favicon that doesn't involve generating | 199 // TODO(sky): Need a way to set the favicon that doesn't involve generating |
| 199 // its url. | 200 // its url. |
| 200 data.favicon_url = current_favicon.is_valid() ? | 201 data.favicon_url = current_favicon.is_valid() ? |
| 201 current_favicon : TemplateURL::GenerateFaviconURL(params.referrer.url); | 202 current_favicon : TemplateURL::GenerateFaviconURL(params.referrer.url); |
| 202 data.safe_for_autoreplace = true; | 203 data.safe_for_autoreplace = true; |
| 203 data.input_encodings.push_back(params.searchable_form_encoding); | 204 data.input_encodings.push_back(params.searchable_form_encoding); |
| 204 url_service->Add(new TemplateURL(profile, data)); | 205 url_service->Add(new TemplateURL(profile, data)); |
| 205 } | 206 } |
| OLD | NEW |