#include "base/prefs/pref_service.h"
#include "chrome/browser/extensions/extension_apitest.h"
+#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/prefs/proxy_config_dictionary.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "extensions/common/extension.h"
+#include "extensions/test/result_catcher.h"
namespace extensions {
ASSERT_TRUE(pref != NULL);
EXPECT_FALSE(pref->IsExtensionControlled());
}
+
+ bool SetIsIncognitoEnabled(bool enabled) {
+ ResultCatcher catcher;
+ extensions::util::SetIsIncognitoEnabled(
+ GetSingleLoadedExtension()->id(), browser()->profile(), enabled);
+ if (!catcher.GetNextResult()) {
+ message_ = catcher.message();
+ return false;
+ }
+ return true;
+ }
};
// Tests direct connection settings.
PrefService* pref_service = browser()->profile()->GetPrefs();
ValidateSettings(ProxyPrefs::MODE_DIRECT, kNoServer, kNoBypass, kNoPac,
pref_service);
+
+ // As the extension is executed with incognito permission, the settings
+ // should propagate to incognito mode.
+ pref_service = browser()->profile()->GetOffTheRecordProfile()->GetPrefs();
+ ValidateSettings(ProxyPrefs::MODE_DIRECT, kNoServer, kNoBypass, kNoPac,
+ pref_service);
}
// Tests auto-detect settings.
PrefService* pref_service = browser()->profile()->GetPrefs();
ValidateSettings(ProxyPrefs::MODE_PAC_SCRIPT, kNoServer, kNoBypass,
"http://wpad/windows.pac", pref_service);
+
+ // As the extension is not executed with incognito permission, the settings
+ // should not propagate to incognito mode.
+ pref_service = browser()->profile()->GetOffTheRecordProfile()->GetPrefs();
+ ExpectNoSettings(pref_service);
+
+ // Now we enable the extension in incognito mode and verify that settings
+ // are applied.
+ ASSERT_TRUE(SetIsIncognitoEnabled(true));
+ ValidateSettings(ProxyPrefs::MODE_PAC_SCRIPT, kNoServer, kNoBypass,
+ "http://wpad/windows.pac", pref_service);
+
+ // Disabling incognito permission should revoke the settings for incognito
+ // mode.
+ ASSERT_TRUE(SetIsIncognitoEnabled(false));
+ ExpectNoSettings(pref_service);
}
// Tests PAC proxy settings.