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

Side by Side Diff: components/favicon/core/favicon_driver_impl.cc

Issue 2732653002: Add favicon integration tests for FaviconDriverImpl (Closed)
Patch Set: Added verification of color Created 3 years, 9 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/favicon/core/favicon_driver_impl.h" 5 #include "components/favicon/core/favicon_driver_impl.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "components/bookmarks/browser/bookmark_model.h" 11 #include "components/bookmarks/browser/bookmark_model.h"
12 #include "components/favicon/core/favicon_driver_observer.h" 12 #include "components/favicon/core/favicon_driver_observer.h"
13 #include "components/favicon/core/favicon_handler.h" 13 #include "components/favicon/core/favicon_handler.h"
14 #include "components/favicon/core/favicon_service.h" 14 #include "components/favicon/core/favicon_service.h"
15 #include "components/favicon/core/favicon_url.h" 15 #include "components/favicon/core/favicon_url.h"
16 #include "components/history/core/browser/history_service.h" 16 #include "components/history/core/browser/history_service.h"
17 17
18 namespace favicon { 18 namespace favicon {
19 namespace { 19 namespace {
20 20
21 #if defined(OS_ANDROID) || defined(OS_IOS)
22 const bool kEnableTouchIcon = true;
23 #else
24 const bool kEnableTouchIcon = false;
25 #endif
26
27 void RecordCandidateMetrics(const std::vector<FaviconURL>& candidates) { 21 void RecordCandidateMetrics(const std::vector<FaviconURL>& candidates) {
28 size_t with_defined_touch_icons = 0; 22 size_t with_defined_touch_icons = 0;
29 size_t with_defined_sizes = 0; 23 size_t with_defined_sizes = 0;
30 for (const auto& candidate : candidates) { 24 for (const auto& candidate : candidates) {
31 if (!candidate.icon_sizes.empty()) { 25 if (!candidate.icon_sizes.empty()) {
32 with_defined_sizes++; 26 with_defined_sizes++;
33 } 27 }
34 if (candidate.icon_type & 28 if (candidate.icon_type &
35 (favicon_base::IconType::TOUCH_ICON | 29 (favicon_base::IconType::TOUCH_ICON |
36 favicon_base::IconType::TOUCH_PRECOMPOSED_ICON)) { 30 favicon_base::IconType::TOUCH_PRECOMPOSED_ICON)) {
37 with_defined_touch_icons++; 31 with_defined_touch_icons++;
38 } 32 }
39 } 33 }
40 UMA_HISTOGRAM_COUNTS_100("Favicons.CandidatesCount", candidates.size()); 34 UMA_HISTOGRAM_COUNTS_100("Favicons.CandidatesCount", candidates.size());
41 UMA_HISTOGRAM_COUNTS_100("Favicons.CandidatesWithDefinedSizesCount", 35 UMA_HISTOGRAM_COUNTS_100("Favicons.CandidatesWithDefinedSizesCount",
42 with_defined_sizes); 36 with_defined_sizes);
43 UMA_HISTOGRAM_COUNTS_100("Favicons.CandidatesWithTouchIconsCount", 37 UMA_HISTOGRAM_COUNTS_100("Favicons.CandidatesWithTouchIconsCount",
44 with_defined_touch_icons); 38 with_defined_touch_icons);
45 } 39 }
46 40
47 } // namespace 41 } // namespace
48 42
49 FaviconDriverImpl::FaviconDriverImpl(FaviconService* favicon_service, 43 FaviconDriverImpl::FaviconDriverImpl(bool enable_touch_icons,
44 FaviconService* favicon_service,
50 history::HistoryService* history_service, 45 history::HistoryService* history_service,
51 bookmarks::BookmarkModel* bookmark_model) 46 bookmarks::BookmarkModel* bookmark_model)
52 : favicon_service_(favicon_service), 47 : favicon_service_(favicon_service),
53 history_service_(history_service), 48 history_service_(history_service),
54 bookmark_model_(bookmark_model) { 49 bookmark_model_(bookmark_model) {
55 favicon_handler_.reset(new FaviconHandler( 50 favicon_handler_.reset(new FaviconHandler(
56 favicon_service_, this, kEnableTouchIcon 51 favicon_service_, this,
57 ? FaviconDriverObserver::NON_TOUCH_LARGEST 52 enable_touch_icons ? FaviconDriverObserver::NON_TOUCH_LARGEST
58 : FaviconDriverObserver::NON_TOUCH_16_DIP)); 53 : FaviconDriverObserver::NON_TOUCH_16_DIP));
59 if (kEnableTouchIcon) { 54 if (enable_touch_icons) {
60 touch_icon_handler_.reset(new FaviconHandler( 55 touch_icon_handler_.reset(new FaviconHandler(
61 favicon_service_, this, FaviconDriverObserver::TOUCH_LARGEST)); 56 favicon_service_, this, FaviconDriverObserver::TOUCH_LARGEST));
62 } 57 }
63 } 58 }
64 59
65 FaviconDriverImpl::~FaviconDriverImpl() { 60 FaviconDriverImpl::~FaviconDriverImpl() {
66 } 61 }
67 62
68 void FaviconDriverImpl::FetchFavicon(const GURL& url) { 63 void FaviconDriverImpl::FetchFavicon(const GURL& url) {
69 favicon_handler_->FetchFavicon(url); 64 favicon_handler_->FetchFavicon(url);
(...skipping 30 matching lines...) Expand all
100 const GURL& page_url, 95 const GURL& page_url,
101 const std::vector<FaviconURL>& candidates) { 96 const std::vector<FaviconURL>& candidates) {
102 DCHECK(!candidates.empty()); 97 DCHECK(!candidates.empty());
103 RecordCandidateMetrics(candidates); 98 RecordCandidateMetrics(candidates);
104 favicon_handler_->OnUpdateFaviconURL(page_url, candidates); 99 favicon_handler_->OnUpdateFaviconURL(page_url, candidates);
105 if (touch_icon_handler_.get()) 100 if (touch_icon_handler_.get())
106 touch_icon_handler_->OnUpdateFaviconURL(page_url, candidates); 101 touch_icon_handler_->OnUpdateFaviconURL(page_url, candidates);
107 } 102 }
108 103
109 } // namespace favicon 104 } // namespace favicon
OLDNEW
« no previous file with comments | « components/favicon/core/favicon_driver_impl.h ('k') | components/favicon/core/favicon_driver_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698