OLD | NEW |
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/md_history_ui.h" | 5 #include "chrome/browser/ui/webui/md_history_ui.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 source->AddBoolean(kShowMenuPromoKey, !MenuPromoShown(profile)); | 134 source->AddBoolean(kShowMenuPromoKey, !MenuPromoShown(profile)); |
135 | 135 |
136 bool group_by_domain = base::CommandLine::ForCurrentProcess()->HasSwitch( | 136 bool group_by_domain = base::CommandLine::ForCurrentProcess()->HasSwitch( |
137 switches::kHistoryEnableGroupByDomain) || profile->IsSupervised(); | 137 switches::kHistoryEnableGroupByDomain) || profile->IsSupervised(); |
138 source->AddBoolean("groupByDomain", group_by_domain); | 138 source->AddBoolean("groupByDomain", group_by_domain); |
139 | 139 |
140 source->AddBoolean("isGuestSession", profile->IsGuestSession()); | 140 source->AddBoolean("isGuestSession", profile->IsGuestSession()); |
141 | 141 |
142 source->AddBoolean(kIsUserSignedInKey, IsUserSignedIn(profile)); | 142 source->AddBoolean(kIsUserSignedInKey, IsUserSignedIn(profile)); |
143 | 143 |
144 source->AddResourcePath("constants.html", IDR_MD_HISTORY_CONSTANTS_HTML); | 144 struct UncompressedResource { |
145 source->AddResourcePath("constants.js", IDR_MD_HISTORY_CONSTANTS_JS); | 145 const char* path; |
146 source->AddResourcePath("images/100/sign_in_promo.jpg", | 146 int idr; |
147 IDR_MD_HISTORY_IMAGES_100_SIGN_IN_PROMO_JPG); | 147 }; |
148 source->AddResourcePath("images/200/sign_in_promo.jpg", | 148 const UncompressedResource uncompressed_resources[] = { |
149 IDR_MD_HISTORY_IMAGES_200_SIGN_IN_PROMO_JPG); | 149 {"constants.html", IDR_MD_HISTORY_CONSTANTS_HTML}, |
150 source->AddResourcePath("history.js", IDR_MD_HISTORY_HISTORY_JS); | 150 {"constants.js", IDR_MD_HISTORY_CONSTANTS_JS}, |
| 151 {"history.js", IDR_MD_HISTORY_HISTORY_JS}, |
| 152 {"images/100/sign_in_promo.jpg", |
| 153 IDR_MD_HISTORY_IMAGES_100_SIGN_IN_PROMO_JPG}, |
| 154 {"images/200/sign_in_promo.jpg", |
| 155 IDR_MD_HISTORY_IMAGES_200_SIGN_IN_PROMO_JPG}, |
| 156 #if !BUILDFLAG(USE_VULCANIZE) |
| 157 {"app.html", IDR_MD_HISTORY_APP_HTML}, |
| 158 {"app.js", IDR_MD_HISTORY_APP_JS}, |
| 159 {"browser_service.html", IDR_MD_HISTORY_BROWSER_SERVICE_HTML}, |
| 160 {"browser_service.js", IDR_MD_HISTORY_BROWSER_SERVICE_JS}, |
| 161 {"grouped_list.html", IDR_MD_HISTORY_GROUPED_LIST_HTML}, |
| 162 {"grouped_list.js", IDR_MD_HISTORY_GROUPED_LIST_JS}, |
| 163 {"history_item.html", IDR_MD_HISTORY_HISTORY_ITEM_HTML}, |
| 164 {"history_item.js", IDR_MD_HISTORY_HISTORY_ITEM_JS}, |
| 165 {"history_list.html", IDR_MD_HISTORY_HISTORY_LIST_HTML}, |
| 166 {"history_list.js", IDR_MD_HISTORY_HISTORY_LIST_JS}, |
| 167 {"history_list_behavior.html", IDR_MD_HISTORY_HISTORY_LIST_BEHAVIOR_HTML}, |
| 168 {"history_list_behavior.js", IDR_MD_HISTORY_HISTORY_LIST_BEHAVIOR_JS}, |
| 169 {"history_toolbar.html", IDR_MD_HISTORY_HISTORY_TOOLBAR_HTML}, |
| 170 {"history_toolbar.js", IDR_MD_HISTORY_HISTORY_TOOLBAR_JS}, |
| 171 {"icons.html", IDR_MD_HISTORY_ICONS_HTML}, |
| 172 {"lazy_load.html", IDR_MD_HISTORY_LAZY_LOAD_HTML}, |
| 173 {"list_container.html", IDR_MD_HISTORY_LIST_CONTAINER_HTML}, |
| 174 {"list_container.js", IDR_MD_HISTORY_LIST_CONTAINER_JS}, |
| 175 {"router.html", IDR_MD_HISTORY_ROUTER_HTML}, |
| 176 {"router.js", IDR_MD_HISTORY_ROUTER_JS}, |
| 177 {"searched_label.html", IDR_MD_HISTORY_SEARCHED_LABEL_HTML}, |
| 178 {"searched_label.js", IDR_MD_HISTORY_SEARCHED_LABEL_JS}, |
| 179 {"shared_style.html", IDR_MD_HISTORY_SHARED_STYLE_HTML}, |
| 180 {"shared_vars.html", IDR_MD_HISTORY_SHARED_VARS_HTML}, |
| 181 {"side_bar.html", IDR_MD_HISTORY_SIDE_BAR_HTML}, |
| 182 {"side_bar.js", IDR_MD_HISTORY_SIDE_BAR_JS}, |
| 183 {"synced_device_card.html", IDR_MD_HISTORY_SYNCED_DEVICE_CARD_HTML}, |
| 184 {"synced_device_card.js", IDR_MD_HISTORY_SYNCED_DEVICE_CARD_JS}, |
| 185 {"synced_device_manager.html", IDR_MD_HISTORY_SYNCED_DEVICE_MANAGER_HTML}, |
| 186 {"synced_device_manager.js", IDR_MD_HISTORY_SYNCED_DEVICE_MANAGER_JS}, |
| 187 #endif |
| 188 }; |
| 189 |
| 190 std::unordered_set<std::string> exclude_from_gzip; |
| 191 for (size_t i = 0; i < arraysize(uncompressed_resources); ++i) { |
| 192 const UncompressedResource& resource = uncompressed_resources[i]; |
| 193 source->AddResourcePath(resource.path, resource.idr); |
| 194 exclude_from_gzip.insert(resource.path); |
| 195 } |
| 196 source->UseGzip(exclude_from_gzip); |
151 | 197 |
152 #if BUILDFLAG(USE_VULCANIZE) | 198 #if BUILDFLAG(USE_VULCANIZE) |
153 source->AddResourcePath("app.html", | 199 source->AddResourcePath("app.html", |
154 IDR_MD_HISTORY_APP_VULCANIZED_HTML); | 200 IDR_MD_HISTORY_APP_VULCANIZED_HTML); |
155 source->AddResourcePath("app.crisper.js", | 201 source->AddResourcePath("app.crisper.js", |
156 IDR_MD_HISTORY_APP_CRISPER_JS); | 202 IDR_MD_HISTORY_APP_CRISPER_JS); |
157 source->AddResourcePath("lazy_load.html", | 203 source->AddResourcePath("lazy_load.html", |
158 IDR_MD_HISTORY_LAZY_LOAD_VULCANIZED_HTML); | 204 IDR_MD_HISTORY_LAZY_LOAD_VULCANIZED_HTML); |
159 source->AddResourcePath("lazy_load.crisper.js", | 205 source->AddResourcePath("lazy_load.crisper.js", |
160 IDR_MD_HISTORY_LAZY_LOAD_CRISPER_JS); | 206 IDR_MD_HISTORY_LAZY_LOAD_CRISPER_JS); |
161 #else | 207 #endif |
162 source->AddResourcePath("app.html", IDR_MD_HISTORY_APP_HTML); | |
163 source->AddResourcePath("app.js", IDR_MD_HISTORY_APP_JS); | |
164 source->AddResourcePath("browser_service.html", | |
165 IDR_MD_HISTORY_BROWSER_SERVICE_HTML); | |
166 source->AddResourcePath("browser_service.js", | |
167 IDR_MD_HISTORY_BROWSER_SERVICE_JS); | |
168 source->AddResourcePath("grouped_list.html", | |
169 IDR_MD_HISTORY_GROUPED_LIST_HTML); | |
170 source->AddResourcePath("grouped_list.js", IDR_MD_HISTORY_GROUPED_LIST_JS); | |
171 source->AddResourcePath("history_item.html", | |
172 IDR_MD_HISTORY_HISTORY_ITEM_HTML); | |
173 source->AddResourcePath("history_item.js", IDR_MD_HISTORY_HISTORY_ITEM_JS); | |
174 source->AddResourcePath("history_list.html", | |
175 IDR_MD_HISTORY_HISTORY_LIST_HTML); | |
176 source->AddResourcePath("history_list.js", IDR_MD_HISTORY_HISTORY_LIST_JS); | |
177 source->AddResourcePath("history_list_behavior.html", | |
178 IDR_MD_HISTORY_HISTORY_LIST_BEHAVIOR_HTML); | |
179 source->AddResourcePath("history_list_behavior.js", | |
180 IDR_MD_HISTORY_HISTORY_LIST_BEHAVIOR_JS); | |
181 source->AddResourcePath("history_toolbar.html", | |
182 IDR_MD_HISTORY_HISTORY_TOOLBAR_HTML); | |
183 source->AddResourcePath("history_toolbar.js", | |
184 IDR_MD_HISTORY_HISTORY_TOOLBAR_JS); | |
185 source->AddResourcePath("icons.html", IDR_MD_HISTORY_ICONS_HTML); | |
186 source->AddResourcePath("lazy_load.html", IDR_MD_HISTORY_LAZY_LOAD_HTML); | |
187 source->AddResourcePath("list_container.html", | |
188 IDR_MD_HISTORY_LIST_CONTAINER_HTML); | |
189 source->AddResourcePath("list_container.js", | |
190 IDR_MD_HISTORY_LIST_CONTAINER_JS); | |
191 source->AddResourcePath("router.html", | |
192 IDR_MD_HISTORY_ROUTER_HTML); | |
193 source->AddResourcePath("router.js", | |
194 IDR_MD_HISTORY_ROUTER_JS); | |
195 source->AddResourcePath("searched_label.html", | |
196 IDR_MD_HISTORY_SEARCHED_LABEL_HTML); | |
197 source->AddResourcePath("searched_label.js", | |
198 IDR_MD_HISTORY_SEARCHED_LABEL_JS); | |
199 source->AddResourcePath("shared_style.html", | |
200 IDR_MD_HISTORY_SHARED_STYLE_HTML); | |
201 source->AddResourcePath("shared_vars.html", | |
202 IDR_MD_HISTORY_SHARED_VARS_HTML); | |
203 source->AddResourcePath("side_bar.html", IDR_MD_HISTORY_SIDE_BAR_HTML); | |
204 source->AddResourcePath("side_bar.js", IDR_MD_HISTORY_SIDE_BAR_JS); | |
205 source->AddResourcePath("synced_device_card.html", | |
206 IDR_MD_HISTORY_SYNCED_DEVICE_CARD_HTML); | |
207 source->AddResourcePath("synced_device_card.js", | |
208 IDR_MD_HISTORY_SYNCED_DEVICE_CARD_JS); | |
209 source->AddResourcePath("synced_device_manager.html", | |
210 IDR_MD_HISTORY_SYNCED_DEVICE_MANAGER_HTML); | |
211 source->AddResourcePath("synced_device_manager.js", | |
212 IDR_MD_HISTORY_SYNCED_DEVICE_MANAGER_JS); | |
213 #endif // BUILDFLAG(USE_VULCANIZE) | |
214 | 208 |
215 source->SetDefaultResource(IDR_MD_HISTORY_HISTORY_HTML); | 209 source->SetDefaultResource(IDR_MD_HISTORY_HISTORY_HTML); |
216 source->SetJsonPath("strings.js"); | 210 source->SetJsonPath("strings.js"); |
217 | 211 |
218 return source; | 212 return source; |
219 } | 213 } |
220 | 214 |
221 } // namespace | 215 } // namespace |
222 | 216 |
223 bool MdHistoryUI::use_test_title_ = false; | 217 bool MdHistoryUI::use_test_title_ = false; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 | 269 |
276 content::WebUIDataSource::Update(profile, chrome::kChromeUIHistoryHost, | 270 content::WebUIDataSource::Update(profile, chrome::kChromeUIHistoryHost, |
277 std::move(update)); | 271 std::move(update)); |
278 } | 272 } |
279 | 273 |
280 void MdHistoryUI::HandleMenuPromoShown(const base::ListValue* args) { | 274 void MdHistoryUI::HandleMenuPromoShown(const base::ListValue* args) { |
281 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean( | 275 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean( |
282 prefs::kMdHistoryMenuPromoShown, true); | 276 prefs::kMdHistoryMenuPromoShown, true); |
283 UpdateDataSource(); | 277 UpdateDataSource(); |
284 } | 278 } |
OLD | NEW |