From a1e62d1553f81d66fa5fdc6a4e54a5531d378bbc Mon Sep 17 00:00:00 2001 From: "joi@chromium.org" Date: Tue, 16 Mar 2010 02:18:43 +0000 Subject: 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 --- chrome_frame/chrome_frame_automation.cc | 69 +++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) (limited to 'chrome_frame/chrome_frame_automation.cc') diff --git a/chrome_frame/chrome_frame_automation.cc b/chrome_frame/chrome_frame_automation.cc index 988f27a7..785e3e5 100644 --- a/chrome_frame/chrome_frame_automation.cc +++ b/chrome_frame/chrome_frame_automation.cc @@ -96,6 +96,9 @@ class ChromeFrameAutomationProxyImpl::CFMsgDispatcher InvokeCallback >(msg, origin); break; + case AutomationMsg_GetEnabledExtensions::ID: + InvokeCallback > >(msg, origin); + break; default: NOTREACHED(); } @@ -724,6 +727,72 @@ void ChromeFrameAutomationClient::InstallExtensionComplete( } } +// Class that maintains context during the async retrieval of fetching the +// list of enabled extensions. When done, GetEnabledExtensionsComplete is +// posted back to the UI thread so that the users of +// ChromeFrameAutomationClient can be notified. +class GetEnabledExtensionsContext { + public: + GetEnabledExtensionsContext( + ChromeFrameAutomationClient* client, void* user_data) : client_(client), + user_data_(user_data) { + extension_directories_ = new std::vector(); + } + + ~GetEnabledExtensionsContext() { + // ChromeFrameAutomationClient::GetEnabledExtensionsComplete takes + // ownership of extension_directories_. + } + + std::vector* extension_directories() { + return extension_directories_; + } + + void GetEnabledExtensionsComplete( + std::vector result) { + (*extension_directories_) = result; + client_->PostTask(FROM_HERE, NewRunnableMethod(client_.get(), + &ChromeFrameAutomationClient::GetEnabledExtensionsComplete, + user_data_, extension_directories_)); + delete this; + } + + private: + scoped_refptr client_; + std::vector* extension_directories_; + void* user_data_; +}; + +void ChromeFrameAutomationClient::GetEnabledExtensions(void* user_data) { + if (automation_server_ == NULL) { + GetEnabledExtensionsComplete(user_data, &std::vector()); + return; + } + + GetEnabledExtensionsContext* ctx = new GetEnabledExtensionsContext( + this, user_data); + + IPC::SyncMessage* msg = new AutomationMsg_GetEnabledExtensions( + 0, ctx->extension_directories()); + + // The context will delete itself after it is called. + automation_server_->SendAsAsync(msg, NewCallback(ctx, + &GetEnabledExtensionsContext::GetEnabledExtensionsComplete), this); +} + +void ChromeFrameAutomationClient::GetEnabledExtensionsComplete( + void* user_data, + std::vector* extension_directories) { + DCHECK_EQ(PlatformThread::CurrentId(), ui_thread_id_); + + if (chrome_frame_delegate_) { + chrome_frame_delegate_->OnGetEnabledExtensionsComplete( + user_data, *extension_directories); + } + + delete extension_directories; +} + void ChromeFrameAutomationClient::OnChromeFrameHostMoved() { // Use a local var to avoid the small possibility of getting the tab_ // member be cleared while we try to use it. -- cgit v1.1