| 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 | 176 |
| 177 // Returns a button with title and action configured for |buttonAction|. | 177 // Returns a button with title and action configured for |buttonAction|. |
| 178 - (UIButton*)buttonForAction:(PageInfoModel::ButtonAction)buttonAction; | 178 - (UIButton*)buttonForAction:(PageInfoModel::ButtonAction)buttonAction; |
| 179 | 179 |
| 180 // Adds the the button |buttonAction| that explains the icons. Returns the y | 180 // Adds the the button |buttonAction| that explains the icons. Returns the y |
| 181 // position delta for the next offset. | 181 // position delta for the next offset. |
| 182 - (CGFloat)addButton:(PageInfoModel::ButtonAction)buttonAction | 182 - (CGFloat)addButton:(PageInfoModel::ButtonAction)buttonAction |
| 183 toSubviews:(NSMutableArray*)subviews | 183 toSubviews:(NSMutableArray*)subviews |
| 184 atOffset:(CGFloat)offset; | 184 atOffset:(CGFloat)offset; |
| 185 | 185 |
| 186 // Sends the IDC_HIDE_PAGE_INFO command to hide the current popup. |
| 187 - (void)close; |
| 188 |
| 186 @property(nonatomic, retain) UIView* containerView; | 189 @property(nonatomic, retain) UIView* containerView; |
| 187 @property(nonatomic, retain) UIView* popupContainer; | 190 @property(nonatomic, retain) UIView* popupContainer; |
| 188 @end | 191 @end |
| 189 | 192 |
| 190 @implementation PageInfoViewController | 193 @implementation PageInfoViewController |
| 191 | 194 |
| 192 @synthesize containerView = containerView_; | 195 @synthesize containerView = containerView_; |
| 193 @synthesize popupContainer = popupContainer_; | 196 @synthesize popupContainer = popupContainer_; |
| 194 | 197 |
| 195 - (id)initWithModel:(PageInfoModel*)model | 198 - (id)initWithModel:(PageInfoModel*)model |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 } | 394 } |
| 392 | 395 |
| 393 for (UIView* view in subviews) { | 396 for (UIView* view in subviews) { |
| 394 [innerContainerView_ addSubview:view]; | 397 [innerContainerView_ addSubview:view]; |
| 395 [innerContainerView_ setSubviewNeedsAdjustmentForRTL:view]; | 398 [innerContainerView_ setSubviewNeedsAdjustmentForRTL:view]; |
| 396 } | 399 } |
| 397 | 400 |
| 398 [scrollView_ setContentSize:innerContainerView_.get().frame.size]; | 401 [scrollView_ setContentSize:innerContainerView_.get().frame.size]; |
| 399 } | 402 } |
| 400 | 403 |
| 404 - (void)close { |
| 405 [containerView_ chromeExecuteCommand:containerView_]; |
| 406 } |
| 407 |
| 401 - (void)dismiss { | 408 - (void)dismiss { |
| 402 [self animatePageInfoViewOut]; | 409 [self animatePageInfoViewOut]; |
| 403 UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, | 410 UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, |
| 404 nil); | 411 nil); |
| 405 } | 412 } |
| 406 | 413 |
| 407 #pragma mark - Helper methods to create subviews. | 414 #pragma mark - Helper methods to create subviews. |
| 408 | 415 |
| 409 - (void)addImageViewForInfo:(const PageInfoModel::SectionInfo&)info | 416 - (void)addImageViewForInfo:(const PageInfoModel::SectionInfo&)info |
| 410 toSubviews:(NSMutableArray*)subviews | 417 toSubviews:(NSMutableArray*)subviews |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 case PageInfoModel::BUTTON_SHOW_SECURITY_HELP: | 478 case PageInfoModel::BUTTON_SHOW_SECURITY_HELP: |
| 472 messageId = IDS_LEARN_MORE; | 479 messageId = IDS_LEARN_MORE; |
| 473 tag = IDC_SHOW_SECURITY_HELP; | 480 tag = IDC_SHOW_SECURITY_HELP; |
| 474 accessibilityID = @"Learn more"; | 481 accessibilityID = @"Learn more"; |
| 475 break; | 482 break; |
| 476 case PageInfoModel::BUTTON_RELOAD: | 483 case PageInfoModel::BUTTON_RELOAD: |
| 477 messageId = IDS_IOS_PAGE_INFO_RELOAD; | 484 messageId = IDS_IOS_PAGE_INFO_RELOAD; |
| 478 tag = IDC_RELOAD; | 485 tag = IDC_RELOAD; |
| 479 accessibilityID = @"Reload button"; | 486 accessibilityID = @"Reload button"; |
| 480 [button addTarget:self | 487 [button addTarget:self |
| 481 action:@selector(dismiss) | 488 action:@selector(close) |
| 482 forControlEvents:UIControlEventTouchUpInside]; | 489 forControlEvents:UIControlEventTouchUpInside]; |
| 483 break; | 490 break; |
| 484 }; | 491 }; |
| 485 | 492 |
| 486 NSString* title = l10n_util::GetNSStringWithFixup(messageId); | 493 NSString* title = l10n_util::GetNSStringWithFixup(messageId); |
| 487 SetA11yLabelAndUiAutomationName(button, messageId, accessibilityID); | 494 SetA11yLabelAndUiAutomationName(button, messageId, accessibilityID); |
| 488 [button setTitle:title forState:UIControlStateNormal]; | 495 [button setTitle:title forState:UIControlStateNormal]; |
| 489 [button setTag:tag]; | 496 [button setTag:tag]; |
| 490 [button addTarget:nil | 497 [button addTarget:nil |
| 491 action:@selector(chromeExecuteCommand:) | 498 action:@selector(chromeExecuteCommand:) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 522 [subviews addObject:button]; | 529 [subviews addObject:button]; |
| 523 | 530 |
| 524 return CGRectGetHeight([button frame]); | 531 return CGRectGetHeight([button frame]); |
| 525 } | 532 } |
| 526 | 533 |
| 527 #pragma mark - UIGestureRecognizerDelegate Implemenation | 534 #pragma mark - UIGestureRecognizerDelegate Implemenation |
| 528 | 535 |
| 529 - (void)rootViewTapped:(UIGestureRecognizer*)sender { | 536 - (void)rootViewTapped:(UIGestureRecognizer*)sender { |
| 530 CGPoint pt = [sender locationInView:containerView_]; | 537 CGPoint pt = [sender locationInView:containerView_]; |
| 531 if (!CGRectContainsPoint([popupContainer_ frame], pt)) { | 538 if (!CGRectContainsPoint([popupContainer_ frame], pt)) { |
| 532 [containerView_ chromeExecuteCommand:containerView_]; | 539 [self close]; |
| 533 } | 540 } |
| 534 } | 541 } |
| 535 | 542 |
| 536 - (BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer | 543 - (BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer |
| 537 shouldReceiveTouch:(UITouch*)touch { | 544 shouldReceiveTouch:(UITouch*)touch { |
| 538 CGPoint pt = [touch locationInView:containerView_]; | 545 CGPoint pt = [touch locationInView:containerView_]; |
| 539 return !CGRectContainsPoint([popupContainer_ frame], pt); | 546 return !CGRectContainsPoint([popupContainer_ frame], pt); |
| 540 } | 547 } |
| 541 | 548 |
| 542 - (void)animatePageInfoViewIn:(CGRect)source { | 549 - (void)animatePageInfoViewIn:(CGRect)source { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 [opacityAnimation setFromValue:@1]; | 635 [opacityAnimation setFromValue:@1]; |
| 629 [opacityAnimation setToValue:@0]; | 636 [opacityAnimation setToValue:@0]; |
| 630 [[containerView_ layer] addAnimation:opacityAnimation forKey:@"animateOut"]; | 637 [[containerView_ layer] addAnimation:opacityAnimation forKey:@"animateOut"]; |
| 631 | 638 |
| 632 [popupContainer_ setAlpha:0]; | 639 [popupContainer_ setAlpha:0]; |
| 633 [containerView_ setAlpha:0]; | 640 [containerView_ setAlpha:0]; |
| 634 [CATransaction commit]; | 641 [CATransaction commit]; |
| 635 } | 642 } |
| 636 | 643 |
| 637 @end | 644 @end |
| OLD | NEW |