| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ |
| 6 #define CHROME_BROWSER_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ | 6 #define CHROME_BROWSER_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| 11 #include "base/callback_list.h" | 11 #include "base/callback_list.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "chrome/browser/web_resource/chrome_web_resource_service.h" | 13 #include "components/web_resource/web_resource_service.h" |
| 14 | 14 |
| 15 class NotificationPromo; | 15 class NotificationPromo; |
| 16 class PrefRegistrySimple; | 16 class PrefRegistrySimple; |
| 17 class PrefService; | 17 class PrefService; |
| 18 | 18 |
| 19 namespace base { | 19 namespace base { |
| 20 class DictionaryValue; | 20 class DictionaryValue; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace user_prefs { | 23 namespace user_prefs { |
| 24 class PrefRegistrySyncable; | 24 class PrefRegistrySyncable; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace version_info { | 27 namespace version_info { |
| 28 enum class Channel; | 28 enum class Channel; |
| 29 } | 29 } |
| 30 | 30 |
| 31 // A PromoResourceService fetches data from a web resource server to be used to | 31 // A PromoResourceService fetches data from a web resource server to be used to |
| 32 // dynamically change the appearance of the New Tab Page. For example, it has | 32 // dynamically change the appearance of the New Tab Page. For example, it has |
| 33 // been used to fetch "tips" to be displayed on the NTP, or to display | 33 // been used to fetch "tips" to be displayed on the NTP, or to display |
| 34 // promotional messages to certain groups of Chrome users. | 34 // promotional messages to certain groups of Chrome users. |
| 35 class PromoResourceService : public ChromeWebResourceService { | 35 class PromoResourceService : public web_resource::WebResourceService { |
| 36 public: | 36 public: |
| 37 using StateChangedCallbackList = base::CallbackList<void()>; | 37 using StateChangedCallbackList = base::CallbackList<void()>; |
| 38 using StateChangedSubscription = StateChangedCallbackList::Subscription; | 38 using StateChangedSubscription = StateChangedCallbackList::Subscription; |
| 39 | 39 |
| 40 static void RegisterPrefs(PrefRegistrySimple* registry); | 40 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 41 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 41 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 42 static void MigrateUserPrefs(PrefService* user_prefs); | 42 static void MigrateUserPrefs(PrefService* user_prefs); |
| 43 | 43 |
| 44 PromoResourceService(PrefService* local_state, version_info::Channel channel); | 44 PromoResourceService(PrefService* local_state, |
| 45 version_info::Channel channel, |
| 46 const std::string& application_locale, |
| 47 net::URLRequestContextGetter* request_context, |
| 48 const char* disable_network_switch, |
| 49 const ParseJSONCallback& parse_json_callback); |
| 45 ~PromoResourceService() override; | 50 ~PromoResourceService() override; |
| 46 | 51 |
| 47 // Registers a callback called when the state of a web resource has been | 52 // Registers a callback called when the state of a web resource has been |
| 48 // changed. A resource may have been added, removed, or altered. | 53 // changed. A resource may have been added, removed, or altered. |
| 49 scoped_ptr<StateChangedSubscription> RegisterStateChangedCallback( | 54 scoped_ptr<StateChangedSubscription> RegisterStateChangedCallback( |
| 50 const base::Closure& closure); | 55 const base::Closure& closure); |
| 51 | 56 |
| 52 private: | 57 private: |
| 53 // Schedule a notification that a web resource is either going to become | 58 // Schedule a notification that a web resource is either going to become |
| 54 // available or be no longer valid. | 59 // available or be no longer valid. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 76 | 81 |
| 77 // Allows the creation of tasks to send a notification. | 82 // Allows the creation of tasks to send a notification. |
| 78 // This allows the PromoResourceService to notify the New Tab Page immediately | 83 // This allows the PromoResourceService to notify the New Tab Page immediately |
| 79 // when a new web resource should be shown or removed. | 84 // when a new web resource should be shown or removed. |
| 80 base::WeakPtrFactory<PromoResourceService> weak_ptr_factory_; | 85 base::WeakPtrFactory<PromoResourceService> weak_ptr_factory_; |
| 81 | 86 |
| 82 DISALLOW_COPY_AND_ASSIGN(PromoResourceService); | 87 DISALLOW_COPY_AND_ASSIGN(PromoResourceService); |
| 83 }; | 88 }; |
| 84 | 89 |
| 85 #endif // CHROME_BROWSER_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ | 90 #endif // CHROME_BROWSER_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ |
| OLD | NEW |