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

Side by Side Diff: chrome/browser/ui/desktop_ios_promotion/desktop_ios_promotion_bubble_controller.cc

Issue 2803293002: Create Bookmark Footnote desktop iOS promotion (Closed)
Patch Set: no explicit remove Created 3 years, 7 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 2017 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/ui/desktop_ios_promotion/desktop_ios_promotion_bubble_c ontroller.h"
6
7 #include "base/bind.h"
8 #include "base/metrics/histogram_macros.h"
9 #include "base/time/time.h"
10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/desktop_ios_promotion/desktop_ios_promotion_util.h"
13 #include "chrome/browser/ui/desktop_ios_promotion/desktop_ios_promotion_view.h"
14 #include "chrome/browser/ui/desktop_ios_promotion/sms_service_factory.h"
15 #include "components/prefs/pref_service.h"
16
17 DesktopIOSPromotionBubbleController::DesktopIOSPromotionBubbleController(
18 Profile* profile,
19 DesktopIOSPromotionView* promotion_view,
20 desktop_ios_promotion::PromotionEntryPoint entry_point)
21 : DesktopIOSPromotionController(profile, entry_point),
22 sms_service_(SMSServiceFactory::GetForProfile(profile)),
23 promotion_view_(promotion_view),
24 weak_ptr_factory_(this) {
25 sms_service_->QueryPhoneNumber(
26 base::Bind(&DesktopIOSPromotionBubbleController::OnGotPhoneNumber,
27 weak_ptr_factory_.GetWeakPtr()));
28 }
29
30 void DesktopIOSPromotionBubbleController::OnSendSMSClicked() {
31 sms_service_->SendSMS(
32 desktop_ios_promotion::GetSMSID(),
33 base::Bind(&DesktopIOSPromotionBubbleController::OnSendSMS,
34 weak_ptr_factory_.GetWeakPtr()));
35
36 // Update Profile prefs.
37 profile_prefs_->SetInteger(prefs::kIOSPromotionSMSEntryPoint,
38 static_cast<int>(entry_point_));
39
40 // Update dismissal reason.
41 dismissal_reason_ = desktop_ios_promotion::PromotionDismissalReason::SEND_SMS;
42 }
43
44 void DesktopIOSPromotionBubbleController::OnNoThanksClicked() {
45 if (entry_point_ !=
46 desktop_ios_promotion::PromotionEntryPoint::FOOTNOTE_FOLLOWUP_BUBBLE) {
47 PrefService* local_state = g_browser_process->local_state();
48 local_state->SetBoolean(
49 desktop_ios_promotion::kEntryPointLocalPrefs
50 [static_cast<int>(entry_point_)][static_cast<int>(
51 desktop_ios_promotion::EntryPointLocalPrefType::DISMISSED)],
52 true);
53 }
54 dismissal_reason_ =
55 desktop_ios_promotion::PromotionDismissalReason::NO_THANKS;
56 }
57
58 std::string DesktopIOSPromotionBubbleController::GetUsersRecoveryPhoneNumber() {
59 return recovery_number_;
60 }
61
62 void DesktopIOSPromotionBubbleController::OnGotPhoneNumber(
63 SMSService::Request* request,
64 bool success,
65 const std::string& number) {
66 DCHECK(promotion_view_);
67 if (success) {
68 recovery_number_ = desktop_ios_promotion::FormatPhoneNumber(number);
69 promotion_view_->UpdateRecoveryPhoneLabel();
70 }
71 UMA_HISTOGRAM_BOOLEAN("DesktopIOSPromotion.QueryPhoneNumberSucceeded",
72 success);
73 }
74
75 void DesktopIOSPromotionBubbleController::OnSendSMS(
76 SMSService::Request* request,
77 bool success,
78 const std::string& number) {
79 UMA_HISTOGRAM_BOOLEAN("DesktopIOSPromotion.SendSMSSucceeded", success);
80 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698