| OLD | NEW |
| 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/web_view/shell/shell_view_controller.h" | 5 #import "ios/web_view/shell/shell_view_controller.h" |
| 6 | 6 |
| 7 #import "ios/web_view/public/criwv.h" | 7 #import "ios/web_view/public/criwv.h" |
| 8 #import "ios/web_view/public/criwv_web_view.h" | 8 #import "ios/web_view/public/criwv_web_view.h" |
| 9 #import "ios/web_view/shell/translate_controller.h" | 9 #import "ios/web_view/shell/translate_controller.h" |
| 10 | 10 |
| 11 #if !defined(__has_feature) || !__has_feature(objc_arc) | 11 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 12 #error "This file requires ARC support." | 12 #error "This file requires ARC support." |
| 13 #endif | 13 #endif |
| 14 | 14 |
| 15 namespace { | |
| 16 const CGFloat kButtonSize = 44; | |
| 17 } | |
| 18 | |
| 19 @interface ShellViewController () | 15 @interface ShellViewController () |
| 20 // Container for |webView|. | 16 // Container for |webView|. |
| 21 @property (nonatomic, strong) UIView* containerView; | 17 @property(nonatomic, strong) UIView* containerView; |
| 22 // Text field used for navigating to URLs. | 18 // Text field used for navigating to URLs. |
| 23 @property (nonatomic, strong) UITextField* field; | 19 @property(nonatomic, strong) UITextField* field; |
| 24 // Toolbar containing navigation buttons and |field|. | 20 // Toolbar containing navigation buttons and |field|. |
| 25 @property (nonatomic, strong) UIToolbar* toolbar; | 21 @property(nonatomic, strong) UIToolbar* toolbar; |
| 26 // CRIWV view which renders the web page. | 22 // CRIWV view which renders the web page. |
| 27 @property (nonatomic, strong) id<CRIWVWebView> webView; | 23 @property(nonatomic, strong) id<CRIWVWebView> webView; |
| 28 // Handles the translation of the content displayed in |webView|. | 24 // Handles the translation of the content displayed in |webView|. |
| 29 @property (nonatomic, strong) TranslateController* translateController; | 25 @property(nonatomic, strong) TranslateController* translateController; |
| 30 | 26 |
| 31 - (void)back; | 27 - (void)back; |
| 32 - (void)forward; | 28 - (void)forward; |
| 33 - (void)stopLoading; | 29 - (void)stopLoading; |
| 34 @end | 30 @end |
| 35 | 31 |
| 36 @implementation ShellViewController | 32 @implementation ShellViewController |
| 37 | 33 |
| 38 @synthesize containerView = _containerView; | 34 @synthesize containerView = _containerView; |
| 39 @synthesize field = _field; | 35 @synthesize field = _field; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 59 | 55 |
| 60 // Set up the container view. | 56 // Set up the container view. |
| 61 self.containerView = [[UIView alloc] init]; | 57 self.containerView = [[UIView alloc] init]; |
| 62 [_containerView setFrame:CGRectMake(0, 64, CGRectGetWidth(bounds), | 58 [_containerView setFrame:CGRectMake(0, 64, CGRectGetWidth(bounds), |
| 63 CGRectGetHeight(bounds) - 64)]; | 59 CGRectGetHeight(bounds) - 64)]; |
| 64 [_containerView setBackgroundColor:[UIColor lightGrayColor]]; | 60 [_containerView setBackgroundColor:[UIColor lightGrayColor]]; |
| 65 [_containerView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | | 61 [_containerView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | |
| 66 UIViewAutoresizingFlexibleHeight]; | 62 UIViewAutoresizingFlexibleHeight]; |
| 67 [self.view addSubview:_containerView]; | 63 [self.view addSubview:_containerView]; |
| 68 | 64 |
| 65 const int kButtonCount = 3; |
| 66 const CGFloat kButtonSize = 44; |
| 67 |
| 69 // Text field. | 68 // Text field. |
| 70 const int kButtonCount = 3; | |
| 71 self.field = [[UITextField alloc] | 69 self.field = [[UITextField alloc] |
| 72 initWithFrame:CGRectMake(kButtonCount * kButtonSize, 6, | 70 initWithFrame:CGRectMake(kButtonCount * kButtonSize, 6, |
| 73 CGRectGetWidth([_toolbar frame]) - | 71 CGRectGetWidth([_toolbar frame]) - |
| 74 kButtonCount * kButtonSize - 10, | 72 kButtonCount * kButtonSize - 10, |
| 75 31)]; | 73 31)]; |
| 76 [_field setDelegate:self]; | 74 [_field setDelegate:self]; |
| 77 [_field setBackground:[[UIImage imageNamed:@"textfield_background"] | 75 [_field setBackground:[[UIImage imageNamed:@"textfield_background"] |
| 78 resizableImageWithCapInsets:UIEdgeInsetsMake( | 76 resizableImageWithCapInsets:UIEdgeInsetsMake( |
| 79 12, 12, 12, 12)]]; | 77 12, 12, 12, 12)]]; |
| 80 [_field setAutoresizingMask:UIViewAutoresizingFlexibleWidth]; | 78 [_field setAutoresizingMask:UIViewAutoresizingFlexibleWidth]; |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 } | 195 } |
| 198 } | 196 } |
| 199 | 197 |
| 200 - (id<CRIWVTranslateDelegate>)translateDelegate { | 198 - (id<CRIWVTranslateDelegate>)translateDelegate { |
| 201 if (!_translateController) | 199 if (!_translateController) |
| 202 self.translateController = [[TranslateController alloc] init]; | 200 self.translateController = [[TranslateController alloc] init]; |
| 203 return _translateController; | 201 return _translateController; |
| 204 } | 202 } |
| 205 | 203 |
| 206 @end | 204 @end |
| OLD | NEW |