| 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" |
| 11 #include "base/mac/objc_property_releaser.h" | 11 #include "base/mac/objc_release_properties.h" |
| 12 #include "base/mac/scoped_nsobject.h" | 12 #include "base/mac/scoped_nsobject.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
| 15 #include "base/strings/sys_string_conversions.h" | 15 #include "base/strings/sys_string_conversions.h" |
| 16 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
| 17 #include "components/strings/grit/components_strings.h" | 17 #include "components/strings/grit/components_strings.h" |
| 18 #import "ios/chrome/browser/ui/animation_util.h" | 18 #import "ios/chrome/browser/ui/animation_util.h" |
| 19 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" | 19 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" |
| 20 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" | 20 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" |
| 21 #import "ios/chrome/browser/ui/fancy_ui/bidi_container_view.h" | 21 #import "ios/chrome/browser/ui/fancy_ui/bidi_container_view.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 std::unique_ptr<PageInfoModelObserver> bridge_; | 144 std::unique_ptr<PageInfoModelObserver> bridge_; |
| 145 | 145 |
| 146 // Width of the view. Depends on the device (iPad/iPhone). | 146 // Width of the view. Depends on the device (iPad/iPhone). |
| 147 CGFloat viewWidth_; | 147 CGFloat viewWidth_; |
| 148 | 148 |
| 149 // Width of the text fields. | 149 // Width of the text fields. |
| 150 CGFloat textWidth_; | 150 CGFloat textWidth_; |
| 151 | 151 |
| 152 // YES when the popup has finished animating in. NO otherwise. | 152 // YES when the popup has finished animating in. NO otherwise. |
| 153 BOOL animateInCompleted_; | 153 BOOL animateInCompleted_; |
| 154 | |
| 155 base::mac::ObjCPropertyReleaser propertyReleaser_PageInfoViewController_; | |
| 156 } | 154 } |
| 157 | 155 |
| 158 // Adds the state image at a pre-determined x position and the given y. This | 156 // Adds the state image at a pre-determined x position and the given y. This |
| 159 // does not affect the next Y position because the image is placed next to | 157 // does not affect the next Y position because the image is placed next to |
| 160 // a text field that is larger and accounts for the image's size. | 158 // a text field that is larger and accounts for the image's size. |
| 161 - (void)addImageViewForInfo:(const PageInfoModel::SectionInfo&)info | 159 - (void)addImageViewForInfo:(const PageInfoModel::SectionInfo&)info |
| 162 toSubviews:(NSMutableArray*)subviews | 160 toSubviews:(NSMutableArray*)subviews |
| 163 atOffset:(CGFloat)offset; | 161 atOffset:(CGFloat)offset; |
| 164 | 162 |
| 165 // Adds the title text field at the given x,y position, and returns the y | 163 // Adds the title text field at the given x,y position, and returns the y |
| (...skipping 26 matching lines...) Expand all Loading... |
| 192 @synthesize containerView = containerView_; | 190 @synthesize containerView = containerView_; |
| 193 @synthesize popupContainer = popupContainer_; | 191 @synthesize popupContainer = popupContainer_; |
| 194 | 192 |
| 195 - (id)initWithModel:(PageInfoModel*)model | 193 - (id)initWithModel:(PageInfoModel*)model |
| 196 bridge:(PageInfoModelObserver*)bridge | 194 bridge:(PageInfoModelObserver*)bridge |
| 197 sourceFrame:(CGRect)source | 195 sourceFrame:(CGRect)source |
| 198 parentView:(UIView*)parent { | 196 parentView:(UIView*)parent { |
| 199 DCHECK(parent); | 197 DCHECK(parent); |
| 200 self = [super init]; | 198 self = [super init]; |
| 201 if (self) { | 199 if (self) { |
| 202 propertyReleaser_PageInfoViewController_.Init( | |
| 203 self, [PageInfoViewController class]); | |
| 204 | |
| 205 scrollView_.reset( | 200 scrollView_.reset( |
| 206 [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 240, 128)]); | 201 [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 240, 128)]); |
| 207 [scrollView_ setMultipleTouchEnabled:YES]; | 202 [scrollView_ setMultipleTouchEnabled:YES]; |
| 208 [scrollView_ setClipsToBounds:YES]; | 203 [scrollView_ setClipsToBounds:YES]; |
| 209 [scrollView_ setShowsHorizontalScrollIndicator:NO]; | 204 [scrollView_ setShowsHorizontalScrollIndicator:NO]; |
| 210 [scrollView_ setIndicatorStyle:UIScrollViewIndicatorStyleBlack]; | 205 [scrollView_ setIndicatorStyle:UIScrollViewIndicatorStyleBlack]; |
| 211 [scrollView_ | 206 [scrollView_ |
| 212 setAutoresizingMask:(UIViewAutoresizingFlexibleTrailingMargin() | | 207 setAutoresizingMask:(UIViewAutoresizingFlexibleTrailingMargin() | |
| 213 UIViewAutoresizingFlexibleTopMargin)]; | 208 UIViewAutoresizingFlexibleTopMargin)]; |
| 214 | 209 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 [self performLayout]; | 260 [self performLayout]; |
| 266 | 261 |
| 267 [self animatePageInfoViewIn:source]; | 262 [self animatePageInfoViewIn:source]; |
| 268 UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, | 263 UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, |
| 269 containerView_); | 264 containerView_); |
| 270 } | 265 } |
| 271 | 266 |
| 272 return self; | 267 return self; |
| 273 } | 268 } |
| 274 | 269 |
| 270 - (void)dealloc { |
| 271 base::mac::ReleaseProperties(self); |
| 272 [super dealloc]; |
| 273 } |
| 274 |
| 275 - (void)performLayout { | 275 - (void)performLayout { |
| 276 CGFloat offset = kInitialLinePadding; | 276 CGFloat offset = kInitialLinePadding; |
| 277 | 277 |
| 278 // Keep the new subviews in an array that gets replaced at the end. | 278 // Keep the new subviews in an array that gets replaced at the end. |
| 279 NSMutableArray* subviews = [NSMutableArray array]; | 279 NSMutableArray* subviews = [NSMutableArray array]; |
| 280 | 280 |
| 281 int sectionCount = model_->GetSectionCount(); | 281 int sectionCount = model_->GetSectionCount(); |
| 282 PageInfoModel::ButtonAction action = PageInfoModel::BUTTON_NONE; | 282 PageInfoModel::ButtonAction action = PageInfoModel::BUTTON_NONE; |
| 283 | 283 |
| 284 for (int i = 0; i < sectionCount; i++) { | 284 for (int i = 0; i < sectionCount; i++) { |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 [opacityAnimation setFromValue:@1]; | 628 [opacityAnimation setFromValue:@1]; |
| 629 [opacityAnimation setToValue:@0]; | 629 [opacityAnimation setToValue:@0]; |
| 630 [[containerView_ layer] addAnimation:opacityAnimation forKey:@"animateOut"]; | 630 [[containerView_ layer] addAnimation:opacityAnimation forKey:@"animateOut"]; |
| 631 | 631 |
| 632 [popupContainer_ setAlpha:0]; | 632 [popupContainer_ setAlpha:0]; |
| 633 [containerView_ setAlpha:0]; | 633 [containerView_ setAlpha:0]; |
| 634 [CATransaction commit]; | 634 [CATransaction commit]; |
| 635 } | 635 } |
| 636 | 636 |
| 637 @end | 637 @end |
| OLD | NEW |