OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_model.h" | 10 #include "chrome/browser/search_engines/template_url_model.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 IPC_MESSAGE_HANDLER(ViewHostMsg_PageHasOSDD, OnPageHasOSDD) | 43 IPC_MESSAGE_HANDLER(ViewHostMsg_PageHasOSDD, OnPageHasOSDD) |
44 IPC_MESSAGE_UNHANDLED(handled = false) | 44 IPC_MESSAGE_UNHANDLED(handled = false) |
45 IPC_END_MESSAGE_MAP() | 45 IPC_END_MESSAGE_MAP() |
46 | 46 |
47 return handled; | 47 return handled; |
48 } | 48 } |
49 | 49 |
50 void SearchEngineTabHelper::OnPageHasOSDD( | 50 void SearchEngineTabHelper::OnPageHasOSDD( |
51 int32 page_id, | 51 int32 page_id, |
52 const GURL& doc_url, | 52 const GURL& doc_url, |
53 const ViewHostMsg_PageHasOSDD_Type& msg_provider_type) { | 53 const search_provider::OSDDType& msg_provider_type) { |
54 // Checks to see if we should generate a keyword based on the OSDD, and if | 54 // Checks to see if we should generate a keyword based on the OSDD, and if |
55 // necessary uses TemplateURLFetcher to download the OSDD and create a | 55 // necessary uses TemplateURLFetcher to download the OSDD and create a |
56 // keyword. | 56 // keyword. |
57 | 57 |
58 // Make sure page_id is the current page and other basic checks. | 58 // Make sure page_id is the current page and other basic checks. |
59 DCHECK(doc_url.is_valid()); | 59 DCHECK(doc_url.is_valid()); |
60 if (!tab_contents()->IsActiveEntry(page_id)) | 60 if (!tab_contents()->IsActiveEntry(page_id)) |
61 return; | 61 return; |
62 if (!tab_contents()->profile()->GetTemplateURLFetcher()) | 62 if (!tab_contents()->profile()->GetTemplateURLFetcher()) |
63 return; | 63 return; |
64 if (tab_contents()->profile()->IsOffTheRecord()) | 64 if (tab_contents()->profile()->IsOffTheRecord()) |
65 return; | 65 return; |
66 | 66 |
67 TemplateURLFetcher::ProviderType provider_type; | 67 TemplateURLFetcher::ProviderType provider_type; |
68 switch (msg_provider_type.type) { | 68 switch (msg_provider_type) { |
69 case ViewHostMsg_PageHasOSDD_Type::AUTODETECTED_PROVIDER: | 69 case search_provider::AUTODETECTED_PROVIDER: |
70 provider_type = TemplateURLFetcher::AUTODETECTED_PROVIDER; | 70 provider_type = TemplateURLFetcher::AUTODETECTED_PROVIDER; |
71 break; | 71 break; |
72 | 72 |
73 case ViewHostMsg_PageHasOSDD_Type::EXPLICIT_DEFAULT_PROVIDER: | 73 case search_provider::EXPLICIT_DEFAULT_PROVIDER: |
74 provider_type = TemplateURLFetcher::EXPLICIT_DEFAULT_PROVIDER; | 74 provider_type = TemplateURLFetcher::EXPLICIT_DEFAULT_PROVIDER; |
75 break; | 75 break; |
76 | 76 |
77 case ViewHostMsg_PageHasOSDD_Type::EXPLICIT_PROVIDER: | 77 case search_provider::EXPLICIT_PROVIDER: |
78 provider_type = TemplateURLFetcher::EXPLICIT_PROVIDER; | 78 provider_type = TemplateURLFetcher::EXPLICIT_PROVIDER; |
79 break; | 79 break; |
80 | 80 |
81 default: | 81 default: |
82 NOTREACHED(); | 82 NOTREACHED(); |
83 return; | 83 return; |
84 } | 84 } |
85 | 85 |
86 const NavigationController& controller = tab_contents()->controller(); | 86 const NavigationController& controller = tab_contents()->controller(); |
87 const NavigationEntry* entry = controller.GetLastCommittedEntry(); | 87 const NavigationEntry* entry = controller.GetLastCommittedEntry(); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 // The favicon url isn't valid. This means there really isn't a favicon, | 191 // The favicon url isn't valid. This means there really isn't a favicon, |
192 // or the favicon url wasn't obtained before the load started. This assumes | 192 // or the favicon url wasn't obtained before the load started. This assumes |
193 // the later. | 193 // the later. |
194 // TODO(sky): Need a way to set the favicon that doesn't involve generating | 194 // TODO(sky): Need a way to set the favicon that doesn't involve generating |
195 // its url. | 195 // its url. |
196 new_url->SetFaviconURL(TemplateURL::GenerateFaviconURL(params.referrer)); | 196 new_url->SetFaviconURL(TemplateURL::GenerateFaviconURL(params.referrer)); |
197 } | 197 } |
198 new_url->set_safe_for_autoreplace(true); | 198 new_url->set_safe_for_autoreplace(true); |
199 url_model->Add(new_url); | 199 url_model->Add(new_url); |
200 } | 200 } |
OLD | NEW |