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

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

Issue 2669173002: Use IOSImageDataFetcherWrapper (Closed)
Patch Set: Update comments 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 #import "components/image_fetcher/ios/ios_image_data_fetcher_wrapper.h"
14 #include "components/omnibox/browser/autocomplete_match.h" 15 #include "components/omnibox/browser/autocomplete_match.h"
15 #include "components/omnibox/browser/omnibox_edit_model.h" 16 #include "components/omnibox/browser/omnibox_edit_model.h"
16 #include "components/omnibox/browser/omnibox_popup_model.h" 17 #include "components/omnibox/browser/omnibox_popup_model.h"
17 #include "components/open_from_clipboard/clipboard_recent_content.h" 18 #include "components/open_from_clipboard/clipboard_recent_content.h"
18 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" 19 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
19 #import "ios/chrome/browser/experimental_flags.h" 20 #import "ios/chrome/browser/experimental_flags.h"
20 #import "ios/chrome/browser/ui/omnibox/omnibox_popup_material_view_controller.h" 21 #import "ios/chrome/browser/ui/omnibox/omnibox_popup_material_view_controller.h"
21 #import "ios/chrome/browser/ui/omnibox/omnibox_popup_positioner.h" 22 #import "ios/chrome/browser/ui/omnibox/omnibox_popup_positioner.h"
22 #include "ios/chrome/browser/ui/omnibox/omnibox_util.h" 23 #include "ios/chrome/browser/ui/omnibox/omnibox_util.h"
23 #include "ios/chrome/browser/ui/omnibox/omnibox_view_ios.h" 24 #include "ios/chrome/browser/ui/omnibox/omnibox_view_ios.h"
24 #include "ios/chrome/browser/ui/ui_util.h" 25 #include "ios/chrome/browser/ui/ui_util.h"
25 #import "ios/chrome/browser/ui/uikit_ui_util.h" 26 #import "ios/chrome/browser/ui/uikit_ui_util.h"
26 #include "ios/chrome/grit/ios_theme_resources.h" 27 #include "ios/chrome/grit/ios_theme_resources.h"
27 #include "ios/web/public/image_fetcher/image_data_fetcher.h"
28 #include "ios/web/public/web_thread.h" 28 #include "ios/web/public/web_thread.h"
29 #include "net/url_request/url_request_context_getter.h" 29 #include "net/url_request/url_request_context_getter.h"
30 #include "ui/gfx/geometry/rect.h" 30 #include "ui/gfx/geometry/rect.h"
31 31
32 namespace { 32 namespace {
33 const CGFloat kExpandAnimationDuration = 0.1; 33 const CGFloat kExpandAnimationDuration = 0.1;
34 const CGFloat kCollapseAnimationDuration = 0.05; 34 const CGFloat kCollapseAnimationDuration = 0.05;
35 const CGFloat kWhiteBackgroundHeight = 74; 35 const CGFloat kWhiteBackgroundHeight = 74;
36 NS_INLINE CGFloat ShadowHeight() { 36 NS_INLINE CGFloat ShadowHeight() {
37 return IsIPadIdiom() ? 10 : 0; 37 return IsIPadIdiom() ? 10 : 0;
38 } 38 }
39 } // namespace 39 } // namespace
40 40
41 using base::UserMetricsAction; 41 using base::UserMetricsAction;
42 42
43 OmniboxPopupViewIOS::OmniboxPopupViewIOS(OmniboxViewIOS* edit_view, 43 OmniboxPopupViewIOS::OmniboxPopupViewIOS(OmniboxViewIOS* edit_view,
44 OmniboxEditModel* edit_model, 44 OmniboxEditModel* edit_model,
45 id<OmniboxPopupPositioner> positioner) 45 id<OmniboxPopupPositioner> positioner)
46 : model_(new OmniboxPopupModel(this, edit_model)), 46 : model_(new OmniboxPopupModel(this, edit_model)),
47 edit_view_(edit_view), 47 edit_view_(edit_view),
48 positioner_(positioner), 48 positioner_(positioner),
49 is_open_(false) { 49 is_open_(false) {
50 DCHECK(edit_view); 50 DCHECK(edit_view);
51 DCHECK(edit_model); 51 DCHECK(edit_model);
52 52
53 std::unique_ptr<web::ImageDataFetcher> imageFetcher = 53 std::unique_ptr<image_fetcher::IOSImageDataFetcherWrapper> imageFetcher =
54 base::MakeUnique<web::ImageDataFetcher>( 54 base::MakeUnique<image_fetcher::IOSImageDataFetcherWrapper>(
55 edit_view->browser_state()->GetRequestContext(),
55 web::WebThread::GetBlockingPool()); 56 web::WebThread::GetBlockingPool());
56 imageFetcher->SetRequestContextGetter(
57 edit_view->browser_state()->GetRequestContext());
58 57
59 popup_controller_.reset([[OmniboxPopupMaterialViewController alloc] 58 popup_controller_.reset([[OmniboxPopupMaterialViewController alloc]
60 initWithPopupView:this 59 initWithPopupView:this
61 withFetcher:std::move(imageFetcher)]); 60 withFetcher:std::move(imageFetcher)]);
62 [popup_controller_ setIncognito:edit_view->browser_state()->IsOffTheRecord()]; 61 [popup_controller_ setIncognito:edit_view->browser_state()->IsOffTheRecord()];
63 popupView_.reset([[UIView alloc] initWithFrame:CGRectZero]); 62 popupView_.reset([[UIView alloc] initWithFrame:CGRectZero]);
64 [popupView_ setClipsToBounds:YES]; 63 [popupView_ setClipsToBounds:YES];
65 CALayer* popupLayer = [popupView_ layer]; 64 CALayer* popupLayer = [popupView_ layer];
66 // Adjust popupView_'s anchor point and height so that it animates down 65 // Adjust popupView_'s anchor point and height so that it animates down
67 // from the top when it appears. 66 // from the top when it appears.
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 UMA_HISTOGRAM_LONG_TIMES_100( 290 UMA_HISTOGRAM_LONG_TIMES_100(
292 "MobileOmnibox.PressedClipboardSuggestionAge", 291 "MobileOmnibox.PressedClipboardSuggestionAge",
293 ClipboardRecentContent::GetInstance()->GetClipboardContentAge()); 292 ClipboardRecentContent::GetInstance()->GetClipboardContentAge());
294 } 293 }
295 edit_view_->OpenMatch(match, disposition, GURL(), base::string16(), row); 294 edit_view_->OpenMatch(match, disposition, GURL(), base::string16(), row);
296 } 295 }
297 296
298 bool OmniboxPopupViewIOS::IsOpen() const { 297 bool OmniboxPopupViewIOS::IsOpen() const {
299 return is_open_; 298 return is_open_;
300 } 299 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698