OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/test/data/webui/history_ui_browsertest.h" | 5 #include "chrome/test/data/webui/history_ui_browsertest.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/history/history_service_factory.h" | 8 #include "chrome/browser/history/history_service_factory.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
11 #include "chrome/common/pref_names.h" | 11 #include "chrome/common/pref_names.h" |
12 #include "chrome/test/base/ui_test_utils.h" | 12 #include "chrome/test/base/ui_test_utils.h" |
13 #include "components/history/core/browser/history_service.h" | 13 #include "components/history/core/browser/history_service.h" |
14 #include "components/prefs/pref_service.h" | 14 #include "components/prefs/pref_service.h" |
15 | 15 |
16 HistoryUIBrowserTest::HistoryUIBrowserTest() | 16 HistoryUIBrowserTest::HistoryUIBrowserTest() : history_(nullptr) {} |
17 : history_(NULL), | 17 HistoryUIBrowserTest::~HistoryUIBrowserTest() {} |
18 baseline_time_(base::Time::Now().LocalMidnight()), | |
19 nav_entry_id_(0) { | |
20 } | |
21 | |
22 HistoryUIBrowserTest::~HistoryUIBrowserTest() { | |
23 } | |
24 | 18 |
25 void HistoryUIBrowserTest::SetUpOnMainThread() { | 19 void HistoryUIBrowserTest::SetUpOnMainThread() { |
26 WebUIBrowserTest::SetUpOnMainThread(); | 20 WebUIBrowserTest::SetUpOnMainThread(); |
27 | 21 |
28 history_ = HistoryServiceFactory::GetForProfile( | 22 history_ = HistoryServiceFactory::GetForProfile( |
29 browser()->profile(), ServiceAccessType::EXPLICIT_ACCESS); | 23 browser()->profile(), ServiceAccessType::EXPLICIT_ACCESS); |
30 ui_test_utils::WaitForHistoryToLoad(history_); | 24 ui_test_utils::WaitForHistoryToLoad(history_); |
31 } | 25 } |
32 | 26 |
33 void HistoryUIBrowserTest::AddPageToHistory( | |
34 int hour_offset, const std::string& url, const std::string& title) { | |
35 // We need the ID scope and page ID so that the visit tracker can find it. | |
36 const history::ContextID id_scope = reinterpret_cast<history::ContextID>(1); | |
37 | |
38 base::Time time = baseline_time_ + base::TimeDelta::FromHours(hour_offset); | |
39 GURL gurl = GURL(url); | |
40 history_->AddPage(gurl, time, id_scope, nav_entry_id_++, GURL(), | |
41 history::RedirectList(), ui::PAGE_TRANSITION_LINK, | |
42 history::SOURCE_BROWSED, false); | |
43 history_->SetPageTitle(gurl, base::UTF8ToUTF16(title)); | |
44 } | |
45 | |
46 void HistoryUIBrowserTest::SetDeleteAllowed(bool allowed) { | 27 void HistoryUIBrowserTest::SetDeleteAllowed(bool allowed) { |
47 browser()->profile()->GetPrefs()-> | 28 browser()->profile()->GetPrefs()-> |
48 SetBoolean(prefs::kAllowDeletingBrowserHistory, allowed); | 29 SetBoolean(prefs::kAllowDeletingBrowserHistory, allowed); |
49 } | 30 } |
50 | |
51 void HistoryUIBrowserTest::ClearAcceptLanguages() { | |
52 browser()->profile()->GetPrefs()-> | |
53 SetString(prefs::kAcceptLanguages, ""); | |
54 } | |
55 | |
OLD | NEW |