OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/compiler_specific.h" |
10 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
11 #include "base/string16.h" | 12 #include "base/string16.h" |
12 #include "chrome/browser/prefs/pref_change_registrar.h" | 13 #include "chrome/browser/prefs/pref_change_registrar.h" |
13 #include "chrome/browser/profiles/profile_keyed_service.h" | 14 #include "chrome/browser/profiles/profile_keyed_service.h" |
14 #include "content/common/notification_observer.h" | 15 #include "content/common/notification_observer.h" |
15 #include "content/common/notification_registrar.h" | 16 #include "content/common/notification_registrar.h" |
16 | 17 |
17 class Profile; | 18 class Profile; |
18 class RefCountedMemory; | 19 class RefCountedMemory; |
19 | 20 |
20 // This class keeps a cache of NTP resources (HTML and CSS) so we don't have to | 21 // This class keeps a cache of NTP resources (HTML and CSS) so we don't have to |
21 // regenerate them all the time. | 22 // regenerate them all the time. |
22 class NTPResourceCache : public NotificationObserver, | 23 class NTPResourceCache : public NotificationObserver, |
23 public ProfileKeyedService { | 24 public ProfileKeyedService { |
24 public: | 25 public: |
25 explicit NTPResourceCache(Profile* profile); | 26 explicit NTPResourceCache(Profile* profile); |
26 virtual ~NTPResourceCache(); | 27 virtual ~NTPResourceCache(); |
27 | 28 |
28 RefCountedMemory* GetNewTabHTML(bool is_incognito); | 29 RefCountedMemory* GetNewTabHTML(bool is_incognito); |
29 RefCountedMemory* GetNewTabCSS(bool is_incognito); | 30 RefCountedMemory* GetNewTabCSS(bool is_incognito); |
30 | 31 |
31 // NotificationObserver interface. | 32 // NotificationObserver interface. |
32 virtual void Observe(int type, | 33 virtual void Observe(int type, |
33 const NotificationSource& source, | 34 const NotificationSource& source, |
34 const NotificationDetails& details); | 35 const NotificationDetails& details) OVERRIDE; |
35 | 36 |
36 private: | 37 private: |
37 Profile* profile_; | 38 Profile* profile_; |
38 | 39 |
39 // Returns a message describing any newly-added sync types, or an empty | 40 // Returns a message describing any newly-added sync types, or an empty |
40 // string if all types have already been acknowledged. | 41 // string if all types have already been acknowledged. |
41 string16 GetSyncTypeMessage(); | 42 string16 GetSyncTypeMessage(); |
42 | 43 |
43 void CreateNewTabIncognitoHTML(); | 44 void CreateNewTabIncognitoHTML(); |
44 scoped_refptr<RefCountedMemory> new_tab_incognito_html_; | 45 scoped_refptr<RefCountedMemory> new_tab_incognito_html_; |
45 void CreateNewTabHTML(); | 46 void CreateNewTabHTML(); |
46 scoped_refptr<RefCountedMemory> new_tab_html_; | 47 scoped_refptr<RefCountedMemory> new_tab_html_; |
47 | 48 |
48 void CreateNewTabIncognitoCSS(); | 49 void CreateNewTabIncognitoCSS(); |
49 scoped_refptr<RefCountedMemory> new_tab_incognito_css_; | 50 scoped_refptr<RefCountedMemory> new_tab_incognito_css_; |
50 void CreateNewTabCSS(); | 51 void CreateNewTabCSS(); |
51 scoped_refptr<RefCountedMemory> new_tab_css_; | 52 scoped_refptr<RefCountedMemory> new_tab_css_; |
52 | 53 |
53 NotificationRegistrar registrar_; | 54 NotificationRegistrar registrar_; |
54 PrefChangeRegistrar pref_change_registrar_; | 55 PrefChangeRegistrar pref_change_registrar_; |
55 | 56 |
56 DISALLOW_COPY_AND_ASSIGN(NTPResourceCache); | 57 DISALLOW_COPY_AND_ASSIGN(NTPResourceCache); |
57 }; | 58 }; |
58 | 59 |
59 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NTP_RESOURCE_CACHE_H_ | 60 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NTP_RESOURCE_CACHE_H_ |
OLD | NEW |