OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/omnibox/page_info_view_controller.h" | 5 #import "ios/chrome/browser/ui/omnibox/page_info_view_controller.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/mac/bundle_locations.h" | 9 #include "base/mac/bundle_locations.h" |
10 #import "base/mac/foundation_util.h" | 10 #import "base/mac/foundation_util.h" |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 - (void)close; | 194 - (void)close; |
195 | 195 |
196 @property(nonatomic, strong) UIView* containerView; | 196 @property(nonatomic, strong) UIView* containerView; |
197 @property(nonatomic, strong) UIView* popupContainer; | 197 @property(nonatomic, strong) UIView* popupContainer; |
198 @end | 198 @end |
199 | 199 |
200 @implementation PageInfoViewController | 200 @implementation PageInfoViewController |
201 | 201 |
202 @synthesize containerView = containerView_; | 202 @synthesize containerView = containerView_; |
203 @synthesize popupContainer = popupContainer_; | 203 @synthesize popupContainer = popupContainer_; |
| 204 @synthesize dispatcher = dispatcher_; |
204 | 205 |
205 - (id)initWithModel:(PageInfoModel*)model | 206 - (id)initWithModel:(PageInfoModel*)model |
206 bridge:(PageInfoModelObserver*)bridge | 207 bridge:(PageInfoModelObserver*)bridge |
207 sourceFrame:(CGRect)source | 208 sourceFrame:(CGRect)source |
208 parentView:(UIView*)parent { | 209 parentView:(UIView*)parent { |
209 DCHECK(parent); | 210 DCHECK(parent); |
210 self = [super init]; | 211 self = [super init]; |
211 if (self) { | 212 if (self) { |
212 scrollView_ = | 213 scrollView_ = |
213 [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 240, 128)]; | 214 [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 240, 128)]; |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 | 400 |
400 for (UIView* view in subviews) { | 401 for (UIView* view in subviews) { |
401 [innerContainerView_ addSubview:view]; | 402 [innerContainerView_ addSubview:view]; |
402 [innerContainerView_ setSubviewNeedsAdjustmentForRTL:view]; | 403 [innerContainerView_ setSubviewNeedsAdjustmentForRTL:view]; |
403 } | 404 } |
404 | 405 |
405 [scrollView_ setContentSize:innerContainerView_.frame.size]; | 406 [scrollView_ setContentSize:innerContainerView_.frame.size]; |
406 } | 407 } |
407 | 408 |
408 - (void)close { | 409 - (void)close { |
| 410 // Refactoring note: _containerView.tag is IDC_HIDE_PAGE_INFO. |
409 [containerView_ chromeExecuteCommand:containerView_]; | 411 [containerView_ chromeExecuteCommand:containerView_]; |
410 } | 412 } |
411 | 413 |
412 - (void)dismiss { | 414 - (void)dismiss { |
413 [self animatePageInfoViewOut]; | 415 [self animatePageInfoViewOut]; |
414 UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, | 416 UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, |
415 nil); | 417 nil); |
416 } | 418 } |
417 | 419 |
418 #pragma mark - Helper methods to create subviews. | 420 #pragma mark - Helper methods to create subviews. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 [label setFrame:frame]; | 466 [label setFrame:frame]; |
465 [subviews addObject:label]; | 467 [subviews addObject:label]; |
466 return CGRectGetHeight(frame); | 468 return CGRectGetHeight(frame); |
467 } | 469 } |
468 | 470 |
469 - (UIButton*)buttonForAction:(PageInfoModel::ButtonAction)buttonAction { | 471 - (UIButton*)buttonForAction:(PageInfoModel::ButtonAction)buttonAction { |
470 if (buttonAction == PageInfoModel::BUTTON_NONE) { | 472 if (buttonAction == PageInfoModel::BUTTON_NONE) { |
471 return nil; | 473 return nil; |
472 } | 474 } |
473 UIButton* button = [[UIButton alloc] initWithFrame:CGRectZero]; | 475 UIButton* button = [[UIButton alloc] initWithFrame:CGRectZero]; |
474 int messageId = IDS_IOS_PAGE_INFO_RELOAD; | 476 int messageId; |
475 NSInteger tag = IDC_RELOAD; | |
476 NSString* accessibilityID = @"Reload button"; | 477 NSString* accessibilityID = @"Reload button"; |
477 switch (buttonAction) { | 478 switch (buttonAction) { |
478 case PageInfoModel::BUTTON_NONE: | 479 case PageInfoModel::BUTTON_NONE: |
479 NOTREACHED(); | 480 NOTREACHED(); |
480 return nil; | 481 return nil; |
481 case PageInfoModel::BUTTON_SHOW_SECURITY_HELP: | 482 case PageInfoModel::BUTTON_SHOW_SECURITY_HELP: |
482 messageId = IDS_LEARN_MORE; | 483 messageId = IDS_LEARN_MORE; |
483 tag = IDC_SHOW_SECURITY_HELP; | 484 button.tag = IDC_SHOW_SECURITY_HELP; |
484 accessibilityID = @"Learn more"; | 485 accessibilityID = @"Learn more"; |
| 486 [button addTarget:nil |
| 487 action:@selector(chromeExecuteCommand:) |
| 488 forControlEvents:UIControlEventTouchUpInside]; |
485 break; | 489 break; |
486 case PageInfoModel::BUTTON_RELOAD: | 490 case PageInfoModel::BUTTON_RELOAD: |
487 messageId = IDS_IOS_PAGE_INFO_RELOAD; | 491 messageId = IDS_IOS_PAGE_INFO_RELOAD; |
488 tag = IDC_RELOAD; | |
489 accessibilityID = @"Reload button"; | 492 accessibilityID = @"Reload button"; |
490 [button addTarget:self | 493 [button addTarget:self |
491 action:@selector(close) | 494 action:@selector(close) |
492 forControlEvents:UIControlEventTouchUpInside]; | 495 forControlEvents:UIControlEventTouchUpInside]; |
| 496 [button addTarget:self.dispatcher |
| 497 action:@selector(reload) |
| 498 forControlEvents:UIControlEventTouchUpInside]; |
493 break; | 499 break; |
494 }; | 500 }; |
495 | 501 |
496 NSString* title = l10n_util::GetNSStringWithFixup(messageId); | 502 NSString* title = l10n_util::GetNSStringWithFixup(messageId); |
497 SetA11yLabelAndUiAutomationName(button, messageId, accessibilityID); | 503 SetA11yLabelAndUiAutomationName(button, messageId, accessibilityID); |
498 [button setTitle:title forState:UIControlStateNormal]; | 504 [button setTitle:title forState:UIControlStateNormal]; |
499 [button setTag:tag]; | |
500 [button addTarget:nil | |
501 action:@selector(chromeExecuteCommand:) | |
502 forControlEvents:UIControlEventTouchUpInside]; | |
503 return button; | 505 return button; |
504 } | 506 } |
505 | 507 |
506 - (CGFloat)addButton:(PageInfoModel::ButtonAction)buttonAction | 508 - (CGFloat)addButton:(PageInfoModel::ButtonAction)buttonAction |
507 toSubviews:(NSMutableArray*)subviews | 509 toSubviews:(NSMutableArray*)subviews |
508 atOffset:(CGFloat)offset { | 510 atOffset:(CGFloat)offset { |
509 UIButton* button = [self buttonForAction:buttonAction]; | 511 UIButton* button = [self buttonForAction:buttonAction]; |
510 if (!button) { | 512 if (!button) { |
511 return 0; | 513 return 0; |
512 } | 514 } |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 [opacityAnimation setFromValue:@1]; | 643 [opacityAnimation setFromValue:@1]; |
642 [opacityAnimation setToValue:@0]; | 644 [opacityAnimation setToValue:@0]; |
643 [[containerView_ layer] addAnimation:opacityAnimation forKey:@"animateOut"]; | 645 [[containerView_ layer] addAnimation:opacityAnimation forKey:@"animateOut"]; |
644 | 646 |
645 [popupContainer_ setAlpha:0]; | 647 [popupContainer_ setAlpha:0]; |
646 [containerView_ setAlpha:0]; | 648 [containerView_ setAlpha:0]; |
647 [CATransaction commit]; | 649 [CATransaction commit]; |
648 } | 650 } |
649 | 651 |
650 @end | 652 @end |
OLD | NEW |