OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_DOM_UI_NTP_RESOURCE_CACHE_H_ | 5 #ifndef CHROME_BROWSER_DOM_UI_NTP_RESOURCE_CACHE_H_ |
6 #define CHROME_BROWSER_DOM_UI_NTP_RESOURCE_CACHE_H_ | 6 #define CHROME_BROWSER_DOM_UI_NTP_RESOURCE_CACHE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
11 #include "chrome/common/notification_observer.h" | 11 #include "chrome/common/notification_observer.h" |
12 #include "chrome/common/notification_registrar.h" | 12 #include "chrome/common/notification_registrar.h" |
13 #include "chrome/browser/prefs/pref_change_registrar.h" | 13 #include "chrome/browser/prefs/pref_change_registrar.h" |
14 | 14 |
15 class Profile; | 15 class Profile; |
16 class RefCountedBytes; | 16 class RefCountedBytes; |
17 | 17 |
18 // This class keeps a cache of NTP resources (HTML and CSS) so we don't have to | 18 // This class keeps a cache of NTP resources (HTML and CSS) so we don't have to |
19 // regenerate them all the time. | 19 // regenerate them all the time. |
20 class NTPResourceCache : public NotificationObserver { | 20 class NTPResourceCache : public NotificationObserver { |
21 public: | 21 public: |
22 explicit NTPResourceCache(Profile* profile); | 22 explicit NTPResourceCache(Profile* profile); |
23 virtual ~NTPResourceCache() {} | 23 virtual ~NTPResourceCache(); |
24 | 24 |
25 RefCountedBytes* GetNewTabHTML(bool is_off_the_record); | 25 RefCountedBytes* GetNewTabHTML(bool is_off_the_record); |
26 RefCountedBytes* GetNewTabCSS(bool is_off_the_record); | 26 RefCountedBytes* GetNewTabCSS(bool is_off_the_record); |
27 | 27 |
28 // NotificationObserver interface. | 28 // NotificationObserver interface. |
29 virtual void Observe(NotificationType type, | 29 virtual void Observe(NotificationType type, |
30 const NotificationSource& source, | 30 const NotificationSource& source, |
31 const NotificationDetails& details); | 31 const NotificationDetails& details); |
32 | 32 |
33 private: | 33 private: |
34 Profile* profile_; | 34 Profile* profile_; |
35 | 35 |
36 void CreateNewTabIncognitoHTML(); | 36 void CreateNewTabIncognitoHTML(); |
37 scoped_refptr<RefCountedBytes> new_tab_incognito_html_; | 37 scoped_refptr<RefCountedBytes> new_tab_incognito_html_; |
38 void CreateNewTabHTML(); | 38 void CreateNewTabHTML(); |
39 scoped_refptr<RefCountedBytes> new_tab_html_; | 39 scoped_refptr<RefCountedBytes> new_tab_html_; |
40 | 40 |
41 void CreateNewTabIncognitoCSS(); | 41 void CreateNewTabIncognitoCSS(); |
42 scoped_refptr<RefCountedBytes> new_tab_incognito_css_; | 42 scoped_refptr<RefCountedBytes> new_tab_incognito_css_; |
43 void CreateNewTabCSS(); | 43 void CreateNewTabCSS(); |
44 scoped_refptr<RefCountedBytes> new_tab_css_; | 44 scoped_refptr<RefCountedBytes> new_tab_css_; |
45 | 45 |
46 NotificationRegistrar registrar_; | 46 NotificationRegistrar registrar_; |
47 PrefChangeRegistrar pref_change_registrar_; | 47 PrefChangeRegistrar pref_change_registrar_; |
48 | 48 |
49 DISALLOW_COPY_AND_ASSIGN(NTPResourceCache); | 49 DISALLOW_COPY_AND_ASSIGN(NTPResourceCache); |
50 }; | 50 }; |
51 | 51 |
52 #endif // CHROME_BROWSER_DOM_UI_NTP_RESOURCE_CACHE_H_ | 52 #endif // CHROME_BROWSER_DOM_UI_NTP_RESOURCE_CACHE_H_ |
OLD | NEW |