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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/web_resource/notification_promo_mobile_ntp.cc
diff --git a/chrome/browser/web_resource/notification_promo_mobile_ntp.cc b/chrome/browser/web_resource/notification_promo_mobile_ntp.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8d5f738dc7fdc3082816455dd9a3f8c922082cc9
--- /dev/null
+++ b/chrome/browser/web_resource/notification_promo_mobile_ntp.cc
@@ -0,0 +1,72 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/web_resource/notification_promo_mobile_ntp.h"
+
+#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.
+#include "base/values.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/web_resource/notification_promo.h"
+
+
+NotificationPromoMobileNtp::NotificationPromoMobileNtp(Profile* profile)
+ : valid_(false),
+ action_args_(NULL),
+ payload_(NULL),
+ notification_promo_(profile) {
+}
+
+NotificationPromoMobileNtp::~NotificationPromoMobileNtp() {}
+
+bool NotificationPromoMobileNtp::InitFromPrefs() {
+ notification_promo_.InitFromPrefs(NotificationPromo::MOBILE_NTP_SYNC_PROMO);
+ return InitFromNotificationPromo();
+}
+
+bool NotificationPromoMobileNtp::InitFromJson(
+ const base::DictionaryValue& json) {
+ notification_promo_.InitFromJson(
+ json, NotificationPromo::MOBILE_NTP_SYNC_PROMO);
+ return InitFromNotificationPromo();
+}
+
+bool NotificationPromoMobileNtp::CanShow() const {
+ return valid() && notification_promo_.CanShow();
+}
+
+bool NotificationPromoMobileNtp::InitFromNotificationPromo() {
+ valid_ = false;
+ requires_mobile_only_sync_ = true;
+ requires_sync_ = true;
+ show_on_most_visited_ = false;
+ show_on_open_tabs_ = true;
+ show_as_virtual_computer_ = true;
+ action_args_ = NULL;
+
+ payload_ = notification_promo_.promo_payload();
+ if (!payload_ ||
+ !payload_->GetString("promo_message_short", &text_) ||
+ !payload_->GetString("promo_message_long", &text_long_) ||
+ !payload_->GetString("promo_action_type", &action_type_) ||
+ !payload_->GetList("promo_action_args", &action_args_) ||
+ !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.
+ 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.
+
+ // All the fields above are required.
+ // 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
+ 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
+
+ payload_->GetBoolean("promo_requires_mobile_only_sync",
+ &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.
+ payload_->GetBoolean("promo_requires_sync", &requires_sync_);
+ payload_->GetBoolean("promo_show_on_most_visited", &show_on_most_visited_);
+ payload_->GetBoolean("promo_show_on_open_tabs", &show_on_open_tabs_);
+ payload_->GetBoolean("promo_show_as_virtual_computer",
+ &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.
+ payload_->GetString("promo_virtual_computer_title", &virtual_computer_title_);
+ payload_->GetString("promo_virtual_computer_lastsync",
+ &virtual_computer_lastsync_);
achuithb 2012/08/22 19:49:20 let's line this up with "
aruslan 2012/08/23 00:49:59 Done.
+
+ return valid_;
+}

Powered by Google App Engine
This is Rietveld 408576698