OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/plugin_data_remover.h" |
| 6 |
| 7 #include "base/command_line.h" |
| 8 #include "base/path_service.h" |
| 9 #include "base/synchronization/waitable_event_watcher.h" |
| 10 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/prefs/pref_service.h" |
| 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/common/chrome_paths.h" |
| 15 #include "chrome/common/chrome_switches.h" |
| 16 #include "chrome/common/pref_names.h" |
| 17 #include "chrome/test/in_process_browser_test.h" |
| 18 #include "chrome/test/ui_test_utils.h" |
| 19 |
| 20 namespace { |
| 21 const char* kNPAPITestPluginMimeType = "application/vnd.npapi-test"; |
| 22 } |
| 23 |
| 24 class PluginDataRemoverTest : public InProcessBrowserTest, |
| 25 public base::WaitableEventWatcher::Delegate { |
| 26 public: |
| 27 PluginDataRemoverTest() : InProcessBrowserTest() { } |
| 28 |
| 29 virtual void SetUpOnMainThread() { |
| 30 old_plugin_data_remover_mime_type_ = |
| 31 g_browser_process->plugin_data_remover_mime_type(); |
| 32 g_browser_process->set_plugin_data_remover_mime_type( |
| 33 kNPAPITestPluginMimeType); |
| 34 } |
| 35 |
| 36 virtual void TearDownOnMainThread() { |
| 37 g_browser_process->set_plugin_data_remover_mime_type( |
| 38 old_plugin_data_remover_mime_type_); |
| 39 } |
| 40 |
| 41 virtual void OnWaitableEventSignaled(base::WaitableEvent* waitable_event) { |
| 42 MessageLoop::current()->Quit(); |
| 43 } |
| 44 |
| 45 virtual void SetUpCommandLine(CommandLine* command_line) { |
| 46 #ifdef OS_MACOSX |
| 47 FilePath browser_directory; |
| 48 PathService::Get(chrome::DIR_APP, &browser_directory); |
| 49 command_line->AppendSwitchPath(switches::kExtraPluginDir, |
| 50 browser_directory.AppendASCII("plugins")); |
| 51 #endif |
| 52 |
| 53 // command_line->AppendSwitch(switches::kPluginStartupDialog); |
| 54 } |
| 55 |
| 56 private: |
| 57 std::string old_plugin_data_remover_mime_type_; |
| 58 }; |
| 59 |
| 60 IN_PROC_BROWSER_TEST_F(PluginDataRemoverTest, RemoveData) { |
| 61 scoped_refptr<PluginDataRemover> plugin_data_remover(new PluginDataRemover()); |
| 62 plugin_data_remover->set_mime_type(kNPAPITestPluginMimeType); |
| 63 base::WaitableEventWatcher watcher; |
| 64 base::WaitableEvent* event = |
| 65 plugin_data_remover->StartRemoving(base::Time()); |
| 66 watcher.StartWatching(event, this); |
| 67 ui_test_utils::RunMessageLoop(); |
| 68 } |
| 69 |
| 70 IN_PROC_BROWSER_TEST_F(PluginDataRemoverTest, AtShutdown) { |
| 71 browser()->profile()->GetPrefs()->SetBoolean( |
| 72 prefs::kClearSiteDataOnExit, true); |
| 73 g_browser_process->local_state()->SetBoolean( |
| 74 prefs::kClearPluginLSODataEnabled, true); |
| 75 } |
OLD | NEW |