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

Unified Diff: ios/chrome/browser/ui/toolbar/web_toolbar_controller.mm

Issue 2852713002: Revert of [ObjC ARC] Converts ios/chrome/browser/ui/toolbar:toolbar to ARC. (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « ios/chrome/browser/ui/toolbar/web_toolbar_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ui/toolbar/web_toolbar_controller.mm
diff --git a/ios/chrome/browser/ui/toolbar/web_toolbar_controller.mm b/ios/chrome/browser/ui/toolbar/web_toolbar_controller.mm
index 528b23ab18dc32ffb78447b53a0c391428192bc7..645a9651e7c63e7355585bf13c83638e123f1d15 100644
--- a/ios/chrome/browser/ui/toolbar/web_toolbar_controller.mm
+++ b/ios/chrome/browser/ui/toolbar/web_toolbar_controller.mm
@@ -13,6 +13,7 @@
#include <memory>
#include "base/command_line.h"
+#include "base/ios/weak_nsobject.h"
#include "base/logging.h"
#include "base/mac/bundle_locations.h"
#include "base/mac/foundation_util.h"
@@ -43,7 +44,6 @@
#import "ios/chrome/browser/ui/keyboard/hardware_keyboard_watcher.h"
#include "ios/chrome/browser/ui/omnibox/location_bar_controller_impl.h"
#include "ios/chrome/browser/ui/omnibox/omnibox_view_ios.h"
-#import "ios/chrome/browser/ui/popup_menu/popup_menu_view.h"
#import "ios/chrome/browser/ui/reversed_animation.h"
#include "ios/chrome/browser/ui/rtl_geometry.h"
#import "ios/chrome/browser/ui/toolbar/toolbar_controller+protected.h"
@@ -72,10 +72,6 @@
#include "ui/base/page_transition_types.h"
#import "ui/gfx/ios/NSString+CrStringDrawing.h"
-#if !defined(__has_feature) || !__has_feature(objc_arc)
-#error "This file requires ARC support."
-#endif
-
using base::UserMetricsAction;
using ios::material::TimingFunction;
@@ -246,23 +242,23 @@
OmniboxPopupPositioner,
ToolbarFrameDelegate> {
// Top-level view for web content.
- UIView* _webToolbar;
- UIButton* _backButton;
- UIButton* _forwardButton;
- UIButton* _reloadButton;
- UIButton* _stopButton;
- UIButton* _starButton;
- UIButton* _voiceSearchButton;
- OmniboxTextFieldIOS* _omniBox;
- UIButton* _cancelButton;
- UIView* _keyBoardAccessoryView;
- UIButton* _keyboardVoiceSearchButton;
+ base::scoped_nsobject<UIView> _webToolbar;
+ base::scoped_nsobject<UIButton> _backButton;
+ base::scoped_nsobject<UIButton> _forwardButton;
+ base::scoped_nsobject<UIButton> _reloadButton;
+ base::scoped_nsobject<UIButton> _stopButton;
+ base::scoped_nsobject<UIButton> _starButton;
+ base::scoped_nsobject<UIButton> _voiceSearchButton;
+ base::scoped_nsobject<OmniboxTextFieldIOS> _omniBox;
+ base::scoped_nsobject<UIButton> _cancelButton;
+ base::scoped_nsobject<UIView> _keyBoardAccessoryView;
+ base::scoped_nsobject<UIButton> _keyboardVoiceSearchButton;
// Progress bar used to show what fraction of the page has loaded.
- MDCProgressView* _determinateProgressView;
- UIImageView* _omniboxBackground;
+ base::scoped_nsobject<MDCProgressView> _determinateProgressView;
+ base::scoped_nsobject<UIImageView> _omniboxBackground;
BOOL _prerenderAnimating;
- UIImageView* _incognitoIcon;
- UIView* _clippingView;
+ base::scoped_nsobject<UIImageView> _incognitoIcon;
+ base::scoped_nsobject<UIView> _clippingView;
std::unique_ptr<LocationBarController> _locationBar;
BOOL _initialLayoutComplete;
@@ -284,21 +280,21 @@
ToolbarButtonMode _forwardButtonMode;
// Keeps track of last known trait collection used by the subviews.
- UITraitCollection* _lastKnownTraitCollection;
+ base::scoped_nsobject<UITraitCollection> _lastKnownTraitCollection;
// A snapshot of the current toolbar view. Only valid for phone, will be nil
// if on tablet.
- UIImage* _snapshot;
+ base::scoped_nsobject<UIImage> _snapshot;
// A hash of the state of the toolbar when the snapshot was taken.
uint32_t _snapshotHash;
// View controller for displaying tab history when the user long presses the
// back or forward button. nil if not visible.
- TabHistoryPopupController* _tabHistoryPopupController;
+ base::scoped_nsobject<TabHistoryPopupController> _tabHistoryPopupController;
// Hardware keyboard watcher, to detect the type of keyboard currently
// attached.
- HardwareKeyboardWatcher* _hardwareKeyboardWatcher;
+ base::scoped_nsobject<HardwareKeyboardWatcher> _hardwareKeyboardWatcher;
// The current browser state.
ios::ChromeBrowserState* _browserState; // weak
@@ -399,19 +395,19 @@
InterfaceIdiom idiom = IsIPadIdiom() ? IPAD_IDIOM : IPHONE_IDIOM;
// Note that |_webToolbar| gets its frame set to -specificControlArea later in
// this method.
- _webToolbar =
- [[UIView alloc] initWithFrame:LayoutRectGetRect(kWebToolbarFrame[idiom])];
+ _webToolbar.reset([[UIView alloc]
+ initWithFrame:LayoutRectGetRect(kWebToolbarFrame[idiom])]);
UIColor* textColor =
_incognito
? [UIColor whiteColor]
: [UIColor colorWithWhite:0 alpha:[MDCTypography body1FontOpacity]];
UIColor* tintColor = _incognito ? textColor : nil;
CGRect omniboxRect = LayoutRectGetRect(kOmniboxFrame[idiom]);
- _omniBox =
- [[OmniboxTextFieldIOS alloc] initWithFrame:omniboxRect
- font:[MDCTypography subheadFont]
- textColor:textColor
- tintColor:tintColor];
+ _omniBox.reset([[OmniboxTextFieldIOS alloc]
+ initWithFrame:omniboxRect
+ font:[MDCTypography subheadFont]
+ textColor:textColor
+ tintColor:tintColor]);
if (_incognito) {
[_omniBox setIncognito:YES];
[_omniBox
@@ -425,15 +421,15 @@
alpha:1.0];
[_omniBox setPlaceholderTextColor:placeholderTextColor];
}
- _backButton = [[UIButton alloc]
- initWithFrame:LayoutRectGetRect(kBackButtonFrame[idiom])];
+ _backButton.reset([[UIButton alloc]
+ initWithFrame:LayoutRectGetRect(kBackButtonFrame[idiom])]);
[_backButton setAutoresizingMask:UIViewAutoresizingFlexibleTrailingMargin() |
UIViewAutoresizingFlexibleTopMargin |
UIViewAutoresizingFlexibleBottomMargin];
// Note that the forward button gets repositioned when -layoutOmnibox is
// called.
- _forwardButton = [[UIButton alloc]
- initWithFrame:LayoutRectGetRect(kForwardButtonFrame[idiom])];
+ _forwardButton.reset([[UIButton alloc]
+ initWithFrame:LayoutRectGetRect(kForwardButtonFrame[idiom])]);
[_forwardButton
setAutoresizingMask:UIViewAutoresizingFlexibleTrailingMargin() |
UIViewAutoresizingFlexibleBottomMargin];
@@ -443,7 +439,7 @@
// _omniboxBackground needs to be added under _omniBox so as not to cover up
// _omniBox.
- _omniboxBackground = [[UIImageView alloc] initWithFrame:omniboxRect];
+ _omniboxBackground.reset([[UIImageView alloc] initWithFrame:omniboxRect]);
[_omniboxBackground
setAutoresizingMask:UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleBottomMargin];
@@ -455,7 +451,7 @@
[_forwardButton setImageEdgeInsets:UIEdgeInsetsMakeDirected(0, -7, 0, 0)];
CGRect clippingFrame =
RectShiftedUpAndResizedForStatusBar(kToolbarFrame[idiom]);
- _clippingView = [[UIView alloc] initWithFrame:clippingFrame];
+ _clippingView.reset([[UIView alloc] initWithFrame:clippingFrame]);
[_clippingView setAutoresizingMask:UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleBottomMargin];
[_clippingView setClipsToBounds:YES];
@@ -475,8 +471,8 @@
setBackgroundColor:
[UIColor colorWithWhite:kNTPBackgroundColorBrightnessIncognito
alpha:1.0]];
- _incognitoIcon = [[UIImageView alloc]
- initWithImage:[UIImage imageNamed:@"incognito_marker_typing"]];
+ _incognitoIcon.reset([[UIImageView alloc]
+ initWithImage:[UIImage imageNamed:@"incognito_marker_typing"]]);
[_incognitoIcon setAlpha:0];
[_incognitoIcon
setAutoresizingMask:UIViewAutoresizingFlexibleTrailingMargin()];
@@ -493,22 +489,22 @@
if (idiom == IPAD_IDIOM) {
// Note that the reload button gets repositioned when -layoutOmnibox is
// called.
- _reloadButton = [[UIButton alloc]
- initWithFrame:LayoutRectGetRect(kStopReloadButtonFrame)];
+ _reloadButton.reset([[UIButton alloc]
+ initWithFrame:LayoutRectGetRect(kStopReloadButtonFrame)]);
[_reloadButton
setAutoresizingMask:UIViewAutoresizingFlexibleTrailingMargin() |
UIViewAutoresizingFlexibleBottomMargin];
- _stopButton = [[UIButton alloc]
- initWithFrame:LayoutRectGetRect(kStopReloadButtonFrame)];
+ _stopButton.reset([[UIButton alloc]
+ initWithFrame:LayoutRectGetRect(kStopReloadButtonFrame)]);
[_stopButton
setAutoresizingMask:UIViewAutoresizingFlexibleTrailingMargin() |
UIViewAutoresizingFlexibleBottomMargin];
- _starButton =
- [[UIButton alloc] initWithFrame:LayoutRectGetRect(kStarButtonFrame)];
+ _starButton.reset(
+ [[UIButton alloc] initWithFrame:LayoutRectGetRect(kStarButtonFrame)]);
[_starButton setAutoresizingMask:UIViewAutoresizingFlexibleBottomMargin |
UIViewAutoresizingFlexibleLeadingMargin()];
- _voiceSearchButton = [[UIButton alloc]
- initWithFrame:LayoutRectGetRect(kVoiceSearchButtonFrame)];
+ _voiceSearchButton.reset([[UIButton alloc]
+ initWithFrame:LayoutRectGetRect(kVoiceSearchButtonFrame)]);
[_voiceSearchButton
setAutoresizingMask:UIViewAutoresizingFlexibleBottomMargin |
UIViewAutoresizingFlexibleLeadingMargin()];
@@ -555,15 +551,15 @@
_backButtonMode = ToolbarButtonModeNormal;
_forwardButtonMode = ToolbarButtonModeNormal;
- UILongPressGestureRecognizer* backLongPress =
+ base::scoped_nsobject<UILongPressGestureRecognizer> backLongPress(
[[UILongPressGestureRecognizer alloc]
initWithTarget:self
- action:@selector(handleLongPress:)];
+ action:@selector(handleLongPress:)]);
[_backButton addGestureRecognizer:backLongPress];
- UILongPressGestureRecognizer* forwardLongPress =
+ base::scoped_nsobject<UILongPressGestureRecognizer> forwardLongPress(
[[UILongPressGestureRecognizer alloc]
initWithTarget:self
- action:@selector(handleLongPress:)];
+ action:@selector(handleLongPress:)]);
[_forwardButton addGestureRecognizer:forwardLongPress];
// TODO(leng): Consider moving this to a pak file as well. For now,
@@ -611,8 +607,8 @@
CGFloat progressWidth = self.view.frame.size.width;
CGFloat progressHeight = 0;
progressHeight = kMaterialProgressBarHeight;
- _determinateProgressView = [[MDCProgressView alloc] init];
- _determinateProgressView.hidden = YES;
+ _determinateProgressView.reset([[MDCProgressView alloc] init]);
+ _determinateProgressView.get().hidden = YES;
[_determinateProgressView
setProgressTintColor:[MDCPalette cr_bluePalette].tint500];
[_determinateProgressView
@@ -676,6 +672,7 @@
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
[_tabHistoryPopupController setDelegate:nil];
+ [super dealloc];
}
#pragma mark -
@@ -749,19 +746,17 @@
- (void)showPrerenderingAnimation {
_prerenderAnimating = YES;
- __weak MDCProgressView* weakDeterminateProgressView =
- _determinateProgressView;
[_determinateProgressView setProgress:0];
[_determinateProgressView setHidden:NO
animated:YES
completion:^(BOOL finished) {
- [weakDeterminateProgressView
+ [_determinateProgressView
setProgress:1
animated:YES
completion:^(BOOL finished) {
- [weakDeterminateProgressView setHidden:YES
- animated:YES
- completion:nil];
+ [_determinateProgressView setHidden:YES
+ animated:YES
+ completion:nil];
}];
}];
}
@@ -791,11 +786,11 @@
}
- (UIView*)bookmarkButtonView {
- return _starButton;
+ return _starButton.get();
}
- (CGRect)visibleOmniboxFrame {
- CGRect frame = _omniboxBackground.frame;
+ CGRect frame = _omniboxBackground.get().frame;
frame = [self.view.superview convertRect:frame
fromView:[_omniboxBackground superview]];
// Account for the omnibox background image transparent sides.
@@ -807,7 +802,7 @@
return nil;
// Below call will be no-op if cached snapshot is valid.
[self updateSnapshotWithWidth:width forced:YES];
- return _snapshot;
+ return [[_snapshot retain] autorelease];
}
- (void)showTabHistoryPopupInView:(UIView*)view
@@ -829,10 +824,10 @@
CGRectGetMaxY(buttonBounds));
CGPoint convertedOrigin =
[view convertPoint:origin fromView:historyButton.imageView];
- _tabHistoryPopupController =
- [[TabHistoryPopupController alloc] initWithOrigin:convertedOrigin
- parentView:view
- items:items];
+ _tabHistoryPopupController.reset([[TabHistoryPopupController alloc]
+ initWithOrigin:convertedOrigin
+ parentView:view
+ items:items]);
[_tabHistoryPopupController setDelegate:self];
// Fade in the popup and notify observers.
@@ -849,7 +844,7 @@
- (void)dismissTabHistoryPopup {
if (!_tabHistoryPopupController)
return;
- TabHistoryPopupController* tempTHPC = _tabHistoryPopupController;
+ TabHistoryPopupController* tempTHPC = _tabHistoryPopupController.get();
[tempTHPC containerView].userInteractionEnabled = NO;
[tempTHPC dismissAnimatedWithCompletion:^{
// Unpress the back/forward button by restoring the normal and
@@ -861,7 +856,7 @@
}];
// reset _tabHistoryPopupController to prevent -applicationDidEnterBackground
// from posting another kTabHistoryPopupWillHideNotification.
- _tabHistoryPopupController = nil;
+ _tabHistoryPopupController.reset();
[[NSNotificationCenter defaultCenter]
postNotificationName:kTabHistoryPopupWillHideNotification
@@ -880,8 +875,9 @@
- (void)traitCollectionDidChange:(UITraitCollection*)previousTraitCollection {
[super traitCollectionDidChange:previousTraitCollection];
- _lastKnownTraitCollection = [UITraitCollection
- traitCollectionWithTraitsFromCollections:@[ self.view.traitCollection ]];
+ _lastKnownTraitCollection.reset([[UITraitCollection
+ traitCollectionWithTraitsFromCollections:@[ self.view.traitCollection ]]
+ retain]);
if (IsIPadIdiom()) {
// Update toolbar accessory views.
BOOL isCompactTabletView = IsCompactTablet(self.view);
@@ -893,7 +889,7 @@
// Update keyboard accessory views.
BOOL hidden = [_keyboardVoiceSearchButton isHidden];
- _keyBoardAccessoryView = nil;
+ _keyBoardAccessoryView.reset();
[_omniBox setInputAccessoryView:[self keyboardAccessoryView]];
[_keyboardVoiceSearchButton setHidden:hidden];
if ([_omniBox isFirstResponder]) {
@@ -914,7 +910,7 @@
// Dismiss the tab history popup without animation.
[self setImagesForNavButton:_backButton withTabHistoryVisible:NO];
[self setImagesForNavButton:_forwardButton withTabHistoryVisible:NO];
- _tabHistoryPopupController = nil;
+ _tabHistoryPopupController.reset(nil);
[[NSNotificationCenter defaultCenter]
postNotificationName:kTabHistoryPopupWillHideNotification
object:nil];
@@ -933,7 +929,7 @@
hasDisabledImage:hasDisabledImage
synchronously:synchronously];
- if (button != _starButton)
+ if (button != _starButton.get())
return;
// The star button behaves slightly differently. It uses the pressed
// image for its selected state as well as its pressed state.
@@ -958,19 +954,19 @@
}
- (IBAction)recordUserMetrics:(id)sender {
- if (sender == _backButton) {
+ if (sender == _backButton.get()) {
base::RecordAction(UserMetricsAction("MobileToolbarBack"));
- } else if (sender == _forwardButton) {
+ } else if (sender == _forwardButton.get()) {
base::RecordAction(UserMetricsAction("MobileToolbarForward"));
- } else if (sender == _reloadButton) {
+ } else if (sender == _reloadButton.get()) {
base::RecordAction(UserMetricsAction("MobileToolbarReload"));
- } else if (sender == _stopButton) {
+ } else if (sender == _stopButton.get()) {
base::RecordAction(UserMetricsAction("MobileToolbarStop"));
- } else if (sender == _voiceSearchButton) {
+ } else if (sender == _voiceSearchButton.get()) {
base::RecordAction(UserMetricsAction("MobileToolbarVoiceSearch"));
- } else if (sender == _keyboardVoiceSearchButton) {
+ } else if (sender == _keyboardVoiceSearchButton.get()) {
base::RecordAction(UserMetricsAction("MobileCustomRowVoiceSearch"));
- } else if (sender == _starButton) {
+ } else if (sender == _starButton.get()) {
base::RecordAction(UserMetricsAction("MobileToolbarToggleBookmark"));
} else {
[super recordUserMetrics:sender];
@@ -995,17 +991,17 @@
}
- (int)imageEnumForButton:(UIButton*)button {
- if (button == _voiceSearchButton)
+ if (button == _voiceSearchButton.get())
return _isTTSPlaying ? WebToolbarButtonNameTTS : WebToolbarButtonNameVoice;
- if (button == _starButton)
+ if (button == _starButton.get())
return WebToolbarButtonNameStar;
- if (button == _stopButton)
+ if (button == _stopButton.get())
return WebToolbarButtonNameStop;
- if (button == _reloadButton)
+ if (button == _reloadButton.get())
return WebToolbarButtonNameReload;
- if (button == _backButton)
+ if (button == _backButton.get())
return WebToolbarButtonNameBack;
- if (button == _forwardButton)
+ if (button == _forwardButton.get())
return WebToolbarButtonNameForward;
return [super imageEnumForButton:button];
}
@@ -1314,7 +1310,7 @@
// Hide the voice search button once the user starts editing the omnibox but
// show it if the omnibox is empty.
bool isEditingOrEmpty = _locationBar->GetLocationEntry()->IsEditingOrEmpty();
- BOOL editingAndNotEmpty = isEditingOrEmpty && _omniBox.text.length != 0;
+ BOOL editingAndNotEmpty = isEditingOrEmpty && _omniBox.get().text.length != 0;
// If the voice search button is visible but about to be hidden (i.e.
// the omnibox is no longer empty) then this is the first omnibox text so
// record a user action.
@@ -1478,7 +1474,7 @@
- (UIButton*)cancelButton {
if (_cancelButton)
return _cancelButton;
- _cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
+ _cancelButton.reset([[UIButton buttonWithType:UIButtonTypeCustom] retain]);
NSString* collapseName = _incognito ? @"collapse_incognito" : @"collapse";
[_cancelButton setImage:[UIImage imageNamed:collapseName]
forState:UIControlStateNormal];
@@ -1634,17 +1630,15 @@
// disappeared.
if (!_prerenderAnimating) {
- __weak MDCProgressView* weakDeterminateProgressView =
- _determinateProgressView;
// Calling -completeAndHide while a prerender animation is in progress
// will result in hiding the progress bar before the animation is
// complete.
[_determinateProgressView setProgress:1
animated:YES
completion:^(BOOL finished) {
- [weakDeterminateProgressView setHidden:YES
- animated:YES
- completion:nil];
+ [_determinateProgressView setHidden:YES
+ animated:YES
+ completion:nil];
}];
}
CGFloat delay = _unitTesting ? 0 : kLoadCompleteHideProgressBarDelay;
@@ -1709,13 +1703,13 @@
if (gesture.state != UIGestureRecognizerStateBegan)
return;
- if (gesture.view == _backButton) {
- GenericChromeCommand* command =
- [[GenericChromeCommand alloc] initWithTag:IDC_SHOW_BACK_HISTORY];
+ if (gesture.view == _backButton.get()) {
+ base::scoped_nsobject<GenericChromeCommand> command(
+ [[GenericChromeCommand alloc] initWithTag:IDC_SHOW_BACK_HISTORY]);
[_backButton chromeExecuteCommand:command];
- } else if (gesture.view == _forwardButton) {
- GenericChromeCommand* command =
- [[GenericChromeCommand alloc] initWithTag:IDC_SHOW_FORWARD_HISTORY];
+ } else if (gesture.view == _forwardButton.get()) {
+ base::scoped_nsobject<GenericChromeCommand> command(
+ [[GenericChromeCommand alloc] initWithTag:IDC_SHOW_FORWARD_HISTORY]);
[_forwardButton chromeExecuteCommand:command];
}
}
@@ -1730,8 +1724,10 @@
if (!isBackButton && newMode == _forwardButtonMode)
return;
- UIImage* normalImage = [button imageForState:UIControlStateNormal];
- UIImage* highlightedImage = [button imageForState:UIControlStateHighlighted];
+ base::scoped_nsobject<UIImage> normalImage(
+ [[button imageForState:UIControlStateNormal] retain]);
+ base::scoped_nsobject<UIImage> highlightedImage(
+ [[button imageForState:UIControlStateHighlighted] retain]);
[button setImage:highlightedImage forState:UIControlStateNormal];
[button setImage:normalImage forState:UIControlStateHighlighted];
if (isBackButton)
@@ -1874,9 +1870,9 @@
CGFloat height = isTablet ? kViewHeightTablet : kViewHeightPhone;
CGRect frame = CGRectMake(0.0, 0.0, width, height);
- _keyBoardAccessoryView =
- [[KeyboardAccessoryView alloc] initWithFrame:frame
- inputViewStyle:UIInputViewStyleKeyboard];
+ _keyBoardAccessoryView.reset([[KeyboardAccessoryView alloc]
+ initWithFrame:frame
+ inputViewStyle:UIInputViewStyleKeyboard]);
[_keyBoardAccessoryView setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
NSArray* buttonTitles =
@@ -1894,7 +1890,8 @@
if (indent < kButtonInset)
indent = kButtonInset;
CGRect parentViewRect = CGRectMake(indent, 0.0, totalWidth, height);
- UIView* parentView = [[UIView alloc] initWithFrame:parentViewRect];
+ base::scoped_nsobject<UIView> parentView(
+ [[UIView alloc] initWithFrame:parentViewRect]);
[parentView setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin |
UIViewAutoresizingFlexibleRightMargin];
[_keyBoardAccessoryView addSubview:parentView];
@@ -1912,7 +1909,8 @@
// Create the voice search button and add it to _keyBoardAccessoryView over
// the text buttons.
- _keyboardVoiceSearchButton = [UIButton buttonWithType:UIButtonTypeCustom];
+ _keyboardVoiceSearchButton.reset(
+ [[UIButton buttonWithType:UIButtonTypeCustom] retain]);
[_keyboardVoiceSearchButton
setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[_keyboardVoiceSearchButton setTag:IDC_VOICE_SEARCH];
@@ -1954,8 +1952,8 @@
[_keyBoardAccessoryView addSubview:_keyboardVoiceSearchButton];
// Reset the external keyboard watcher.
- _hardwareKeyboardWatcher = [[HardwareKeyboardWatcher alloc]
- initWithAccessoryView:_keyBoardAccessoryView];
+ _hardwareKeyboardWatcher.reset([[HardwareKeyboardWatcher alloc]
+ initWithAccessoryView:_keyBoardAccessoryView]);
return _keyBoardAccessoryView;
}
@@ -1970,8 +1968,8 @@
// Use a GenericChromeCommand because |sender| already has a tag set for a
// different command.
- GenericChromeCommand* command =
- [[GenericChromeCommand alloc] initWithTag:IDC_PRELOAD_VOICE_SEARCH];
+ base::scoped_nsobject<GenericChromeCommand> command(
+ [[GenericChromeCommand alloc] initWithTag:IDC_PRELOAD_VOICE_SEARCH]);
[sender chromeExecuteCommand:command];
}
@@ -2474,7 +2472,7 @@
return;
}
// If the snapshot is valid, don't redraw.
- if (_snapshot && _snapshotHash == [self snapshotHashWithWidth:width])
+ if (_snapshot.get() && _snapshotHash == [self snapshotHashWithWidth:width])
return;
// Don't update the snapshot while the progress bar is moving, or while the
@@ -2499,7 +2497,7 @@
UIGraphicsBeginImageContextWithOptions(frame.size, NO, 0.0);
[[self view].layer renderInContext:UIGraphicsGetCurrentContext()];
- _snapshot = UIGraphicsGetImageFromCurrentImageContext();
+ _snapshot.reset([UIGraphicsGetImageFromCurrentImageContext() retain]);
UIGraphicsEndImageContext();
// In the past, when the current tab was prerendered, taking a snapshot
@@ -2574,7 +2572,7 @@
}
- (OmniboxTextFieldIOS*)omnibox {
- return _omniBox;
+ return _omniBox.get();
}
@end
« no previous file with comments | « ios/chrome/browser/ui/toolbar/web_toolbar_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698