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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16( | 104 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16( |
105 pass ? "plugin_not_found" : "OK")); | 105 pass ? "plugin_not_found" : "OK")); |
106 ui_test_utils::NavigateToURL(window, url); | 106 ui_test_utils::NavigateToURL(window, url); |
107 ASSERT_EQ(expected_title, title_watcher.WaitAndGetTitle()); | 107 ASSERT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
108 } | 108 } |
109 | 109 |
110 static void CrashFlash() { | 110 static void CrashFlash() { |
111 scoped_refptr<content::MessageLoopRunner> runner = | 111 scoped_refptr<content::MessageLoopRunner> runner = |
112 new content::MessageLoopRunner; | 112 new content::MessageLoopRunner; |
113 BrowserThread::PostTask( | 113 BrowserThread::PostTask( |
114 BrowserThread::IO, | 114 BrowserThread::IO, FROM_HERE, |
115 FROM_HERE, | 115 base::BindOnce(&CrashFlashInternal, runner->QuitClosure())); |
116 base::Bind(&CrashFlashInternal, runner->QuitClosure())); | |
117 runner->Run(); | 116 runner->Run(); |
118 } | 117 } |
119 | 118 |
120 static void GetFlashPath(std::vector<base::FilePath>* paths) { | 119 static void GetFlashPath(std::vector<base::FilePath>* paths) { |
121 paths->clear(); | 120 paths->clear(); |
122 std::vector<content::WebPluginInfo> plugins = GetPlugins(); | 121 std::vector<content::WebPluginInfo> plugins = GetPlugins(); |
123 for (std::vector<content::WebPluginInfo>::const_iterator it = | 122 for (std::vector<content::WebPluginInfo>::const_iterator it = |
124 plugins.begin(); it != plugins.end(); ++it) { | 123 plugins.begin(); it != plugins.end(); ++it) { |
125 if (it->name == base::ASCIIToUTF16(content::kFlashPluginName)) | 124 if (it->name == base::ASCIIToUTF16(content::kFlashPluginName)) |
126 paths->push_back(it->path); | 125 paths->push_back(it->path); |
127 } | 126 } |
128 } | 127 } |
129 | 128 |
130 static std::vector<content::WebPluginInfo> GetPlugins() { | 129 static std::vector<content::WebPluginInfo> GetPlugins() { |
131 std::vector<content::WebPluginInfo> plugins; | 130 std::vector<content::WebPluginInfo> plugins; |
132 scoped_refptr<content::MessageLoopRunner> runner = | 131 scoped_refptr<content::MessageLoopRunner> runner = |
133 new content::MessageLoopRunner; | 132 new content::MessageLoopRunner; |
134 content::PluginService::GetInstance()->GetPlugins( | 133 content::PluginService::GetInstance()->GetPlugins( |
135 base::Bind(&GetPluginsInfoCallback, &plugins, runner->QuitClosure())); | 134 base::Bind(&GetPluginsInfoCallback, &plugins, runner->QuitClosure())); |
136 runner->Run(); | 135 runner->Run(); |
137 return plugins; | 136 return plugins; |
138 } | 137 } |
139 | 138 |
140 static void EnsureFlashProcessCount(int expected) { | 139 static void EnsureFlashProcessCount(int expected) { |
141 int actual = 0; | 140 int actual = 0; |
142 scoped_refptr<content::MessageLoopRunner> runner = | 141 scoped_refptr<content::MessageLoopRunner> runner = |
143 new content::MessageLoopRunner; | 142 new content::MessageLoopRunner; |
144 BrowserThread::PostTask( | 143 BrowserThread::PostTask( |
145 BrowserThread::IO, | 144 BrowserThread::IO, FROM_HERE, |
146 FROM_HERE, | 145 base::BindOnce(&CountPluginProcesses, &actual, runner->QuitClosure())); |
147 base::Bind(&CountPluginProcesses, &actual, runner->QuitClosure())); | |
148 runner->Run(); | 146 runner->Run(); |
149 ASSERT_EQ(expected, actual); | 147 ASSERT_EQ(expected, actual); |
150 } | 148 } |
151 | 149 |
152 private: | 150 private: |
153 static void CrashFlashInternal(const base::Closure& quit_task) { | 151 static void CrashFlashInternal(const base::Closure& quit_task) { |
154 bool found = false; | 152 bool found = false; |
155 for (content::BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) { | 153 for (content::BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) { |
156 if (iter.GetData().process_type != content::PROCESS_TYPE_PPAPI_PLUGIN) | 154 if (iter.GetData().process_type != content::PROCESS_TYPE_PPAPI_PLUGIN) |
157 continue; | 155 continue; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 for (size_t i = 0; i < arraysize(expected); ++i) { | 227 for (size_t i = 0; i < arraysize(expected); ++i) { |
230 size_t j = 0; | 228 size_t j = 0; |
231 for (; j < plugins.size(); ++j) { | 229 for (; j < plugins.size(); ++j) { |
232 if (plugins[j].name == base::ASCIIToUTF16(expected[i])) | 230 if (plugins[j].name == base::ASCIIToUTF16(expected[i])) |
233 break; | 231 break; |
234 } | 232 } |
235 ASSERT_TRUE(j != plugins.size()) << "Didn't find " << expected[i]; | 233 ASSERT_TRUE(j != plugins.size()) << "Didn't find " << expected[i]; |
236 } | 234 } |
237 } | 235 } |
238 #endif | 236 #endif |
OLD | NEW |