diff options
author | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-16 02:18:43 +0000 |
---|---|---|
committer | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-16 02:18:43 +0000 |
commit | a1e62d1553f81d66fa5fdc6a4e54a5531d378bbc (patch) | |
tree | b14f0d7693c0843222d765da77d9c1ccc3e2de46 /chrome_frame/chrome_frame_automation.cc | |
parent | d5b42ac0413ca4dbac88bce952044808ba40b1a9 (diff) | |
download | chromium_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_automation.cc')
-rw-r--r-- | chrome_frame/chrome_frame_automation.cc | 69 |
1 files changed, 69 insertions, 0 deletions
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<Tuple1<AutomationMsg_ExtensionResponseValues> >(msg, origin); break; + case AutomationMsg_GetEnabledExtensions::ID: + InvokeCallback<Tuple1<std::vector<FilePath> > >(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<FilePath>(); + } + + ~GetEnabledExtensionsContext() { + // ChromeFrameAutomationClient::GetEnabledExtensionsComplete takes + // ownership of extension_directories_. + } + + std::vector<FilePath>* extension_directories() { + return extension_directories_; + } + + void GetEnabledExtensionsComplete( + std::vector<FilePath> result) { + (*extension_directories_) = result; + client_->PostTask(FROM_HERE, NewRunnableMethod(client_.get(), + &ChromeFrameAutomationClient::GetEnabledExtensionsComplete, + user_data_, extension_directories_)); + delete this; + } + + private: + scoped_refptr<ChromeFrameAutomationClient> client_; + std::vector<FilePath>* extension_directories_; + void* user_data_; +}; + +void ChromeFrameAutomationClient::GetEnabledExtensions(void* user_data) { + if (automation_server_ == NULL) { + GetEnabledExtensionsComplete(user_data, &std::vector<FilePath>()); + 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<FilePath>* 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. |