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

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

Issue 7232023: Added last_modified field to TemplateURL and database. Updated unit tests, including refactoring ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 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) 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_TEMPLATE_URL_SERVICE_H_ 5 #ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_
6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ 6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 // TemplateURLService takes ownership of any TemplateURL passed to it. If there 55 // TemplateURLService takes ownership of any TemplateURL passed to it. If there
56 // is a WebDataService, deletion is handled by WebDataService, otherwise 56 // is a WebDataService, deletion is handled by WebDataService, otherwise
57 // TemplateURLService handles deletion. 57 // TemplateURLService handles deletion.
58 58
59 class TemplateURLService : public WebDataServiceConsumer, 59 class TemplateURLService : public WebDataServiceConsumer,
60 public ProfileKeyedService, 60 public ProfileKeyedService,
61 public NotificationObserver { 61 public NotificationObserver {
62 public: 62 public:
63 typedef std::map<std::string, std::string> QueryTerms; 63 typedef std::map<std::string, std::string> QueryTerms;
64 typedef std::vector<const TemplateURL*> TemplateURLVector; 64 typedef std::vector<const TemplateURL*> TemplateURLVector;
65 // Type for a static function pointer that acts as a time source.
66 typedef base::Time(TimeProvider)();
65 67
66 // Struct used for initializing the data store with fake data. 68 // Struct used for initializing the data store with fake data.
67 // Each initializer is mapped to a TemplateURL. 69 // Each initializer is mapped to a TemplateURL.
68 struct Initializer { 70 struct Initializer {
69 const char* const keyword; 71 const char* const keyword;
70 const char* const url; 72 const char* const url;
71 const char* const content; 73 const char* const content;
72 }; 74 };
73 75
74 explicit TemplateURLService(Profile* profile); 76 explicit TemplateURLService(Profile* profile);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 search_engine_dialog_chosen_slot_ = slot; 235 search_engine_dialog_chosen_slot_ = slot;
234 } 236 }
235 237
236 int GetSearchEngineDialogSlot() const { 238 int GetSearchEngineDialogSlot() const {
237 return search_engine_dialog_chosen_slot_; 239 return search_engine_dialog_chosen_slot_;
238 } 240 }
239 241
240 // Registers the preferences used to save a TemplateURL to prefs. 242 // Registers the preferences used to save a TemplateURL to prefs.
241 static void RegisterUserPrefs(PrefService* prefs); 243 static void RegisterUserPrefs(PrefService* prefs);
242 244
245 #if defined(UNIT_TEST)
246 // Set a different time provider function, such as
247 // base::MockTimeProvider::StaticNow, when testing calls to base::Time::Now.
248 void set_time_provider(TimeProvider* time_provider) {
249 time_provider_ = time_provider;
250 }
251 #endif
252
243 protected: 253 protected:
244 // Cover method for the method of the same name on the HistoryService. 254 // Cover method for the method of the same name on the HistoryService.
245 // url is the one that was visited with the given search terms. 255 // url is the one that was visited with the given search terms.
246 // 256 //
247 // This exists and is virtual for testing. 257 // This exists and is virtual for testing.
248 virtual void SetKeywordSearchTermsForURL(const TemplateURL* t_url, 258 virtual void SetKeywordSearchTermsForURL(const TemplateURL* t_url,
249 const GURL& url, 259 const GURL& url,
250 const string16& term); 260 const string16& term);
251 261
252 private: 262 private:
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 // preferences have changed. 443 // preferences have changed.
434 scoped_ptr<PrefSetObserver> default_search_prefs_; 444 scoped_ptr<PrefSetObserver> default_search_prefs_;
435 445
436 // ID assigned to next TemplateURL added to this model. This is an ever 446 // ID assigned to next TemplateURL added to this model. This is an ever
437 // increasing integer that is initialized from the database. 447 // increasing integer that is initialized from the database.
438 TemplateURLID next_id_; 448 TemplateURLID next_id_;
439 449
440 // List of extension IDs waiting for Load to have keywords registered. 450 // List of extension IDs waiting for Load to have keywords registered.
441 std::vector<std::string> pending_extension_ids_; 451 std::vector<std::string> pending_extension_ids_;
442 452
453 // Function returning current time in base::Time units.
454 TimeProvider* time_provider_;
455
443 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); 456 DISALLOW_COPY_AND_ASSIGN(TemplateURLService);
444 }; 457 };
445 458
446 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ 459 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/template_url_prepopulate_data.cc ('k') | chrome/browser/search_engines/template_url_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698