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

Side by Side Diff: ios/chrome/browser/ui/bookmarks/bookmark_promo_controller.mm

Issue 2746473003: [ObjC ARC] Converts ios/chrome/browser/ui/bookmarks:bookmarks to ARC. (Closed)
Patch Set: fix test Created 3 years, 9 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #import "ios/chrome/browser/ui/bookmarks/bookmark_promo_controller.h" 5 #import "ios/chrome/browser/ui/bookmarks/bookmark_promo_controller.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/mac/scoped_nsobject.h"
10 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
11 #include "base/metrics/user_metrics.h" 10 #include "base/metrics/user_metrics.h"
12 #include "components/pref_registry/pref_registry_syncable.h" 11 #include "components/pref_registry/pref_registry_syncable.h"
13 #include "components/prefs/pref_service.h" 12 #include "components/prefs/pref_service.h"
14 #include "components/signin/core/browser/signin_manager.h" 13 #include "components/signin/core/browser/signin_manager.h"
15 #include "google_apis/gaia/google_service_auth_error.h" 14 #include "google_apis/gaia/google_service_auth_error.h"
16 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" 15 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
17 #include "ios/chrome/browser/pref_names.h" 16 #include "ios/chrome/browser/pref_names.h"
18 #include "ios/chrome/browser/signin/signin_manager_factory.h" 17 #include "ios/chrome/browser/signin/signin_manager_factory.h"
19 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" 18 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h"
20 #import "ios/chrome/browser/ui/commands/show_signin_command.h" 19 #import "ios/chrome/browser/ui/commands/show_signin_command.h"
21 #import "ios/chrome/browser/ui/ui_util.h" 20 #import "ios/chrome/browser/ui/ui_util.h"
22 21
22 #if !defined(__has_feature) || !__has_feature(objc_arc)
23 #error "This file requires ARC support."
24 #endif
25
23 namespace { 26 namespace {
24 // Enum is used to record the actions performed by the user on the promo cell. 27 // Enum is used to record the actions performed by the user on the promo cell.
25 // |Stars.PromoActions|. 28 // |Stars.PromoActions|.
26 enum { 29 enum {
27 // Recorded each time the promo cell is presented to the user. 30 // Recorded each time the promo cell is presented to the user.
28 BOOKMARKS_PROMO_ACTION_DISPLAYED, 31 BOOKMARKS_PROMO_ACTION_DISPLAYED,
29 // The user selected the NO THANKS button. 32 // The user selected the NO THANKS button.
30 BOOKMARKS_PROMO_ACTION_DISMISSED, 33 BOOKMARKS_PROMO_ACTION_DISMISSED,
31 // The user selected the SIGN-IN button. 34 // The user selected the SIGN-IN button.
32 BOOKMARKS_PROMO_ACTION_COMPLETED, 35 BOOKMARKS_PROMO_ACTION_COMPLETED,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 username:username 82 username:username
80 password:password]; 83 password:password];
81 } 84 }
82 85
83 void GoogleSignedOut(const std::string& account_id, 86 void GoogleSignedOut(const std::string& account_id,
84 const std::string& username) override { 87 const std::string& username) override {
85 [controller_ googleSignedOutWithAcountId:account_id username:username]; 88 [controller_ googleSignedOutWithAcountId:account_id username:username];
86 } 89 }
87 90
88 private: 91 private:
89 // Weak 92 __weak BookmarkPromoController* controller_;
90 BookmarkPromoController* controller_;
91 }; 93 };
92 } // namespace 94 } // namespace
93 95
94 @implementation BookmarkPromoController 96 @implementation BookmarkPromoController
95 97
96 @synthesize delegate = _delegate; 98 @synthesize delegate = _delegate;
97 @synthesize promoState = _promoState; 99 @synthesize promoState = _promoState;
98 100
99 + (void)registerBrowserStatePrefs:(user_prefs::PrefRegistrySyncable*)registry { 101 + (void)registerBrowserStatePrefs:(user_prefs::PrefRegistrySyncable*)registry {
100 registry->RegisterBooleanPref(prefs::kIosBookmarkPromoAlreadySeen, false); 102 registry->RegisterBooleanPref(prefs::kIosBookmarkPromoAlreadySeen, false);
(...skipping 20 matching lines...) Expand all
121 return self; 123 return self;
122 } 124 }
123 125
124 - (void)dealloc { 126 - (void)dealloc {
125 if (!_isIncognito) { 127 if (!_isIncognito) {
126 DCHECK(_browserState); 128 DCHECK(_browserState);
127 SigninManager* signinManager = 129 SigninManager* signinManager =
128 ios::SigninManagerFactory::GetForBrowserState(_browserState); 130 ios::SigninManagerFactory::GetForBrowserState(_browserState);
129 signinManager->RemoveObserver(_signinObserver.get()); 131 signinManager->RemoveObserver(_signinObserver.get());
130 } 132 }
131 [super dealloc];
132 } 133 }
133 134
134 - (void)showSignIn { 135 - (void)showSignIn {
135 UMA_HISTOGRAM_ENUMERATION(kBookmarksPromoActionsHistogram, 136 UMA_HISTOGRAM_ENUMERATION(kBookmarksPromoActionsHistogram,
136 BOOKMARKS_PROMO_ACTION_COMPLETED, 137 BOOKMARKS_PROMO_ACTION_COMPLETED,
137 BOOKMARKS_PROMO_ACTION_COUNT); 138 BOOKMARKS_PROMO_ACTION_COUNT);
138 base::RecordAction( 139 base::RecordAction(
139 base::UserMetricsAction("Signin_Signin_FromBookmarkManager")); 140 base::UserMetricsAction("Signin_Signin_FromBookmarkManager"));
140 base::scoped_nsobject<ShowSigninCommand> command([[ShowSigninCommand alloc] 141 ShowSigninCommand* command = [[ShowSigninCommand alloc]
141 initWithOperation:AUTHENTICATION_OPERATION_SIGNIN 142 initWithOperation:AUTHENTICATION_OPERATION_SIGNIN
142 signInAccessPoint:signin_metrics::AccessPoint:: 143 signInAccessPoint:signin_metrics::AccessPoint::
143 ACCESS_POINT_BOOKMARK_MANAGER]); 144 ACCESS_POINT_BOOKMARK_MANAGER];
144 [self chromeExecuteCommand:command]; 145 [self chromeExecuteCommand:command];
145 } 146 }
146 147
147 - (void)hidePromoCell { 148 - (void)hidePromoCell {
148 DCHECK(!_isIncognito); 149 DCHECK(!_isIncognito);
149 DCHECK(_browserState); 150 DCHECK(_browserState);
150 151
151 UMA_HISTOGRAM_ENUMERATION(kBookmarksPromoActionsHistogram, 152 UMA_HISTOGRAM_ENUMERATION(kBookmarksPromoActionsHistogram,
152 BOOKMARKS_PROMO_ACTION_DISMISSED, 153 BOOKMARKS_PROMO_ACTION_DISMISSED,
153 BOOKMARKS_PROMO_ACTION_COUNT); 154 BOOKMARKS_PROMO_ACTION_COUNT);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 self.promoState = NO; 208 self.promoState = NO;
208 } 209 }
209 210
210 // Called when the currently signed-in user for a user has been signed out. 211 // Called when the currently signed-in user for a user has been signed out.
211 - (void)googleSignedOutWithAcountId:(const std::string&)account_id 212 - (void)googleSignedOutWithAcountId:(const std::string&)account_id
212 username:(const std::string&)username { 213 username:(const std::string&)username {
213 [self updatePromoState]; 214 [self updatePromoState];
214 } 215 }
215 216
216 @end 217 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698