Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: chrome/browser/web_resource/promo_resource_service.h

Issue 8851007: WIP / Do not commit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_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 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/memory/weak_ptr.h"
11 #include "chrome/browser/web_resource/notification_promo.h" 12 #include "chrome/browser/web_resource/notification_promo.h"
12 #include "chrome/browser/web_resource/web_resource_service.h" 13 #include "chrome/browser/web_resource/web_resource_service.h"
13 #include "chrome/common/chrome_version_info.h" 14 #include "chrome/common/chrome_version_info.h"
14 15
15 namespace base { 16 namespace base {
16 class DictionaryValue; 17 class DictionaryValue;
17 } 18 }
18 19
19 class AppsPromoLogoFetcher; 20 class AppsPromoLogoFetcher;
20 class PrefService; 21 class PrefService;
21 class Profile; 22 class Profile;
22 // A PromoResourceService fetches data from a web resource server to be used to 23 // A PromoResourceService fetches data from a web resource server to be used to
23 // dynamically change the appearance of the New Tab Page. For example, it has 24 // dynamically change the appearance of the New Tab Page. For example, it has
24 // been used to fetch "tips" to be displayed on the NTP, or to display 25 // been used to fetch "tips" to be displayed on the NTP, or to display
25 // promotional messages to certain groups of Chrome users. 26 // promotional messages to certain groups of Chrome users.
26 // 27 //
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 PromoResourceServiceTest, UnpackWebStoreSignalHttpLogo); 75 PromoResourceServiceTest, UnpackWebStoreSignalHttpLogo);
75 76
76 virtual ~PromoResourceService(); 77 virtual ~PromoResourceService();
77 78
78 int GetPromoServiceVersion(); 79 int GetPromoServiceVersion();
79 80
80 // Gets the locale of the last promos fetched from the server. This is saved 81 // Gets the locale of the last promos fetched from the server. This is saved
81 // so we can fetch new data if the locale changes. 82 // so we can fetch new data if the locale changes.
82 std::string GetPromoLocale(); 83 std::string GetPromoLocale();
83 84
84 void Init();
85
86 // Returns true if |builds_targeted| includes the release channel Chrome 85 // Returns true if |builds_targeted| includes the release channel Chrome
87 // belongs to. For testing purposes, you can override the current channel 86 // belongs to. For testing purposes, you can override the current channel
88 // with set_channel. 87 // with set_channel.
89 bool IsBuildTargeted(int builds_targeted); 88 bool IsBuildTargeted(int builds_targeted);
90 89
91 // Schedule a notification that a web resource is either going to become 90 // Schedule a notification that a web resource is either going to become
92 // available or be no longer valid. 91 // available or be no longer valid.
93 void ScheduleNotification(double start, double end); 92 void ScheduleNotification(double start, double end);
94 93
95 // Schedules the initial notification for when the web resource is going 94 // Schedules the initial notification for when the web resource is going
96 // to become available or no longer valid. This performs a few additional 95 // to become available or no longer valid. This performs a few additional
97 // checks than ScheduleNotification, namely it schedules updates immediately 96 // checks than ScheduleNotification, namely it schedules updates immediately
98 // if the promo service or Chrome locale has changed. 97 // if the promo service or Chrome locale has changed.
99 void ScheduleNotificationOnInit(); 98 void ScheduleNotificationOnInit();
100 99
100 // If delay_ms is positive, schedule notification with the delay.
101 // If delay_ms is 0, notify immediately by calling WebResourceStateChange().
102 // If delay_ms is negative, do nothing.
103 void PostNotification(int64 delay_ms);
104
105 // Notify listeners that the state of a web resource has changed.
106 void PromoResourceStateChange();
107
101 // Overrides the current Chrome release channel for testing purposes. 108 // Overrides the current Chrome release channel for testing purposes.
102 void set_channel(chrome::VersionInfo::Channel channel) { channel_ = channel; } 109 void set_channel(chrome::VersionInfo::Channel channel) { channel_ = channel; }
103 110
104 // WebResourceService override. 111 // WebResourceService override.
105 virtual void Unpack(const base::DictionaryValue& parsed_json) OVERRIDE; 112 virtual void Unpack(const base::DictionaryValue& parsed_json) OVERRIDE;
106 113
107 // Unpack the web resource as a custom notification signal. Expects a start 114 // Unpack the web resource as a custom notification signal. Expects a start
108 // and end signal, with the promo to be shown in the tooltip of the start 115 // and end signal, with the promo to be shown in the tooltip of the start
109 // signal field. Delivery will be in json in the form of: 116 // signal field. Delivery will be in json in the form of:
110 // { 117 // {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 // NotificationPromo::Delegate override. 239 // NotificationPromo::Delegate override.
233 virtual void OnNotificationParsed(double start, double end, 240 virtual void OnNotificationParsed(double start, double end,
234 bool new_notification) OVERRIDE; 241 bool new_notification) OVERRIDE;
235 242
236 // The profile this service belongs to. 243 // The profile this service belongs to.
237 Profile* profile_; 244 Profile* profile_;
238 245
239 // Overrides the current Chrome release channel for testing purposes. 246 // Overrides the current Chrome release channel for testing purposes.
240 chrome::VersionInfo::Channel channel_; 247 chrome::VersionInfo::Channel channel_;
241 248
249 // Allows the creation of tasks to send a notification.
250 // This allows the PromoResourceService to notify the New Tab Page immediately
251 // when a new web resource should be shown or removed.
252 base::WeakPtrFactory<PromoResourceService> weak_ptr_factory_;
253
254 // Notification type when an update is done.
255 int notification_type_;
256
257 // True if a task has been set to update the cache when a new web resource
258 // becomes available.
259 bool web_resource_update_scheduled_;
260
242 // A helper that downloads the promo logo. 261 // A helper that downloads the promo logo.
243 scoped_ptr<AppsPromoLogoFetcher> apps_promo_logo_fetcher_; 262 scoped_ptr<AppsPromoLogoFetcher> apps_promo_logo_fetcher_;
244 263
245 DISALLOW_COPY_AND_ASSIGN(PromoResourceService); 264 DISALLOW_COPY_AND_ASSIGN(PromoResourceService);
246 }; 265 };
247 266
248 #endif // CHROME_BROWSER_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ 267 #endif // CHROME_BROWSER_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/tab_modal_dialog_ui.cc ('k') | chrome/browser/web_resource/promo_resource_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698