| 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/process_util.h" | 8 #include "base/process_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/plugin_prefs.h" | 10 #include "chrome/browser/plugin_prefs.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 return plugins; | 77 return plugins; |
| 78 } | 78 } |
| 79 | 79 |
| 80 static void EnableFlash(bool enable, Profile* profile) { | 80 static void EnableFlash(bool enable, Profile* profile) { |
| 81 FilePath flash_path = GetFlashPath(); | 81 FilePath flash_path = GetFlashPath(); |
| 82 ASSERT_FALSE(flash_path.empty()); | 82 ASSERT_FALSE(flash_path.empty()); |
| 83 | 83 |
| 84 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile); | 84 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile); |
| 85 scoped_refptr<content::MessageLoopRunner> runner = | 85 scoped_refptr<content::MessageLoopRunner> runner = |
| 86 new content::MessageLoopRunner; | 86 new content::MessageLoopRunner; |
| 87 plugin_prefs->EnablePlugin(enable, flash_path, runner->QuitClosure()); | 87 plugin_prefs->EnablePlugin(enable, flash_path, |
| 88 base::Bind(&AssertPluginEnabled, runner)); |
| 88 runner->Run(); | 89 runner->Run(); |
| 89 } | 90 } |
| 90 | 91 |
| 91 static void EnsureFlashProcessCount(int expected) { | 92 static void EnsureFlashProcessCount(int expected) { |
| 92 int actual = 0; | 93 int actual = 0; |
| 93 scoped_refptr<content::MessageLoopRunner> runner = | 94 scoped_refptr<content::MessageLoopRunner> runner = |
| 94 new content::MessageLoopRunner; | 95 new content::MessageLoopRunner; |
| 95 BrowserThread::PostTask( | 96 BrowserThread::PostTask( |
| 96 BrowserThread::IO, | 97 BrowserThread::IO, |
| 97 FROM_HERE, | 98 FROM_HERE, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 125 | 126 |
| 126 static void CountPluginProcesses(int* count, const base::Closure& quit_task) { | 127 static void CountPluginProcesses(int* count, const base::Closure& quit_task) { |
| 127 for (content::BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) { | 128 for (content::BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) { |
| 128 if (iter.GetData().type == content::PROCESS_TYPE_PLUGIN || | 129 if (iter.GetData().type == content::PROCESS_TYPE_PLUGIN || |
| 129 iter.GetData().type == content::PROCESS_TYPE_PPAPI_PLUGIN) { | 130 iter.GetData().type == content::PROCESS_TYPE_PPAPI_PLUGIN) { |
| 130 (*count)++; | 131 (*count)++; |
| 131 } | 132 } |
| 132 } | 133 } |
| 133 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, quit_task); | 134 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, quit_task); |
| 134 } | 135 } |
| 136 |
| 137 static void AssertPluginEnabled( |
| 138 scoped_refptr<content::MessageLoopRunner> runner, |
| 139 bool did_enable) { |
| 140 ASSERT_TRUE(did_enable); |
| 141 runner->Quit(); |
| 142 } |
| 135 }; | 143 }; |
| 136 | 144 |
| 137 // Tests a bunch of basic scenarios with Flash. | 145 // Tests a bunch of basic scenarios with Flash. |
| 138 IN_PROC_BROWSER_TEST_F(ChromePluginTest, Flash) { | 146 IN_PROC_BROWSER_TEST_F(ChromePluginTest, Flash) { |
| 139 // Official builds always have bundled Flash. | 147 // Official builds always have bundled Flash. |
| 140 #if !defined(OFFICIAL_BUILD) | 148 #if !defined(OFFICIAL_BUILD) |
| 141 if (GetFlashPath().empty()) { | 149 if (GetFlashPath().empty()) { |
| 142 LOG(INFO) << "Test not running because couldn't find Flash."; | 150 LOG(INFO) << "Test not running because couldn't find Flash."; |
| 143 return; | 151 return; |
| 144 } | 152 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 std::vector<webkit::WebPluginInfo> plugins = GetPlugins(); | 205 std::vector<webkit::WebPluginInfo> plugins = GetPlugins(); |
| 198 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(expected); ++i) { | 206 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(expected); ++i) { |
| 199 size_t j = 0; | 207 size_t j = 0; |
| 200 for (; j < plugins.size(); ++j) { | 208 for (; j < plugins.size(); ++j) { |
| 201 if (plugins[j].name == ASCIIToUTF16(expected[i])) | 209 if (plugins[j].name == ASCIIToUTF16(expected[i])) |
| 202 break; | 210 break; |
| 203 } | 211 } |
| 204 ASSERT_TRUE(j != plugins.size()) << "Didn't find " << expected[i]; | 212 ASSERT_TRUE(j != plugins.size()) << "Didn't find " << expected[i]; |
| 205 } | 213 } |
| 206 } | 214 } |
| OLD | NEW |