Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 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/history_ui.h" | 5 #include "chrome/browser/ui/webui/browsing_history_handler.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/command_line.h" | |
| 12 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
| 13 #include "base/i18n/time_formatting.h" | 12 #include "base/i18n/time_formatting.h" |
| 14 #include "base/memory/singleton.h" | |
| 15 #include "base/message_loop/message_loop.h" | |
| 16 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 17 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
| 18 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 19 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 21 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 22 #include "base/values.h" | 19 #include "base/values.h" |
| 23 #include "chrome/browser/banners/app_banner_settings_helper.h" | 20 #include "chrome/browser/banners/app_banner_settings_helper.h" |
| 24 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 21 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 25 #include "chrome/browser/chrome_notification_types.h" | |
| 26 #include "chrome/browser/engagement/site_engagement_service.h" | 22 #include "chrome/browser/engagement/site_engagement_service.h" |
| 27 #include "chrome/browser/history/history_service_factory.h" | 23 #include "chrome/browser/history/history_service_factory.h" |
| 28 #include "chrome/browser/history/history_utils.h" | 24 #include "chrome/browser/history/history_utils.h" |
| 29 #include "chrome/browser/history/web_history_service_factory.h" | 25 #include "chrome/browser/history/web_history_service_factory.h" |
| 30 #include "chrome/browser/prefs/incognito_mode_prefs.h" | |
| 31 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
| 32 #include "chrome/browser/signin/signin_manager_factory.h" | |
| 33 #include "chrome/browser/sync/profile_sync_service_factory.h" | 27 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 34 #include "chrome/browser/ui/browser_finder.h" | 28 #include "chrome/browser/ui/browser_finder.h" |
| 35 #include "chrome/browser/ui/chrome_pages.h" | 29 #include "chrome/browser/ui/chrome_pages.h" |
| 36 #include "chrome/browser/ui/webui/favicon_source.h" | 30 #include "chrome/browser/ui/webui/favicon_source.h" |
| 37 #include "chrome/browser/ui/webui/metrics_handler.h" | |
| 38 #include "chrome/common/chrome_switches.h" | |
| 39 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
| 40 #include "chrome/common/url_constants.h" | |
| 41 #include "chrome/grit/generated_resources.h" | 32 #include "chrome/grit/generated_resources.h" |
| 42 #include "components/bookmarks/browser/bookmark_model.h" | 33 #include "components/bookmarks/browser/bookmark_model.h" |
| 43 #include "components/bookmarks/browser/bookmark_utils.h" | 34 #include "components/bookmarks/browser/bookmark_utils.h" |
| 44 #include "components/browser_sync/browser/profile_sync_service.h" | 35 #include "components/browser_sync/browser/profile_sync_service.h" |
| 45 #include "components/history/core/browser/history_service.h" | 36 #include "components/history/core/browser/history_service.h" |
| 46 #include "components/history/core/browser/history_types.h" | 37 #include "components/history/core/browser/history_types.h" |
| 47 #include "components/history/core/browser/web_history_service.h" | 38 #include "components/history/core/browser/web_history_service.h" |
| 48 #include "components/search/search.h" | 39 #include "components/keyed_service/core/service_access_type.h" |
| 49 #include "components/signin/core/browser/signin_manager.h" | 40 #include "components/query_parser/snippet.h" |
| 50 #include "components/sync_driver/device_info.h" | 41 #include "components/sync_driver/device_info.h" |
| 42 #include "components/sync_driver/device_info_tracker.h" | |
| 51 #include "components/url_formatter/url_formatter.h" | 43 #include "components/url_formatter/url_formatter.h" |
| 52 #include "content/public/browser/url_data_source.h" | 44 #include "content/public/browser/url_data_source.h" |
| 53 #include "content/public/browser/web_ui.h" | 45 #include "content/public/browser/web_ui.h" |
| 54 #include "content/public/browser/web_ui_data_source.h" | |
| 55 #include "grit/browser_resources.h" | |
| 56 #include "grit/theme_resources.h" | |
| 57 #include "net/base/escape.h" | |
| 58 #include "sync/protocol/history_delete_directive_specifics.pb.h" | 46 #include "sync/protocol/history_delete_directive_specifics.pb.h" |
| 47 #include "sync/protocol/sync_enums.pb.h" | |
| 59 #include "ui/base/l10n/l10n_util.h" | 48 #include "ui/base/l10n/l10n_util.h" |
| 60 #include "ui/base/l10n/time_format.h" | 49 #include "ui/base/l10n/time_format.h" |
| 61 #include "ui/base/resource/resource_bundle.h" | |
| 62 #include "ui/base/webui/web_ui_util.h" | |
| 63 | 50 |
| 64 #if defined(ENABLE_EXTENSIONS) | 51 #if defined(ENABLE_EXTENSIONS) |
| 65 #include "chrome/browser/extensions/activity_log/activity_log.h" | 52 #include "chrome/browser/extensions/activity_log/activity_log.h" |
| 66 #endif | 53 #endif |
| 67 | 54 |
| 68 #if defined(ENABLE_SUPERVISED_USERS) | 55 #if defined(ENABLE_SUPERVISED_USERS) |
| 69 #include "chrome/browser/supervised_user/supervised_user_navigation_observer.h" | 56 #include "chrome/browser/supervised_user/supervised_user_navigation_observer.h" |
| 70 #include "chrome/browser/supervised_user/supervised_user_service.h" | 57 #include "chrome/browser/supervised_user/supervised_user_service.h" |
| 71 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" | 58 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" |
| 72 #include "chrome/browser/supervised_user/supervised_user_url_filter.h" | 59 #include "chrome/browser/supervised_user/supervised_user_url_filter.h" |
| 73 #endif | 60 #endif |
| 74 | 61 |
| 75 #if defined(OS_ANDROID) | 62 #if defined(OS_ANDROID) |
| 76 #include "chrome/browser/android/chrome_application.h" | 63 #include "chrome/browser/android/chrome_application.h" |
| 77 #endif | 64 #endif |
| 78 | 65 |
| 79 #if !defined(OS_ANDROID) && !defined(OS_IOS) | |
| 80 #include "chrome/browser/ui/webui/foreign_session_handler.h" | |
| 81 #include "chrome/browser/ui/webui/history_login_handler.h" | |
| 82 #endif | |
| 83 | |
| 84 using bookmarks::BookmarkModel; | |
| 85 | |
| 86 static const char kStringsJsFile[] = "strings.js"; | |
| 87 static const char kHistoryJsFile[] = "history.js"; | |
| 88 static const char kOtherDevicesJsFile[] = "other_devices.js"; | |
| 89 | |
| 90 // The amount of time to wait for a response from the WebHistoryService. | 66 // The amount of time to wait for a response from the WebHistoryService. |
| 91 static const int kWebHistoryTimeoutSeconds = 3; | 67 static const int kWebHistoryTimeoutSeconds = 3; |
| 92 | 68 |
| 69 using bookmarks::BookmarkModel; | |
| 70 | |
| 93 namespace { | 71 namespace { |
| 94 | 72 |
| 95 // Buckets for UMA histograms. | 73 // Buckets for UMA histograms. |
| 96 enum WebHistoryQueryBuckets { | 74 enum WebHistoryQueryBuckets { |
| 97 WEB_HISTORY_QUERY_FAILED = 0, | 75 WEB_HISTORY_QUERY_FAILED = 0, |
| 98 WEB_HISTORY_QUERY_SUCCEEDED, | 76 WEB_HISTORY_QUERY_SUCCEEDED, |
| 99 WEB_HISTORY_QUERY_TIMED_OUT, | 77 WEB_HISTORY_QUERY_TIMED_OUT, |
| 100 NUM_WEB_HISTORY_QUERY_BUCKETS | 78 NUM_WEB_HISTORY_QUERY_BUCKETS |
| 101 }; | 79 }; |
| 102 | 80 |
| 103 #if defined(OS_MACOSX) | |
| 104 const char kIncognitoModeShortcut[] = "(" | |
| 105 "\xE2\x87\xA7" // Shift symbol (U+21E7 'UPWARDS WHITE ARROW'). | |
| 106 "\xE2\x8C\x98" // Command symbol (U+2318 'PLACE OF INTEREST SIGN'). | |
| 107 "N)"; | |
| 108 #elif defined(OS_WIN) | |
| 109 const char kIncognitoModeShortcut[] = "(Ctrl+Shift+N)"; | |
| 110 #else | |
| 111 const char kIncognitoModeShortcut[] = "(Shift+Ctrl+N)"; | |
| 112 #endif | |
| 113 | |
| 114 // Identifiers for the type of device from which a history entry originated. | 81 // Identifiers for the type of device from which a history entry originated. |
| 115 static const char kDeviceTypeLaptop[] = "laptop"; | 82 static const char kDeviceTypeLaptop[] = "laptop"; |
| 116 static const char kDeviceTypePhone[] = "phone"; | 83 static const char kDeviceTypePhone[] = "phone"; |
| 117 static const char kDeviceTypeTablet[] = "tablet"; | 84 static const char kDeviceTypeTablet[] = "tablet"; |
| 118 | 85 |
| 119 content::WebUIDataSource* CreateHistoryUIHTMLSource(Profile* profile) { | |
| 120 PrefService* prefs = profile->GetPrefs(); | |
| 121 | |
| 122 // Check if the profile is authenticated. Guest profiles or incognito | |
| 123 // windows may not have a sign in manager, and are considered not | |
| 124 // authenticated. | |
| 125 SigninManagerBase* signin_manager = | |
| 126 SigninManagerFactory::GetForProfile(profile); | |
| 127 bool is_authenticated = signin_manager != nullptr && | |
| 128 signin_manager->IsAuthenticated(); | |
| 129 | |
| 130 content::WebUIDataSource* source = | |
| 131 content::WebUIDataSource::Create(chrome::kChromeUIHistoryFrameHost); | |
| 132 source->AddBoolean("isUserSignedIn", is_authenticated); | |
| 133 source->AddLocalizedString("collapseSessionMenuItemText", | |
| 134 IDS_HISTORY_OTHER_SESSIONS_COLLAPSE_SESSION); | |
| 135 source->AddLocalizedString("expandSessionMenuItemText", | |
| 136 IDS_HISTORY_OTHER_SESSIONS_EXPAND_SESSION); | |
| 137 source->AddLocalizedString("restoreSessionMenuItemText", | |
| 138 IDS_HISTORY_OTHER_SESSIONS_OPEN_ALL); | |
| 139 source->AddLocalizedString("xMore", IDS_HISTORY_OTHER_DEVICES_X_MORE); | |
| 140 source->AddLocalizedString("loading", IDS_HISTORY_LOADING); | |
| 141 source->AddLocalizedString("title", IDS_HISTORY_TITLE); | |
| 142 source->AddLocalizedString("newest", IDS_HISTORY_NEWEST); | |
| 143 source->AddLocalizedString("newer", IDS_HISTORY_NEWER); | |
| 144 source->AddLocalizedString("older", IDS_HISTORY_OLDER); | |
| 145 source->AddLocalizedString("searchResultsFor", IDS_HISTORY_SEARCHRESULTSFOR); | |
| 146 source->AddLocalizedString("searchResult", IDS_HISTORY_SEARCH_RESULT); | |
| 147 source->AddLocalizedString("searchResults", IDS_HISTORY_SEARCH_RESULTS); | |
| 148 source->AddLocalizedString("foundSearchResults", | |
| 149 IDS_HISTORY_FOUND_SEARCH_RESULTS); | |
| 150 source->AddLocalizedString("history", IDS_HISTORY_BROWSERESULTS); | |
| 151 source->AddLocalizedString("cont", IDS_HISTORY_CONTINUED); | |
| 152 source->AddLocalizedString("searchButton", IDS_HISTORY_SEARCH_BUTTON); | |
| 153 source->AddLocalizedString("noSearchResults", IDS_HISTORY_NO_SEARCH_RESULTS); | |
| 154 source->AddLocalizedString("noResults", IDS_HISTORY_NO_RESULTS); | |
| 155 source->AddLocalizedString("historyInterval", IDS_HISTORY_INTERVAL); | |
| 156 source->AddLocalizedString("removeSelected", | |
| 157 IDS_HISTORY_REMOVE_SELECTED_ITEMS); | |
| 158 source->AddLocalizedString("clearAllHistory", | |
| 159 IDS_HISTORY_OPEN_CLEAR_BROWSING_DATA_DIALOG); | |
| 160 | |
| 161 auto availability = IncognitoModePrefs::GetAvailability(profile->GetPrefs()); | |
| 162 base::string16 delete_warning = availability == IncognitoModePrefs::ENABLED ? | |
| 163 l10n_util::GetStringFUTF16(IDS_HISTORY_DELETE_PRIOR_VISITS_WARNING, | |
| 164 base::UTF8ToUTF16(kIncognitoModeShortcut)) : | |
| 165 l10n_util::GetStringUTF16( | |
| 166 IDS_HISTORY_DELETE_PRIOR_VISITS_WARNING_NO_INCOGNITO); | |
| 167 source->AddString("deleteWarning", delete_warning); | |
| 168 | |
| 169 source->AddLocalizedString("removeBookmark", IDS_HISTORY_REMOVE_BOOKMARK); | |
| 170 source->AddLocalizedString("actionMenuDescription", | |
| 171 IDS_HISTORY_ACTION_MENU_DESCRIPTION); | |
| 172 source->AddLocalizedString("removeFromHistory", IDS_HISTORY_REMOVE_PAGE); | |
| 173 source->AddLocalizedString("moreFromSite", IDS_HISTORY_MORE_FROM_SITE); | |
| 174 source->AddLocalizedString("groupByDomainLabel", IDS_GROUP_BY_DOMAIN_LABEL); | |
| 175 source->AddLocalizedString("rangeLabel", IDS_HISTORY_RANGE_LABEL); | |
| 176 source->AddLocalizedString("rangeAllTime", IDS_HISTORY_RANGE_ALL_TIME); | |
| 177 source->AddLocalizedString("rangeWeek", IDS_HISTORY_RANGE_WEEK); | |
| 178 source->AddLocalizedString("rangeMonth", IDS_HISTORY_RANGE_MONTH); | |
| 179 source->AddLocalizedString("rangeToday", IDS_HISTORY_RANGE_TODAY); | |
| 180 source->AddLocalizedString("rangeNext", IDS_HISTORY_RANGE_NEXT); | |
| 181 source->AddLocalizedString("rangePrevious", IDS_HISTORY_RANGE_PREVIOUS); | |
| 182 source->AddLocalizedString("numberVisits", IDS_HISTORY_NUMBER_VISITS); | |
| 183 source->AddLocalizedString("filterAllowed", IDS_HISTORY_FILTER_ALLOWED); | |
| 184 source->AddLocalizedString("filterBlocked", IDS_HISTORY_FILTER_BLOCKED); | |
| 185 source->AddLocalizedString("inContentPack", IDS_HISTORY_IN_CONTENT_PACK); | |
| 186 source->AddLocalizedString("allowItems", IDS_HISTORY_FILTER_ALLOW_ITEMS); | |
| 187 source->AddLocalizedString("blockItems", IDS_HISTORY_FILTER_BLOCK_ITEMS); | |
| 188 source->AddLocalizedString("blockedVisitText", | |
| 189 IDS_HISTORY_BLOCKED_VISIT_TEXT); | |
| 190 source->AddLocalizedString("hasSyncedResults", | |
| 191 IDS_HISTORY_HAS_SYNCED_RESULTS); | |
| 192 source->AddLocalizedString("noSyncedResults", IDS_HISTORY_NO_SYNCED_RESULTS); | |
| 193 source->AddLocalizedString("cancel", IDS_CANCEL); | |
| 194 source->AddLocalizedString("deleteConfirm", | |
| 195 IDS_HISTORY_DELETE_PRIOR_VISITS_CONFIRM_BUTTON); | |
| 196 source->AddLocalizedString("bookmarked", IDS_HISTORY_ENTRY_BOOKMARKED); | |
| 197 source->AddLocalizedString("entrySummary", IDS_HISTORY_ENTRY_SUMMARY); | |
| 198 source->AddBoolean("isFullHistorySyncEnabled", | |
| 199 WebHistoryServiceFactory::GetForProfile(profile) != NULL); | |
| 200 bool group_by_domain = base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 201 switches::kHistoryEnableGroupByDomain); | |
| 202 // Supervised users get the "group by domain" version, but not on mobile, | |
| 203 // because that version isn't adjusted for small screens yet. crbug.com/452859 | |
| 204 #if !defined(OS_ANDROID) && !defined(OS_IOS) | |
| 205 group_by_domain = group_by_domain || profile->IsSupervised(); | |
| 206 #endif | |
| 207 source->AddBoolean("groupByDomain", group_by_domain); | |
| 208 bool allow_deleting_history = | |
| 209 prefs->GetBoolean(prefs::kAllowDeletingBrowserHistory); | |
| 210 source->AddBoolean("allowDeletingHistory", allow_deleting_history); | |
| 211 source->AddBoolean("isInstantExtendedApiEnabled", | |
| 212 search::IsInstantExtendedAPIEnabled()); | |
| 213 source->AddBoolean("isSupervisedProfile", profile->IsSupervised()); | |
| 214 source->AddBoolean("hideDeleteVisitUI", | |
| 215 profile->IsSupervised() && !allow_deleting_history); | |
| 216 | |
| 217 source->SetJsonPath(kStringsJsFile); | |
| 218 source->AddResourcePath(kHistoryJsFile, IDR_HISTORY_JS); | |
| 219 source->AddResourcePath(kOtherDevicesJsFile, IDR_OTHER_DEVICES_JS); | |
| 220 source->SetDefaultResource(IDR_HISTORY_HTML); | |
| 221 source->DisableDenyXFrameOptions(); | |
| 222 | |
| 223 return source; | |
| 224 } | |
| 225 | |
| 226 // Returns a localized version of |visit_time| including a relative | 86 // Returns a localized version of |visit_time| including a relative |
| 227 // indicator (e.g. today, yesterday). | 87 // indicator (e.g. today, yesterday). |
| 228 base::string16 getRelativeDateLocalized(const base::Time& visit_time) { | 88 base::string16 getRelativeDateLocalized(const base::Time& visit_time) { |
|
Dan Beam
2015/11/20 20:13:00
GetRelativeDateLocalized
tsergeant
2015/11/22 23:45:18
Done.
| |
| 229 base::Time midnight = base::Time::Now().LocalMidnight(); | 89 base::Time midnight = base::Time::Now().LocalMidnight(); |
| 230 base::string16 date_str = ui::TimeFormat::RelativeDate(visit_time, &midnight); | 90 base::string16 date_str = ui::TimeFormat::RelativeDate(visit_time, &midnight); |
| 231 if (date_str.empty()) { | 91 if (date_str.empty()) { |
| 232 date_str = base::TimeFormatFriendlyDate(visit_time); | 92 date_str = base::TimeFormatFriendlyDate(visit_time); |
| 233 } else { | 93 } else { |
| 234 date_str = l10n_util::GetStringFUTF16( | 94 date_str = l10n_util::GetStringFUTF16( |
| 235 IDS_HISTORY_DATE_WITH_RELATIVE_TIME, | 95 IDS_HISTORY_DATE_WITH_RELATIVE_TIME, |
| 236 date_str, | 96 date_str, |
| 237 base::TimeFormatFriendlyDate(visit_time)); | 97 base::TimeFormatFriendlyDate(visit_time)); |
| 238 } | 98 } |
| 239 return date_str; | 99 return date_str; |
| 240 } | 100 } |
| 241 | 101 |
| 242 | |
| 243 // Sets the correct year when substracting months from a date. | 102 // Sets the correct year when substracting months from a date. |
| 244 void normalizeMonths(base::Time::Exploded* exploded) { | 103 void normalizeMonths(base::Time::Exploded* exploded) { |
|
Dan Beam
2015/11/20 20:13:00
NormalizeMonths
tsergeant
2015/11/22 23:45:18
Done.
| |
| 245 // Decrease a year at a time until we have a proper date. | 104 // Decrease a year at a time until we have a proper date. |
| 246 while (exploded->month < 1) { | 105 while (exploded->month < 1) { |
| 247 exploded->month += 12; | 106 exploded->month += 12; |
| 248 exploded->year--; | 107 exploded->year--; |
| 249 } | 108 } |
| 250 } | 109 } |
| 251 | 110 |
| 252 // Returns true if |entry| represents a local visit that had no corresponding | 111 // Returns true if |entry| represents a local visit that had no corresponding |
| 253 // visit on the server. | 112 // visit on the server. |
| 254 bool IsLocalOnlyResult(const BrowsingHistoryHandler::HistoryEntry& entry) { | 113 bool IsLocalOnlyResult(const BrowsingHistoryHandler::HistoryEntry& entry) { |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 283 } | 142 } |
| 284 return; | 143 return; |
| 285 } | 144 } |
| 286 | 145 |
| 287 *name = l10n_util::GetStringUTF8(IDS_HISTORY_UNKNOWN_DEVICE); | 146 *name = l10n_util::GetStringUTF8(IDS_HISTORY_UNKNOWN_DEVICE); |
| 288 *type = kDeviceTypeLaptop; | 147 *type = kDeviceTypeLaptop; |
| 289 } | 148 } |
| 290 | 149 |
| 291 } // namespace | 150 } // namespace |
| 292 | 151 |
| 293 //////////////////////////////////////////////////////////////////////////////// | |
| 294 // | |
| 295 // BrowsingHistoryHandler | |
| 296 // | |
| 297 //////////////////////////////////////////////////////////////////////////////// | |
| 298 | |
| 299 BrowsingHistoryHandler::HistoryEntry::HistoryEntry( | 152 BrowsingHistoryHandler::HistoryEntry::HistoryEntry( |
| 300 BrowsingHistoryHandler::HistoryEntry::EntryType entry_type, | 153 BrowsingHistoryHandler::HistoryEntry::EntryType entry_type, |
| 301 const GURL& url, const base::string16& title, base::Time time, | 154 const GURL& url, const base::string16& title, base::Time time, |
| 302 const std::string& client_id, bool is_search_result, | 155 const std::string& client_id, bool is_search_result, |
| 303 const base::string16& snippet, bool blocked_visit, | 156 const base::string16& snippet, bool blocked_visit, |
| 304 const std::string& accept_languages) { | 157 const std::string& accept_languages) { |
| 305 this->entry_type = entry_type; | 158 this->entry_type = entry_type; |
| 306 this->url = url; | 159 this->url = url; |
| 307 this->title = title; | 160 this->title = title; |
| 308 this->time = time; | 161 this->time = time; |
| (...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1023 | 876 |
| 1024 void BrowsingHistoryHandler::OnURLsDeleted( | 877 void BrowsingHistoryHandler::OnURLsDeleted( |
| 1025 history::HistoryService* history_service, | 878 history::HistoryService* history_service, |
| 1026 bool all_history, | 879 bool all_history, |
| 1027 bool expired, | 880 bool expired, |
| 1028 const history::URLRows& deleted_rows, | 881 const history::URLRows& deleted_rows, |
| 1029 const std::set<GURL>& favicon_urls) { | 882 const std::set<GURL>& favicon_urls) { |
| 1030 if (all_history || DeletionsDiffer(deleted_rows, urls_to_be_deleted_)) | 883 if (all_history || DeletionsDiffer(deleted_rows, urls_to_be_deleted_)) |
| 1031 web_ui()->CallJavascriptFunction("historyDeleted"); | 884 web_ui()->CallJavascriptFunction("historyDeleted"); |
| 1032 } | 885 } |
| 1033 | |
| 1034 //////////////////////////////////////////////////////////////////////////////// | |
| 1035 // | |
| 1036 // HistoryUI | |
| 1037 // | |
| 1038 //////////////////////////////////////////////////////////////////////////////// | |
| 1039 | |
| 1040 HistoryUI::HistoryUI(content::WebUI* web_ui) : WebUIController(web_ui) { | |
| 1041 web_ui->AddMessageHandler(new BrowsingHistoryHandler()); | |
| 1042 web_ui->AddMessageHandler(new MetricsHandler()); | |
| 1043 | |
| 1044 // On mobile we deal with foreign sessions differently. | |
| 1045 #if !defined(OS_ANDROID) && !defined(OS_IOS) | |
| 1046 if (search::IsInstantExtendedAPIEnabled()) { | |
| 1047 web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler()); | |
| 1048 web_ui->AddMessageHandler(new HistoryLoginHandler()); | |
| 1049 } | |
| 1050 #endif | |
| 1051 | |
| 1052 // Set up the chrome://history-frame/ source. | |
| 1053 Profile* profile = Profile::FromWebUI(web_ui); | |
| 1054 content::WebUIDataSource::Add(profile, CreateHistoryUIHTMLSource(profile)); | |
| 1055 } | |
| 1056 | |
| 1057 HistoryUI::~HistoryUI() {} | |
| 1058 | |
| 1059 // static | |
| 1060 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes( | |
| 1061 ui::ScaleFactor scale_factor) { | |
| 1062 return ResourceBundle::GetSharedInstance(). | |
| 1063 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor); | |
| 1064 } | |
| OLD | NEW |