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

Unified 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: Converted PluginPref#CanEnablePlugin to use PluginFinder's async interface. Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/plugin_prefs.h » ('j') | chrome/browser/plugin_prefs.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/automation/testing_automation_provider.cc
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index ffb1274d2025b6f313e645eaa55af04b8fa906c5..7da7461c4a7e445b5f1bce0f8b5713231bd14a0e 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -206,6 +206,25 @@ void SendSuccessReply(base::WeakPtr<AutomationProvider> automation,
AutomationJSONReply(automation.get(), reply_message).SendSuccess(NULL);
}
+// Helper to process the result of CanEnablePlugin.
+void CanEnablePluginCallback(base::WeakPtr<AutomationProvider> automation,
+ IPC::Message* reply_message,
+ bool enable,
+ const FilePath::StringType& path,
+ const std::string& error_msg,
+ scoped_refptr<PluginPrefs> prefs,
+ bool can_enable) {
+ if (!can_enable) {
+ if (automation)
Bernhard Bauer 2012/08/24 08:15:34 Nit: braces please.
ibraaaa 2012/08/24 15:51:29 Done.
+ AutomationJSONReply(automation.get(), reply_message).SendError(
+ StringPrintf(error_msg.c_str(), path.c_str()));
+ return;
+ }
+
+ prefs->EnablePlugin(enable, FilePath(path),
+ base::Bind(SendSuccessReply, automation, reply_message));
+}
+
// Helper to resolve the overloading of PostTask.
void PostTask(BrowserThread::ID id, const base::Closure& callback) {
BrowserThread::PostTask(id, FROM_HERE, callback);
@@ -3384,15 +3403,11 @@ void TestingAutomationProvider::EnablePlugin(Browser* browser,
AutomationJSONReply(this, reply_message).SendError("path not specified.");
return;
}
- PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(browser->profile());
- if (!plugin_prefs->CanEnablePlugin(true, FilePath(path))) {
- AutomationJSONReply(this, reply_message).SendError(
- StringPrintf("Could not enable plugin for path %s.", path.c_str()));
- return;
- }
- plugin_prefs->EnablePlugin(
- true, FilePath(path),
- base::Bind(SendSuccessReply, AsWeakPtr(), reply_message));
+ scoped_refptr<PluginPrefs> plugin_prefs(
+ PluginPrefs::GetForProfile(browser->profile()));
+ plugin_prefs->CanEnablePlugin(true, FilePath(path),
+ base::Bind(&CanEnablePluginCallback, AsWeakPtr(), reply_message, true,
+ path, "Could not enable plugin for path %s.", plugin_prefs));
}
// Sample json input:
@@ -3406,15 +3421,11 @@ void TestingAutomationProvider::DisablePlugin(Browser* browser,
AutomationJSONReply(this, reply_message).SendError("path not specified.");
return;
}
- PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(browser->profile());
- if (!plugin_prefs->CanEnablePlugin(false, FilePath(path))) {
- AutomationJSONReply(this, reply_message).SendError(
- StringPrintf("Could not disable plugin for path %s.", path.c_str()));
- return;
- }
- plugin_prefs->EnablePlugin(
- false, FilePath(path),
- base::Bind(SendSuccessReply, AsWeakPtr(), reply_message));
+ scoped_refptr<PluginPrefs> plugin_prefs(
+ PluginPrefs::GetForProfile(browser->profile()));
+ plugin_prefs->CanEnablePlugin(false, FilePath(path),
+ base::Bind(&CanEnablePluginCallback, AsWeakPtr(), reply_message, false,
+ path, "Could not disable plugin for path %s.", plugin_prefs));
}
// Sample json input:
« no previous file with comments | « no previous file | chrome/browser/plugin_prefs.h » ('j') | chrome/browser/plugin_prefs.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698