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

Side by Side Diff: chrome/browser/web_resource/notification_promo_mobile_ntp.cc

Issue 10860025: Remove promotion-type-specific JSON handling from NotificationPromo (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase. Created 8 years, 4 months 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/web_resource/notification_promo_mobile_ntp.h"
6
7 #include "base/logging.h"
Dan Beam 2012/08/22 19:43:27 probably don't need this any more
aruslan 2012/08/23 00:49:59 Thanks! Done.
8 #include "base/values.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/web_resource/notification_promo.h"
11
12
13 NotificationPromoMobileNtp::NotificationPromoMobileNtp(Profile* profile)
14 : valid_(false),
15 action_args_(NULL),
16 payload_(NULL),
17 notification_promo_(profile) {
18 }
19
20 NotificationPromoMobileNtp::~NotificationPromoMobileNtp() {}
21
22 bool NotificationPromoMobileNtp::InitFromPrefs() {
23 notification_promo_.InitFromPrefs(NotificationPromo::MOBILE_NTP_SYNC_PROMO);
24 return InitFromNotificationPromo();
25 }
26
27 bool NotificationPromoMobileNtp::InitFromJson(
28 const base::DictionaryValue& json) {
29 notification_promo_.InitFromJson(
30 json, NotificationPromo::MOBILE_NTP_SYNC_PROMO);
31 return InitFromNotificationPromo();
32 }
33
34 bool NotificationPromoMobileNtp::CanShow() const {
35 return valid() && notification_promo_.CanShow();
36 }
37
38 bool NotificationPromoMobileNtp::InitFromNotificationPromo() {
39 valid_ = false;
40 requires_mobile_only_sync_ = true;
41 requires_sync_ = true;
42 show_on_most_visited_ = false;
43 show_on_open_tabs_ = true;
44 show_as_virtual_computer_ = true;
45 action_args_ = NULL;
46
47 payload_ = notification_promo_.promo_payload();
48 if (!payload_ ||
49 !payload_->GetString("promo_message_short", &text_) ||
50 !payload_->GetString("promo_message_long", &text_long_) ||
51 !payload_->GetString("promo_action_type", &action_type_) ||
52 !payload_->GetList("promo_action_args", &action_args_) ||
53 !action_args_)
Dan Beam 2012/08/22 19:43:27 nit: curlies (when conditional or body is over 1 l
aruslan 2012/08/23 00:49:59 Done.
54 return valid_;
achuithb 2012/08/22 19:49:20 Let's return false here. No need to be indirect.
aruslan 2012/08/23 00:49:59 Done.
55
56 // All the fields above are required.
57 // All the fields below are optional and used to override the defaults.
achuithb 2012/08/22 19:49:20 Which comment is true?
aruslan 2012/08/23 00:49:59 Both; I changed the comments to be more comprehens
58 valid_ = true;
Dan Beam 2012/08/22 19:43:27 what happens if any of the next payload->Get*() ca
aruslan 2012/08/23 00:49:59 Yes; I changed the comments to make it more appare
59
60 payload_->GetBoolean("promo_requires_mobile_only_sync",
61 &requires_mobile_only_sync_);
achuithb 2012/08/22 19:49:20 let's line this up with "
aruslan 2012/08/23 00:49:59 Done.
62 payload_->GetBoolean("promo_requires_sync", &requires_sync_);
63 payload_->GetBoolean("promo_show_on_most_visited", &show_on_most_visited_);
64 payload_->GetBoolean("promo_show_on_open_tabs", &show_on_open_tabs_);
65 payload_->GetBoolean("promo_show_as_virtual_computer",
66 &show_as_virtual_computer_);
achuithb 2012/08/22 19:49:20 let's line this up with the "
aruslan 2012/08/23 00:49:59 Done.
67 payload_->GetString("promo_virtual_computer_title", &virtual_computer_title_);
68 payload_->GetString("promo_virtual_computer_lastsync",
69 &virtual_computer_lastsync_);
achuithb 2012/08/22 19:49:20 let's line this up with "
aruslan 2012/08/23 00:49:59 Done.
70
71 return valid_;
72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698