Index: chrome/browser/instant/instant_service.h |
diff --git a/chrome/browser/instant/instant_service.h b/chrome/browser/instant/instant_service.h |
index 9bf8f5d64851cf2b80807dab6090ba25e92f2824..8bb7966d7ae02005eaece90ed9ec0950ea142c2f 100644 |
--- a/chrome/browser/instant/instant_service.h |
+++ b/chrome/browser/instant/instant_service.h |
@@ -5,45 +5,119 @@ |
#ifndef CHROME_BROWSER_INSTANT_INSTANT_SERVICE_H_ |
#define CHROME_BROWSER_INSTANT_INSTANT_SERVICE_H_ |
+#include <list> |
#include <set> |
+#include <string> |
+#include <utility> |
+#include <vector> |
#include "base/basictypes.h" |
#include "base/compiler_specific.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "base/observer_list.h" |
+#include "base/prefs/public/pref_change_registrar.h" |
+#include "base/string16.h" |
+#include "chrome/browser/history/history_types.h" |
#include "chrome/browser/profiles/profile_keyed_service.h" |
+#include "chrome/common/instant_types.h" |
#include "content/public/browser/notification_observer.h" |
#include "content/public/browser/notification_registrar.h" |
-// Tracks render process host IDs that are associated with Instant. |
+class InstantLoader; |
+class InstantServiceObserver; |
+class Profile; |
+class ThemeService; |
+ |
+namespace history { |
+class TopSites; |
+} |
+ |
+// Tracks Instant-related per-profile things, such as render process host IDs, |
+// chrome://settings preferences, omnibox size, theme background, etc. |
class InstantService : public ProfileKeyedService, |
public content::NotificationObserver { |
public: |
- InstantService(); |
+ explicit InstantService(Profile* profile); |
virtual ~InstantService(); |
- // Add, remove, and query RenderProcessHost IDs that are associated with |
- // Instant processes. |
+ Profile* profile() const { return profile_; } |
+ InstantLoader* loader() const { return loader_.get(); } |
+ |
+ const std::list<std::pair<int64, std::string> >& debug_events() const { |
+ return debug_events_; |
+ } |
+ void LogDebugEvent(const std::string& message); |
+ |
+ void AddObserver(InstantServiceObserver* observer); |
+ void RemoveObserver(InstantServiceObserver* observer); |
+ |
+ // Add and query RenderProcessHost IDs associated with Instant processes. |
void AddInstantProcess(int process_id); |
bool IsInstantProcess(int process_id) const; |
#if defined(UNIT_TEST) |
- int GetInstantProcessCount() const { |
- return process_ids_.size(); |
- } |
+ int GetInstantProcessCount() const { return process_ids_.size(); } |
#endif |
- private: |
- // Overridden from ProfileKeyedService: |
- virtual void Shutdown() OVERRIDE; |
+ const string16& omnibox_font_name() const { return omnibox_font_name_; } |
+ size_t omnibox_font_size() const { return omnibox_font_size_; } |
+ |
+ // The omnibox start margin is the same in all browser windows in a profile, |
+ // so it can be considered a per-profile setting. It is used in contexts |
+ // where there are no browser windows available, such as in InstantLoader. |
+ // However, since InstantService has no knowledge of browser windows, this |
+ // information must be passed to us by say, an InstantController. If there |
+ // are multiple windows open, and the margin changes, each instance of |
+ // InstantController will call us with this info, but it shouldn't be a |
+ // problem since, as above, the info will be the same in all calls. |
+ int omnibox_start_margin() const { return omnibox_start_margin_; } |
+ void set_omnibox_start_margin(int omnibox_start_margin) { |
+ omnibox_start_margin_ = omnibox_start_margin; |
+ } |
+ |
+ const ThemeBackgroundInfo& theme_info() const { return theme_info_; } |
+ const std::vector<MostVisitedItem>& most_visited_items() const { |
+ return most_visited_items_; |
+ } |
+ |
+ void InstantSupportDecided(); |
+ |
+ private: |
// Overridden from content::NotificationObserver: |
virtual void Observe(int type, |
const content::NotificationSource& source, |
const content::NotificationDetails& details) OVERRIDE; |
- // The process ids associated with Instant processes. |
+ void PrefChanged(const std::string& pref_name); |
samarth
2013/03/01 17:59:53
Comments for what these do please.
sreeram
2013/03/07 18:18:46
Done.
|
+ void ParseTheme(ThemeService* theme_service); |
+ void RequestMostVisitedItems(history::TopSites* top_sites); |
+ void MostVisitedItemsReceived(const history::MostVisitedURLList& data); |
+ |
+ Profile* const profile_; |
+ scoped_ptr<InstantLoader> loader_; |
+ |
+ std::list<std::pair<int64, std::string> > debug_events_; |
samarth
2013/03/01 17:59:53
A typedef here (mapping InstantService::DebugMessa
sreeram
2013/03/07 18:18:46
Done.
|
+ |
+ ObserverList<InstantServiceObserver> observers_; |
+ content::NotificationRegistrar notification_registrar_; |
+ PrefChangeRegistrar pref_change_registrar_; |
+ |
+ // The process IDs associated with Instant processes. |
std::set<int> process_ids_; |
- content::NotificationRegistrar registrar_; |
+ // Omnibox font name and size. Initialized at startup. These never change. |
+ string16 omnibox_font_name_; |
+ size_t omnibox_font_size_; |
+ |
+ int omnibox_start_margin_; |
+ |
+ bool instant_pref_enabled_; |
+ bool instant_enabled_; |
+ |
+ ThemeBackgroundInfo theme_info_; |
+ |
+ std::vector<MostVisitedItem> most_visited_items_; |
DISALLOW_COPY_AND_ASSIGN(InstantService); |
}; |