Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / supervised_user / supervised_user_browsertest.cc
index 10dfdcd..213e0b5 100644 (file)
@@ -22,7 +22,6 @@
 #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"
@@ -54,7 +53,7 @@ class SupervisedUserBlockModeTest : public InProcessBrowserTest {
   };
 
   SupervisedUserBlockModeTest() : supervised_user_service_(NULL) {}
-  virtual ~SupervisedUserBlockModeTest() {}
+  ~SupervisedUserBlockModeTest() override {}
 
   void CheckShownPageIsInterstitial(WebContents* tab) {
     CheckShownPage(tab, content::PAGE_TYPE_INTERSTITIAL);
@@ -97,7 +96,7 @@ class SupervisedUserBlockModeTest : public InProcessBrowserTest {
   }
 
  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 =
@@ -115,7 +114,7 @@ class SupervisedUserBlockModeTest : public InProcessBrowserTest {
             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();
@@ -228,6 +227,9 @@ IN_PROC_BROWSER_TEST_F(SupervisedUserBlockModeTest,
                        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);
@@ -235,11 +237,11 @@ IN_PROC_BROWSER_TEST_F(SupervisedUserBlockModeTest,
       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);
 
@@ -259,13 +261,10 @@ IN_PROC_BROWSER_TEST_F(SupervisedUserBlockModeTest,
   // 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(
@@ -302,11 +301,12 @@ IN_PROC_BROWSER_TEST_F(SupervisedUserBlockModeTest, Unblock) {
       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());