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