| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 // This class pulls data from a web resource (such as a JSON feed) which | 5 // This class pulls data from a web resource (such as a JSON feed) which |
| 6 // has been stored in the user's preferences file. Used mainly | 6 // has been stored in the user's preferences file. Used mainly |
| 7 // by the suggestions and tips area of the new tab page. | 7 // by the suggestions and tips area of the new tab page. |
| 8 | 8 |
| 9 // Current sketch of tip cache format, hardcoded for popgadget data in | 9 // Current sketch of tip cache format, hardcoded for popgadget data in |
| 10 // basic text form: | 10 // basic text form: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 class DictionaryValue; | 24 class DictionaryValue; |
| 25 class DOMUI; | 25 class DOMUI; |
| 26 class PrefService; | 26 class PrefService; |
| 27 class Value; | 27 class Value; |
| 28 | 28 |
| 29 class TipsHandler : public DOMMessageHandler { | 29 class TipsHandler : public DOMMessageHandler { |
| 30 public: | 30 public: |
| 31 TipsHandler() : tips_cache_(NULL) {} | 31 TipsHandler() : tips_cache_(NULL) {} |
| 32 virtual ~TipsHandler() {} | 32 virtual ~TipsHandler() {} |
| 33 | 33 |
| 34 // DOMMessageHandler implementation and overrides. | 34 // DOMMessageHandler implementation and overrides. |
| 35 virtual DOMMessageHandler* Attach(DOMUI* dom_ui); | 35 virtual DOMMessageHandler* Attach(DOMUI* dom_ui); |
| 36 virtual void RegisterMessages(); | 36 virtual void RegisterMessages(); |
| 37 | 37 |
| 38 // Callback which pulls tips data from the preferences. | 38 // Callback which pulls tips data from the preferences. |
| 39 void HandleGetTips(const Value* content); | 39 void HandleGetTips(const Value* content); |
| 40 | 40 |
| 41 // Register tips cache with pref service. | 41 // Register tips cache with pref service. |
| 42 static void RegisterUserPrefs(PrefService* prefs); | 42 static void RegisterUserPrefs(PrefService* prefs); |
| 43 | 43 |
| 44 private: | 44 private: |
| 45 // Make sure the string we are pushing to the NTP is a valid URL. | 45 // Make sure the string we are pushing to the NTP is a valid URL. |
| 46 bool IsValidURL(const std::wstring& url_string); | 46 bool IsValidURL(const std::wstring& url_string); |
| 47 | 47 |
| 48 // So we can push data out to the page that has called this handler. |
| 49 DOMUI* dom_ui_; |
| 50 |
| 48 // Filled with data from cache in preferences. | 51 // Filled with data from cache in preferences. |
| 49 const DictionaryValue* tips_cache_; | 52 const DictionaryValue* tips_cache_; |
| 50 | 53 |
| 51 DISALLOW_COPY_AND_ASSIGN(TipsHandler); | 54 DISALLOW_COPY_AND_ASSIGN(TipsHandler); |
| 52 }; | 55 }; |
| 53 | 56 |
| 54 #endif // CHROME_BROWSER_DOM_UI_TIPS_HANDLER_H_ | 57 #endif // CHROME_BROWSER_DOM_UI_TIPS_HANDLER_H_ |
| 55 | 58 |
| OLD | NEW |