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" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/task.h" | 12 #include "base/task.h" |
13 #include "chrome/browser/search_engines/search_host_to_urls_map.h" | 13 #include "chrome/browser/search_engines/search_host_to_urls_map.h" |
14 #include "chrome/browser/search_engines/search_terms_data.h" | 14 #include "chrome/browser/search_engines/search_terms_data.h" |
15 #include "chrome/browser/search_engines/template_url.h" | 15 #include "chrome/browser/search_engines/template_url.h" |
16 #include "chrome/browser/search_engines/template_url_service.h" | 16 #include "chrome/browser/search_engines/template_url_service.h" |
17 #include "chrome/browser/search_engines/util.h" | 17 #include "chrome/browser/search_engines/util.h" |
18 #include "chrome/browser/webdata/web_data_service.h" | 18 #include "chrome/browser/webdata/web_data_service.h" |
19 #include "chrome/common/chrome_notification_types.h" | 19 #include "chrome/common/chrome_notification_types.h" |
20 #include "content/browser/browser_thread.h" | 20 #include "content/browser/browser_thread.h" |
21 #include "content/public/browser/notification_observer.h" | 21 #include "content/public/browser/notification_observer.h" |
22 #include "content/public/browser/notification_registrar.h" | 22 #include "content/public/browser/notification_registrar.h" |
23 #include "content/common/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
24 #include "content/public/browser/notification_source.h" | 24 #include "content/public/browser/notification_source.h" |
25 | 25 |
26 typedef SearchHostToURLsMap::TemplateURLSet TemplateURLSet; | 26 typedef SearchHostToURLsMap::TemplateURLSet TemplateURLSet; |
27 | 27 |
28 namespace { | 28 namespace { |
29 | 29 |
30 // Implementation of SearchTermsData that may be used on the I/O thread. | 30 // Implementation of SearchTermsData that may be used on the I/O thread. |
31 class IOThreadSearchTermsData : public SearchTermsData { | 31 class IOThreadSearchTermsData : public SearchTermsData { |
32 public: | 32 public: |
33 explicit IOThreadSearchTermsData(const std::string& google_base_url); | 33 explicit IOThreadSearchTermsData(const std::string& google_base_url); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 DISALLOW_COPY_AND_ASSIGN(GoogleURLObserver); | 120 DISALLOW_COPY_AND_ASSIGN(GoogleURLObserver); |
121 }; | 121 }; |
122 | 122 |
123 GoogleURLObserver::GoogleURLObserver( | 123 GoogleURLObserver::GoogleURLObserver( |
124 GoogleURLChangeNotifier* change_notifier, | 124 GoogleURLChangeNotifier* change_notifier, |
125 int ui_death_notification, | 125 int ui_death_notification, |
126 const content::NotificationSource& ui_death_source) | 126 const content::NotificationSource& ui_death_source) |
127 : change_notifier_(change_notifier) { | 127 : change_notifier_(change_notifier) { |
128 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 128 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
129 registrar_.Add(this, chrome::NOTIFICATION_GOOGLE_URL_UPDATED, | 129 registrar_.Add(this, chrome::NOTIFICATION_GOOGLE_URL_UPDATED, |
130 NotificationService::AllSources()); | 130 content::NotificationService::AllSources()); |
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 content::NotificationSource& source, | 135 const content::NotificationSource& source, |
136 const content::NotificationDetails& details) { | 136 const content::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, |
(...skipping 157 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 |