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/notification_promo_mobile_ntp.h" | 5 #include "chrome/browser/web_resource/notification_promo_mobile_ntp.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "chrome/browser/profiles/profile.h" | |
9 #include "chrome/browser/web_resource/notification_promo.h" | 8 #include "chrome/browser/web_resource/notification_promo.h" |
10 | 9 |
11 | 10 NotificationPromoMobileNtp::NotificationPromoMobileNtp() |
12 NotificationPromoMobileNtp::NotificationPromoMobileNtp(Profile* profile) | |
13 : valid_(false), | 11 : valid_(false), |
14 action_args_(NULL), | 12 action_args_(NULL), |
15 payload_(NULL), | 13 payload_(NULL) { |
16 notification_promo_(profile) { | |
17 } | 14 } |
18 | 15 |
19 NotificationPromoMobileNtp::~NotificationPromoMobileNtp() { | 16 NotificationPromoMobileNtp::~NotificationPromoMobileNtp() { |
20 } | 17 } |
21 | 18 |
22 bool NotificationPromoMobileNtp::InitFromPrefs() { | 19 bool NotificationPromoMobileNtp::InitFromPrefs() { |
23 notification_promo_.InitFromPrefs(NotificationPromo::MOBILE_NTP_SYNC_PROMO); | 20 notification_promo_.InitFromPrefs(NotificationPromo::MOBILE_NTP_SYNC_PROMO); |
24 return InitFromNotificationPromo(); | 21 return InitFromNotificationPromo(); |
25 } | 22 } |
26 | 23 |
(...skipping 21 matching lines...) Expand all Loading... |
48 payload_ = notification_promo_.promo_payload(); | 45 payload_ = notification_promo_.promo_payload(); |
49 if (!payload_ || | 46 if (!payload_ || |
50 !payload_->GetString("promo_message_short", &text_) || | 47 !payload_->GetString("promo_message_short", &text_) || |
51 !payload_->GetString("promo_message_long", &text_long_) || | 48 !payload_->GetString("promo_message_long", &text_long_) || |
52 !payload_->GetString("promo_action_type", &action_type_) || | 49 !payload_->GetString("promo_action_type", &action_type_) || |
53 !payload_->GetList("promo_action_args", &action_args_) || | 50 !payload_->GetList("promo_action_args", &action_args_) || |
54 !action_args_) { | 51 !action_args_) { |
55 return false; | 52 return false; |
56 } | 53 } |
57 | 54 |
58 // The rest of the fields is optional. | 55 // The rest of the fields are optional. |
59 valid_ = true; | 56 valid_ = true; |
60 payload_->GetBoolean("promo_requires_mobile_only_sync", | 57 payload_->GetBoolean("promo_requires_mobile_only_sync", |
61 &requires_mobile_only_sync_); | 58 &requires_mobile_only_sync_); |
62 payload_->GetBoolean("promo_requires_sync", &requires_sync_); | 59 payload_->GetBoolean("promo_requires_sync", &requires_sync_); |
63 payload_->GetBoolean("promo_show_on_most_visited", &show_on_most_visited_); | 60 payload_->GetBoolean("promo_show_on_most_visited", &show_on_most_visited_); |
64 payload_->GetBoolean("promo_show_on_open_tabs", &show_on_open_tabs_); | 61 payload_->GetBoolean("promo_show_on_open_tabs", &show_on_open_tabs_); |
65 payload_->GetBoolean("promo_show_as_virtual_computer", | 62 payload_->GetBoolean("promo_show_as_virtual_computer", |
66 &show_as_virtual_computer_); | 63 &show_as_virtual_computer_); |
67 payload_->GetString("promo_virtual_computer_title", &virtual_computer_title_); | 64 payload_->GetString("promo_virtual_computer_title", &virtual_computer_title_); |
68 payload_->GetString("promo_virtual_computer_lastsync", | 65 payload_->GetString("promo_virtual_computer_lastsync", |
69 &virtual_computer_lastsync_); | 66 &virtual_computer_lastsync_); |
70 | 67 |
71 return valid_; | 68 return valid_; |
72 } | 69 } |
OLD | NEW |