Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: chrome/browser/search_engines/search_provider_install_data.h

Issue 268643002: Use the DefaultSearchManager as the exclusive authority on DSE, ignoring Web Data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: D'oh. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #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 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/callback.h" 11 #include "base/callback.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 "chrome/browser/webdata/web_data_service.h"
17 16
18 class GURL; 17 class GURL;
18 class Profile;
19 class SearchHostToURLsMap; 19 class SearchHostToURLsMap;
20 class TemplateURL; 20 class TemplateURL;
21 class TemplateURLService;
21 22
22 namespace content { 23 namespace content {
23 class RenderProcessHost; 24 class RenderProcessHost;
24 } 25 }
25 26
26 // Provides the search provider install state for the I/O thread. It works by 27 // 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 28 // 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 29 // away the results after the callbacks are done, so the results are always up
29 // to date with what is in the database. 30 // to date with what is in the database.
30 class SearchProviderInstallData : public WebDataServiceConsumer { 31 class 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
(...skipping 13 matching lines...) Expand all
54 void CallWhenLoaded(const base::Closure& closure); 55 void CallWhenLoaded(const base::Closure& closure);
55 56
56 // Returns the search provider install state for the given origin. 57 // Returns the search provider install state for the given origin.
57 // This should only be called while a task is called back from CallWhenLoaded. 58 // This should only be called while a task is called back from CallWhenLoaded.
58 State GetInstallState(const GURL& requested_origin); 59 State GetInstallState(const GURL& requested_origin);
59 60
60 // Called when the google base url has changed. 61 // Called when the google base url has changed.
61 void OnGoogleURLChange(const std::string& google_base_url); 62 void OnGoogleURLChange(const std::string& google_base_url);
62 63
63 private: 64 private:
64 // WebDataServiceConsumer 65 // Receives a copy of the TemplateURLService's keywords on the IO thread.
65 // Notification that the keywords have been loaded. 66 void OnTemplateURLsLoaded(ScopedVector<TemplateURL> template_urls,
66 // This is invoked from WebDataService, and should not be directly 67 TemplateURL* default_provider);
67 // invoked.
68 virtual void OnWebDataServiceRequestDone(
69 WebDataService::Handle h,
70 const WDTypedResult* result) OVERRIDE;
71 68
72 // Stores information about the default search provider. 69 // Stores information about the default search provider.
73 void SetDefault(const TemplateURL* template_url); 70 void SetDefault(const TemplateURL* template_url);
74 71
75 // Sets up the loaded state and then lets clients know that the search 72 // Sets up the loaded state and then lets clients know that the search
76 // provider install state has been loaded. 73 // provider install state has been loaded.
77 void OnLoadFailed(); 74 void OnLoadFailed();
78 75
79 // Does notifications to let clients know that the search provider 76 // Does notifications to let clients know that the search provider
80 // install state has been loaded. 77 // install state has been loaded.
81 void NotifyLoaded(); 78 void NotifyLoaded();
82 79
83 // The list of closures to call after the load has finished. 80 // The original data source. Only accessed on the UI thread.
81 TemplateURLService* template_url_service_;
82
83 // The list of closures to call after the load has finished. If empty, there
84 // is no pending load.
84 std::vector<base::Closure> closure_queue_; 85 std::vector<base::Closure> closure_queue_;
85 86
86 // Service used to store entries.
87 scoped_refptr<WebDataService> web_service_;
88
89 // If non-zero, we're waiting on a load.
90 WebDataService::Handle load_handle_;
91
92 // Holds results of a load that was done using this class. 87 // Holds results of a load that was done using this class.
93 scoped_ptr<SearchHostToURLsMap> provider_map_; 88 scoped_ptr<SearchHostToURLsMap> provider_map_;
94 89
95 // The list of template urls that are owned by the class. 90 // The list of template urls that are owned by the class.
96 ScopedVector<TemplateURL> template_urls_; 91 ScopedVector<TemplateURL> template_urls_;
97 92
98 // The security origin for the default search provider. 93 // The security origin for the default search provider.
99 std::string default_search_origin_; 94 std::string default_search_origin_;
100 95
101 // The google base url. 96 // The google base url.
102 std::string google_base_url_; 97 std::string google_base_url_;
103 98
104 base::WeakPtrFactory<SearchProviderInstallData> weak_factory_; 99 base::WeakPtrFactory<SearchProviderInstallData> weak_factory_;
105 100
106 DISALLOW_COPY_AND_ASSIGN(SearchProviderInstallData); 101 DISALLOW_COPY_AND_ASSIGN(SearchProviderInstallData);
107 }; 102 };
108 103
109 #endif // CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_DATA_H_ 104 #endif // CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698