| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 IPC_BEGIN_MESSAGE_MAP(SearchEngineTabHelper, message) | 89 IPC_BEGIN_MESSAGE_MAP(SearchEngineTabHelper, message) |
| 90 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_PageHasOSDD, OnPageHasOSDD) | 90 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_PageHasOSDD, OnPageHasOSDD) |
| 91 IPC_MESSAGE_UNHANDLED(handled = false) | 91 IPC_MESSAGE_UNHANDLED(handled = false) |
| 92 IPC_END_MESSAGE_MAP() | 92 IPC_END_MESSAGE_MAP() |
| 93 | 93 |
| 94 return handled; | 94 return handled; |
| 95 } | 95 } |
| 96 | 96 |
| 97 SearchEngineTabHelper::SearchEngineTabHelper(WebContents* web_contents) | 97 SearchEngineTabHelper::SearchEngineTabHelper(WebContents* web_contents) |
| 98 : content::WebContentsObserver(web_contents), | 98 : content::WebContentsObserver(web_contents), |
| 99 delegate_(nullptr), |
| 99 weak_ptr_factory_(this) { | 100 weak_ptr_factory_(this) { |
| 100 DCHECK(web_contents); | 101 DCHECK(web_contents); |
| 101 } | 102 } |
| 102 | 103 |
| 103 void SearchEngineTabHelper::OnPageHasOSDD( | 104 void SearchEngineTabHelper::OnPageHasOSDD( |
| 104 const GURL& page_url, | 105 const GURL& page_url, |
| 105 const GURL& osdd_url, | 106 const GURL& osdd_url, |
| 106 const search_provider::OSDDType& msg_provider_type) { | 107 const search_provider::OSDDType& msg_provider_type) { |
| 107 // 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 |
| 108 // necessary uses TemplateURLFetcher to download the OSDD and create a | 109 // necessary uses TemplateURLFetcher to download the OSDD and create a |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 // the favicon url wasn't obtained before the load started. This assumes the | 220 // the favicon url wasn't obtained before the load started. This assumes the |
| 220 // latter. | 221 // latter. |
| 221 // TODO(sky): Need a way to set the favicon that doesn't involve generating | 222 // TODO(sky): Need a way to set the favicon that doesn't involve generating |
| 222 // its url. | 223 // its url. |
| 223 data.favicon_url = current_favicon.is_valid() ? | 224 data.favicon_url = current_favicon.is_valid() ? |
| 224 current_favicon : TemplateURL::GenerateFaviconURL(params.referrer.url); | 225 current_favicon : TemplateURL::GenerateFaviconURL(params.referrer.url); |
| 225 data.safe_for_autoreplace = true; | 226 data.safe_for_autoreplace = true; |
| 226 data.input_encodings.push_back(params.searchable_form_encoding); | 227 data.input_encodings.push_back(params.searchable_form_encoding); |
| 227 url_service->Add(new TemplateURL(data)); | 228 url_service->Add(new TemplateURL(data)); |
| 228 } | 229 } |
| OLD | NEW |