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

Side by Side Diff: ios/chrome/today_extension/today_view_controller.mm

Issue 2938433002: [ObjC ARC] Converts ios/chrome/today_extension:today_extension to ARC. (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « ios/chrome/today_extension/physical_web_optin_footer.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/today_extension/today_view_controller.h" 5 #import "ios/chrome/today_extension/today_view_controller.h"
6 6
7 #import <CommonCrypto/CommonDigest.h> 7 #import <CommonCrypto/CommonDigest.h>
8 #import <NotificationCenter/NotificationCenter.h> 8 #import <NotificationCenter/NotificationCenter.h>
9 #include <unistd.h> 9 #include <unistd.h>
10 10
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 setLayoutMargins:UIEdgeInsetsMake(ui_util::kFirstLineButtonMargin, 369 setLayoutMargins:UIEdgeInsetsMake(ui_util::kFirstLineButtonMargin,
370 firstLineOuterMargin, 370 firstLineOuterMargin,
371 ui_util::kFirstLineButtonMargin, 371 ui_util::kFirstLineButtonMargin,
372 firstLineOuterMargin)]; 372 firstLineOuterMargin)];
373 373
374 _urlsTable.reset([[UITableView alloc] initWithFrame:CGRectZero]); 374 _urlsTable.reset([[UITableView alloc] initWithFrame:CGRectZero]);
375 [_urlsTable setDataSource:self]; 375 [_urlsTable setDataSource:self];
376 [_urlsTable setRowHeight:ui_util::kSecondLineHeight]; 376 [_urlsTable setRowHeight:ui_util::kSecondLineHeight];
377 [_urlsTable setSeparatorStyle:UITableViewCellSeparatorStyleNone]; 377 [_urlsTable setSeparatorStyle:UITableViewCellSeparatorStyleNone];
378 _tableViewHeight.reset( 378 _tableViewHeight.reset(
379 [[[_urlsTable heightAnchor] constraintEqualToConstant:0] retain]); 379 [[_urlsTable heightAnchor] constraintEqualToConstant:0]);
380 [_tableViewHeight setActive:YES]; 380 [_tableViewHeight setActive:YES];
381 381
382 _contentStackView.reset([[UIStackView alloc] 382 _contentStackView.reset([[UIStackView alloc]
383 initWithArrangedSubviews:@[ _buttonsView, _urlsTable ]]); 383 initWithArrangedSubviews:@[ _buttonsView, _urlsTable ]]);
384 [[_urlsTable widthAnchor] 384 [[_urlsTable widthAnchor]
385 constraintEqualToAnchor:[_contentStackView widthAnchor]] 385 constraintEqualToAnchor:[_contentStackView widthAnchor]]
386 .active = YES; 386 .active = YES;
387 [_contentStackView setAxis:UILayoutConstraintAxisVertical]; 387 [_contentStackView setAxis:UILayoutConstraintAxisVertical];
388 [_contentStackView setDistribution:UIStackViewDistributionFill]; 388 [_contentStackView setDistribution:UIStackViewDistributionFill];
389 [_contentStackView setSpacing:0]; 389 [_contentStackView setSpacing:0];
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 return; 528 return;
529 if (footerLabel == PW_OPTIN_DIALOG && 529 if (footerLabel == PW_OPTIN_DIALOG &&
530 _currentFooterLabel != PW_OPTIN_DIALOG) { 530 _currentFooterLabel != PW_OPTIN_DIALOG) {
531 TodayMetricsLogger::GetInstance()->RecordUserAction( 531 TodayMetricsLogger::GetInstance()->RecordUserAction(
532 base::UserMetricsAction("PhysicalWeb.OptinDisplayed")); 532 base::UserMetricsAction("PhysicalWeb.OptinDisplayed"));
533 } 533 }
534 534
535 _currentFooterLabel = footerLabel; 535 _currentFooterLabel = footerLabel;
536 [[_footerLabel view] removeFromSuperview]; 536 [[_footerLabel view] removeFromSuperview];
537 base::WeakNSObject<TodayViewController> weakSelf(self); 537 base::WeakNSObject<TodayViewController> weakSelf(self);
538 base::mac::ScopedBlock<ProceduralBlock> learnMoreBlock; 538 ProceduralBlock learnMoreBlock = ^{
539 base::mac::ScopedBlock<ProceduralBlock> turnOffPhysicalWeb; 539 [weakSelf learnMore];
540 base::mac::ScopedBlock<ProceduralBlock> turnOnPhysicalWeb; 540 };
541 base::mac::ScopedBlock<ProceduralBlock> optInPhysicalWeb;
542 base::mac::ScopedBlock<ProceduralBlock> optOutPhysicalWeb;
543 541
544 learnMoreBlock.reset( 542 ProceduralBlock turnOffPhysicalWeb;
545 ^{ 543 ProceduralBlock turnOnPhysicalWeb;
546 [weakSelf learnMore]; 544 ProceduralBlock optInPhysicalWeb;
547 }, 545 ProceduralBlock optOutPhysicalWeb;
548 base::scoped_policy::RETAIN); 546
549 if (![[LockScreenState sharedInstance] isScreenLocked]) { 547 if (![[LockScreenState sharedInstance] isScreenLocked]) {
550 turnOffPhysicalWeb.reset( 548 turnOffPhysicalWeb = ^{
551 ^{ 549 [weakSelf setPhysicalWebEnabled:NO];
552 [weakSelf setPhysicalWebEnabled:NO]; 550 };
553 },
554 base::scoped_policy::RETAIN);
555 551
556 turnOnPhysicalWeb.reset( 552 turnOnPhysicalWeb = ^{
557 ^{ 553 [weakSelf setPhysicalWebEnabled:YES];
558 [weakSelf setPhysicalWebEnabled:YES]; 554 };
559 },
560 base::scoped_policy::RETAIN);
561 555
562 optInPhysicalWeb.reset( 556 optInPhysicalWeb = ^{
563 ^{ 557 [weakSelf physicalWebOptIn];
564 [weakSelf physicalWebOptIn]; 558 };
565 },
566 base::scoped_policy::RETAIN);
567 559
568 optOutPhysicalWeb.reset( 560 optOutPhysicalWeb = ^{
569 ^{ 561 [weakSelf physicalWebOptOut];
570 [weakSelf physicalWebOptOut]; 562 };
571 },
572 base::scoped_policy::RETAIN);
573 } 563 }
574 564
575 switch (footerLabel) { 565 switch (footerLabel) {
576 case NO_FOOTER_LABEL: 566 case NO_FOOTER_LABEL:
577 _footerLabel.reset(); 567 _footerLabel.reset();
578 break; 568 break;
579 case PW_IS_OFF_FOOTER_LABEL: 569 case PW_IS_OFF_FOOTER_LABEL:
580 _footerLabel.reset([[PWIsOffFooterLabel alloc] 570 _footerLabel.reset([[PWIsOffFooterLabel alloc]
581 initWithLearnMoreBlock:learnMoreBlock 571 initWithLearnMoreBlock:learnMoreBlock
582 turnOnBlock:turnOnPhysicalWeb]); 572 turnOnBlock:turnOnPhysicalWeb]);
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 if (cell) { 961 if (cell) {
972 [cell setTitle:l10n_util::GetNSString( 962 [cell setTitle:l10n_util::GetNSString(
973 IDS_IOS_OPEN_COPIED_LINK_TODAY_EXTENSION) 963 IDS_IOS_OPEN_COPIED_LINK_TODAY_EXTENSION)
974 url:_pasteURL]; 964 url:_pasteURL];
975 965
976 } else { 966 } else {
977 base::WeakNSObject<TodayViewController> weakSelf(self); 967 base::WeakNSObject<TodayViewController> weakSelf(self);
978 URLActionBlock action = ^(NSString* url) { 968 URLActionBlock action = ^(NSString* url) {
979 [weakSelf openClipboardURLInChrome:url]; 969 [weakSelf openClipboardURLInChrome:url];
980 }; 970 };
981 cell = [[[URLTableCell alloc] 971 cell = [[URLTableCell alloc]
982 initWithTitle:l10n_util::GetNSString( 972 initWithTitle:l10n_util::GetNSString(
983 IDS_IOS_OPEN_COPIED_LINK_TODAY_EXTENSION) 973 IDS_IOS_OPEN_COPIED_LINK_TODAY_EXTENSION)
984 url:_pasteURL 974 url:_pasteURL
985 icon:@"todayview_clipboard" 975 icon:@"todayview_clipboard"
986 leftInset:_defaultLeadingMarginInset 976 leftInset:_defaultLeadingMarginInset
987 reuseIdentifier:pasteboardReusableID 977 reuseIdentifier:pasteboardReusableID
988 block:action] autorelease]; 978 block:action];
989 cell.selectionStyle = UITableViewCellSelectionStyleNone; 979 cell.selectionStyle = UITableViewCellSelectionStyleNone;
990 } 980 }
991 return cell; 981 return cell;
992 } 982 }
993 983
994 - (URLTableCell*)cellForShowMore { 984 - (URLTableCell*)cellForShowMore {
995 NSString* showMoreReusableID = @"ShowMoreCell"; 985 NSString* showMoreReusableID = @"ShowMoreCell";
996 URLTableCell* cell = base::mac::ObjCCast<URLTableCell>( 986 URLTableCell* cell = base::mac::ObjCCast<URLTableCell>(
997 [_urlsTable dequeueReusableCellWithIdentifier:showMoreReusableID]); 987 [_urlsTable dequeueReusableCellWithIdentifier:showMoreReusableID]);
998 NSString* title = l10n_util::GetNSString( 988 NSString* title = l10n_util::GetNSString(
999 IDS_IOS_PYSICAL_WEB_TODAY_EXTENSION_SHOW_MORE_BEACONS); 989 IDS_IOS_PYSICAL_WEB_TODAY_EXTENSION_SHOW_MORE_BEACONS);
1000 if (cell) { 990 if (cell) {
1001 [cell setTitle:title url:@""]; 991 [cell setTitle:title url:@""];
1002 } else { 992 } else {
1003 base::WeakNSObject<TodayViewController> weakSelf(self); 993 base::WeakNSObject<TodayViewController> weakSelf(self);
1004 URLActionBlock action = ^(NSString* url) { 994 URLActionBlock action = ^(NSString* url) {
1005 [weakSelf setDisplayAllPhysicalWebItems:YES]; 995 [weakSelf setDisplayAllPhysicalWebItems:YES];
1006 [weakSelf refreshWidget]; 996 [weakSelf refreshWidget];
1007 }; 997 };
1008 cell = [[[URLTableCell alloc] initWithTitle:title 998 cell = [[URLTableCell alloc] initWithTitle:title
1009 url:@"" 999 url:@""
1010 icon:@"" 1000 icon:@""
1011 leftInset:_defaultLeadingMarginInset 1001 leftInset:_defaultLeadingMarginInset
1012 reuseIdentifier:showMoreReusableID 1002 reuseIdentifier:showMoreReusableID
1013 block:action] autorelease]; 1003 block:action];
1014 cell.selectionStyle = UITableViewCellSelectionStyleNone; 1004 cell.selectionStyle = UITableViewCellSelectionStyleNone;
1015 } 1005 }
1016 return cell; 1006 return cell;
1017 } 1007 }
1018 1008
1019 - (URLTableCell*)cellForPhysicalWebURLAtIndex:(NSInteger)index { 1009 - (URLTableCell*)cellForPhysicalWebURLAtIndex:(NSInteger)index {
1020 NSString* physicalWebReusableID = @"PhysicalWebCell"; 1010 NSString* physicalWebReusableID = @"PhysicalWebCell";
1021 URLTableCell* cell = base::mac::ObjCCast<URLTableCell>( 1011 URLTableCell* cell = base::mac::ObjCCast<URLTableCell>(
1022 [_urlsTable dequeueReusableCellWithIdentifier:physicalWebReusableID]); 1012 [_urlsTable dequeueReusableCellWithIdentifier:physicalWebReusableID]);
1023 PhysicalWebDevice* device = [[_scanner devices] objectAtIndex:index]; 1013 PhysicalWebDevice* device = [[_scanner devices] objectAtIndex:index];
1024 if (cell) { 1014 if (cell) {
1025 [cell setTitle:[device title] url:[[device url] absoluteString]]; 1015 [cell setTitle:[device title] url:[[device url] absoluteString]];
1026 } else { 1016 } else {
1027 base::WeakNSObject<TodayViewController> weakSelf(self); 1017 base::WeakNSObject<TodayViewController> weakSelf(self);
1028 URLActionBlock action = ^(NSString* url) { 1018 URLActionBlock action = ^(NSString* url) {
1029 [weakSelf openPhysicalWebURLInChrome:url]; 1019 [weakSelf openPhysicalWebURLInChrome:url];
1030 }; 1020 };
1031 cell = [[[URLTableCell alloc] initWithTitle:[device title] 1021 cell = [[URLTableCell alloc] initWithTitle:[device title]
1032 url:[[device url] absoluteString] 1022 url:[[device url] absoluteString]
1033 icon:@"todayview_physical_web" 1023 icon:@"todayview_physical_web"
1034 leftInset:_defaultLeadingMarginInset 1024 leftInset:_defaultLeadingMarginInset
1035 reuseIdentifier:physicalWebReusableID 1025 reuseIdentifier:physicalWebReusableID
1036 block:action] autorelease]; 1026 block:action];
1037 cell.selectionStyle = UITableViewCellSelectionStyleNone; 1027 cell.selectionStyle = UITableViewCellSelectionStyleNone;
1038 } 1028 }
1039 return cell; 1029 return cell;
1040 } 1030 }
1041 1031
1042 - (UITableViewCell*)tableView:(UITableView*)tableView 1032 - (UITableViewCell*)tableView:(UITableView*)tableView
1043 cellForRowAtIndexPath:(NSIndexPath*)indexPath { 1033 cellForRowAtIndexPath:(NSIndexPath*)indexPath {
1044 DCHECK(tableView == _urlsTable.get()); 1034 DCHECK(tableView == _urlsTable.get());
1045 NSInteger indexRequested = [indexPath row]; 1035 NSInteger indexRequested = [indexPath row];
1046 NSInteger lastRowIndex = 1036 NSInteger lastRowIndex =
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 if (ui_util::IsRTL()) { 1087 if (ui_util::IsRTL()) {
1098 _defaultLeadingMarginInset = defaultMarginInsets.right; 1088 _defaultLeadingMarginInset = defaultMarginInsets.right;
1099 } else { 1089 } else {
1100 _defaultLeadingMarginInset = defaultMarginInsets.left; 1090 _defaultLeadingMarginInset = defaultMarginInsets.left;
1101 } 1091 }
1102 } 1092 }
1103 return UIEdgeInsetsZero; 1093 return UIEdgeInsetsZero;
1104 } 1094 }
1105 1095
1106 @end 1096 @end
OLDNEW
« no previous file with comments | « ios/chrome/today_extension/physical_web_optin_footer.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698