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

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

Issue 2669173002: Use IOSImageDataFetcherWrapper (Closed)
Patch Set: Rebase Created 3 years, 10 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_macros.h" 11 #include "base/metrics/histogram_macros.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 "base/threading/sequenced_worker_pool.h" 14 #include "base/threading/sequenced_worker_pool.h"
15 #import "components/image_fetcher/ios/ios_image_data_fetcher_wrapper.h"
15 #include "components/omnibox/browser/autocomplete_match.h" 16 #include "components/omnibox/browser/autocomplete_match.h"
16 #include "components/omnibox/browser/omnibox_edit_model.h" 17 #include "components/omnibox/browser/omnibox_edit_model.h"
17 #include "components/omnibox/browser/omnibox_popup_model.h" 18 #include "components/omnibox/browser/omnibox_popup_model.h"
18 #include "components/open_from_clipboard/clipboard_recent_content.h" 19 #include "components/open_from_clipboard/clipboard_recent_content.h"
19 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" 20 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
20 #import "ios/chrome/browser/experimental_flags.h" 21 #import "ios/chrome/browser/experimental_flags.h"
21 #import "ios/chrome/browser/ui/omnibox/omnibox_popup_material_view_controller.h" 22 #import "ios/chrome/browser/ui/omnibox/omnibox_popup_material_view_controller.h"
22 #import "ios/chrome/browser/ui/omnibox/omnibox_popup_positioner.h" 23 #import "ios/chrome/browser/ui/omnibox/omnibox_popup_positioner.h"
23 #include "ios/chrome/browser/ui/omnibox/omnibox_util.h" 24 #include "ios/chrome/browser/ui/omnibox/omnibox_util.h"
24 #include "ios/chrome/browser/ui/omnibox/omnibox_view_ios.h" 25 #include "ios/chrome/browser/ui/omnibox/omnibox_view_ios.h"
25 #include "ios/chrome/browser/ui/ui_util.h" 26 #include "ios/chrome/browser/ui/ui_util.h"
26 #import "ios/chrome/browser/ui/uikit_ui_util.h" 27 #import "ios/chrome/browser/ui/uikit_ui_util.h"
27 #include "ios/chrome/grit/ios_theme_resources.h" 28 #include "ios/chrome/grit/ios_theme_resources.h"
28 #include "ios/web/public/image_fetcher/image_data_fetcher.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 namespace { 33 namespace {
34 const CGFloat kExpandAnimationDuration = 0.1; 34 const CGFloat kExpandAnimationDuration = 0.1;
35 const CGFloat kCollapseAnimationDuration = 0.05; 35 const CGFloat kCollapseAnimationDuration = 0.05;
36 const CGFloat kWhiteBackgroundHeight = 74; 36 const CGFloat kWhiteBackgroundHeight = 74;
37 NS_INLINE CGFloat ShadowHeight() { 37 NS_INLINE CGFloat ShadowHeight() {
38 return IsIPadIdiom() ? 10 : 0; 38 return IsIPadIdiom() ? 10 : 0;
39 } 39 }
40 } // namespace 40 } // namespace
41 41
42 using base::UserMetricsAction; 42 using base::UserMetricsAction;
43 43
44 OmniboxPopupViewIOS::OmniboxPopupViewIOS(OmniboxViewIOS* edit_view, 44 OmniboxPopupViewIOS::OmniboxPopupViewIOS(OmniboxViewIOS* edit_view,
45 OmniboxEditModel* edit_model, 45 OmniboxEditModel* edit_model,
46 id<OmniboxPopupPositioner> positioner) 46 id<OmniboxPopupPositioner> positioner)
47 : model_(new OmniboxPopupModel(this, edit_model)), 47 : model_(new OmniboxPopupModel(this, edit_model)),
48 edit_view_(edit_view), 48 edit_view_(edit_view),
49 positioner_(positioner), 49 positioner_(positioner),
50 is_open_(false) { 50 is_open_(false) {
51 DCHECK(edit_view); 51 DCHECK(edit_view);
52 DCHECK(edit_model); 52 DCHECK(edit_model);
53 53
54 std::unique_ptr<web::ImageDataFetcher> imageFetcher = 54 std::unique_ptr<image_fetcher::IOSImageDataFetcherWrapper> imageFetcher =
55 base::MakeUnique<web::ImageDataFetcher>( 55 base::MakeUnique<image_fetcher::IOSImageDataFetcherWrapper>(
56 edit_view->browser_state()->GetRequestContext(),
56 web::WebThread::GetBlockingPool()); 57 web::WebThread::GetBlockingPool());
57 imageFetcher->SetRequestContextGetter(
58 edit_view->browser_state()->GetRequestContext());
59 58
60 popup_controller_.reset([[OmniboxPopupMaterialViewController alloc] 59 popup_controller_.reset([[OmniboxPopupMaterialViewController alloc]
61 initWithPopupView:this 60 initWithPopupView:this
62 withFetcher:std::move(imageFetcher)]); 61 withFetcher:std::move(imageFetcher)]);
63 [popup_controller_ setIncognito:edit_view->browser_state()->IsOffTheRecord()]; 62 [popup_controller_ setIncognito:edit_view->browser_state()->IsOffTheRecord()];
64 popupView_.reset([[UIView alloc] initWithFrame:CGRectZero]); 63 popupView_.reset([[UIView alloc] initWithFrame:CGRectZero]);
65 [popupView_ setClipsToBounds:YES]; 64 [popupView_ setClipsToBounds:YES];
66 CALayer* popupLayer = [popupView_ layer]; 65 CALayer* popupLayer = [popupView_ layer];
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.
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 UMA_HISTOGRAM_LONG_TIMES_100( 291 UMA_HISTOGRAM_LONG_TIMES_100(
293 "MobileOmnibox.PressedClipboardSuggestionAge", 292 "MobileOmnibox.PressedClipboardSuggestionAge",
294 ClipboardRecentContent::GetInstance()->GetClipboardContentAge()); 293 ClipboardRecentContent::GetInstance()->GetClipboardContentAge());
295 } 294 }
296 edit_view_->OpenMatch(match, disposition, GURL(), base::string16(), row); 295 edit_view_->OpenMatch(match, disposition, GURL(), base::string16(), row);
297 } 296 }
298 297
299 bool OmniboxPopupViewIOS::IsOpen() const { 298 bool OmniboxPopupViewIOS::IsOpen() const {
300 return is_open_; 299 return is_open_;
301 } 300 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/omnibox/omnibox_popup_material_view_controller.mm ('k') | ios/chrome/browser/ui/settings/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698