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

Side by Side Diff: ios/chrome/browser/ui/webui/history/history_ui.cc

Issue 1915473002: Add a testing switch to override the query for other forms of browsing history (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 8 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
« no previous file with comments | « ios/chrome/browser/BUILD.gn ('k') | ios/chrome/browser/ui/webui/history/history_ui.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ios/chrome/browser/ui/webui/history/history_ui.h"
6
7 #include "base/command_line.h"
8 #include "base/memory/ref_counted_memory.h"
9 #include "base/strings/string16.h"
10 #include "base/strings/utf_string_conversions.h"
11 #include "components/grit/components_scaled_resources.h"
12 #include "components/keyed_service/core/service_access_type.h"
13 #include "components/search/search.h"
14 #include "components/signin/core/browser/signin_manager.h"
15 #include "components/strings/grit/components_strings.h"
16 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
17 #include "ios/chrome/browser/chrome_switches.h"
18 #include "ios/chrome/browser/chrome_url_constants.h"
19 #include "ios/chrome/browser/history/web_history_service_factory.h"
20 #include "ios/chrome/browser/signin/signin_manager_factory.h"
21 #include "ios/chrome/browser/ui/webui/history/browsing_history_handler.h"
22 #include "ios/chrome/browser/ui/webui/history/metrics_handler.h"
23 #include "ios/chrome/grit/ios_resources.h"
24 #include "ios/public/provider/web/web_ui_ios.h"
25 #include "ios/web/public/web_ui_ios_data_source.h"
26 #include "ui/base/l10n/l10n_util.h"
27 #include "ui/base/resource/resource_bundle.h"
28
29 static const char kStringsJsFile[] = "strings.js";
30 static const char kHistoryJsFile[] = "history.js";
31 static const char kOtherDevicesJsFile[] = "other_devices.js";
32
33 namespace {
34
35 const char kIncognitoModeShortcut[] =
36 "("
37 "\xE2\x87\xA7" // Shift symbol (U+21E7 'UPWARDS WHITE ARROW').
38 "\xE2\x8C\x98" // Command symbol (U+2318 'PLACE OF INTEREST SIGN').
39 "N)";
40
41 web::WebUIIOSDataSource* CreateHistoryUIHTMLSource(
42 ios::ChromeBrowserState* browser_state) {
43 // Check if the browser state is authenticated. Incognito tabs may not have
44 // a sign in manager, and are considered not authenticated.
45 SigninManagerBase* signin_manager =
46 ios::SigninManagerFactory::GetForBrowserState(browser_state);
47 bool is_authenticated =
48 signin_manager != nullptr && signin_manager->IsAuthenticated();
49
50 web::WebUIIOSDataSource* source =
51 web::WebUIIOSDataSource::Create(kChromeUIHistoryFrameHost);
52 source->AddBoolean("isUserSignedIn", is_authenticated);
53 source->AddLocalizedString("collapseSessionMenuItemText",
54 IDS_HISTORY_OTHER_SESSIONS_COLLAPSE_SESSION);
55 source->AddLocalizedString("expandSessionMenuItemText",
56 IDS_HISTORY_OTHER_SESSIONS_EXPAND_SESSION);
57 source->AddLocalizedString("restoreSessionMenuItemText",
58 IDS_HISTORY_OTHER_SESSIONS_OPEN_ALL);
59 source->AddLocalizedString("xMore", IDS_HISTORY_OTHER_DEVICES_X_MORE);
60 source->AddLocalizedString("loading", IDS_HISTORY_LOADING);
61 source->AddLocalizedString("title", IDS_HISTORY_TITLE);
62 source->AddLocalizedString("newest", IDS_HISTORY_NEWEST);
63 source->AddLocalizedString("newer", IDS_HISTORY_NEWER);
64 source->AddLocalizedString("older", IDS_HISTORY_OLDER);
65 source->AddLocalizedString("searchResultsFor", IDS_HISTORY_SEARCHRESULTSFOR);
66 source->AddLocalizedString("searchResult", IDS_HISTORY_SEARCH_RESULT);
67 source->AddLocalizedString("searchResults", IDS_HISTORY_SEARCH_RESULTS);
68 source->AddLocalizedString("foundSearchResults",
69 IDS_HISTORY_FOUND_SEARCH_RESULTS);
70 source->AddLocalizedString("history", IDS_HISTORY_BROWSERESULTS);
71 source->AddLocalizedString("cont", IDS_HISTORY_CONTINUED);
72 source->AddLocalizedString("searchButton", IDS_HISTORY_SEARCH_BUTTON);
73 source->AddLocalizedString("noSearchResults", IDS_HISTORY_NO_SEARCH_RESULTS);
74 source->AddLocalizedString("noResults", IDS_HISTORY_NO_RESULTS);
75 source->AddLocalizedString("historyInterval", IDS_HISTORY_INTERVAL);
76 source->AddLocalizedString("removeSelected",
77 IDS_HISTORY_REMOVE_SELECTED_ITEMS);
78 source->AddLocalizedString("clearAllHistory",
79 IDS_HISTORY_OPEN_CLEAR_BROWSING_DATA_DIALOG);
80
81 base::string16 delete_warning =
82 l10n_util::GetStringFUTF16(IDS_HISTORY_DELETE_PRIOR_VISITS_WARNING,
83 base::UTF8ToUTF16(kIncognitoModeShortcut));
84 source->AddString("deleteWarning", delete_warning);
85
86 source->AddLocalizedString("removeBookmark", IDS_HISTORY_REMOVE_BOOKMARK);
87 source->AddLocalizedString("actionMenuDescription",
88 IDS_HISTORY_ACTION_MENU_DESCRIPTION);
89 source->AddLocalizedString("removeFromHistory", IDS_HISTORY_REMOVE_PAGE);
90 source->AddLocalizedString("moreFromSite", IDS_HISTORY_MORE_FROM_SITE);
91 source->AddLocalizedString("groupByDomainLabel",
92 IDS_HISTORY_GROUP_BY_DOMAIN_LABEL);
93 source->AddLocalizedString("rangeLabel", IDS_HISTORY_RANGE_LABEL);
94 source->AddLocalizedString("rangeAllTime", IDS_HISTORY_RANGE_ALL_TIME);
95 source->AddLocalizedString("rangeWeek", IDS_HISTORY_RANGE_WEEK);
96 source->AddLocalizedString("rangeMonth", IDS_HISTORY_RANGE_MONTH);
97 source->AddLocalizedString("rangeToday", IDS_HISTORY_RANGE_TODAY);
98 source->AddLocalizedString("rangeNext", IDS_HISTORY_RANGE_NEXT);
99 source->AddLocalizedString("rangePrevious", IDS_HISTORY_RANGE_PREVIOUS);
100 source->AddLocalizedString("numberVisits", IDS_HISTORY_NUMBER_VISITS);
101 source->AddLocalizedString("filterAllowed", IDS_HISTORY_FILTER_ALLOWED);
102 source->AddLocalizedString("filterBlocked", IDS_HISTORY_FILTER_BLOCKED);
103 source->AddLocalizedString("inContentPack", IDS_HISTORY_IN_CONTENT_PACK);
104 source->AddLocalizedString("allowItems", IDS_HISTORY_FILTER_ALLOW_ITEMS);
105 source->AddLocalizedString("blockItems", IDS_HISTORY_FILTER_BLOCK_ITEMS);
106 source->AddLocalizedString("blockedVisitText",
107 IDS_HISTORY_BLOCKED_VISIT_TEXT);
108 source->AddLocalizedString("hasSyncedResults",
109 IDS_HISTORY_HAS_SYNCED_RESULTS);
110 source->AddLocalizedString("noSyncedResults", IDS_HISTORY_NO_SYNCED_RESULTS);
111 source->AddString(
112 "otherFormsOfBrowsingHistory",
113 l10n_util::GetStringFUTF16(IDS_HISTORY_OTHER_FORMS_OF_HISTORY,
114 base::ASCIIToUTF16(kHistoryMyActivityURL)));
115 source->AddLocalizedString("cancel", IDS_CANCEL);
116 source->AddLocalizedString("deleteConfirm",
117 IDS_HISTORY_DELETE_PRIOR_VISITS_CONFIRM_BUTTON);
118 source->AddBoolean(
119 "isFullHistorySyncEnabled",
120 ios::WebHistoryServiceFactory::GetForBrowserState(browser_state) != NULL);
121 bool group_by_domain = base::CommandLine::ForCurrentProcess()->HasSwitch(
122 switches::kHistoryEnableGroupByDomain);
123 source->AddBoolean("groupByDomain", group_by_domain);
124 source->AddBoolean("allowDeletingHistory", true);
125 source->AddBoolean("isInstantExtendedApiEnabled",
126 search::IsInstantExtendedAPIEnabled());
127 source->AddBoolean("isSupervisedProfile", false);
128 source->AddBoolean("hideDeleteVisitUI", false);
129 source->SetJsonPath(kStringsJsFile);
130 source->AddResourcePath(kHistoryJsFile, IDR_IOS_HISTORY_JS);
131 source->AddResourcePath(kOtherDevicesJsFile,
132 IDR_IOS_HISTORY_OTHER_DEVICES_JS);
133 source->SetDefaultResource(IDR_IOS_HISTORY_HTML);
134 source->DisableDenyXFrameOptions();
135
136 return source;
137 }
138
139 } // namespace
140
141 HistoryUI::HistoryUI(web::WebUIIOS* web_ui) : web::WebUIIOSController(web_ui) {
142 web_ui->AddMessageHandler(new BrowsingHistoryHandler());
143 web_ui->AddMessageHandler(new MetricsHandler());
144
145 // Set up the chrome://history-frame/ source.
146 ios::ChromeBrowserState* browser_state =
147 ios::ChromeBrowserState::FromWebUIIOS(web_ui);
148 web::WebUIIOSDataSource::Add(browser_state,
149 CreateHistoryUIHTMLSource(browser_state));
150 }
151
152 HistoryUI::~HistoryUI() {}
153
154 // static
155 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes(
156 ui::ScaleFactor scale_factor) {
157 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale(
158 IDR_HISTORY_FAVICON, scale_factor);
159 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/BUILD.gn ('k') | ios/chrome/browser/ui/webui/history/history_ui.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698