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

Side by Side Diff: chrome/browser/ui/webui/browsing_history_handler.cc

Issue 1596273003: [Android] Use fallback icon if there is no large favicon on the history page (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 "chrome/browser/ui/webui/browsing_history_handler.h" 5 #include "chrome/browser/ui/webui/browsing_history_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <set> 9 #include <set>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/i18n/rtl.h" 13 #include "base/i18n/rtl.h"
14 #include "base/i18n/time_formatting.h" 14 #include "base/i18n/time_formatting.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/strings/string16.h" 16 #include "base/strings/string16.h"
17 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
18 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
19 #include "base/time/time.h" 19 #include "base/time/time.h"
20 #include "base/values.h" 20 #include "base/values.h"
21 #include "chrome/browser/banners/app_banner_settings_helper.h" 21 #include "chrome/browser/banners/app_banner_settings_helper.h"
22 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 22 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
23 #include "chrome/browser/engagement/site_engagement_service.h" 23 #include "chrome/browser/engagement/site_engagement_service.h"
24 #include "chrome/browser/favicon/fallback_icon_service_factory.h"
25 #include "chrome/browser/favicon/large_icon_service_factory.h"
24 #include "chrome/browser/history/history_service_factory.h" 26 #include "chrome/browser/history/history_service_factory.h"
25 #include "chrome/browser/history/history_utils.h" 27 #include "chrome/browser/history/history_utils.h"
26 #include "chrome/browser/history/web_history_service_factory.h" 28 #include "chrome/browser/history/web_history_service_factory.h"
27 #include "chrome/browser/profiles/profile.h" 29 #include "chrome/browser/profiles/profile.h"
28 #include "chrome/browser/sync/profile_sync_service_factory.h" 30 #include "chrome/browser/sync/profile_sync_service_factory.h"
29 #include "chrome/browser/ui/browser_finder.h" 31 #include "chrome/browser/ui/browser_finder.h"
30 #include "chrome/browser/ui/chrome_pages.h" 32 #include "chrome/browser/ui/chrome_pages.h"
31 #include "chrome/browser/ui/webui/favicon_source.h" 33 #include "chrome/browser/ui/webui/favicon_source.h"
34 #include "chrome/browser/ui/webui/large_icon_source.h"
32 #include "chrome/common/features.h" 35 #include "chrome/common/features.h"
33 #include "chrome/common/pref_names.h" 36 #include "chrome/common/pref_names.h"
34 #include "components/bookmarks/browser/bookmark_model.h" 37 #include "components/bookmarks/browser/bookmark_model.h"
35 #include "components/bookmarks/browser/bookmark_utils.h" 38 #include "components/bookmarks/browser/bookmark_utils.h"
36 #include "components/browser_sync/browser/profile_sync_service.h" 39 #include "components/browser_sync/browser/profile_sync_service.h"
40 #include "components/favicon/core/fallback_icon_service.h"
41 #include "components/favicon/core/fallback_url_util.h"
42 #include "components/favicon/core/large_icon_service.h"
37 #include "components/history/core/browser/history_service.h" 43 #include "components/history/core/browser/history_service.h"
38 #include "components/history/core/browser/history_types.h" 44 #include "components/history/core/browser/history_types.h"
39 #include "components/history/core/browser/web_history_service.h" 45 #include "components/history/core/browser/web_history_service.h"
40 #include "components/keyed_service/core/service_access_type.h" 46 #include "components/keyed_service/core/service_access_type.h"
41 #include "components/prefs/pref_service.h" 47 #include "components/prefs/pref_service.h"
42 #include "components/query_parser/snippet.h" 48 #include "components/query_parser/snippet.h"
43 #include "components/sync_driver/device_info.h" 49 #include "components/sync_driver/device_info.h"
44 #include "components/sync_driver/device_info_tracker.h" 50 #include "components/sync_driver/device_info_tracker.h"
45 #include "components/url_formatter/url_formatter.h" 51 #include "components/url_formatter/url_formatter.h"
46 #include "content/public/browser/url_data_source.h" 52 #include "content/public/browser/url_data_source.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 // When the domain is empty, use the scheme instead. This allows for a 219 // When the domain is empty, use the scheme instead. This allows for a
214 // sensible treatment of e.g. file: URLs when group by domain is on. 220 // sensible treatment of e.g. file: URLs when group by domain is on.
215 if (domain.empty()) 221 if (domain.empty())
216 domain = base::UTF8ToUTF16(url.scheme() + ":"); 222 domain = base::UTF8ToUTF16(url.scheme() + ":");
217 223
218 // The items which are to be written into result are also described in 224 // The items which are to be written into result are also described in
219 // chrome/browser/resources/history/history.js in @typedef for 225 // chrome/browser/resources/history/history.js in @typedef for
220 // HistoryEntry. Please update it whenever you add or remove 226 // HistoryEntry. Please update it whenever you add or remove
221 // any keys in result. 227 // any keys in result.
222 result->SetString("domain", domain); 228 result->SetString("domain", domain);
229
230 result->SetString("fallbackFaviconText",
231 base::UTF16ToASCII(favicon::GetFallbackIconText(url)));
232
223 result->SetDouble("time", time.ToJsTime()); 233 result->SetDouble("time", time.ToJsTime());
224 234
225 // Pass the timestamps in a list. 235 // Pass the timestamps in a list.
226 scoped_ptr<base::ListValue> timestamps(new base::ListValue); 236 scoped_ptr<base::ListValue> timestamps(new base::ListValue);
227 for (std::set<int64_t>::const_iterator it = all_timestamps.begin(); 237 for (std::set<int64_t>::const_iterator it = all_timestamps.begin();
228 it != all_timestamps.end(); ++it) { 238 it != all_timestamps.end(); ++it) {
229 timestamps->AppendDouble(base::Time::FromInternalValue(*it).ToJsTime()); 239 timestamps->AppendDouble(base::Time::FromInternalValue(*it).ToJsTime());
230 } 240 }
231 result->Set("allTimestamps", timestamps.release()); 241 result->Set("allTimestamps", timestamps.release());
232 242
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 } 311 }
302 312
303 BrowsingHistoryHandler::~BrowsingHistoryHandler() { 313 BrowsingHistoryHandler::~BrowsingHistoryHandler() {
304 query_task_tracker_.TryCancelAll(); 314 query_task_tracker_.TryCancelAll();
305 web_history_request_.reset(); 315 web_history_request_.reset();
306 } 316 }
307 317
308 void BrowsingHistoryHandler::RegisterMessages() { 318 void BrowsingHistoryHandler::RegisterMessages() {
309 // Create our favicon data source. 319 // Create our favicon data source.
310 Profile* profile = Profile::FromWebUI(web_ui()); 320 Profile* profile = Profile::FromWebUI(web_ui());
321
322 #if defined(OS_ANDROID)
323 favicon::FallbackIconService* fallback_icon_service =
324 FallbackIconServiceFactory::GetForBrowserContext(profile);
325 favicon::LargeIconService* large_icon_service =
326 LargeIconServiceFactory::GetForBrowserContext(profile);
327 content::URLDataSource::Add(
328 profile, new LargeIconSource(fallback_icon_service, large_icon_service));
329 #else
311 content::URLDataSource::Add( 330 content::URLDataSource::Add(
312 profile, new FaviconSource(profile, FaviconSource::ANY)); 331 profile, new FaviconSource(profile, FaviconSource::ANY));
332 #endif
313 333
314 // Get notifications when history is cleared. 334 // Get notifications when history is cleared.
315 history::HistoryService* hs = HistoryServiceFactory::GetForProfile( 335 history::HistoryService* hs = HistoryServiceFactory::GetForProfile(
316 profile, ServiceAccessType::EXPLICIT_ACCESS); 336 profile, ServiceAccessType::EXPLICIT_ACCESS);
317 if (hs) 337 if (hs)
318 history_service_observer_.Add(hs); 338 history_service_observer_.Add(hs);
319 339
320 web_ui()->RegisterMessageCallback("queryHistory", 340 web_ui()->RegisterMessageCallback("queryHistory",
321 base::Bind(&BrowsingHistoryHandler::HandleQueryHistory, 341 base::Bind(&BrowsingHistoryHandler::HandleQueryHistory,
322 base::Unretained(this))); 342 base::Unretained(this)));
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 912
893 void BrowsingHistoryHandler::OnURLsDeleted( 913 void BrowsingHistoryHandler::OnURLsDeleted(
894 history::HistoryService* history_service, 914 history::HistoryService* history_service,
895 bool all_history, 915 bool all_history,
896 bool expired, 916 bool expired,
897 const history::URLRows& deleted_rows, 917 const history::URLRows& deleted_rows,
898 const std::set<GURL>& favicon_urls) { 918 const std::set<GURL>& favicon_urls) {
899 if (all_history || DeletionsDiffer(deleted_rows, urls_to_be_deleted_)) 919 if (all_history || DeletionsDiffer(deleted_rows, urls_to_be_deleted_))
900 web_ui()->CallJavascriptFunction("historyDeleted"); 920 web_ui()->CallJavascriptFunction("historyDeleted");
901 } 921 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/history/history_mobile.css ('k') | chrome/browser/ui/webui/large_icon_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698