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/instant_service.h

Issue 16413002: Moved theme related state from BrowserInstantController to InstantService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 7 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 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/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "base/observer_list.h"
17 #include "chrome/browser/history/history_types.h" 18 #include "chrome/browser/history/history_types.h"
18 #include "chrome/common/instant_types.h" 19 #include "chrome/common/instant_types.h"
19 #include "components/browser_context_keyed_service/browser_context_keyed_service .h" 20 #include "components/browser_context_keyed_service/browser_context_keyed_service .h"
20 #include "content/public/browser/notification_observer.h" 21 #include "content/public/browser/notification_observer.h"
21 #include "content/public/browser/notification_registrar.h" 22 #include "content/public/browser/notification_registrar.h"
22 23
23 class GURL; 24 class GURL;
24 class InstantIOContext; 25 class InstantIOContext;
26 class InstantServiceObserver;
25 class Profile; 27 class Profile;
28 class ThemeService;
26 29
27 namespace net { 30 namespace net {
28 class URLRequest; 31 class URLRequest;
29 } 32 }
30 33
31 // Tracks render process host IDs that are associated with Instant. 34 // Tracks render process host IDs that are associated with Instant.
32 class InstantService : public BrowserContextKeyedService, 35 class InstantService : public BrowserContextKeyedService,
33 public content::NotificationObserver { 36 public content::NotificationObserver {
34 public: 37 public:
35 explicit InstantService(Profile* profile); 38 explicit InstantService(Profile* profile);
36 virtual ~InstantService(); 39 virtual ~InstantService();
37 40
38 // Add, remove, and query RenderProcessHost IDs that are associated with 41 // Add, remove, and query RenderProcessHost IDs that are associated with
39 // Instant processes. 42 // Instant processes.
40 void AddInstantProcess(int process_id); 43 void AddInstantProcess(int process_id);
41 bool IsInstantProcess(int process_id) const; 44 bool IsInstantProcess(int process_id) const;
42 45
46 // Adds/Removes InstantService observers.
47 void AddObserver(InstantServiceObserver* observer);
48 void RemoveObserver(InstantServiceObserver* observer);
49
43 #if defined(UNIT_TEST) 50 #if defined(UNIT_TEST)
44 int GetInstantProcessCount() const { 51 int GetInstantProcessCount() const {
45 return process_ids_.size(); 52 return process_ids_.size();
46 } 53 }
47 #endif 54 #endif
48 55
49 // Most visited item API. 56 // Most visited item API.
50 57
51 // Invoked by the InstantController when the Instant page wants to delete a 58 // Invoked by the InstantController when the Instant page wants to delete a
52 // Most Visited item. 59 // Most Visited item.
53 void DeleteMostVisitedItem(const GURL& url); 60 void DeleteMostVisitedItem(const GURL& url);
54 61
55 // Invoked by the InstantController when the Instant page wants to undo the 62 // Invoked by the InstantController when the Instant page wants to undo the
56 // blacklist action. 63 // blacklist action.
57 void UndoMostVisitedDeletion(const GURL& url); 64 void UndoMostVisitedDeletion(const GURL& url);
58 65
59 // Invoked by the InstantController when the Instant page wants to undo all 66 // Invoked by the InstantController when the Instant page wants to undo all
60 // Most Visited deletions. 67 // Most Visited deletions.
61 void UndoAllMostVisitedDeletions(); 68 void UndoAllMostVisitedDeletions();
62 69
63 // Returns the last added InstantMostVisitedItems. 70 // Returns the last added InstantMostVisitedItems.
64 void GetCurrentMostVisitedItems( 71 void GetCurrentMostVisitedItems(
65 std::vector<InstantMostVisitedItem>* items) const; 72 std::vector<InstantMostVisitedItem>* items) const;
66 73
74 // Invoked by |instant_| to update theme information for NTP.
samarth 2013/06/19 00:14:36 The "by |instant_|" part doesn't make sense here.
kmadhusu 2013/06/19 02:27:24 Fixed.
75 void UpdateThemeInfo();
76
67 private: 77 private:
68 // Overridden from BrowserContextKeyedService: 78 // Overridden from BrowserContextKeyedService:
69 virtual void Shutdown() OVERRIDE; 79 virtual void Shutdown() OVERRIDE;
70 80
71 // Overridden from content::NotificationObserver: 81 // Overridden from content::NotificationObserver:
72 virtual void Observe(int type, 82 virtual void Observe(int type,
73 const content::NotificationSource& source, 83 const content::NotificationSource& source,
74 const content::NotificationDetails& details) OVERRIDE; 84 const content::NotificationDetails& details) OVERRIDE;
75 85
76 // Called when we get new most visited items from TopSites, registered as an 86 // Called when we get new most visited items from TopSites, registered as an
77 // async callback. Parses them and sends them to the renderer via 87 // async callback. Parses them and sends them to the renderer via
78 // SendMostVisitedItems. 88 // SendMostVisitedItems.
79 void OnMostVisitedItemsReceived(const history::MostVisitedURLList& data); 89 void OnMostVisitedItemsReceived(const history::MostVisitedURLList& data);
80 90
91 // Theme changed notification handler.
92 void OnThemeChanged(ThemeService* theme_service);
93
81 Profile* const profile_; 94 Profile* const profile_;
82 95
83 // The process ids associated with Instant processes. 96 // The process ids associated with Instant processes.
84 std::set<int> process_ids_; 97 std::set<int> process_ids_;
85 98
86 // InstantMostVisitedItems sent to the Instant Pages. 99 // InstantMostVisitedItems sent to the Instant Pages.
87 std::vector<InstantMostVisitedItem> most_visited_items_; 100 std::vector<InstantMostVisitedItem> most_visited_items_;
88 101
102 // Theme-related data for NTP overlay to adopt themes.
103 ThemeBackgroundInfo theme_info_;
104
105 ObserverList<InstantServiceObserver> observers_;
106
89 content::NotificationRegistrar registrar_; 107 content::NotificationRegistrar registrar_;
90 108
91 scoped_refptr<InstantIOContext> instant_io_context_; 109 scoped_refptr<InstantIOContext> instant_io_context_;
92 110
93 // Used for Top Sites async retrieval. 111 // Used for Top Sites async retrieval.
94 base::WeakPtrFactory<InstantService> weak_ptr_factory_; 112 base::WeakPtrFactory<InstantService> weak_ptr_factory_;
95 113
96 DISALLOW_COPY_AND_ASSIGN(InstantService); 114 DISALLOW_COPY_AND_ASSIGN(InstantService);
97 }; 115 };
98 116
99 #endif // CHROME_BROWSER_SEARCH_INSTANT_SERVICE_H_ 117 #endif // CHROME_BROWSER_SEARCH_INSTANT_SERVICE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/search/instant_service.cc » ('j') | chrome/browser/search/instant_service.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698