| OLD | NEW |
| 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 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 83 |
| 84 // Schedules the initial notification for when the web resource is going | 84 // Schedules the initial notification for when the web resource is going |
| 85 // to become available or no longer valid. This performs a few additional | 85 // to become available or no longer valid. This performs a few additional |
| 86 // checks than ScheduleNotification, namely it schedules updates immediately | 86 // checks than ScheduleNotification, namely it schedules updates immediately |
| 87 // if the promo service or Chrome locale has changed. | 87 // if the promo service or Chrome locale has changed. |
| 88 void ScheduleNotificationOnInit(); | 88 void ScheduleNotificationOnInit(); |
| 89 | 89 |
| 90 // Overrides the current Chrome release channel for testing purposes. | 90 // Overrides the current Chrome release channel for testing purposes. |
| 91 void set_channel(chrome::VersionInfo::Channel channel) { channel_ = channel; } | 91 void set_channel(chrome::VersionInfo::Channel channel) { channel_ = channel; } |
| 92 | 92 |
| 93 virtual void Unpack(const DictionaryValue& parsed_json); | 93 virtual void Unpack(const base::DictionaryValue& parsed_json); |
| 94 | 94 |
| 95 // Unpack the web resource as a custom promo signal. Expects a start and end | 95 // Unpack the web resource as a custom promo signal. Expects a start and end |
| 96 // signal, with the promo to be shown in the tooltip of the start signal | 96 // signal, with the promo to be shown in the tooltip of the start signal |
| 97 // field. Delivery will be in json in the form of: | 97 // field. Delivery will be in json in the form of: |
| 98 // { | 98 // { |
| 99 // "topic": { | 99 // "topic": { |
| 100 // "answers": [ | 100 // "answers": [ |
| 101 // { | 101 // { |
| 102 // "answer_id": "1067976", | 102 // "answer_id": "1067976", |
| 103 // "name": "promo_start", | 103 // "name": "promo_start", |
| (...skipping 21 matching lines...) Expand all Loading... |
| 125 // | 125 // |
| 126 // For "promo_start" or "promo_end", the date to start or stop showing the | 126 // For "promo_start" or "promo_end", the date to start or stop showing the |
| 127 // promotional line is given by the "inproduct" line. | 127 // promotional line is given by the "inproduct" line. |
| 128 // For "promo_start", the promotional line itself is given in the "tooltip" | 128 // For "promo_start", the promotional line itself is given in the "tooltip" |
| 129 // field. The "question" field gives the type of builds that should be shown | 129 // field. The "question" field gives the type of builds that should be shown |
| 130 // this promo (see the BuildType enum in web_resource_service.cc) and the | 130 // this promo (see the BuildType enum in web_resource_service.cc) and the |
| 131 // number of hours that each promo group should see it, separated by ":". | 131 // number of hours that each promo group should see it, separated by ":". |
| 132 // For example, "7:24" would indicate that all builds should see the promo, | 132 // For example, "7:24" would indicate that all builds should see the promo, |
| 133 // and each group should see it for 24 hours. | 133 // and each group should see it for 24 hours. |
| 134 // | 134 // |
| 135 void UnpackPromoSignal(const DictionaryValue& parsed_json); | 135 void UnpackPromoSignal(const base::DictionaryValue& parsed_json); |
| 136 | 136 |
| 137 // Unpack the promo resource as a custom logo signal. Expects a start and end | 137 // Unpack the promo resource as a custom logo signal. Expects a start and end |
| 138 // signal. Delivery will be in json in the form of: | 138 // signal. Delivery will be in json in the form of: |
| 139 // { | 139 // { |
| 140 // "topic": { | 140 // "topic": { |
| 141 // "answers": [ | 141 // "answers": [ |
| 142 // { | 142 // { |
| 143 // "answer_id": "107366", | 143 // "answer_id": "107366", |
| 144 // "name": "custom_logo_start", | 144 // "name": "custom_logo_start", |
| 145 // "question": "", | 145 // "question": "", |
| 146 // "tooltip": "", | 146 // "tooltip": "", |
| 147 // "inproduct": "10/8/09 12:00", | 147 // "inproduct": "10/8/09 12:00", |
| 148 // "inproduct_target": null | 148 // "inproduct_target": null |
| 149 // }, | 149 // }, |
| 150 // { | 150 // { |
| 151 // "answer_id": "107366", | 151 // "answer_id": "107366", |
| 152 // "name": "custom_logo_end", | 152 // "name": "custom_logo_end", |
| 153 // "question": "", | 153 // "question": "", |
| 154 // "tooltip": "", | 154 // "tooltip": "", |
| 155 // "inproduct": "10/8/09 12:00", | 155 // "inproduct": "10/8/09 12:00", |
| 156 // "inproduct_target": null | 156 // "inproduct_target": null |
| 157 // }, | 157 // }, |
| 158 // ... | 158 // ... |
| 159 // ] | 159 // ] |
| 160 // } | 160 // } |
| 161 // } | 161 // } |
| 162 // | 162 // |
| 163 void UnpackLogoSignal(const DictionaryValue& parsed_json); | 163 void UnpackLogoSignal(const base::DictionaryValue& parsed_json); |
| 164 | 164 |
| 165 // Unpack the web store promo. Expects JSON delivery in the following format: | 165 // Unpack the web store promo. Expects JSON delivery in the following format: |
| 166 // { | 166 // { |
| 167 // "topic": { | 167 // "topic": { |
| 168 // "answers": [ | 168 // "answers": [ |
| 169 // { | 169 // { |
| 170 // "answer_id": "1143011", | 170 // "answer_id": "1143011", |
| 171 // "name": "webstore_promo:15:", | 171 // "name": "webstore_promo:15:", |
| 172 // "question": "Browse thousands of apps and games for Chrome.", | 172 // "question": "Browse thousands of apps and games for Chrome.", |
| 173 // "inproduct_target": "Visit the Chrome Web Store", | 173 // "inproduct_target": "Visit the Chrome Web Store", |
| 174 // "inproduct": "https://chrome.google.com/webstore?hl=en", | 174 // "inproduct": "https://chrome.google.com/webstore?hl=en", |
| 175 // "tooltip": "No thanks, hide this" | 175 // "tooltip": "No thanks, hide this" |
| 176 // }, | 176 // }, |
| 177 // ... | 177 // ... |
| 178 // ] | 178 // ] |
| 179 // } | 179 // } |
| 180 // } | 180 // } |
| 181 // The properties are defined as follows: | 181 // The properties are defined as follows: |
| 182 // inproduct: the release channels targeted (bitwise or of BuildTypes) | 182 // inproduct: the release channels targeted (bitwise or of BuildTypes) |
| 183 // question: the promo header text | 183 // question: the promo header text |
| 184 // inproduct_target: the promo button text | 184 // inproduct_target: the promo button text |
| 185 // inproduct: the promo button link | 185 // inproduct: the promo button link |
| 186 // tooltip: the text for the "hide this" link on the promo | 186 // tooltip: the text for the "hide this" link on the promo |
| 187 // name: starts with "webstore_promo" to identify the signal. the second | 187 // name: starts with "webstore_promo" to identify the signal. the second |
| 188 // part contains the release channels targeted (bitwise or of | 188 // part contains the release channels targeted (bitwise or of |
| 189 // BuildTypes). The third part is optional and specifies the URL of | 189 // BuildTypes). The third part is optional and specifies the URL of |
| 190 // the logo image. In the example above, the URL is empty so the | 190 // the logo image. In the example above, the URL is empty so the |
| 191 // default webstore logo will be used. | 191 // default webstore logo will be used. |
| 192 // answer_id: the promo's id | 192 // answer_id: the promo's id |
| 193 void UnpackWebStoreSignal(const DictionaryValue& parsed_json); | 193 void UnpackWebStoreSignal(const base::DictionaryValue& parsed_json); |
| 194 | 194 |
| 195 // Gets mutable dictionary attached to user's preferences, so that we | 195 // Gets mutable dictionary attached to user's preferences, so that we |
| 196 // can write resource data back to user's pref file. | 196 // can write resource data back to user's pref file. |
| 197 DictionaryValue* web_resource_cache_; | 197 base::DictionaryValue* web_resource_cache_; |
| 198 | 198 |
| 199 // Overrides the current Chrome release channel for testing purposes. | 199 // Overrides the current Chrome release channel for testing purposes. |
| 200 chrome::VersionInfo::Channel channel_; | 200 chrome::VersionInfo::Channel channel_; |
| 201 | 201 |
| 202 DISALLOW_COPY_AND_ASSIGN(PromoResourceService); | 202 DISALLOW_COPY_AND_ASSIGN(PromoResourceService); |
| 203 }; | 203 }; |
| 204 | 204 |
| 205 #endif // CHROME_BROWSER_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ | 205 #endif // CHROME_BROWSER_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ |
| OLD | NEW |