| 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 // When |page_url| has file: scheme, this method doesn't work because of |
| 114 // http://b/issue?id=863583. For that reason, this doesn't check and allow |
| 115 // urls referring to osdd urls with same schemes. |
| 116 if (!osdd_url.is_valid() || !osdd_url.SchemeIsHTTPOrHTTPS()) |
| 114 return; | 117 return; |
| 118 |
| 115 Profile* profile = | 119 Profile* profile = |
| 116 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 120 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| 117 if (page_url != web_contents()->GetLastCommittedURL() || | 121 if (page_url != web_contents()->GetLastCommittedURL() || |
| 118 !TemplateURLFetcherFactory::GetForProfile(profile) || | 122 !TemplateURLFetcherFactory::GetForProfile(profile) || |
| 119 profile->IsOffTheRecord()) | 123 profile->IsOffTheRecord()) |
| 120 return; | 124 return; |
| 121 | 125 |
| 122 TemplateURLFetcher::ProviderType provider_type = | 126 TemplateURLFetcher::ProviderType provider_type = |
| 123 (msg_provider_type == search_provider::AUTODETECTED_PROVIDER) ? | 127 (msg_provider_type == search_provider::AUTODETECTED_PROVIDER) ? |
| 124 TemplateURLFetcher::AUTODETECTED_PROVIDER : | 128 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 | 224 // the favicon url wasn't obtained before the load started. This assumes the |
| 221 // latter. | 225 // latter. |
| 222 // TODO(sky): Need a way to set the favicon that doesn't involve generating | 226 // TODO(sky): Need a way to set the favicon that doesn't involve generating |
| 223 // its url. | 227 // its url. |
| 224 data.favicon_url = current_favicon.is_valid() ? | 228 data.favicon_url = current_favicon.is_valid() ? |
| 225 current_favicon : TemplateURL::GenerateFaviconURL(params.referrer.url); | 229 current_favicon : TemplateURL::GenerateFaviconURL(params.referrer.url); |
| 226 data.safe_for_autoreplace = true; | 230 data.safe_for_autoreplace = true; |
| 227 data.input_encodings.push_back(params.searchable_form_encoding); | 231 data.input_encodings.push_back(params.searchable_form_encoding); |
| 228 url_service->Add(new TemplateURL(data)); | 232 url_service->Add(new TemplateURL(data)); |
| 229 } | 233 } |
| OLD | NEW |