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/search_engines/search_provider_install_data.h" | 5 #include "chrome/browser/search_engines/search_provider_install_data.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 registrar_.Add(this, chrome::NOTIFICATION_GOOGLE_URL_UPDATED, | 122 registrar_.Add(this, chrome::NOTIFICATION_GOOGLE_URL_UPDATED, |
123 content::NotificationService::AllSources()); | 123 content::NotificationService::AllSources()); |
124 registrar_.Add(this, ui_death_notification, ui_death_source); | 124 registrar_.Add(this, ui_death_notification, ui_death_source); |
125 } | 125 } |
126 | 126 |
127 void GoogleURLObserver::Observe(int type, | 127 void GoogleURLObserver::Observe(int type, |
128 const content::NotificationSource& source, | 128 const content::NotificationSource& source, |
129 const content::NotificationDetails& details) { | 129 const content::NotificationDetails& details) { |
130 if (type == chrome::NOTIFICATION_GOOGLE_URL_UPDATED) { | 130 if (type == chrome::NOTIFICATION_GOOGLE_URL_UPDATED) { |
131 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 131 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
132 base::Bind(&GoogleURLChangeNotifier::OnChange, | 132 base::Bind(&GoogleURLChangeNotifier::OnChange, change_notifier_.get(), |
133 change_notifier_.get(), | |
134 UIThreadSearchTermsData().GoogleBaseURLValue())); | 133 UIThreadSearchTermsData().GoogleBaseURLValue())); |
135 } else { | 134 } else { |
136 // This must be the death notification. | 135 // This must be the death notification. |
137 delete this; | 136 delete this; |
138 } | 137 } |
139 } | 138 } |
140 | 139 |
141 // Indicates if the two inputs have the same security origin. | 140 // Indicates if the two inputs have the same security origin. |
142 // |requested_origin| should only be a security origin (no path, etc.). | 141 // |requested_origin| should only be a security origin (no path, etc.). |
143 // It is ok if |template_url| is NULL. | 142 // It is ok if |template_url| is NULL. |
144 static bool IsSameOrigin(const GURL& requested_origin, | 143 static bool IsSameOrigin(const GURL& requested_origin, |
145 const TemplateURL* template_url, | 144 const TemplateURL* template_url, |
146 const SearchTermsData& search_terms_data) { | 145 const SearchTermsData& search_terms_data) { |
147 DCHECK(requested_origin == requested_origin.GetOrigin()); | 146 DCHECK(requested_origin == requested_origin.GetOrigin()); |
148 return template_url && requested_origin == | 147 return requested_origin == |
Peter Kasting
2012/04/10 01:24:33
I don't think our lone caller will ever pass NULL
| |
149 TemplateURLService::GenerateSearchURLUsingTermsData( | 148 TemplateURLService::GenerateSearchURLUsingTermsData(template_url, |
150 template_url, | |
151 search_terms_data).GetOrigin(); | 149 search_terms_data).GetOrigin(); |
152 } | 150 } |
153 | 151 |
154 } // namespace | 152 } // namespace |
155 | 153 |
156 SearchProviderInstallData::SearchProviderInstallData( | 154 SearchProviderInstallData::SearchProviderInstallData( |
157 Profile* profile, | 155 Profile* profile, |
158 int ui_death_notification, | 156 int ui_death_notification, |
159 const content::NotificationSource& ui_death_source) | 157 const content::NotificationSource& ui_death_source) |
160 : web_service_(profile->GetWebDataService(Profile::EXPLICIT_ACCESS)), | 158 : web_service_(profile->GetWebDataService(Profile::EXPLICIT_ACCESS)), |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
294 | 292 |
295 std::for_each(closure_queue.begin(), | 293 std::for_each(closure_queue.begin(), |
296 closure_queue.end(), | 294 closure_queue.end(), |
297 std::mem_fun_ref(&base::Closure::Run)); | 295 std::mem_fun_ref(&base::Closure::Run)); |
298 | 296 |
299 // Since we expect this request to be rare, clear out the information. This | 297 // Since we expect this request to be rare, clear out the information. This |
300 // also keeps the responses current as the search providers change. | 298 // also keeps the responses current as the search providers change. |
301 provider_map_.reset(); | 299 provider_map_.reset(); |
302 SetDefault(NULL); | 300 SetDefault(NULL); |
303 } | 301 } |
OLD | NEW |