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 #include "chrome/browser/web_resource/promo_resource_service.h" | 5 #include "chrome/browser/web_resource/promo_resource_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
13 #include "chrome/browser/prefs/pref_service.h" | 13 #include "chrome/browser/prefs/pref_service.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/web_resource/notification_promo.h" | 15 #include "chrome/browser/web_resource/notification_promo.h" |
16 #include "chrome/common/chrome_notification_types.h" | 16 #include "chrome/common/chrome_notification_types.h" |
17 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
18 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
19 #include "content/public/browser/browser_thread.h" | |
20 #include "content/public/browser/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
21 #include "googleurl/src/gurl.h" | 20 #include "googleurl/src/gurl.h" |
22 | 21 |
23 namespace { | 22 namespace { |
24 | 23 |
25 // Delay on first fetch so we don't interfere with startup. | 24 // Delay on first fetch so we don't interfere with startup. |
26 const int kStartResourceFetchDelay = 5000; | 25 const int kStartResourceFetchDelay = 5000; |
27 | 26 |
28 // Delay between calls to fetch the promo json: 6 hours in production, and 3 min | 27 // Delay between calls to fetch the promo json: 6 hours in production, and 3 min |
29 // in debug. | 28 // in debug. |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 } | 165 } |
167 | 166 |
168 void PromoResourceService::Unpack(const DictionaryValue& parsed_json) { | 167 void PromoResourceService::Unpack(const DictionaryValue& parsed_json) { |
169 for (size_t i = 0; i < arraysize(kValidPromoTypes); ++i) { | 168 for (size_t i = 0; i < arraysize(kValidPromoTypes); ++i) { |
170 NotificationPromo notification_promo(profile_); | 169 NotificationPromo notification_promo(profile_); |
171 notification_promo.InitFromJson(parsed_json, kValidPromoTypes[i]); | 170 notification_promo.InitFromJson(parsed_json, kValidPromoTypes[i]); |
172 if (notification_promo.new_notification()) | 171 if (notification_promo.new_notification()) |
173 ScheduleNotification(notification_promo); | 172 ScheduleNotification(notification_promo); |
174 } | 173 } |
175 } | 174 } |
OLD | NEW |