Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #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/compiler_specific.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/string16.h" | 12 #include "base/string16.h" |
| 13 #include "chrome/browser/prefs/pref_change_registrar.h" | 13 #include "chrome/browser/prefs/pref_change_registrar.h" |
| 14 #include "chrome/browser/profiles/profile_keyed_service.h" | 14 #include "chrome/browser/profiles/profile_keyed_service.h" |
| 15 #include "content/public/browser/notification_observer.h" | 15 #include "content/public/browser/notification_observer.h" |
| 16 #include "content/public/browser/notification_registrar.h" | 16 #include "content/public/browser/notification_registrar.h" |
| 17 | 17 |
| 18 class Profile; | 18 class Profile; |
| 19 class RefCountedMemory; | 19 class RefCountedMemory; |
| 20 | 20 |
| 21 // 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 |
| 22 // regenerate them all the time. | 22 // regenerate them all the time. |
| 23 class NTPResourceCache : public content::NotificationObserver, | 23 class NTPResourceCache : public content::NotificationObserver, |
| 24 public ProfileKeyedService { | 24 public ProfileKeyedService { |
| 25 public: | 25 public: |
| 26 explicit NTPResourceCache(Profile* profile); | 26 explicit NTPResourceCache(Profile* profile); |
| 27 virtual ~NTPResourceCache(); | 27 virtual ~NTPResourceCache(); |
| 28 | 28 |
| 29 // Helper to determine if the resource cache should be invalidated. | |
| 30 // This is called on every page load, and can be used to check values that | |
| 31 // don't generate a notification when changed (e.g., system preferences). | |
| 32 bool InvalidateNewTabCache(); | |
| 33 | |
| 29 RefCountedMemory* GetNewTabHTML(bool is_incognito); | 34 RefCountedMemory* GetNewTabHTML(bool is_incognito); |
| 30 RefCountedMemory* GetNewTabCSS(bool is_incognito); | 35 RefCountedMemory* GetNewTabCSS(bool is_incognito); |
| 31 | 36 |
| 32 // content::NotificationObserver interface. | 37 // content::NotificationObserver interface. |
| 33 virtual void Observe(int type, | 38 virtual void Observe(int type, |
| 34 const content::NotificationSource& source, | 39 const content::NotificationSource& source, |
| 35 const content::NotificationDetails& details) OVERRIDE; | 40 const content::NotificationDetails& details) OVERRIDE; |
| 36 | 41 |
| 37 private: | 42 private: |
| 38 Profile* profile_; | 43 Profile* profile_; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 50 | 55 |
| 51 void CreateNewTabIncognitoCSS(); | 56 void CreateNewTabIncognitoCSS(); |
| 52 scoped_refptr<RefCountedMemory> new_tab_incognito_css_; | 57 scoped_refptr<RefCountedMemory> new_tab_incognito_css_; |
| 53 void CreateNewTabCSS(); | 58 void CreateNewTabCSS(); |
| 54 scoped_refptr<RefCountedMemory> new_tab_css_; | 59 scoped_refptr<RefCountedMemory> new_tab_css_; |
| 55 | 60 |
| 56 content::NotificationRegistrar registrar_; | 61 content::NotificationRegistrar registrar_; |
| 57 PrefChangeRegistrar pref_change_registrar_; | 62 PrefChangeRegistrar pref_change_registrar_; |
| 58 #endif | 63 #endif |
| 59 | 64 |
| 65 bool isSwipeTrackingFromScrollEventsEnabled_; | |
|
Evan Stade
2012/04/17 21:29:53
comment (this is where I'd put the comment that yo
Patrick Dubroy
2012/04/18 14:43:06
Done.
| |
| 66 | |
| 60 DISALLOW_COPY_AND_ASSIGN(NTPResourceCache); | 67 DISALLOW_COPY_AND_ASSIGN(NTPResourceCache); |
| 61 }; | 68 }; |
| 62 | 69 |
| 63 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NTP_RESOURCE_CACHE_H_ | 70 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NTP_RESOURCE_CACHE_H_ |
| OLD | NEW |