Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Side by Side Diff: ios/chrome/browser/ui/omnibox/omnibox_popup_view_ios.mm

Issue 2602903002: Factor iOS native image loading into a utility function. (Closed)
Patch Set: Fixed BUILD files. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/metrics/user_metrics.h" 12 #include "base/metrics/user_metrics.h"
13 #include "base/metrics/user_metrics_action.h" 13 #include "base/metrics/user_metrics_action.h"
14 #include "components/omnibox/browser/autocomplete_match.h" 14 #include "components/omnibox/browser/autocomplete_match.h"
15 #include "components/omnibox/browser/omnibox_edit_model.h" 15 #include "components/omnibox/browser/omnibox_edit_model.h"
16 #include "components/omnibox/browser/omnibox_popup_model.h" 16 #include "components/omnibox/browser/omnibox_popup_model.h"
17 #include "components/open_from_clipboard/clipboard_recent_content.h" 17 #include "components/open_from_clipboard/clipboard_recent_content.h"
18 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" 18 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
19 #import "ios/chrome/browser/experimental_flags.h" 19 #import "ios/chrome/browser/experimental_flags.h"
20 #import "ios/chrome/browser/ui/omnibox/omnibox_popup_material_view_controller.h" 20 #import "ios/chrome/browser/ui/omnibox/omnibox_popup_material_view_controller.h"
21 #import "ios/chrome/browser/ui/omnibox/omnibox_popup_positioner.h" 21 #import "ios/chrome/browser/ui/omnibox/omnibox_popup_positioner.h"
22 #include "ios/chrome/browser/ui/omnibox/omnibox_util.h" 22 #include "ios/chrome/browser/ui/omnibox/omnibox_util.h"
23 #include "ios/chrome/browser/ui/omnibox/omnibox_view_ios.h" 23 #include "ios/chrome/browser/ui/omnibox/omnibox_view_ios.h"
24 #include "ios/chrome/browser/ui/ui_util.h" 24 #include "ios/chrome/browser/ui/ui_util.h"
25 #import "ios/chrome/browser/ui/uikit_ui_util.h"
25 #include "ios/chrome/grit/ios_theme_resources.h" 26 #include "ios/chrome/grit/ios_theme_resources.h"
26 #include "ios/web/public/image_fetcher/image_data_fetcher.h" 27 #include "ios/web/public/image_fetcher/image_data_fetcher.h"
27 #include "ios/web/public/web_thread.h" 28 #include "ios/web/public/web_thread.h"
28 #include "net/url_request/url_request_context_getter.h" 29 #include "net/url_request/url_request_context_getter.h"
29 #include "ui/base/resource/resource_bundle.h"
30 #include "ui/gfx/geometry/rect.h" 30 #include "ui/gfx/geometry/rect.h"
31 #include "ui/gfx/image/image.h"
32 31
33 namespace { 32 namespace {
34 const CGFloat kExpandAnimationDuration = 0.1; 33 const CGFloat kExpandAnimationDuration = 0.1;
35 const CGFloat kCollapseAnimationDuration = 0.05; 34 const CGFloat kCollapseAnimationDuration = 0.05;
36 const CGFloat kWhiteBackgroundHeight = 74; 35 const CGFloat kWhiteBackgroundHeight = 74;
37 NS_INLINE CGFloat ShadowHeight() { 36 NS_INLINE CGFloat ShadowHeight() {
38 return IsIPadIdiom() ? 10 : 0; 37 return IsIPadIdiom() ? 10 : 0;
39 } 38 }
40 } // namespace 39 } // namespace
41 40
(...skipping 25 matching lines...) Expand all
67 // Adjust popupView_'s anchor point and height so that it animates down 66 // Adjust popupView_'s anchor point and height so that it animates down
68 // from the top when it appears. 67 // from the top when it appears.
69 popupLayer.anchorPoint = CGPointMake(0.5, 0); 68 popupLayer.anchorPoint = CGPointMake(0.5, 0);
70 UIView* popupControllerView = [popup_controller_ view]; 69 UIView* popupControllerView = [popup_controller_ view];
71 CGRect popupControllerFrame = popupControllerView.frame; 70 CGRect popupControllerFrame = popupControllerView.frame;
72 popupControllerFrame.origin = CGPointZero; 71 popupControllerFrame.origin = CGPointZero;
73 popupControllerView.frame = popupControllerFrame; 72 popupControllerView.frame = popupControllerFrame;
74 [popupView_ addSubview:popupControllerView]; 73 [popupView_ addSubview:popupControllerView];
75 if (IsIPadIdiom()) { 74 if (IsIPadIdiom()) {
76 [popupView_ setAutoresizingMask:UIViewAutoresizingFlexibleWidth]; 75 [popupView_ setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
77 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 76 base::scoped_nsobject<UIImageView> shadowView([[UIImageView alloc]
78 gfx::Image shadowImage = 77 initWithImage:NativeImage(IDR_IOS_TOOLBAR_SHADOW_FULL_BLEED)]);
79 rb.GetNativeImageNamed(IDR_IOS_TOOLBAR_SHADOW_FULL_BLEED);
80 base::scoped_nsobject<UIImageView> shadowView(
81 [[UIImageView alloc] initWithImage:shadowImage.ToUIImage()]);
82 [shadowView setUserInteractionEnabled:NO]; 78 [shadowView setUserInteractionEnabled:NO];
83 [shadowView setTranslatesAutoresizingMaskIntoConstraints:NO]; 79 [shadowView setTranslatesAutoresizingMaskIntoConstraints:NO];
84 [popupView_ addSubview:shadowView]; 80 [popupView_ addSubview:shadowView];
85 81
86 // Add constraints to position |shadowView| at the bottom of |popupView_| 82 // Add constraints to position |shadowView| at the bottom of |popupView_|
87 // with the same width as |popupView_|. 83 // with the same width as |popupView_|.
88 NSDictionary* views = NSDictionaryOfVariableBindings(shadowView); 84 NSDictionary* views = NSDictionaryOfVariableBindings(shadowView);
89 [popupView_ 85 [popupView_
90 addConstraints:[NSLayoutConstraint 86 addConstraints:[NSLayoutConstraint
91 constraintsWithVisualFormat:@"H:|[shadowView]|" 87 constraintsWithVisualFormat:@"H:|[shadowView]|"
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 UMA_HISTOGRAM_LONG_TIMES_100( 291 UMA_HISTOGRAM_LONG_TIMES_100(
296 "MobileOmnibox.PressedClipboardSuggestionAge", 292 "MobileOmnibox.PressedClipboardSuggestionAge",
297 ClipboardRecentContent::GetInstance()->GetClipboardContentAge()); 293 ClipboardRecentContent::GetInstance()->GetClipboardContentAge());
298 } 294 }
299 edit_view_->OpenMatch(match, disposition, GURL(), base::string16(), row); 295 edit_view_->OpenMatch(match, disposition, GURL(), base::string16(), row);
300 } 296 }
301 297
302 bool OmniboxPopupViewIOS::IsOpen() const { 298 bool OmniboxPopupViewIOS::IsOpen() const {
303 return is_open_; 299 return is_open_;
304 } 300 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698