| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/bind_helpers.h" |
| 5 #include "base/location.h" | 6 #include "base/location.h" |
| 7 #include "base/memory/scoped_ptr.h" |
| 6 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 8 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| 9 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 10 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.h" |
| 12 #include "chrome/browser/extensions/extension_apitest.h" | 14 #include "chrome/browser/extensions/extension_apitest.h" |
| 15 #include "chrome/browser/lifetime/keep_alive_types.h" |
| 16 #include "chrome/browser/lifetime/scoped_keep_alive.h" |
| 13 #include "chrome/browser/net/prediction_options.h" | 17 #include "chrome/browser/net/prediction_options.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 17 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
| 18 #include "chrome/test/base/ui_test_utils.h" | 22 #include "chrome/test/base/ui_test_utils.h" |
| 19 #include "components/autofill/core/common/autofill_pref_names.h" | 23 #include "components/autofill/core/common/autofill_pref_names.h" |
| 20 #include "components/content_settings/core/common/pref_names.h" | 24 #include "components/content_settings/core/common/pref_names.h" |
| 21 #include "components/password_manager/core/common/password_manager_pref_names.h" | 25 #include "components/password_manager/core/common/password_manager_pref_names.h" |
| 22 #include "components/prefs/pref_service.h" | 26 #include "components/prefs/pref_service.h" |
| 23 #include "components/translate/core/common/translate_pref_names.h" | 27 #include "components/translate/core/common/translate_pref_names.h" |
| 24 #include "content/public/browser/notification_service.h" | 28 #include "content/public/browser/notification_service.h" |
| 25 #include "content/public/common/webrtc_ip_handling_policy.h" | 29 #include "content/public/common/webrtc_ip_handling_policy.h" |
| 26 #include "extensions/browser/extension_registry.h" | 30 #include "extensions/browser/extension_registry.h" |
| 27 #include "extensions/browser/test_extension_registry_observer.h" | 31 #include "extensions/browser/test_extension_registry_observer.h" |
| 28 #include "extensions/test/extension_test_message_listener.h" | 32 #include "extensions/test/extension_test_message_listener.h" |
| 29 #include "extensions/test/result_catcher.h" | 33 #include "extensions/test/result_catcher.h" |
| 30 | 34 |
| 31 namespace { | |
| 32 | |
| 33 void ReleaseBrowserProcessModule() { | |
| 34 g_browser_process->ReleaseModule(); | |
| 35 } | |
| 36 | |
| 37 } // namespace | |
| 38 | |
| 39 class ExtensionPreferenceApiTest : public ExtensionApiTest { | 35 class ExtensionPreferenceApiTest : public ExtensionApiTest { |
| 40 protected: | 36 protected: |
| 41 ExtensionPreferenceApiTest() : profile_(NULL) {} | 37 ExtensionPreferenceApiTest() : profile_(NULL) {} |
| 42 | 38 |
| 43 void CheckPreferencesSet() { | 39 void CheckPreferencesSet() { |
| 44 PrefService* prefs = profile_->GetPrefs(); | 40 PrefService* prefs = profile_->GetPrefs(); |
| 45 const PrefService::Preference* pref = prefs->FindPreference( | 41 const PrefService::Preference* pref = prefs->FindPreference( |
| 46 prefs::kBlockThirdPartyCookies); | 42 prefs::kBlockThirdPartyCookies); |
| 47 ASSERT_TRUE(pref); | 43 ASSERT_TRUE(pref); |
| 48 EXPECT_TRUE(pref->IsExtensionControlled()); | 44 EXPECT_TRUE(pref->IsExtensionControlled()); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 void SetUpOnMainThread() override { | 79 void SetUpOnMainThread() override { |
| 84 ExtensionApiTest::SetUpOnMainThread(); | 80 ExtensionApiTest::SetUpOnMainThread(); |
| 85 | 81 |
| 86 // The browser might get closed later (and therefore be destroyed), so we | 82 // The browser might get closed later (and therefore be destroyed), so we |
| 87 // save the profile. | 83 // save the profile. |
| 88 profile_ = browser()->profile(); | 84 profile_ = browser()->profile(); |
| 89 | 85 |
| 90 // Closing the last browser window also releases a module reference. Make | 86 // Closing the last browser window also releases a module reference. Make |
| 91 // sure it's not the last one, so the message loop doesn't quit | 87 // sure it's not the last one, so the message loop doesn't quit |
| 92 // unexpectedly. | 88 // unexpectedly. |
| 93 g_browser_process->AddRefModule(); | 89 keep_alive_.reset(new ScopedKeepAlive(KeepAliveOrigin::BROWSER, |
| 90 KeepAliveRestartOption::DISABLED)); |
| 94 } | 91 } |
| 95 | 92 |
| 96 void TearDownOnMainThread() override { | 93 void TearDownOnMainThread() override { |
| 97 // ReleaseBrowserProcessModule() needs to be called in a message loop, so we | 94 // BrowserProcess::Shutdown() needs to be called in a message loop, so we |
| 98 // post a task to do it, then run the message loop. | 95 // post a task to release the keep alive, then run the message loop. |
| 99 base::ThreadTaskRunnerHandle::Get()->PostTask( | 96 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 100 FROM_HERE, base::Bind(&ReleaseBrowserProcessModule)); | 97 FROM_HERE, base::Bind(&scoped_ptr<ScopedKeepAlive>::reset, |
| 98 base::Unretained(&keep_alive_), nullptr)); |
| 101 content::RunAllPendingInMessageLoop(); | 99 content::RunAllPendingInMessageLoop(); |
| 102 | 100 |
| 103 ExtensionApiTest::TearDownOnMainThread(); | 101 ExtensionApiTest::TearDownOnMainThread(); |
| 104 } | 102 } |
| 105 | 103 |
| 106 Profile* profile_; | 104 Profile* profile_; |
| 105 scoped_ptr<ScopedKeepAlive> keep_alive_; |
| 107 }; | 106 }; |
| 108 | 107 |
| 109 // http://crbug.com/177163 | 108 // http://crbug.com/177163 |
| 110 #if defined(OS_WIN) && !defined(NDEBUG) | 109 #if defined(OS_WIN) && !defined(NDEBUG) |
| 111 #define MAYBE_Standard DISABLED_Standard | 110 #define MAYBE_Standard DISABLED_Standard |
| 112 #else | 111 #else |
| 113 #define MAYBE_Standard Standard | 112 #define MAYBE_Standard Standard |
| 114 #endif | 113 #endif |
| 115 IN_PROC_BROWSER_TEST_F(ExtensionPreferenceApiTest, MAYBE_Standard) { | 114 IN_PROC_BROWSER_TEST_F(ExtensionPreferenceApiTest, MAYBE_Standard) { |
| 116 PrefService* prefs = profile_->GetPrefs(); | 115 PrefService* prefs = profile_->GetPrefs(); |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 listener_incognito10.Reply("ok"); | 341 listener_incognito10.Reply("ok"); |
| 343 | 342 |
| 344 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 343 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 345 EXPECT_TRUE(catcher_incognito.GetNextResult()) << catcher.message(); | 344 EXPECT_TRUE(catcher_incognito.GetNextResult()) << catcher.message(); |
| 346 } | 345 } |
| 347 | 346 |
| 348 IN_PROC_BROWSER_TEST_F(ExtensionPreferenceApiTest, DataReductionProxy) { | 347 IN_PROC_BROWSER_TEST_F(ExtensionPreferenceApiTest, DataReductionProxy) { |
| 349 EXPECT_TRUE(RunExtensionTest("preference/data_reduction_proxy")) << | 348 EXPECT_TRUE(RunExtensionTest("preference/data_reduction_proxy")) << |
| 350 message_; | 349 message_; |
| 351 } | 350 } |
| OLD | NEW |