| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <stdint.h> | 7 #include <stdint.h> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 handler.RegisterMessages(); | 290 handler.RegisterMessages(); |
| 291 sync_service()->SetSyncActive(true); | 291 sync_service()->SetSyncActive(true); |
| 292 | 292 |
| 293 web_history_service()->ExpireHistoryBetween(std::set<GURL>(), base::Time(), | 293 web_history_service()->ExpireHistoryBetween(std::set<GURL>(), base::Time(), |
| 294 base::Time::Max(), callback); | 294 base::Time::Max(), callback); |
| 295 | 295 |
| 296 EXPECT_EQ(2U, web_ui()->call_data().size()); | 296 EXPECT_EQ(2U, web_ui()->call_data().size()); |
| 297 EXPECT_EQ("historyDeleted", web_ui()->call_data().back()->function_name()); | 297 EXPECT_EQ("historyDeleted", web_ui()->call_data().back()->function_name()); |
| 298 } | 298 } |
| 299 | 299 |
| 300 // BrowsingHistoryHandler does not fire historyDeleted while a web history |
| 301 // delete request is happening. |
| 302 { |
| 303 sync_service()->SetSyncActive(true); |
| 304 BrowsingHistoryHandlerWithWebUIForTesting handler(web_ui()); |
| 305 handler.RegisterMessages(); |
| 306 |
| 307 // Simulate an ongoing delete request. |
| 308 handler.has_pending_delete_request_ = true; |
| 309 |
| 310 web_history_service()->ExpireHistoryBetween( |
| 311 std::set<GURL>(), base::Time(), base::Time::Max(), |
| 312 base::Bind(&BrowsingHistoryHandler::RemoveWebHistoryComplete, |
| 313 handler.weak_factory_.GetWeakPtr())); |
| 314 |
| 315 EXPECT_EQ(3U, web_ui()->call_data().size()); |
| 316 EXPECT_EQ("deleteComplete", web_ui()->call_data().back()->function_name()); |
| 317 } |
| 318 |
| 300 // When history sync is not active, we don't listen to WebHistoryService | 319 // When history sync is not active, we don't listen to WebHistoryService |
| 301 // deletions. The WebHistoryService object still exists (because it's a | 320 // deletions. The WebHistoryService object still exists (because it's a |
| 302 // BrowserContextKeyedService), but is not visible to BrowsingHistoryHandler. | 321 // BrowserContextKeyedService), but is not visible to BrowsingHistoryHandler. |
| 303 { | 322 { |
| 304 sync_service()->SetSyncActive(false); | 323 sync_service()->SetSyncActive(false); |
| 305 BrowsingHistoryHandlerWithWebUIForTesting handler(web_ui()); | 324 BrowsingHistoryHandlerWithWebUIForTesting handler(web_ui()); |
| 306 handler.RegisterMessages(); | 325 handler.RegisterMessages(); |
| 307 | 326 |
| 308 web_history_service()->ExpireHistoryBetween(std::set<GURL>(), base::Time(), | 327 web_history_service()->ExpireHistoryBetween(std::set<GURL>(), base::Time(), |
| 309 base::Time::Max(), callback); | 328 base::Time::Max(), callback); |
| 310 | 329 |
| 311 // No additional WebUI calls were made. | 330 // No additional WebUI calls were made. |
| 312 EXPECT_EQ(2U, web_ui()->call_data().size()); | 331 EXPECT_EQ(3U, web_ui()->call_data().size()); |
| 313 } | 332 } |
| 314 } | 333 } |
| 315 | 334 |
| 316 #if !defined(OS_ANDROID) | 335 #if !defined(OS_ANDROID) |
| 317 TEST_F(BrowsingHistoryHandlerTest, MdTruncatesTitles) { | 336 TEST_F(BrowsingHistoryHandlerTest, MdTruncatesTitles) { |
| 318 MdHistoryUI::SetEnabledForTesting(true); | 337 MdHistoryUI::SetEnabledForTesting(true); |
| 319 | 338 |
| 320 history::URLResult long_result( | 339 history::URLResult long_result( |
| 321 GURL("http://looooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" | 340 GURL("http://looooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" |
| 322 "oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" | 341 "oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 342 const base::DictionaryValue* first_entry; | 361 const base::DictionaryValue* first_entry; |
| 343 ASSERT_TRUE(arg2->GetDictionary(0, &first_entry)); | 362 ASSERT_TRUE(arg2->GetDictionary(0, &first_entry)); |
| 344 | 363 |
| 345 base::string16 title; | 364 base::string16 title; |
| 346 ASSERT_TRUE(first_entry->GetString("title", &title)); | 365 ASSERT_TRUE(first_entry->GetString("title", &title)); |
| 347 | 366 |
| 348 ASSERT_EQ(0u, title.find(base::ASCIIToUTF16("http://loooo"))); | 367 ASSERT_EQ(0u, title.find(base::ASCIIToUTF16("http://loooo"))); |
| 349 EXPECT_EQ(300u, title.size()); | 368 EXPECT_EQ(300u, title.size()); |
| 350 } | 369 } |
| 351 #endif | 370 #endif |
| OLD | NEW |