Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: chrome/browser/automation/testing_automation_provider.cc

Issue 10872034: Changing PluginPrefs to use PluginFinder's async interface. (Closed) Base URL: http://git.chromium.org/chromium/src.git@test_async
Patch Set: Fixed bug in chromeos loading the plugins page Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/chrome_plugin_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/automation/testing_automation_provider.h" 5 #include "chrome/browser/automation/testing_automation_provider.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 197
198 namespace { 198 namespace {
199 199
200 // Helper to reply asynchronously if |automation| is still valid. 200 // Helper to reply asynchronously if |automation| is still valid.
201 void SendSuccessReply(base::WeakPtr<AutomationProvider> automation, 201 void SendSuccessReply(base::WeakPtr<AutomationProvider> automation,
202 IPC::Message* reply_message) { 202 IPC::Message* reply_message) {
203 if (automation) 203 if (automation)
204 AutomationJSONReply(automation.get(), reply_message).SendSuccess(NULL); 204 AutomationJSONReply(automation.get(), reply_message).SendSuccess(NULL);
205 } 205 }
206 206
207 // Helper to process the result of CanEnablePlugin.
208 void DidEnablePlugin(base::WeakPtr<AutomationProvider> automation,
209 IPC::Message* reply_message,
210 const FilePath::StringType& path,
211 const std::string& error_msg,
212 bool did_enable) {
213 if (did_enable) {
214 SendSuccessReply(automation, reply_message);
215 } else {
216 if (automation) {
217 AutomationJSONReply(automation.get(), reply_message).SendError(
218 StringPrintf(error_msg.c_str(), path.c_str()));
219 }
220 }
221 }
222
207 // Helper to resolve the overloading of PostTask. 223 // Helper to resolve the overloading of PostTask.
208 void PostTask(BrowserThread::ID id, const base::Closure& callback) { 224 void PostTask(BrowserThread::ID id, const base::Closure& callback) {
209 BrowserThread::PostTask(id, FROM_HERE, callback); 225 BrowserThread::PostTask(id, FROM_HERE, callback);
210 } 226 }
211 227
212 void SendMouseClick(int flags) { 228 void SendMouseClick(int flags) {
213 ui_controls::MouseButton button = ui_controls::LEFT; 229 ui_controls::MouseButton button = ui_controls::LEFT;
214 if ((flags & ui::EF_LEFT_MOUSE_BUTTON) == 230 if ((flags & ui::EF_LEFT_MOUSE_BUTTON) ==
215 ui::EF_LEFT_MOUSE_BUTTON) { 231 ui::EF_LEFT_MOUSE_BUTTON) {
216 button = ui_controls::LEFT; 232 button = ui_controls::LEFT;
(...skipping 3093 matching lines...) Expand 10 before | Expand all | Expand 10 after
3310 // "path": "/Library/Internet Plug-Ins/Flash Player.plugin" } 3326 // "path": "/Library/Internet Plug-Ins/Flash Player.plugin" }
3311 void TestingAutomationProvider::EnablePlugin(Browser* browser, 3327 void TestingAutomationProvider::EnablePlugin(Browser* browser,
3312 DictionaryValue* args, 3328 DictionaryValue* args,
3313 IPC::Message* reply_message) { 3329 IPC::Message* reply_message) {
3314 FilePath::StringType path; 3330 FilePath::StringType path;
3315 if (!args->GetString("path", &path)) { 3331 if (!args->GetString("path", &path)) {
3316 AutomationJSONReply(this, reply_message).SendError("path not specified."); 3332 AutomationJSONReply(this, reply_message).SendError("path not specified.");
3317 return; 3333 return;
3318 } 3334 }
3319 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(browser->profile()); 3335 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(browser->profile());
3320 if (!plugin_prefs->CanEnablePlugin(true, FilePath(path))) { 3336 plugin_prefs->EnablePlugin(true, FilePath(path),
3321 AutomationJSONReply(this, reply_message).SendError( 3337 base::Bind(&DidEnablePlugin, AsWeakPtr(), reply_message,
3322 StringPrintf("Could not enable plugin for path %s.", path.c_str())); 3338 path, "Could not enable plugin for path %s."));
3323 return;
3324 }
3325 plugin_prefs->EnablePlugin(
3326 true, FilePath(path),
3327 base::Bind(SendSuccessReply, AsWeakPtr(), reply_message));
3328 } 3339 }
3329 3340
3330 // Sample json input: 3341 // Sample json input:
3331 // { "command": "DisablePlugin", 3342 // { "command": "DisablePlugin",
3332 // "path": "/Library/Internet Plug-Ins/Flash Player.plugin" } 3343 // "path": "/Library/Internet Plug-Ins/Flash Player.plugin" }
3333 void TestingAutomationProvider::DisablePlugin(Browser* browser, 3344 void TestingAutomationProvider::DisablePlugin(Browser* browser,
3334 DictionaryValue* args, 3345 DictionaryValue* args,
3335 IPC::Message* reply_message) { 3346 IPC::Message* reply_message) {
3336 FilePath::StringType path; 3347 FilePath::StringType path;
3337 if (!args->GetString("path", &path)) { 3348 if (!args->GetString("path", &path)) {
3338 AutomationJSONReply(this, reply_message).SendError("path not specified."); 3349 AutomationJSONReply(this, reply_message).SendError("path not specified.");
3339 return; 3350 return;
3340 } 3351 }
3341 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(browser->profile()); 3352 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(browser->profile());
3342 if (!plugin_prefs->CanEnablePlugin(false, FilePath(path))) { 3353 plugin_prefs->EnablePlugin(false, FilePath(path),
3343 AutomationJSONReply(this, reply_message).SendError( 3354 base::Bind(&DidEnablePlugin, AsWeakPtr(), reply_message,
3344 StringPrintf("Could not disable plugin for path %s.", path.c_str())); 3355 path, "Could not disable plugin for path %s."));
3345 return;
3346 }
3347 plugin_prefs->EnablePlugin(
3348 false, FilePath(path),
3349 base::Bind(SendSuccessReply, AsWeakPtr(), reply_message));
3350 } 3356 }
3351 3357
3352 // Sample json input: 3358 // Sample json input:
3353 // { "command": "SaveTabContents", 3359 // { "command": "SaveTabContents",
3354 // "tab_index": 0, 3360 // "tab_index": 0,
3355 // "filename": <a full pathname> } 3361 // "filename": <a full pathname> }
3356 // Sample json output: 3362 // Sample json output:
3357 // {} 3363 // {}
3358 void TestingAutomationProvider::SaveTabContents( 3364 void TestingAutomationProvider::SaveTabContents(
3359 Browser* browser, 3365 Browser* browser,
(...skipping 3076 matching lines...) Expand 10 before | Expand all | Expand 10 after
6436 void TestingAutomationProvider::OnRemoveProvider() { 6442 void TestingAutomationProvider::OnRemoveProvider() {
6437 if (g_browser_process) 6443 if (g_browser_process)
6438 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); 6444 g_browser_process->GetAutomationProviderList()->RemoveProvider(this);
6439 } 6445 }
6440 6446
6441 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, 6447 void TestingAutomationProvider::EnsureTabSelected(Browser* browser,
6442 WebContents* tab) { 6448 WebContents* tab) {
6443 if (chrome::GetActiveWebContents(browser) != tab) 6449 if (chrome::GetActiveWebContents(browser) != tab)
6444 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); 6450 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true);
6445 } 6451 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chrome_plugin_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698