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

Side by Side Diff: chrome/browser/ui/webui/ntp/ntp_resource_cache.h

Issue 11345008: Remove content::NotificationObserver dependency from most Prefs code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head for commit Created 8 years, 1 month 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_UI_WEBUI_NTP_NTP_RESOURCE_CACHE_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_NTP_NTP_RESOURCE_CACHE_H_
6 #define CHROME_BROWSER_UI_WEBUI_NTP_NTP_RESOURCE_CACHE_H_ 6 #define CHROME_BROWSER_UI_WEBUI_NTP_NTP_RESOURCE_CACHE_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/prefs/public/pref_change_registrar.h" 11 #include "base/prefs/public/pref_change_registrar.h"
12 #include "base/prefs/public/pref_observer.h"
12 #include "base/string16.h" 13 #include "base/string16.h"
13 #include "chrome/browser/profiles/profile_keyed_service.h" 14 #include "chrome/browser/profiles/profile_keyed_service.h"
14 #include "content/public/browser/notification_observer.h" 15 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h" 16 #include "content/public/browser/notification_registrar.h"
16 17
17 class Profile; 18 class Profile;
18 19
19 namespace base { 20 namespace base {
20 class RefCountedMemory; 21 class RefCountedMemory;
21 } 22 }
22 23
23 namespace ui { 24 namespace ui {
24 class ThemeProvider; 25 class ThemeProvider;
25 } 26 }
26 27
27 // This class keeps a cache of NTP resources (HTML and CSS) so we don't have to 28 // This class keeps a cache of NTP resources (HTML and CSS) so we don't have to
28 // regenerate them all the time. 29 // regenerate them all the time.
29 class NTPResourceCache : public content::NotificationObserver, 30 class NTPResourceCache : public content::NotificationObserver,
31 public PrefObserver,
30 public ProfileKeyedService { 32 public ProfileKeyedService {
31 public: 33 public:
32 explicit NTPResourceCache(Profile* profile); 34 explicit NTPResourceCache(Profile* profile);
33 virtual ~NTPResourceCache(); 35 virtual ~NTPResourceCache();
34 36
35 base::RefCountedMemory* GetNewTabHTML(bool is_incognito); 37 base::RefCountedMemory* GetNewTabHTML(bool is_incognito);
36 base::RefCountedMemory* GetNewTabCSS(bool is_incognito); 38 base::RefCountedMemory* GetNewTabCSS(bool is_incognito);
37 39
38 // content::NotificationObserver interface. 40 // content::NotificationObserver interface.
39 virtual void Observe(int type, 41 virtual void Observe(int type,
40 const content::NotificationSource& source, 42 const content::NotificationSource& source,
41 const content::NotificationDetails& details) OVERRIDE; 43 const content::NotificationDetails& details) OVERRIDE;
42 44
45 // PrefObserver interface.
46 virtual void OnPreferenceChanged(PrefServiceBase* service,
47 const std::string& pref_name) OVERRIDE;
48
43 // Returns the CSS background-position-y style for new_tab_theme.css: 49 // Returns the CSS background-position-y style for new_tab_theme.css:
44 // - |y_pos| is the vertical offset of theme image in content view. 50 // - |y_pos| is the vertical offset of theme image in content view.
45 // - |alignment| is alignment of theme image. 51 // - |alignment| is alignment of theme image.
46 static std::string GetNewTabBackgroundPositionY(int y_pos, int alignment); 52 static std::string GetNewTabBackgroundPositionY(int y_pos, int alignment);
47 53
48 private: 54 private:
49 Profile* profile_; 55 Profile* profile_;
50 56
51 void CreateNewTabHTML(); 57 void CreateNewTabHTML();
52 scoped_refptr<base::RefCountedMemory> new_tab_html_; 58 scoped_refptr<base::RefCountedMemory> new_tab_html_;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 92
87 // Y-pos of |background_position| of new_tab_theme.css notified from 93 // Y-pos of |background_position| of new_tab_theme.css notified from
88 // |SearchViewController| via 94 // |SearchViewController| via
89 // chrome::NOTIFICATION_NTP_BACKGROUND_THEME_Y_POS_CHANGED. 95 // chrome::NOTIFICATION_NTP_BACKGROUND_THEME_Y_POS_CHANGED.
90 int css_background_y_pos_; 96 int css_background_y_pos_;
91 97
92 DISALLOW_COPY_AND_ASSIGN(NTPResourceCache); 98 DISALLOW_COPY_AND_ASSIGN(NTPResourceCache);
93 }; 99 };
94 100
95 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NTP_RESOURCE_CACHE_H_ 101 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NTP_RESOURCE_CACHE_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/ntp/ntp_login_handler.cc ('k') | chrome/browser/ui/webui/ntp/ntp_resource_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698