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

Unified Diff: chrome/browser/search_engines/template_url_service.h

Issue 367863005: No chrome dependencies in TemplateURLService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/search_engines/template_url_service.h
diff --git a/chrome/browser/search_engines/template_url_service.h b/chrome/browser/search_engines/template_url_service.h
index 34e18f65c7f8e4370af62c6cd5c7997ebd7cfb7f..4786038a3a52d442d0082de3a67cd0e88a86e42a 100644
--- a/chrome/browser/search_engines/template_url_service.h
+++ b/chrome/browser/search_engines/template_url_service.h
@@ -23,18 +23,16 @@
#include "components/search_engines/template_url.h"
#include "components/search_engines/template_url_id.h"
#include "components/webdata/common/web_data_service_consumer.h"
-#include "content/public/browser/notification_observer.h"
-#include "content/public/browser/notification_registrar.h"
#include "sync/api/sync_change.h"
#include "sync/api/syncable_service.h"
class GURL;
class PrefService;
-class Profile;
class SearchHostToURLsMap;
class SearchTermsData;
class TemplateURL;
struct TemplateURLData;
+class TemplateURLService;
class TemplateURLServiceObserver;
namespace rappor {
@@ -46,9 +44,27 @@ class SyncData;
class SyncErrorFactory;
}
-namespace history {
-struct URLVisitedDetails;
-}
+// This interface provides history related functionalities required by
Peter Kasting 2014/07/02 20:45:57 Nit: functionalities -> functionality
hashimoto 2014/07/03 00:05:07 Done.
+// TemplateURLService.
+// TODO(hashimoto): Get rid of this once HistoryService gets componentized.
+class KeywordHistoryServiceInterface {
Peter Kasting 2014/07/02 20:45:57 Nit: I think this interface should be declared in
hashimoto 2014/07/03 00:05:07 Some components have "XXXClient" classes which are
hashimoto 2014/07/03 07:13:31 Colin, I'm going to introduce a new interface Keyw
+ public:
+ virtual ~KeywordHistoryServiceInterface() {}
+
+ // Sets the pointer to the owner of this object.
+ virtual void SetOwner(TemplateURLService* owner) = 0;
+
+ // Deletes all search terms for the specified keyword.
+ virtual void DeleteAllSearchTermsForKeyword(TemplateURLID id) = 0;
+
+ // Sets the search terms for the specified url and keyword.
+ virtual void SetKeywordSearchTermsForURL(const GURL& url,
+ TemplateURLID id,
+ const base::string16& term) = 0;
+
+ // Adds the given URL to history as a keyword generated visit.
+ virtual void AddKeywordGeneratedVisit(const GURL& url) = 0;
+};
// TemplateURLService is the backend for keywords. It's used by
// KeywordAutocomplete.
@@ -59,8 +75,6 @@ struct URLVisitedDetails;
// This allows TemplateURLService to notify listeners of changes as well as keep
// the database in sync.
//
-// There is a TemplateURLService per Profile.
-//
// TemplateURLService does not load the vector of TemplateURLs in its
// constructor (except for testing). Use the Load method to trigger a load.
// When TemplateURLService has completed loading, observers are notified via
@@ -73,7 +87,6 @@ struct URLVisitedDetails;
class TemplateURLService : public WebDataServiceConsumer,
public KeyedService,
- public content::NotificationObserver,
public syncer::SyncableService {
public:
typedef std::map<std::string, std::string> QueryTerms;
@@ -91,7 +104,16 @@ class TemplateURLService : public WebDataServiceConsumer,
const char* const content;
};
- TemplateURLService(Profile* profile,
+ struct URLVisitedDetails {
+ GURL url;
+ bool is_keyword_transition;
+ };
+
+ TemplateURLService(PrefService* prefs,
+ scoped_ptr<SearchTermsData> search_terms_data,
+ KeywordWebDataService* web_data_service,
+ scoped_ptr<KeywordHistoryServiceInterface> history_service,
+ GoogleURLTracker* google_url_tracker,
rappor::RapporService* rappor_service,
const base::Closure& dsp_change_callback);
// The following is for testing.
@@ -299,10 +321,8 @@ class TemplateURLService : public WebDataServiceConsumer,
base::string16 GetKeywordShortName(const base::string16& keyword,
bool* is_omnibox_api_extension_keyword);
- // content::NotificationObserver implementation.
- virtual void Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) OVERRIDE;
+ // Called by the history service when a URL is visited.
+ void OnHistoryURLVisited(const URLVisitedDetails& details);
// KeyedService implementation.
virtual void Shutdown() OVERRIDE;
@@ -515,8 +535,7 @@ class TemplateURLService : public WebDataServiceConsumer,
// Iterates through the TemplateURLs to see if one matches the visited url.
// For each TemplateURL whose url matches the visited url
// SetKeywordSearchTermsForURL is invoked.
- void UpdateKeywordSearchTermsForURL(
- const history::URLVisitedDetails& details);
+ void UpdateKeywordSearchTermsForURL(const URLVisitedDetails& details);
// If necessary, generates a visit for the site http:// + t_url.keyword().
void AddTabToSearchVisit(const TemplateURL& t_url);
@@ -649,7 +668,6 @@ class TemplateURLService : public WebDataServiceConsumer,
// engine.
void UpdateExtensionDefaultSearchEngine();
- content::NotificationRegistrar notification_registrar_;
PrefChangeRegistrar pref_change_registrar_;
// Mapping from keyword to the TemplateURL.
@@ -667,17 +685,19 @@ class TemplateURLService : public WebDataServiceConsumer,
// header dependencies.
scoped_ptr<SearchHostToURLsMap> provider_map_;
- // Used to obtain the WebDataService.
- // When Load is invoked, if we haven't yet loaded, the WebDataService is
- // obtained from the Profile. This allows us to lazily access the database.
- Profile* profile_;
-
PrefService* prefs_;
- rappor::RapporService* rappor_service_;
-
scoped_ptr<SearchTermsData> search_terms_data_;
Peter Kasting 2014/07/02 20:45:57 Tiny nit: The order of these members feels a littl
hashimoto 2014/07/03 00:05:07 My logic behind this ordering is based on how ofte
Peter Kasting 2014/07/03 00:12:31 Hmm. That ordering is not at all obvious to a rea
hashimoto 2014/07/03 00:36:24 Also this ordering divides these members into 3 ca
+ // Service used to store entries.
+ scoped_refptr<KeywordWebDataService> web_data_service_;
+
+ scoped_ptr<KeywordHistoryServiceInterface> history_service_;
+
+ GoogleURLTracker* google_url_tracker_;
+
+ rappor::RapporService* rappor_service_;
+
// This closure is run when the default search provider is set to Google.
base::Closure dsp_change_callback_;
@@ -692,12 +712,9 @@ class TemplateURLService : public WebDataServiceConsumer,
// If non-zero, we're waiting on a load.
KeywordWebDataService::Handle load_handle_;
- // Service used to store entries.
- scoped_refptr<KeywordWebDataService> web_data_service_;
-
// All visits that occurred before we finished loading. Once loaded
// UpdateKeywordSearchTermsForURL is invoked for each element of the vector.
- std::vector<history::URLVisitedDetails> visits_to_add_;
+ std::vector<URLVisitedDetails> visits_to_add_;
// Once loaded, the default search provider. This is a pointer to a
// TemplateURL owned by |template_urls_|.

Powered by Google App Engine
This is Rietveld 408576698