Chromium Code Reviews| OLD | NEW | 
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_INSTANT_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SEARCH_INSTANT_SERVICE_H_ | 
| 6 #define CHROME_BROWSER_SEARCH_INSTANT_SERVICE_H_ | 6 #define CHROME_BROWSER_SEARCH_INSTANT_SERVICE_H_ | 
| 7 | 7 | 
| 8 #include <map> | 8 #include <map> | 
| 9 #include <set> | 9 #include <set> | 
| 10 #include <string> | 10 #include <string> | 
| 11 #include <vector> | 11 #include <vector> | 
| 12 | 12 | 
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" | 
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" | 
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" | 
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" | 
| 17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" | 
| 18 #include "base/prefs/pref_change_registrar.h" | 18 #include "base/prefs/pref_change_registrar.h" | 
| 19 #include "chrome/browser/google/google_url_tracker.h" | 19 #include "chrome/browser/google/google_url_tracker.h" | 
| 20 #include "chrome/browser/history/history_types.h" | 20 #include "chrome/browser/history/history_types.h" | 
| 21 #include "chrome/browser/search_engines/template_url_service_observer.h" | |
| 21 #include "chrome/browser/ui/search/instant_search_prerenderer.h" | 22 #include "chrome/browser/ui/search/instant_search_prerenderer.h" | 
| 22 #include "chrome/common/instant_types.h" | 23 #include "chrome/common/instant_types.h" | 
| 23 #include "components/keyed_service/core/keyed_service.h" | 24 #include "components/keyed_service/core/keyed_service.h" | 
| 24 #include "content/public/browser/notification_observer.h" | 25 #include "content/public/browser/notification_observer.h" | 
| 25 #include "content/public/browser/notification_registrar.h" | 26 #include "content/public/browser/notification_registrar.h" | 
| 26 | 27 | 
| 27 class GURL; | 28 class GURL; | 
| 28 class InstantIOContext; | 29 class InstantIOContext; | 
| 29 class InstantServiceObserver; | 30 class InstantServiceObserver; | 
| 30 class InstantTestBase; | 31 class InstantTestBase; | 
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 // changed. | 94 // changed. | 
| 94 void OnOmniboxStartMarginChanged(int start_margin); | 95 void OnOmniboxStartMarginChanged(int start_margin); | 
| 95 | 96 | 
| 96 InstantSearchPrerenderer* instant_search_prerenderer() { | 97 InstantSearchPrerenderer* instant_search_prerenderer() { | 
| 97 return instant_prerenderer_.get(); | 98 return instant_prerenderer_.get(); | 
| 98 } | 99 } | 
| 99 | 100 | 
| 100 int omnibox_start_margin() const { return omnibox_start_margin_; } | 101 int omnibox_start_margin() const { return omnibox_start_margin_; } | 
| 101 | 102 | 
| 102 private: | 103 private: | 
| 104 class DefaultSearchEngineWatcher : public TemplateURLServiceObserver { | |
| 
 
Peter Kasting
2014/05/03 00:28:18
What do we gain by having this class instead of ma
 
erikwright (departed)
2014/05/03 00:54:08
It maintains encapsulation. OnTemplateURLServiceCh
 
Peter Kasting
2014/05/03 01:18:17
That's fine, you should be declaring that method p
 
erikwright (departed)
2014/05/03 01:24:59
It's not as though converting from an InstantServi
 
Peter Kasting
2014/05/03 01:31:01
It requires an explicit upcast or assignment.  Tha
 
erikwright (departed)
2014/05/05 01:49:38
Done.
 
 | |
| 105 public: | |
| 106 explicit DefaultSearchEngineWatcher(InstantService* outer); | |
| 
 
Peter Kasting
2014/05/03 00:28:18
Nit: I suggest explicitly declaring a virtual dest
 
erikwright (departed)
2014/05/05 01:49:38
Done.
 
 | |
| 107 virtual void OnTemplateURLServiceChanged() OVERRIDE; | |
| 108 | |
| 109 private: | |
| 110 InstantService* outer_; | |
| 111 DISALLOW_COPY_AND_ASSIGN(DefaultSearchEngineWatcher); | |
| 
 
Peter Kasting
2014/05/03 00:28:18
Tiny nit: I'd put a blank line above this.  Also p
 
erikwright (departed)
2014/05/05 01:49:38
Done.
 
 | |
| 112 }; | |
| 113 | |
| 103 friend class InstantExtendedTest; | 114 friend class InstantExtendedTest; | 
| 104 friend class InstantServiceTest; | 115 friend class InstantServiceTest; | 
| 105 friend class InstantTestBase; | 116 friend class InstantTestBase; | 
| 106 friend class InstantUnitTestBase; | 117 friend class InstantUnitTestBase; | 
| 107 | 118 | 
| 108 FRIEND_TEST_ALL_PREFIXES(InstantExtendedManualTest, | 119 FRIEND_TEST_ALL_PREFIXES(InstantExtendedManualTest, | 
| 109 MANUAL_SearchesFromFakebox); | 120 MANUAL_SearchesFromFakebox); | 
| 110 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, ProcessIsolation); | 121 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, ProcessIsolation); | 
| 111 FRIEND_TEST_ALL_PREFIXES(InstantServiceTest, SendsSearchURLsToRenderer); | 122 FRIEND_TEST_ALL_PREFIXES(InstantServiceTest, SendsSearchURLsToRenderer); | 
| 112 | 123 | 
| (...skipping 15 matching lines...) Expand all Loading... | |
| 128 | 139 | 
| 129 // Notifies the observer about the last known most visited items. | 140 // Notifies the observer about the last known most visited items. | 
| 130 void NotifyAboutMostVisitedItems(); | 141 void NotifyAboutMostVisitedItems(); | 
| 131 | 142 | 
| 132 // Theme changed notification handler. | 143 // Theme changed notification handler. | 
| 133 void OnThemeChanged(ThemeService* theme_service); | 144 void OnThemeChanged(ThemeService* theme_service); | 
| 134 | 145 | 
| 135 void OnGoogleURLUpdated(Profile* profile, | 146 void OnGoogleURLUpdated(Profile* profile, | 
| 136 GoogleURLTracker::UpdatedDetails* details); | 147 GoogleURLTracker::UpdatedDetails* details); | 
| 137 | 148 | 
| 138 void OnDefaultSearchProviderChanged(const std::string& pref_name); | 149 void OnTemplateURLServiceChanged(); | 
| 139 | 150 | 
| 140 void ResetInstantSearchPrerenderer(); | 151 void ResetInstantSearchPrerenderer(); | 
| 141 | 152 | 
| 142 Profile* const profile_; | 153 Profile* const profile_; | 
| 143 | 154 | 
| 144 // The process ids associated with Instant processes. | 155 // The process ids associated with Instant processes. | 
| 145 std::set<int> process_ids_; | 156 std::set<int> process_ids_; | 
| 146 | 157 | 
| 147 // InstantMostVisitedItems sent to the Instant Pages. | 158 // InstantMostVisitedItems sent to the Instant Pages. | 
| 148 std::vector<InstantMostVisitedItem> most_visited_items_; | 159 std::vector<InstantMostVisitedItem> most_visited_items_; | 
| (...skipping 12 matching lines...) Expand all Loading... | |
| 161 PrefChangeRegistrar profile_pref_registrar_; | 172 PrefChangeRegistrar profile_pref_registrar_; | 
| 162 | 173 | 
| 163 scoped_refptr<InstantIOContext> instant_io_context_; | 174 scoped_refptr<InstantIOContext> instant_io_context_; | 
| 164 | 175 | 
| 165 // Set to NULL if the default search provider does not support Instant. | 176 // Set to NULL if the default search provider does not support Instant. | 
| 166 scoped_ptr<InstantSearchPrerenderer> instant_prerenderer_; | 177 scoped_ptr<InstantSearchPrerenderer> instant_prerenderer_; | 
| 167 | 178 | 
| 168 // Used for Top Sites async retrieval. | 179 // Used for Top Sites async retrieval. | 
| 169 base::WeakPtrFactory<InstantService> weak_ptr_factory_; | 180 base::WeakPtrFactory<InstantService> weak_ptr_factory_; | 
| 170 | 181 | 
| 182 // Used to avoid resetting the instant_prerenderer_ if an unrelated change to | |
| 183 // the TemplateURLService occurs. | |
| 184 GURL current_search_result_prefetch_base_url_; | |
| 185 | |
| 186 DefaultSearchEngineWatcher default_search_engine_watcher_; | |
| 187 | |
| 171 DISALLOW_COPY_AND_ASSIGN(InstantService); | 188 DISALLOW_COPY_AND_ASSIGN(InstantService); | 
| 172 }; | 189 }; | 
| 173 | 190 | 
| 174 #endif // CHROME_BROWSER_SEARCH_INSTANT_SERVICE_H_ | 191 #endif // CHROME_BROWSER_SEARCH_INSTANT_SERVICE_H_ | 
| OLD | NEW |