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_fetcher_factory.h" | 8 #include "chrome/browser/search_engines/template_url_fetcher_factory.h" |
9 #include "chrome/browser/search_engines/template_url_service_factory.h" | 9 #include "chrome/browser/search_engines/template_url_service_factory.h" |
10 #include "chrome/browser/ui/search_engines/search_engine_tab_helper_delegate.h" | 10 #include "chrome/browser/ui/search_engines/search_engine_tab_helper_delegate.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 | 103 |
104 void SearchEngineTabHelper::OnPageHasOSDD( | 104 void SearchEngineTabHelper::OnPageHasOSDD( |
105 const GURL& page_url, | 105 const GURL& page_url, |
106 const GURL& osdd_url, | 106 const GURL& osdd_url, |
107 const search_provider::OSDDType& msg_provider_type) { | 107 const search_provider::OSDDType& msg_provider_type) { |
108 // Checks to see if we should generate a keyword based on the OSDD, and if | 108 // Checks to see if we should generate a keyword based on the OSDD, and if |
109 // necessary uses TemplateURLFetcher to download the OSDD and create a | 109 // necessary uses TemplateURLFetcher to download the OSDD and create a |
110 // keyword. | 110 // keyword. |
111 | 111 |
112 // Make sure that the page is the current page and other basic checks. | 112 // Make sure that the page is the current page and other basic checks. |
113 if (!osdd_url.is_valid()) | 113 if (!osdd_url.is_valid() || !osdd_url.SchemeIsHTTPOrHTTPS()) |
Peter Kasting
2015/02/18 21:58:56
I feel like perhaps file: URLs should be allowed t
meacer
2015/02/18 22:25:11
Hmm, that would still allow file:// urls to enumer
meacer
2015/02/23 20:37:37
Okay, I was going to allow file:// urls, but it tu
| |
114 return; | 114 return; |
115 | |
115 Profile* profile = | 116 Profile* profile = |
116 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 117 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
117 if (page_url != web_contents()->GetLastCommittedURL() || | 118 if (page_url != web_contents()->GetLastCommittedURL() || |
118 !TemplateURLFetcherFactory::GetForProfile(profile) || | 119 !TemplateURLFetcherFactory::GetForProfile(profile) || |
119 profile->IsOffTheRecord()) | 120 profile->IsOffTheRecord()) |
120 return; | 121 return; |
121 | 122 |
122 TemplateURLFetcher::ProviderType provider_type = | 123 TemplateURLFetcher::ProviderType provider_type = |
123 (msg_provider_type == search_provider::AUTODETECTED_PROVIDER) ? | 124 (msg_provider_type == search_provider::AUTODETECTED_PROVIDER) ? |
124 TemplateURLFetcher::AUTODETECTED_PROVIDER : | 125 TemplateURLFetcher::AUTODETECTED_PROVIDER : |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
220 // the favicon url wasn't obtained before the load started. This assumes the | 221 // the favicon url wasn't obtained before the load started. This assumes the |
221 // latter. | 222 // latter. |
222 // TODO(sky): Need a way to set the favicon that doesn't involve generating | 223 // TODO(sky): Need a way to set the favicon that doesn't involve generating |
223 // its url. | 224 // its url. |
224 data.favicon_url = current_favicon.is_valid() ? | 225 data.favicon_url = current_favicon.is_valid() ? |
225 current_favicon : TemplateURL::GenerateFaviconURL(params.referrer.url); | 226 current_favicon : TemplateURL::GenerateFaviconURL(params.referrer.url); |
226 data.safe_for_autoreplace = true; | 227 data.safe_for_autoreplace = true; |
227 data.input_encodings.push_back(params.searchable_form_encoding); | 228 data.input_encodings.push_back(params.searchable_form_encoding); |
228 url_service->Add(new TemplateURL(data)); | 229 url_service->Add(new TemplateURL(data)); |
229 } | 230 } |
OLD | NEW |