#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/chrome_notification_types.h"
-#include "chrome/browser/common/cancelable_request.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
#include "chrome/common/chrome_switches.h"
-#include "chrome/common/pref_names.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/infobars/core/confirm_infobar_delegate.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/test/browser_test_utils.h"
-#include "grit/generated_resources.h"
#include "testing/gmock/include/gmock/gmock.h"
-#include "ui/base/l10n/l10n_util.h"
using content::InterstitialPage;
using content::NavigationController;
};
SupervisedUserBlockModeTest() : supervised_user_service_(NULL) {}
- virtual ~SupervisedUserBlockModeTest() {}
+ ~SupervisedUserBlockModeTest() override {}
void CheckShownPageIsInterstitial(WebContents* tab) {
CheckShownPage(tab, content::PAGE_TYPE_INTERSTITIAL);
}
protected:
- virtual void SetUpOnMainThread() OVERRIDE {
+ void SetUpOnMainThread() override {
// Set up the SupervisedUserNavigationObserver manually since the profile
// was not supervised when the browser was created.
content::WebContents* web_contents =
new base::FundamentalValue(SupervisedUserURLFilter::BLOCK)));
}
- virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
+ void SetUpCommandLine(CommandLine* command_line) override {
// Enable the test server and remap all URLs to it.
ASSERT_TRUE(test_server()->Start());
std::string host_port = test_server()->host_port_pair().ToString();
const std::string& text_query,
const history::QueryOptions& options,
history::QueryResults* results) {
- CancelableRequestConsumer history_request_consumer;
base::RunLoop run_loop;
+ base::CancelableTaskTracker history_task_tracker;
history_service->QueryHistory(
base::UTF8ToUTF16(text_query),
options,
- &history_request_consumer,
base::Bind(&SupervisedUserBlockModeTest::QueryHistoryComplete,
base::Unretained(this),
results,
- &run_loop));
+ &run_loop),
+ &history_task_tracker);
run_loop.Run(); // Will go until ...Complete calls Quit.
}
void QueryHistoryComplete(history::QueryResults* new_results,
base::RunLoop* run_loop,
- HistoryService::Handle /* handle */,
history::QueryResults* results) {
results->Swap(new_results);
run_loop->Quit(); // Will return out to QueryHistory.
// On pressing the "back" button, the new tab should be closed, and we should
// get back to the previous active tab.
MockTabStripModelObserver observer(tab_strip);
+ base::RunLoop run_loop;
EXPECT_CALL(observer,
- TabClosingAt(tab_strip, tab, tab_strip->active_index()));
+ TabClosingAt(tab_strip, tab, tab_strip->active_index()))
+ .WillOnce(testing::InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
GoBack(tab);
+ run_loop.Run();
EXPECT_EQ(prev_tab, tab_strip->GetActiveWebContents());
}
HistoryVisitRecorded) {
GURL allowed_url("http://www.example.com/files/simple.html");
+ scoped_refptr<SupervisedUserURLFilter> filter =
+ supervised_user_service_->GetURLFilterForUIThread();
+
// Set the host as allowed.
scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
dict->SetBooleanWithoutPathExpansion(allowed_url.host(), true);
SupervisedUserSettingsServiceFactory::GetForProfile(
browser()->profile());
supervised_user_settings_service->SetLocalSettingForTesting(
- supervised_users::kContentPackManualBehaviorHosts,
- dict.PassAs<base::Value>());
- EXPECT_EQ(
- SupervisedUserService::MANUAL_ALLOW,
- supervised_user_service_->GetManualBehaviorForHost(allowed_url.host()));
+ supervised_users::kContentPackManualBehaviorHosts, dict.Pass());
+ EXPECT_EQ(SupervisedUserURLFilter::ALLOW,
+ filter->GetFilteringBehaviorForURL(allowed_url));
+ EXPECT_EQ(SupervisedUserURLFilter::ALLOW,
+ filter->GetFilteringBehaviorForURL(allowed_url.GetWithEmptyPath()));
ui_test_utils::NavigateToURL(browser(), allowed_url);
// Check that we went back to the first URL and that the manual behaviors
// have not changed.
EXPECT_EQ(allowed_url.spec(), tab->GetURL().spec());
- EXPECT_EQ(SupervisedUserService::MANUAL_ALLOW,
- supervised_user_service_->GetManualBehaviorForHost(
- "www.example.com"));
- EXPECT_EQ(
- SupervisedUserService::MANUAL_NONE,
- supervised_user_service_->GetManualBehaviorForHost(
- "www.new-example.com"));
+ EXPECT_EQ(SupervisedUserURLFilter::ALLOW,
+ filter->GetFilteringBehaviorForURL(allowed_url.GetWithEmptyPath()));
+ EXPECT_EQ(SupervisedUserURLFilter::BLOCK,
+ filter->GetFilteringBehaviorForURL(blocked_url.GetWithEmptyPath()));
// Query the history entry.
HistoryService* history_service = HistoryServiceFactory::GetForProfile(
SupervisedUserSettingsServiceFactory::GetForProfile(
browser()->profile());
supervised_user_settings_service->SetLocalSettingForTesting(
- supervised_users::kContentPackManualBehaviorHosts,
- dict.PassAs<base::Value>());
- EXPECT_EQ(
- SupervisedUserService::MANUAL_ALLOW,
- supervised_user_service_->GetManualBehaviorForHost(test_url.host()));
+ supervised_users::kContentPackManualBehaviorHosts, dict.Pass());
+
+ scoped_refptr<SupervisedUserURLFilter> filter =
+ supervised_user_service_->GetURLFilterForUIThread();
+ EXPECT_EQ(SupervisedUserURLFilter::ALLOW,
+ filter->GetFilteringBehaviorForURL(test_url.GetWithEmptyPath()));
observer.Wait();
EXPECT_EQ(test_url, web_contents->GetURL());