| 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/strings/utf_string_conversions.h" | 14 #include "base/strings/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/test/base/in_process_browser_test.h" | 18 #include "chrome/test/base/in_process_browser_test.h" |
| 19 #include "chrome/test/base/ui_test_utils.h" | 19 #include "chrome/test/base/ui_test_utils.h" |
| 20 #include "content/public/browser/browser_child_process_host_iterator.h" | 20 #include "content/public/browser/browser_child_process_host_iterator.h" |
| 21 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 22 #include "content/public/browser/child_process_data.h" | 22 #include "content/public/browser/child_process_data.h" |
| 23 #include "content/public/browser/plugin_service.h" | 23 #include "content/public/browser/plugin_service.h" |
| 24 #include "content/public/common/content_paths.h" | 24 #include "content/public/common/content_paths.h" |
| 25 #include "content/public/common/process_type.h" | 25 #include "content/public/common/process_type.h" |
| 26 #include "content/public/common/webplugininfo.h" |
| 26 #include "content/public/test/browser_test_utils.h" | 27 #include "content/public/test/browser_test_utils.h" |
| 27 #include "content/public/test/test_utils.h" | 28 #include "content/public/test/test_utils.h" |
| 28 #include "net/base/net_util.h" | 29 #include "net/base/net_util.h" |
| 29 #include "webkit/plugins/plugin_constants.h" | 30 #include "webkit/plugins/plugin_constants.h" |
| 30 #include "webkit/plugins/webplugininfo.h" | |
| 31 | 31 |
| 32 using content::BrowserThread; | 32 using content::BrowserThread; |
| 33 | 33 |
| 34 namespace { | 34 namespace { |
| 35 | 35 |
| 36 class CallbackBarrier : public base::RefCountedThreadSafe<CallbackBarrier> { | 36 class CallbackBarrier : public base::RefCountedThreadSafe<CallbackBarrier> { |
| 37 public: | 37 public: |
| 38 explicit CallbackBarrier(const base::Closure& target_callback) | 38 explicit CallbackBarrier(const base::Closure& target_callback) |
| 39 : target_callback_(target_callback), | 39 : target_callback_(target_callback), |
| 40 outstanding_callbacks_(0), | 40 outstanding_callbacks_(0), |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 new content::MessageLoopRunner; | 99 new content::MessageLoopRunner; |
| 100 BrowserThread::PostTask( | 100 BrowserThread::PostTask( |
| 101 BrowserThread::IO, | 101 BrowserThread::IO, |
| 102 FROM_HERE, | 102 FROM_HERE, |
| 103 base::Bind(&CrashFlashInternal, runner->QuitClosure())); | 103 base::Bind(&CrashFlashInternal, runner->QuitClosure())); |
| 104 runner->Run(); | 104 runner->Run(); |
| 105 } | 105 } |
| 106 | 106 |
| 107 static void GetFlashPath(std::vector<base::FilePath>* paths) { | 107 static void GetFlashPath(std::vector<base::FilePath>* paths) { |
| 108 paths->clear(); | 108 paths->clear(); |
| 109 std::vector<webkit::WebPluginInfo> plugins = GetPlugins(); | 109 std::vector<content::WebPluginInfo> plugins = GetPlugins(); |
| 110 for (std::vector<webkit::WebPluginInfo>::const_iterator it = | 110 for (std::vector<content::WebPluginInfo>::const_iterator it = |
| 111 plugins.begin(); it != plugins.end(); ++it) { | 111 plugins.begin(); it != plugins.end(); ++it) { |
| 112 if (it->name == ASCIIToUTF16(kFlashPluginName)) | 112 if (it->name == ASCIIToUTF16(kFlashPluginName)) |
| 113 paths->push_back(it->path); | 113 paths->push_back(it->path); |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 | 116 |
| 117 static std::vector<webkit::WebPluginInfo> GetPlugins() { | 117 static std::vector<content::WebPluginInfo> GetPlugins() { |
| 118 std::vector<webkit::WebPluginInfo> plugins; | 118 std::vector<content::WebPluginInfo> plugins; |
| 119 scoped_refptr<content::MessageLoopRunner> runner = | 119 scoped_refptr<content::MessageLoopRunner> runner = |
| 120 new content::MessageLoopRunner; | 120 new content::MessageLoopRunner; |
| 121 content::PluginService::GetInstance()->GetPlugins( | 121 content::PluginService::GetInstance()->GetPlugins( |
| 122 base::Bind(&GetPluginsInfoCallback, &plugins, runner->QuitClosure())); | 122 base::Bind(&GetPluginsInfoCallback, &plugins, runner->QuitClosure())); |
| 123 runner->Run(); | 123 runner->Run(); |
| 124 return plugins; | 124 return plugins; |
| 125 } | 125 } |
| 126 | 126 |
| 127 static void EnableFlash(bool enable, Profile* profile) { | 127 static void EnableFlash(bool enable, Profile* profile) { |
| 128 std::vector<base::FilePath> paths; | 128 std::vector<base::FilePath> paths; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 continue; | 163 continue; |
| 164 } | 164 } |
| 165 base::KillProcess(iter.GetData().handle, 0, true); | 165 base::KillProcess(iter.GetData().handle, 0, true); |
| 166 found = true; | 166 found = true; |
| 167 } | 167 } |
| 168 ASSERT_TRUE(found) << "Didn't find Flash process!"; | 168 ASSERT_TRUE(found) << "Didn't find Flash process!"; |
| 169 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, quit_task); | 169 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, quit_task); |
| 170 } | 170 } |
| 171 | 171 |
| 172 static void GetPluginsInfoCallback( | 172 static void GetPluginsInfoCallback( |
| 173 std::vector<webkit::WebPluginInfo>* rv, | 173 std::vector<content::WebPluginInfo>* rv, |
| 174 const base::Closure& quit_task, | 174 const base::Closure& quit_task, |
| 175 const std::vector<webkit::WebPluginInfo>& plugins) { | 175 const std::vector<content::WebPluginInfo>& plugins) { |
| 176 *rv = plugins; | 176 *rv = plugins; |
| 177 quit_task.Run(); | 177 quit_task.Run(); |
| 178 } | 178 } |
| 179 | 179 |
| 180 static void CountPluginProcesses(int* count, const base::Closure& quit_task) { | 180 static void CountPluginProcesses(int* count, const base::Closure& quit_task) { |
| 181 for (content::BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) { | 181 for (content::BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) { |
| 182 if (iter.GetData().process_type == content::PROCESS_TYPE_PLUGIN || | 182 if (iter.GetData().process_type == content::PROCESS_TYPE_PLUGIN || |
| 183 iter.GetData().process_type == content::PROCESS_TYPE_PPAPI_PLUGIN) { | 183 iter.GetData().process_type == content::PROCESS_TYPE_PPAPI_PLUGIN) { |
| 184 (*count)++; | 184 (*count)++; |
| 185 } | 185 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 "Shockwave Flash", | 245 "Shockwave Flash", |
| 246 "Native Client", | 246 "Native Client", |
| 247 "Chrome Remote Desktop Viewer", | 247 "Chrome Remote Desktop Viewer", |
| 248 #if defined(OS_CHROMEOS) | 248 #if defined(OS_CHROMEOS) |
| 249 "Google Talk Plugin", | 249 "Google Talk Plugin", |
| 250 "Google Talk Plugin Video Accelerator", | 250 "Google Talk Plugin Video Accelerator", |
| 251 "Netflix", | 251 "Netflix", |
| 252 #endif | 252 #endif |
| 253 }; | 253 }; |
| 254 | 254 |
| 255 std::vector<webkit::WebPluginInfo> plugins = GetPlugins(); | 255 std::vector<content::WebPluginInfo> plugins = GetPlugins(); |
| 256 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(expected); ++i) { | 256 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(expected); ++i) { |
| 257 size_t j = 0; | 257 size_t j = 0; |
| 258 for (; j < plugins.size(); ++j) { | 258 for (; j < plugins.size(); ++j) { |
| 259 if (plugins[j].name == ASCIIToUTF16(expected[i])) | 259 if (plugins[j].name == ASCIIToUTF16(expected[i])) |
| 260 break; | 260 break; |
| 261 } | 261 } |
| 262 ASSERT_TRUE(j != plugins.size()) << "Didn't find " << expected[i]; | 262 ASSERT_TRUE(j != plugins.size()) << "Didn't find " << expected[i]; |
| 263 } | 263 } |
| 264 } | 264 } |
| OLD | NEW |