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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
13 #include "base/process_util.h" | 13 #include "base/process_util.h" |
14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
15 #include "chrome/browser/plugins/plugin_prefs.h" | 15 #include "chrome/browser/plugins/plugin_prefs.h" |
16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
17 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 18 #include "chrome/common/chrome_process_type.h" |
18 #include "chrome/test/base/in_process_browser_test.h" | 19 #include "chrome/test/base/in_process_browser_test.h" |
19 #include "chrome/test/base/ui_test_utils.h" | 20 #include "chrome/test/base/ui_test_utils.h" |
20 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
21 #include "content/public/browser/browser_child_process_host_iterator.h" | 22 #include "content/public/browser/browser_child_process_host_iterator.h" |
22 #include "content/public/browser/child_process_data.h" | 23 #include "content/public/browser/child_process_data.h" |
23 #include "content/public/browser/plugin_service.h" | 24 #include "content/public/browser/plugin_service.h" |
24 #include "content/public/common/content_paths.h" | 25 #include "content/public/common/content_paths.h" |
25 #include "content/public/test/browser_test_utils.h" | 26 #include "content/public/test/browser_test_utils.h" |
26 #include "content/public/test/test_utils.h" | 27 #include "content/public/test/test_utils.h" |
27 #include "net/base/net_util.h" | 28 #include "net/base/net_util.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 FROM_HERE, | 151 FROM_HERE, |
151 base::Bind(&CountPluginProcesses, &actual, runner->QuitClosure())); | 152 base::Bind(&CountPluginProcesses, &actual, runner->QuitClosure())); |
152 runner->Run(); | 153 runner->Run(); |
153 ASSERT_EQ(expected, actual); | 154 ASSERT_EQ(expected, actual); |
154 } | 155 } |
155 | 156 |
156 private: | 157 private: |
157 static void CrashFlashInternal(const base::Closure& quit_task) { | 158 static void CrashFlashInternal(const base::Closure& quit_task) { |
158 bool found = false; | 159 bool found = false; |
159 for (content::BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) { | 160 for (content::BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) { |
160 if (iter.GetData().type != content::PROCESS_TYPE_PLUGIN && | 161 if (iter.GetData().process_type != content::PROCESS_TYPE_PLUGIN && |
161 iter.GetData().type != content::PROCESS_TYPE_PPAPI_PLUGIN) { | 162 iter.GetData().process_type != content::PROCESS_TYPE_PPAPI_PLUGIN) { |
162 continue; | 163 continue; |
163 } | 164 } |
164 base::KillProcess(iter.GetData().handle, 0, true); | 165 base::KillProcess(iter.GetData().handle, 0, true); |
165 found = true; | 166 found = true; |
166 } | 167 } |
167 ASSERT_TRUE(found) << "Didn't find Flash process!"; | 168 ASSERT_TRUE(found) << "Didn't find Flash process!"; |
168 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, quit_task); | 169 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, quit_task); |
169 } | 170 } |
170 | 171 |
171 static void GetPluginsInfoCallback( | 172 static void GetPluginsInfoCallback( |
172 std::vector<webkit::WebPluginInfo>* rv, | 173 std::vector<webkit::WebPluginInfo>* rv, |
173 const base::Closure& quit_task, | 174 const base::Closure& quit_task, |
174 const std::vector<webkit::WebPluginInfo>& plugins) { | 175 const std::vector<webkit::WebPluginInfo>& plugins) { |
175 *rv = plugins; | 176 *rv = plugins; |
176 quit_task.Run(); | 177 quit_task.Run(); |
177 } | 178 } |
178 | 179 |
179 static void CountPluginProcesses(int* count, const base::Closure& quit_task) { | 180 static void CountPluginProcesses(int* count, const base::Closure& quit_task) { |
180 for (content::BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) { | 181 for (content::BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) { |
181 if (iter.GetData().type == content::PROCESS_TYPE_PLUGIN || | 182 if (iter.GetData().process_type == content::PROCESS_TYPE_PLUGIN || |
182 iter.GetData().type == content::PROCESS_TYPE_PPAPI_PLUGIN) { | 183 iter.GetData().process_type == content::PROCESS_TYPE_PPAPI_PLUGIN) { |
183 (*count)++; | 184 (*count)++; |
184 } | 185 } |
185 } | 186 } |
186 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, quit_task); | 187 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, quit_task); |
187 } | 188 } |
188 }; | 189 }; |
189 | 190 |
190 // Tests a bunch of basic scenarios with Flash. | 191 // Tests a bunch of basic scenarios with Flash. |
191 // This test fails under ASan on Mac, see http://crbug.com/147004. | 192 // This test fails under ASan on Mac, see http://crbug.com/147004. |
192 // It fails elsewhere, too. See http://crbug.com/152071. | 193 // It fails elsewhere, too. See http://crbug.com/152071. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 std::vector<webkit::WebPluginInfo> plugins = GetPlugins(); | 255 std::vector<webkit::WebPluginInfo> plugins = GetPlugins(); |
255 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(expected); ++i) { | 256 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(expected); ++i) { |
256 size_t j = 0; | 257 size_t j = 0; |
257 for (; j < plugins.size(); ++j) { | 258 for (; j < plugins.size(); ++j) { |
258 if (plugins[j].name == ASCIIToUTF16(expected[i])) | 259 if (plugins[j].name == ASCIIToUTF16(expected[i])) |
259 break; | 260 break; |
260 } | 261 } |
261 ASSERT_TRUE(j != plugins.size()) << "Didn't find " << expected[i]; | 262 ASSERT_TRUE(j != plugins.size()) << "Didn't find " << expected[i]; |
262 } | 263 } |
263 } | 264 } |
OLD | NEW |