summaryrefslogtreecommitdiffstats
path: root/chrome_frame/chrome_frame_npapi.cc
diff options
context:
space:
mode:
authorrogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-23 17:03:41 +0000
committerrogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-23 17:03:41 +0000
commit00f6b77b89dcd900c873ed9da13dbaa2e90fe022 (patch)
treef8cc2494b35a8cacef56b51c973a1d89548212cd /chrome_frame/chrome_frame_npapi.cc
parent61452e358d496c5e0ac66c7e5f1639dff3c496ac (diff)
downloadchromium_src-00f6b77b89dcd900c873ed9da13dbaa2e90fe022.zip
chromium_src-00f6b77b89dcd900c873ed9da13dbaa2e90fe022.tar.gz
chromium_src-00f6b77b89dcd900c873ed9da13dbaa2e90fe022.tar.bz2
Add bindings to chrome frame to call the new extension automation apis.
TEST=see unit tests BUG=0 Review URL: http://codereview.chromium.org/284017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29902 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/chrome_frame_npapi.cc')
-rw-r--r--chrome_frame/chrome_frame_npapi.cc85
1 files changed, 85 insertions, 0 deletions
diff --git a/chrome_frame/chrome_frame_npapi.cc b/chrome_frame/chrome_frame_npapi.cc
index e1c5548..6c9791f 100644
--- a/chrome_frame/chrome_frame_npapi.cc
+++ b/chrome_frame/chrome_frame_npapi.cc
@@ -55,11 +55,15 @@ const NPUTF8* ChromeFrameNPAPI::plugin_property_identifier_names_[] = {
const NPUTF8* ChromeFrameNPAPI::plugin_method_identifier_names_[] = {
"postMessage",
"postPrivateMessage",
+ "installExtension",
+ "loadExtension",
};
ChromeFrameNPAPI::PluginMethod ChromeFrameNPAPI::plugin_methods_[] = {
&ChromeFrameNPAPI::postMessage,
&ChromeFrameNPAPI::postPrivateMessage,
+ &ChromeFrameNPAPI::installExtension,
+ &ChromeFrameNPAPI::loadExtension,
};
NPIdentifier
@@ -1383,6 +1387,87 @@ bool ChromeFrameNPAPI::postPrivateMessage(NPObject* npobject,
return true;
}
+bool ChromeFrameNPAPI::installExtension(NPObject* npobject,
+ const NPVariant* args,
+ uint32_t arg_count,
+ NPVariant* result) {
+ if (arg_count > 2 || !NPVARIANT_IS_STRING(args[0]) ||
+ (arg_count == 2 && !NPVARIANT_IS_OBJECT(args[1]))) {
+ NOTREACHED();
+ return false;
+ }
+
+ if (!is_privileged_) {
+ DLOG(WARNING) << "installExtension invoked in non-privileged mode";
+ return false;
+ }
+
+ if (!automation_client_.get()) {
+ DLOG(WARNING) << "installExtension invoked with no automaton client";
+ NOTREACHED();
+ return false;
+ }
+
+ const NPString& crx_path_str = args[0].value.stringValue;
+ std::string crx_path_a(crx_path_str.UTF8Characters, crx_path_str.UTF8Length);
+ FilePath::StringType crx_path_u(UTF8ToWide(crx_path_a));
+ FilePath crx_path(crx_path_u);
+ NPObject* retained_function = npapi::RetainObject(args[1].value.objectValue);
+
+ automation_client_->InstallExtension(crx_path, retained_function);
+ // The response to this command will be returned in the OnExtensionInstalled
+ // delegate callback function.
+
+ return true;
+}
+
+void ChromeFrameNPAPI::OnExtensionInstalled(
+ const FilePath& path,
+ void* user_data,
+ AutomationMsg_ExtensionResponseValues res) {
+ ScopedNpVariant result;
+ NPVariant param;
+ INT32_TO_NPVARIANT(res, param);
+ NPObject* func = reinterpret_cast<NPObject*>(user_data);
+
+ InvokeDefault(func, param, &result);
+ npapi::ReleaseObject(func);
+}
+
+bool ChromeFrameNPAPI::loadExtension(NPObject* npobject,
+ const NPVariant* args,
+ uint32_t arg_count,
+ NPVariant* result) {
+ if (arg_count > 2 || !NPVARIANT_IS_STRING(args[0]) ||
+ (arg_count == 2 && !NPVARIANT_IS_OBJECT(args[1]))) {
+ NOTREACHED();
+ return false;
+ }
+
+ if (!is_privileged_) {
+ DLOG(WARNING) << "loadExtension invoked in non-privileged mode";
+ return false;
+ }
+
+ if (!automation_client_.get()) {
+ DLOG(WARNING) << "loadExtension invoked with no automaton client";
+ NOTREACHED();
+ return false;
+ }
+
+ const NPString& path_str = args[0].value.stringValue;
+ std::string path_a(path_str.UTF8Characters, path_str.UTF8Length);
+ FilePath::StringType path_u(UTF8ToWide(path_a));
+ FilePath path(path_u);
+ NPObject* retained_function = npapi::RetainObject(args[1].value.objectValue);
+
+ automation_client_->LoadExpandedExtension(path, retained_function);
+ // The response to this command will be returned in the OnExtensionInstalled
+ // delegate callback function.
+
+ return true;
+}
+
void ChromeFrameNPAPI::FireEvent(const std::string& event_type,
const std::string& data) {
NPVariant arg;