| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/find_bar/find_bar_controller_ios.h" | 5 #import "ios/chrome/browser/ui/find_bar/find_bar_controller_ios.h" |
| 6 | 6 |
| 7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
| 9 #include "base/ios/ios_util.h" | 9 #include "base/ios/ios_util.h" |
| 10 #include "base/mac/bundle_locations.h" | 10 #include "base/mac/bundle_locations.h" |
| 11 #include "base/mac/foundation_util.h" | 11 #include "base/mac/foundation_util.h" |
| 12 #include "base/mac/objc_property_releaser.h" | 12 #include "base/mac/objc_release_properties.h" |
| 13 #include "base/mac/scoped_nsobject.h" | 13 #include "base/mac/scoped_nsobject.h" |
| 14 #include "base/strings/sys_string_conversions.h" | 14 #include "base/strings/sys_string_conversions.h" |
| 15 #include "components/strings/grit/components_strings.h" | 15 #include "components/strings/grit/components_strings.h" |
| 16 #import "ios/chrome/browser/find_in_page/find_in_page_controller.h" | 16 #import "ios/chrome/browser/find_in_page/find_in_page_controller.h" |
| 17 #import "ios/chrome/browser/find_in_page/find_in_page_model.h" | 17 #import "ios/chrome/browser/find_in_page/find_in_page_model.h" |
| 18 #import "ios/chrome/browser/ui/UIView+SizeClassSupport.h" | 18 #import "ios/chrome/browser/ui/UIView+SizeClassSupport.h" |
| 19 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" | 19 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" |
| 20 #import "ios/chrome/browser/ui/find_bar/find_bar_view.h" | 20 #import "ios/chrome/browser/ui/find_bar/find_bar_view.h" |
| 21 #include "ios/chrome/browser/ui/ui_util.h" | 21 #include "ios/chrome/browser/ui/ui_util.h" |
| 22 #include "ui/base/l10n/l10n_util_mac.h" | 22 #include "ui/base/l10n/l10n_util_mac.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 37 // For the first |kSearchDelayChars| characters, delay by |kSearchLongDelay| | 37 // For the first |kSearchDelayChars| characters, delay by |kSearchLongDelay| |
| 38 // For the remaining characters, delay by |kSearchShortDelay|. | 38 // For the remaining characters, delay by |kSearchShortDelay|. |
| 39 const NSUInteger kSearchDelayChars = 3; | 39 const NSUInteger kSearchDelayChars = 3; |
| 40 const NSTimeInterval kSearchLongDelay = 1.0; | 40 const NSTimeInterval kSearchLongDelay = 1.0; |
| 41 const NSTimeInterval kSearchShortDelay = 0.100; | 41 const NSTimeInterval kSearchShortDelay = 0.100; |
| 42 | 42 |
| 43 } // anonymous namespace | 43 } // anonymous namespace |
| 44 | 44 |
| 45 #pragma mark - FindBarControllerIOS | 45 #pragma mark - FindBarControllerIOS |
| 46 | 46 |
| 47 @interface FindBarControllerIOS ()<UITextFieldDelegate> { | 47 @interface FindBarControllerIOS ()<UITextFieldDelegate> |
| 48 base::mac::ObjCPropertyReleaser _propertyReleaser_FindInPageController; | |
| 49 } | |
| 50 | 48 |
| 51 // Set up iPad UI | 49 // Set up iPad UI |
| 52 - (void)setUpIPad; | 50 - (void)setUpIPad; |
| 53 // Set up iPhone UI | 51 // Set up iPhone UI |
| 54 - (void)setUpIPhone; | 52 - (void)setUpIPhone; |
| 55 // Animate find bar to iPad top right, or, when possible, to align find bar | 53 // Animate find bar to iPad top right, or, when possible, to align find bar |
| 56 // horizontally with |alignmentFrame|. | 54 // horizontally with |alignmentFrame|. |
| 57 - (void)showIPadFindBarView:(BOOL)animate | 55 - (void)showIPadFindBarView:(BOOL)animate |
| 58 intoView:(UIView*)parentView | 56 intoView:(UIView*)parentView |
| 59 withFrame:(CGRect)targetFrame | 57 withFrame:(CGRect)targetFrame |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 @synthesize view = _view; | 94 @synthesize view = _view; |
| 97 @synthesize findBarView = _findBarView; | 95 @synthesize findBarView = _findBarView; |
| 98 @synthesize delayTimer = _delayTimer; | 96 @synthesize delayTimer = _delayTimer; |
| 99 @synthesize isIncognito = _isIncognito; | 97 @synthesize isIncognito = _isIncognito; |
| 100 | 98 |
| 101 #pragma mark - Lifecycle | 99 #pragma mark - Lifecycle |
| 102 | 100 |
| 103 - (instancetype)initWithIncognito:(BOOL)isIncognito { | 101 - (instancetype)initWithIncognito:(BOOL)isIncognito { |
| 104 self = [super init]; | 102 self = [super init]; |
| 105 if (self) { | 103 if (self) { |
| 106 _propertyReleaser_FindInPageController.Init(self, | |
| 107 [FindBarControllerIOS class]); | |
| 108 _isIncognito = isIncognito; | 104 _isIncognito = isIncognito; |
| 109 } | 105 } |
| 110 return self; | 106 return self; |
| 111 } | 107 } |
| 112 | 108 |
| 109 - (void)dealloc { |
| 110 base::mac::ReleaseProperties(self); |
| 111 [super dealloc]; |
| 112 } |
| 113 |
| 113 #pragma mark View Setup & Teardown | 114 #pragma mark View Setup & Teardown |
| 114 | 115 |
| 115 - (UIView*)newFindBarView { | 116 - (UIView*)newFindBarView { |
| 116 BOOL isIPad = IsIPadIdiom(); | 117 BOOL isIPad = IsIPadIdiom(); |
| 117 UIView* findBarBackground = nil; | 118 UIView* findBarBackground = nil; |
| 118 if (isIPad) { | 119 if (isIPad) { |
| 119 // Future self.view. Contains only |contentView|. Is an image view that is | 120 // Future self.view. Contains only |contentView|. Is an image view that is |
| 120 // typecast elsewhere but always is exposed as a UIView. | 121 // typecast elsewhere but always is exposed as a UIView. |
| 121 findBarBackground = | 122 findBarBackground = |
| 122 [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 345, 62)]; | 123 [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 345, 62)]; |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 object:self]; | 472 object:self]; |
| 472 } | 473 } |
| 473 | 474 |
| 474 - (BOOL)textFieldShouldReturn:(UITextField*)textField { | 475 - (BOOL)textFieldShouldReturn:(UITextField*)textField { |
| 475 DCHECK(textField == self.findBarView.inputField); | 476 DCHECK(textField == self.findBarView.inputField); |
| 476 [self.findBarView.inputField resignFirstResponder]; | 477 [self.findBarView.inputField resignFirstResponder]; |
| 477 return YES; | 478 return YES; |
| 478 } | 479 } |
| 479 | 480 |
| 480 @end | 481 @end |
| OLD | NEW |