summaryrefslogtreecommitdiffstats
path: root/chrome_frame/chrome_frame_automation.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_automation.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_automation.cc')
-rw-r--r--chrome_frame/chrome_frame_automation.cc87
1 files changed, 87 insertions, 0 deletions
diff --git a/chrome_frame/chrome_frame_automation.cc b/chrome_frame/chrome_frame_automation.cc
index 56548de..17fb43d 100644
--- a/chrome_frame/chrome_frame_automation.cc
+++ b/chrome_frame/chrome_frame_automation.cc
@@ -78,6 +78,14 @@ class ChromeFrameAutomationProxyImpl::CFMsgDispatcher
InvokeCallback<Tuple1<AutomationMsg_NavigationResponseValues> >(msg,
origin);
break;
+ case AutomationMsg_InstallExtension::ID:
+ InvokeCallback<Tuple1<AutomationMsg_ExtensionResponseValues> >(msg,
+ origin);
+ break;
+ case AutomationMsg_LoadExpandedExtension::ID:
+ InvokeCallback<Tuple1<AutomationMsg_ExtensionResponseValues> >(msg,
+ origin);
+ break;
default:
NOTREACHED();
}
@@ -598,6 +606,85 @@ void ChromeFrameAutomationClient::FindInPage(const std::wstring& search_string,
automation_server_->SendAsAsync(msg, NULL, this);
}
+// Class that maintains context during the async load/install extension
+// operation. When done, InstallExtensionComplete is posted back to the UI
+// thread so that the users of ChromeFrameAutomationClient can be notified.
+class InstallExtensionContext {
+ public:
+ InstallExtensionContext(ChromeFrameAutomationClient* client,
+ const FilePath& crx_path, void* user_data) : client_(client),
+ crx_path_(crx_path), user_data_(user_data) {
+ }
+
+ ~InstallExtensionContext() {
+ }
+
+ void InstallExtensionComplete(AutomationMsg_ExtensionResponseValues res) {
+ client_->PostTask(FROM_HERE, NewRunnableMethod(client_,
+ &ChromeFrameAutomationClient::InstallExtensionComplete, crx_path_,
+ user_data_, res));
+ delete this;
+ }
+
+ private:
+ ChromeFrameAutomationClient* client_;
+ FilePath crx_path_;
+ void* user_data_;
+};
+
+void ChromeFrameAutomationClient::InstallExtension(
+ const FilePath& crx_path,
+ void* user_data) {
+ if (automation_server_ == NULL) {
+ InstallExtensionComplete(crx_path,
+ user_data,
+ AUTOMATION_MSG_EXTENSION_INSTALL_FAILED);
+ return;
+ }
+
+ InstallExtensionContext* ctx = new InstallExtensionContext(
+ this, crx_path, user_data);
+
+ IPC::SyncMessage* msg =
+ new AutomationMsg_InstallExtension(0, crx_path, NULL);
+
+ // The context will delete itself after it is called.
+ automation_server_->SendAsAsync(msg, NewCallback(ctx,
+ &InstallExtensionContext::InstallExtensionComplete), this);
+}
+
+void ChromeFrameAutomationClient::InstallExtensionComplete(
+ const FilePath& crx_path,
+ void* user_data,
+ AutomationMsg_ExtensionResponseValues res) {
+ DCHECK(PlatformThread::CurrentId() == ui_thread_id_);
+
+ if (chrome_frame_delegate_) {
+ chrome_frame_delegate_->OnExtensionInstalled(crx_path, user_data, res);
+ }
+}
+
+void ChromeFrameAutomationClient::LoadExpandedExtension(
+ const FilePath& path,
+ void* user_data) {
+ if (automation_server_ == NULL) {
+ InstallExtensionComplete(path,
+ user_data,
+ AUTOMATION_MSG_EXTENSION_INSTALL_FAILED);
+ return;
+ }
+
+ InstallExtensionContext* ctx = new InstallExtensionContext(
+ this, path, user_data);
+
+ IPC::SyncMessage* msg =
+ new AutomationMsg_LoadExpandedExtension(0, path, NULL);
+
+ // The context will delete itself after it is called.
+ automation_server_->SendAsAsync(msg, NewCallback(ctx,
+ &InstallExtensionContext::InstallExtensionComplete), this);
+}
+
void ChromeFrameAutomationClient::CreateExternalTab() {
AutomationLaunchResult launch_result = AUTOMATION_SUCCESS;
DCHECK(IsWindow());