1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 #ifndef CHROME_FRAME_CUSTOM_SYNC_CALL_CONTEXT_H_
5 #define CHROME_FRAME_CUSTOM_SYNC_CALL_CONTEXT_H_
8 #include "base/ref_counted.h"
9 #include "chrome_frame/sync_msg_reply_dispatcher.h"
10 #include "chrome_frame/chrome_frame_automation.h"
11 #include "ipc/ipc_sync_message.h"
14 // Move the implementations of these classes to the source file.
16 // Class that maintains context during the async load/install extension
17 // operation. When done, InstallExtensionComplete is posted back to the UI
18 // thread so that the users of ChromeFrameAutomationClient can be notified.
19 class InstallExtensionContext
20 : public SyncMessageReplyDispatcher::SyncMessageCallContext
{
22 typedef Tuple1
<AutomationMsg_ExtensionResponseValues
> output_type
;
24 InstallExtensionContext(ChromeFrameAutomationClient
* client
,
25 const FilePath
& crx_path
, void* user_data
) : client_(client
),
26 crx_path_(crx_path
), user_data_(user_data
) {
29 ~InstallExtensionContext() {
32 void Completed(AutomationMsg_ExtensionResponseValues res
) {
33 client_
->PostTask(FROM_HERE
, NewRunnableMethod(client_
.get(),
34 &ChromeFrameAutomationClient::InstallExtensionComplete
, crx_path_
,
39 scoped_refptr
<ChromeFrameAutomationClient
> client_
;
44 // Class that maintains context during the async retrieval of fetching the
45 // list of enabled extensions. When done, GetEnabledExtensionsComplete is
46 // posted back to the UI thread so that the users of
47 // ChromeFrameAutomationClient can be notified.
48 class GetEnabledExtensionsContext
49 : public SyncMessageReplyDispatcher::SyncMessageCallContext
{
51 typedef Tuple1
<std::vector
<FilePath
> > output_type
;
53 GetEnabledExtensionsContext(
54 ChromeFrameAutomationClient
* client
, void* user_data
) : client_(client
),
55 user_data_(user_data
) {
56 extension_directories_
= new std::vector
<FilePath
>();
59 ~GetEnabledExtensionsContext() {
60 // ChromeFrameAutomationClient::GetEnabledExtensionsComplete takes
61 // ownership of extension_directories_.
64 std::vector
<FilePath
>* extension_directories() {
65 return extension_directories_
;
69 std::vector
<FilePath
> result
) {
70 (*extension_directories_
) = result
;
71 client_
->PostTask(FROM_HERE
, NewRunnableMethod(client_
.get(),
72 &ChromeFrameAutomationClient::GetEnabledExtensionsComplete
,
73 user_data_
, extension_directories_
));
77 scoped_refptr
<ChromeFrameAutomationClient
> client_
;
78 std::vector
<FilePath
>* extension_directories_
;
82 // Class that maintains contextual information for the create and connect
83 // external tab operations.
84 class CreateExternalTabContext
85 : public SyncMessageReplyDispatcher::SyncMessageCallContext
{
87 typedef Tuple3
<HWND
, HWND
, int> output_type
;
88 explicit CreateExternalTabContext(ChromeFrameAutomationClient
* client
)
92 void Completed(HWND chrome_window
, HWND tab_window
, int tab_handle
) {
93 AutomationLaunchResult launch_result
=
94 client_
->CreateExternalTabComplete(chrome_window
, tab_window
,
96 client_
->PostTask(FROM_HERE
,
99 &ChromeFrameAutomationClient::InitializeComplete
,
104 scoped_refptr
<ChromeFrameAutomationClient
> client_
;
107 // This class maintains context information for the BeginNavigate operations
108 // pertaining to the external tab.
109 class BeginNavigateContext
110 : public SyncMessageReplyDispatcher::SyncMessageCallContext
{
112 explicit BeginNavigateContext(ChromeFrameAutomationClient
* client
)
115 typedef Tuple1
<AutomationMsg_NavigationResponseValues
> output_type
;
117 void Completed(AutomationMsg_NavigationResponseValues response
) {
118 client_
->BeginNavigateCompleted(response
);
122 scoped_refptr
<ChromeFrameAutomationClient
> client_
;
125 #endif // CHROME_FRAME_CUSTOM_SYNC_CALL_CONTEXT_H_