summaryrefslogtreecommitdiffstats
path: root/chrome_frame/chrome_frame_npapi.cc
diff options
context:
space:
mode:
authorjoi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-16 02:18:43 +0000
committerjoi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-16 02:18:43 +0000
commita1e62d1553f81d66fa5fdc6a4e54a5531d378bbc (patch)
treeb14f0d7693c0843222d765da77d9c1ccc3e2de46 /chrome_frame/chrome_frame_npapi.cc
parentd5b42ac0413ca4dbac88bce952044808ba40b1a9 (diff)
downloadchromium_src-a1e62d1553f81d66fa5fdc6a4e54a5531d378bbc.zip
chromium_src-a1e62d1553f81d66fa5fdc6a4e54a5531d378bbc.tar.gz
chromium_src-a1e62d1553f81d66fa5fdc6a4e54a5531d378bbc.tar.bz2
Adds an automation message to retrieve the list of enabled extensions, and CF bindings for it.
TEST=unit test to follow BUG=none Review URL: http://codereview.chromium.org/901002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41667 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/chrome_frame_npapi.cc')
-rw-r--r--chrome_frame/chrome_frame_npapi.cc53
1 files changed, 52 insertions, 1 deletions
diff --git a/chrome_frame/chrome_frame_npapi.cc b/chrome_frame/chrome_frame_npapi.cc
index c760453..573d32e 100644
--- a/chrome_frame/chrome_frame_npapi.cc
+++ b/chrome_frame/chrome_frame_npapi.cc
@@ -64,7 +64,8 @@ const NPUTF8* ChromeFrameNPAPI::plugin_method_identifier_names_[] = {
"postPrivateMessage",
"installExtension",
"loadExtension",
- "enableExtensionAutomation"
+ "enableExtensionAutomation",
+ "getEnabledExtensions"
};
ChromeFrameNPAPI::PluginMethod ChromeFrameNPAPI::plugin_methods_[] = {
@@ -73,6 +74,7 @@ ChromeFrameNPAPI::PluginMethod ChromeFrameNPAPI::plugin_methods_[] = {
&ChromeFrameNPAPI::installExtension,
&ChromeFrameNPAPI::loadExtension,
&ChromeFrameNPAPI::enableExtensionAutomation,
+ &ChromeFrameNPAPI::getEnabledExtensions,
};
NPIdentifier
@@ -1414,6 +1416,55 @@ bool ChromeFrameNPAPI::enableExtensionAutomation(NPObject* npobject,
return true;
}
+bool ChromeFrameNPAPI::getEnabledExtensions(NPObject* npobject,
+ const NPVariant* args,
+ uint32_t arg_count,
+ NPVariant* result) {
+ if (arg_count > 1 || !NPVARIANT_IS_OBJECT(args[0])) {
+ NOTREACHED();
+ return false;
+ }
+
+ if (!is_privileged_) {
+ DLOG(WARNING) << "getEnabledExtensions invoked in non-privileged mode";
+ return false;
+ }
+
+ if (!automation_client_.get()) {
+ DLOG(WARNING) << "getEnabledExtensions invoked with no automaton client";
+ NOTREACHED();
+ return false;
+ }
+
+ NPObject* retained_function = npapi::RetainObject(args[0].value.objectValue);
+
+ automation_client_->GetEnabledExtensions(retained_function);
+ // The response to this command will be returned in the
+ // OnGetEnabledExtensionsCompleted delegate callback function.
+
+ return true;
+}
+
+void ChromeFrameNPAPI::OnGetEnabledExtensionsComplete(
+ void* user_data,
+ const std::vector<FilePath>& extension_directories) {
+ std::vector<std::wstring> extension_paths;
+ for (size_t i = 0; i < extension_directories.size(); ++i) {
+ extension_paths.push_back(extension_directories[i].ToWStringHack());
+ }
+ std::wstring tab_delimited = JoinString(extension_paths, L'\t');
+
+ std::string res = WideToUTF8(tab_delimited);
+
+ ScopedNpVariant result;
+ NPVariant param;
+ STRINGN_TO_NPVARIANT(res.c_str(), res.length(), param);
+
+ NPObject* func = reinterpret_cast<NPObject*>(user_data);
+ InvokeDefault(func, param, &result);
+ npapi::ReleaseObject(func);
+}
+
void ChromeFrameNPAPI::FireEvent(const std::string& event_type,
const std::string& data) {
NPVariant arg;