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 #include "ios/chrome/browser/ui/omnibox/omnibox_popup_view_ios.h" | 5 #include "ios/chrome/browser/ui/omnibox/omnibox_popup_view_ios.h" |
6 | 6 |
7 #import <QuartzCore/QuartzCore.h> | 7 #import <QuartzCore/QuartzCore.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #import "ios/chrome/browser/ui/omnibox/omnibox_popup_positioner.h" | 23 #import "ios/chrome/browser/ui/omnibox/omnibox_popup_positioner.h" |
24 #include "ios/chrome/browser/ui/omnibox/omnibox_util.h" | 24 #include "ios/chrome/browser/ui/omnibox/omnibox_util.h" |
25 #include "ios/chrome/browser/ui/omnibox/omnibox_view_ios.h" | 25 #include "ios/chrome/browser/ui/omnibox/omnibox_view_ios.h" |
26 #include "ios/chrome/browser/ui/ui_util.h" | 26 #include "ios/chrome/browser/ui/ui_util.h" |
27 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 27 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
28 #include "ios/chrome/grit/ios_theme_resources.h" | 28 #include "ios/chrome/grit/ios_theme_resources.h" |
29 #include "ios/web/public/web_thread.h" | 29 #include "ios/web/public/web_thread.h" |
30 #include "net/url_request/url_request_context_getter.h" | 30 #include "net/url_request/url_request_context_getter.h" |
31 #include "ui/gfx/geometry/rect.h" | 31 #include "ui/gfx/geometry/rect.h" |
32 | 32 |
| 33 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 34 #error "This file requires ARC support." |
| 35 #endif |
| 36 |
33 namespace { | 37 namespace { |
34 const CGFloat kExpandAnimationDuration = 0.1; | 38 const CGFloat kExpandAnimationDuration = 0.1; |
35 const CGFloat kCollapseAnimationDuration = 0.05; | 39 const CGFloat kCollapseAnimationDuration = 0.05; |
36 const CGFloat kWhiteBackgroundHeight = 74; | 40 const CGFloat kWhiteBackgroundHeight = 74; |
37 NS_INLINE CGFloat ShadowHeight() { | 41 NS_INLINE CGFloat ShadowHeight() { |
38 return IsIPadIdiom() ? 10 : 0; | 42 return IsIPadIdiom() ? 10 : 0; |
39 } | 43 } |
40 } // namespace | 44 } // namespace |
41 | 45 |
42 using base::UserMetricsAction; | 46 using base::UserMetricsAction; |
(...skipping 23 matching lines...) Expand all Loading... |
66 // Adjust popupView_'s anchor point and height so that it animates down | 70 // Adjust popupView_'s anchor point and height so that it animates down |
67 // from the top when it appears. | 71 // from the top when it appears. |
68 popupLayer.anchorPoint = CGPointMake(0.5, 0); | 72 popupLayer.anchorPoint = CGPointMake(0.5, 0); |
69 UIView* popupControllerView = [popup_controller_ view]; | 73 UIView* popupControllerView = [popup_controller_ view]; |
70 CGRect popupControllerFrame = popupControllerView.frame; | 74 CGRect popupControllerFrame = popupControllerView.frame; |
71 popupControllerFrame.origin = CGPointZero; | 75 popupControllerFrame.origin = CGPointZero; |
72 popupControllerView.frame = popupControllerFrame; | 76 popupControllerView.frame = popupControllerFrame; |
73 [popupView_ addSubview:popupControllerView]; | 77 [popupView_ addSubview:popupControllerView]; |
74 if (IsIPadIdiom()) { | 78 if (IsIPadIdiom()) { |
75 [popupView_ setAutoresizingMask:UIViewAutoresizingFlexibleWidth]; | 79 [popupView_ setAutoresizingMask:UIViewAutoresizingFlexibleWidth]; |
76 base::scoped_nsobject<UIImageView> shadowView([[UIImageView alloc] | 80 UIImageView* shadowView = [[UIImageView alloc] |
77 initWithImage:NativeImage(IDR_IOS_TOOLBAR_SHADOW_FULL_BLEED)]); | 81 initWithImage:NativeImage(IDR_IOS_TOOLBAR_SHADOW_FULL_BLEED)]; |
78 [shadowView setUserInteractionEnabled:NO]; | 82 [shadowView setUserInteractionEnabled:NO]; |
79 [shadowView setTranslatesAutoresizingMaskIntoConstraints:NO]; | 83 [shadowView setTranslatesAutoresizingMaskIntoConstraints:NO]; |
80 [popupView_ addSubview:shadowView]; | 84 [popupView_ addSubview:shadowView]; |
81 | 85 |
82 // Add constraints to position |shadowView| at the bottom of |popupView_| | 86 // Add constraints to position |shadowView| at the bottom of |popupView_| |
83 // with the same width as |popupView_|. | 87 // with the same width as |popupView_|. |
84 NSDictionary* views = NSDictionaryOfVariableBindings(shadowView); | 88 NSDictionary* views = NSDictionaryOfVariableBindings(shadowView); |
85 [popupView_ | 89 [popupView_ |
86 addConstraints:[NSLayoutConstraint | 90 addConstraints:[NSLayoutConstraint |
87 constraintsWithVisualFormat:@"H:|[shadowView]|" | 91 constraintsWithVisualFormat:@"H:|[shadowView]|" |
88 options:0 | 92 options:0 |
89 metrics:nil | 93 metrics:nil |
90 views:views]]; | 94 views:views]]; |
91 [popupView_ addConstraint:[NSLayoutConstraint | 95 [popupView_ addConstraint:[NSLayoutConstraint |
92 constraintWithItem:shadowView | 96 constraintWithItem:shadowView |
93 attribute:NSLayoutAttributeBottom | 97 attribute:NSLayoutAttributeBottom |
94 relatedBy:NSLayoutRelationEqual | 98 relatedBy:NSLayoutRelationEqual |
95 toItem:popupView_ | 99 toItem:popupView_ |
96 attribute:NSLayoutAttributeBottom | 100 attribute:NSLayoutAttributeBottom |
97 multiplier:1 | 101 multiplier:1 |
98 constant:0]]; | 102 constant:0]]; |
99 } else { | 103 } else { |
100 // Add a white background to prevent seing the logo scroll through the | 104 // Add a white background to prevent seing the logo scroll through the |
101 // omnibox. | 105 // omnibox. |
102 base::scoped_nsobject<UIView> whiteBackground( | 106 UIView* whiteBackground = [[UIView alloc] initWithFrame:CGRectZero]; |
103 [[UIView alloc] initWithFrame:CGRectZero]); | |
104 [popupView_ addSubview:whiteBackground]; | 107 [popupView_ addSubview:whiteBackground]; |
105 [whiteBackground setBackgroundColor:[UIColor whiteColor]]; | 108 [whiteBackground setBackgroundColor:[UIColor whiteColor]]; |
106 | 109 |
107 // Set constraints to |whiteBackground|. | 110 // Set constraints to |whiteBackground|. |
108 [whiteBackground setTranslatesAutoresizingMaskIntoConstraints:NO]; | 111 [whiteBackground setTranslatesAutoresizingMaskIntoConstraints:NO]; |
109 NSDictionary* metrics = @{ @"height" : @(kWhiteBackgroundHeight) }; | 112 NSDictionary* metrics = @{ @"height" : @(kWhiteBackgroundHeight) }; |
110 NSDictionary* views = NSDictionaryOfVariableBindings(whiteBackground); | 113 NSDictionary* views = NSDictionaryOfVariableBindings(whiteBackground); |
111 [popupView_ | 114 [popupView_ |
112 addConstraints:[NSLayoutConstraint | 115 addConstraints:[NSLayoutConstraint |
113 constraintsWithVisualFormat:@"H:|[whiteBackground]|" | 116 constraintsWithVisualFormat:@"H:|[whiteBackground]|" |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 UMA_HISTOGRAM_LONG_TIMES_100( | 294 UMA_HISTOGRAM_LONG_TIMES_100( |
292 "MobileOmnibox.PressedClipboardSuggestionAge", | 295 "MobileOmnibox.PressedClipboardSuggestionAge", |
293 ClipboardRecentContent::GetInstance()->GetClipboardContentAge()); | 296 ClipboardRecentContent::GetInstance()->GetClipboardContentAge()); |
294 } | 297 } |
295 edit_view_->OpenMatch(match, disposition, GURL(), base::string16(), row); | 298 edit_view_->OpenMatch(match, disposition, GURL(), base::string16(), row); |
296 } | 299 } |
297 | 300 |
298 bool OmniboxPopupViewIOS::IsOpen() const { | 301 bool OmniboxPopupViewIOS::IsOpen() const { |
299 return is_open_; | 302 return is_open_; |
300 } | 303 } |
OLD | NEW |