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

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

Issue 2677023003: Clean up IconNTP-related code (Closed)
Patch Set: Remove unnecessary includes. 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 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/command_line.h"
8 #include "base/logging.h" 7 #include "base/logging.h"
9 #include "base/metrics/field_trial.h"
10 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
11 #include "build/build_config.h" 9 #include "build/build_config.h"
12 #include "components/bookmarks/browser/bookmark_model.h" 10 #include "components/bookmarks/browser/bookmark_model.h"
13 #include "components/favicon/core/favicon_driver_observer.h" 11 #include "components/favicon/core/favicon_driver_observer.h"
14 #include "components/favicon/core/favicon_handler.h" 12 #include "components/favicon/core/favicon_handler.h"
15 #include "components/favicon/core/favicon_service.h" 13 #include "components/favicon/core/favicon_service.h"
16 #include "components/history/core/browser/history_service.h" 14 #include "components/history/core/browser/history_service.h"
17 #include "ui/base/ui_base_switches.h"
18 15
19 namespace favicon { 16 namespace favicon {
20 namespace { 17 namespace {
21 18
22 // Returns whether icon NTP is enabled by experiment.
23 // TODO(huangs): Remove all 3 copies of this routine once Icon NTP launches.
24 bool IsIconNTPEnabled() {
25 // Note: It's important to query the field trial state first, to ensure that
26 // UMA reports the correct group.
27 const std::string group_name = base::FieldTrialList::FindFullName("IconNTP");
28 using base::CommandLine;
29 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableIconNtp))
30 return false;
31 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableIconNtp))
32 return true;
33
34 return base::StartsWith(group_name, "Enabled", base::CompareCase::SENSITIVE);
35 }
36
37 #if defined(OS_ANDROID) || defined(OS_IOS) 19 #if defined(OS_ANDROID) || defined(OS_IOS)
38 const bool kEnableTouchIcon = true; 20 const bool kEnableTouchIcon = true;
39 #else 21 #else
40 const bool kEnableTouchIcon = false; 22 const bool kEnableTouchIcon = false;
41 #endif 23 #endif
42 24
43 } // namespace 25 } // namespace
44 26
45 FaviconDriverImpl::FaviconDriverImpl(FaviconService* favicon_service, 27 FaviconDriverImpl::FaviconDriverImpl(FaviconService* favicon_service,
46 history::HistoryService* history_service, 28 history::HistoryService* history_service,
47 bookmarks::BookmarkModel* bookmark_model) 29 bookmarks::BookmarkModel* bookmark_model)
48 : favicon_service_(favicon_service), 30 : favicon_service_(favicon_service),
49 history_service_(history_service), 31 history_service_(history_service),
50 bookmark_model_(bookmark_model) { 32 bookmark_model_(bookmark_model) {
51 favicon_handler_.reset(new FaviconHandler( 33 favicon_handler_.reset(new FaviconHandler(
52 favicon_service_, this, kEnableTouchIcon 34 favicon_service_, this, kEnableTouchIcon
53 ? FaviconDriverObserver::NON_TOUCH_LARGEST 35 ? FaviconDriverObserver::NON_TOUCH_LARGEST
54 : FaviconDriverObserver::NON_TOUCH_16_DIP)); 36 : FaviconDriverObserver::NON_TOUCH_16_DIP));
55 if (kEnableTouchIcon || IsIconNTPEnabled()) { 37 if (kEnableTouchIcon) {
56 touch_icon_handler_.reset(new FaviconHandler( 38 touch_icon_handler_.reset(new FaviconHandler(
57 favicon_service_, this, FaviconDriverObserver::TOUCH_LARGEST)); 39 favicon_service_, this, FaviconDriverObserver::TOUCH_LARGEST));
58 } 40 }
59 } 41 }
60 42
61 FaviconDriverImpl::~FaviconDriverImpl() { 43 FaviconDriverImpl::~FaviconDriverImpl() {
62 } 44 }
63 45
64 void FaviconDriverImpl::FetchFavicon(const GURL& url) { 46 void FaviconDriverImpl::FetchFavicon(const GURL& url) {
65 favicon_handler_->FetchFavicon(url); 47 favicon_handler_->FetchFavicon(url);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 void FaviconDriverImpl::OnUpdateFaviconURL( 97 void FaviconDriverImpl::OnUpdateFaviconURL(
116 const GURL& page_url, 98 const GURL& page_url,
117 const std::vector<FaviconURL>& candidates) { 99 const std::vector<FaviconURL>& candidates) {
118 DCHECK(!candidates.empty()); 100 DCHECK(!candidates.empty());
119 favicon_handler_->OnUpdateFaviconURL(page_url, candidates); 101 favicon_handler_->OnUpdateFaviconURL(page_url, candidates);
120 if (touch_icon_handler_.get()) 102 if (touch_icon_handler_.get())
121 touch_icon_handler_->OnUpdateFaviconURL(page_url, candidates); 103 touch_icon_handler_->OnUpdateFaviconURL(page_url, candidates);
122 } 104 }
123 105
124 } // namespace favicon 106 } // namespace favicon
OLDNEW
« no previous file with comments | « chrome/renderer/searchbox/searchbox_extension.cc ('k') | content/browser/renderer_host/render_process_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698