1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_FRAME_CUSTOM_SYNC_CALL_CONTEXT_H_
#define CHROME_FRAME_CUSTOM_SYNC_CALL_CONTEXT_H_
#include <vector>
#include "base/ref_counted.h"
#include "chrome_frame/sync_msg_reply_dispatcher.h"
#include "chrome_frame/chrome_frame_automation.h"
#include "ipc/ipc_sync_message.h"
// TODO(ananta)
// Move the implementations of these classes to the source file.
// 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 SyncMessageReplyDispatcher::SyncMessageCallContext {
public:
typedef Tuple1<AutomationMsg_ExtensionResponseValues> output_type;
InstallExtensionContext(ChromeFrameAutomationClient* client,
const FilePath& crx_path, void* user_data) : client_(client),
crx_path_(crx_path), user_data_(user_data) {
}
~InstallExtensionContext() {
}
void Completed(AutomationMsg_ExtensionResponseValues res) {
client_->PostTask(FROM_HERE, NewRunnableMethod(client_.get(),
&ChromeFrameAutomationClient::InstallExtensionComplete, crx_path_,
user_data_, res));
}
private:
scoped_refptr<ChromeFrameAutomationClient> client_;
FilePath crx_path_;
void* user_data_;
};
// 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 SyncMessageReplyDispatcher::SyncMessageCallContext {
public:
typedef Tuple1<std::vector<FilePath> > output_type;
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 Completed(
std::vector<FilePath> result) {
(*extension_directories_) = result;
client_->PostTask(FROM_HERE, NewRunnableMethod(client_.get(),
&ChromeFrameAutomationClient::GetEnabledExtensionsComplete,
user_data_, extension_directories_));
}
private:
scoped_refptr<ChromeFrameAutomationClient> client_;
std::vector<FilePath>* extension_directories_;
void* user_data_;
};
// Class that maintains contextual information for the create and connect
// external tab operations.
class CreateExternalTabContext
: public SyncMessageReplyDispatcher::SyncMessageCallContext {
public:
typedef Tuple3<HWND, HWND, int> output_type;
explicit CreateExternalTabContext(ChromeFrameAutomationClient* client)
: client_(client) {
}
void Completed(HWND chrome_window, HWND tab_window, int tab_handle) {
AutomationLaunchResult launch_result =
client_->CreateExternalTabComplete(chrome_window, tab_window,
tab_handle);
client_->PostTask(FROM_HERE,
NewRunnableMethod(
client_.get(),
&ChromeFrameAutomationClient::InitializeComplete,
launch_result));
}
private:
scoped_refptr<ChromeFrameAutomationClient> client_;
};
// This class maintains context information for the BeginNavigate operations
// pertaining to the external tab.
class BeginNavigateContext
: public SyncMessageReplyDispatcher::SyncMessageCallContext {
public:
explicit BeginNavigateContext(ChromeFrameAutomationClient* client)
: client_(client) {}
typedef Tuple1<AutomationMsg_NavigationResponseValues> output_type;
void Completed(AutomationMsg_NavigationResponseValues response) {
client_->BeginNavigateCompleted(response);
}
private:
scoped_refptr<ChromeFrameAutomationClient> client_;
};
#endif // CHROME_FRAME_CUSTOM_SYNC_CALL_CONTEXT_H_
|