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 #ifndef CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_DATA_H_ | 5 #ifndef CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_DATA_H_ |
6 #define CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_DATA_H_ | 6 #define CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_DATA_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/task_queue.h" | 16 #include "base/task_queue.h" |
17 #include "chrome/browser/webdata/web_data_service.h" | 17 #include "chrome/browser/webdata/web_data_service.h" |
18 | 18 |
19 class GURL; | 19 class GURL; |
20 class NotificationSource; | 20 class NotificationSource; |
21 class NotificationType; | |
22 class SearchHostToURLsMap; | 21 class SearchHostToURLsMap; |
23 class Task; | 22 class Task; |
24 class TemplateURL; | 23 class TemplateURL; |
25 | 24 |
26 // Provides the search provider install state for the I/O thread. It works by | 25 // Provides the search provider install state for the I/O thread. It works by |
27 // loading the data on demand (when CallWhenLoaded is called) and then throwing | 26 // loading the data on demand (when CallWhenLoaded is called) and then throwing |
28 // away the results after the callbacks are done, so the results are always up | 27 // away the results after the callbacks are done, so the results are always up |
29 // to date with what is in the database. | 28 // to date with what is in the database. |
30 class SearchProviderInstallData : public WebDataServiceConsumer, | 29 class SearchProviderInstallData : public WebDataServiceConsumer, |
31 public base::SupportsWeakPtr<SearchProviderInstallData> { | 30 public base::SupportsWeakPtr<SearchProviderInstallData> { |
32 public: | 31 public: |
33 enum State { | 32 enum State { |
34 // The search provider is not installed. | 33 // The search provider is not installed. |
35 NOT_INSTALLED = 0, | 34 NOT_INSTALLED = 0, |
36 | 35 |
37 // The search provider is in the user's set but is not | 36 // The search provider is in the user's set but is not |
38 INSTALLED_BUT_NOT_DEFAULT = 1, | 37 INSTALLED_BUT_NOT_DEFAULT = 1, |
39 | 38 |
40 // The search provider is set as the user's default. | 39 // The search provider is set as the user's default. |
41 INSTALLED_AS_DEFAULT = 2 | 40 INSTALLED_AS_DEFAULT = 2 |
42 }; | 41 }; |
43 | 42 |
44 // |ui_death_notification| and |ui_death_source| indentify a notification that | 43 // |ui_death_notification| and |ui_death_source| indentify a notification that |
45 // may be observed on the UI thread to know when this class no longer needs to | 44 // may be observed on the UI thread to know when this class no longer needs to |
46 // be kept up to date. (Note that this class may be deleted before or after | 45 // be kept up to date. (Note that this class may be deleted before or after |
47 // that notification occurs. It doesn't matter.) | 46 // that notification occurs. It doesn't matter.) |
48 SearchProviderInstallData(WebDataService* web_service, | 47 SearchProviderInstallData(WebDataService* web_service, |
49 NotificationType ui_death_notification, | 48 int ui_death_notification, |
50 const NotificationSource& ui_death_source); | 49 const NotificationSource& ui_death_source); |
51 virtual ~SearchProviderInstallData(); | 50 virtual ~SearchProviderInstallData(); |
52 | 51 |
53 // Use to determine when the search provider information is loaded. The | 52 // Use to determine when the search provider information is loaded. The |
54 // callback may happen synchronously or asynchronously. This takes ownership | 53 // callback may happen synchronously or asynchronously. This takes ownership |
55 // of |task|. There is no need to do anything special to make it function | 54 // of |task|. There is no need to do anything special to make it function |
56 // (as it just relies on the normal I/O thread message loop). | 55 // (as it just relies on the normal I/O thread message loop). |
57 void CallWhenLoaded(Task* task); | 56 void CallWhenLoaded(Task* task); |
58 | 57 |
59 // Returns the search provider install state for the given origin. | 58 // Returns the search provider install state for the given origin. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 // The security origin for the default search provider. | 99 // The security origin for the default search provider. |
101 std::string default_search_origin_; | 100 std::string default_search_origin_; |
102 | 101 |
103 // The google base url. | 102 // The google base url. |
104 std::string google_base_url_; | 103 std::string google_base_url_; |
105 | 104 |
106 DISALLOW_COPY_AND_ASSIGN(SearchProviderInstallData); | 105 DISALLOW_COPY_AND_ASSIGN(SearchProviderInstallData); |
107 }; | 106 }; |
108 | 107 |
109 #endif // CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_DATA_H_ | 108 #endif // CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_DATA_H_ |
OLD | NEW |