| 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/search_engines/search_provider_install_data.h" | 5 #include "chrome/browser/search_engines/search_provider_install_data.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 registrar_.Add(this, ui_death_notification, ui_death_source); | 131 registrar_.Add(this, ui_death_notification, ui_death_source); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void GoogleURLObserver::Observe(int type, | 134 void GoogleURLObserver::Observe(int type, |
| 135 const NotificationSource& source, | 135 const NotificationSource& source, |
| 136 const NotificationDetails& details) { | 136 const NotificationDetails& details) { |
| 137 if (type == chrome::NOTIFICATION_GOOGLE_URL_UPDATED) { | 137 if (type == chrome::NOTIFICATION_GOOGLE_URL_UPDATED) { |
| 138 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 138 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 139 NewRunnableMethod(change_notifier_.get(), | 139 NewRunnableMethod(change_notifier_.get(), |
| 140 &GoogleURLChangeNotifier::OnChange, | 140 &GoogleURLChangeNotifier::OnChange, |
| 141 UIThreadSearchTermsData().GoogleBaseURLValue())); | 141 UIThreadSearchTermsData(NULL).GoogleBaseURLValue())); |
| 142 } else { | 142 } else { |
| 143 // This must be the death notification. | 143 // This must be the death notification. |
| 144 delete this; | 144 delete this; |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 | 147 |
| 148 // Indicates if the two inputs have the same security origin. | 148 // Indicates if the two inputs have the same security origin. |
| 149 // |requested_origin| should only be a security origin (no path, etc.). | 149 // |requested_origin| should only be a security origin (no path, etc.). |
| 150 // It is ok if |template_url| is NULL. | 150 // It is ok if |template_url| is NULL. |
| 151 static bool IsSameOrigin(const GURL& requested_origin, | 151 static bool IsSameOrigin(const GURL& requested_origin, |
| 152 const TemplateURL* template_url, | 152 const TemplateURL* template_url, |
| 153 const SearchTermsData& search_terms_data) { | 153 const SearchTermsData& search_terms_data) { |
| 154 DCHECK(requested_origin == requested_origin.GetOrigin()); | 154 DCHECK(requested_origin == requested_origin.GetOrigin()); |
| 155 return template_url && requested_origin == | 155 return template_url && requested_origin == |
| 156 TemplateURLService::GenerateSearchURLUsingTermsData( | 156 TemplateURLService::GenerateSearchURLUsingTermsData( |
| 157 template_url, | 157 template_url, |
| 158 search_terms_data).GetOrigin(); | 158 search_terms_data).GetOrigin(); |
| 159 } | 159 } |
| 160 | 160 |
| 161 } // namespace | 161 } // namespace |
| 162 | 162 |
| 163 SearchProviderInstallData::SearchProviderInstallData( | 163 SearchProviderInstallData::SearchProviderInstallData( |
| 164 WebDataService* web_service, | 164 WebDataService* web_service, |
| 165 int ui_death_notification, | 165 int ui_death_notification, |
| 166 const NotificationSource& ui_death_source) | 166 const NotificationSource& ui_death_source) |
| 167 : web_service_(web_service), | 167 : web_service_(web_service), |
| 168 load_handle_(0), | 168 load_handle_(0), |
| 169 google_base_url_(UIThreadSearchTermsData().GoogleBaseURLValue()) { | 169 google_base_url_(UIThreadSearchTermsData(NULL).GoogleBaseURLValue()) { |
| 170 // GoogleURLObserver is responsible for killing itself when | 170 // GoogleURLObserver is responsible for killing itself when |
| 171 // the given notification occurs. | 171 // the given notification occurs. |
| 172 new GoogleURLObserver(new GoogleURLChangeNotifier(AsWeakPtr()), | 172 new GoogleURLObserver(new GoogleURLChangeNotifier(AsWeakPtr()), |
| 173 ui_death_notification, ui_death_source); | 173 ui_death_notification, ui_death_source); |
| 174 DetachFromThread(); | 174 DetachFromThread(); |
| 175 } | 175 } |
| 176 | 176 |
| 177 SearchProviderInstallData::~SearchProviderInstallData() { | 177 SearchProviderInstallData::~SearchProviderInstallData() { |
| 178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 179 | 179 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 void SearchProviderInstallData::NotifyLoaded() { | 298 void SearchProviderInstallData::NotifyLoaded() { |
| 299 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 299 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 300 | 300 |
| 301 task_queue_.Run(); | 301 task_queue_.Run(); |
| 302 | 302 |
| 303 // Since we expect this request to be rare, clear out the information. This | 303 // Since we expect this request to be rare, clear out the information. This |
| 304 // also keeps the responses current as the search providers change. | 304 // also keeps the responses current as the search providers change. |
| 305 provider_map_.reset(); | 305 provider_map_.reset(); |
| 306 SetDefault(NULL); | 306 SetDefault(NULL); |
| 307 } | 307 } |
| OLD | NEW |