Initialize all data members in HTTPResponseInfo's new ctor and remove the related...
[chromium-blink-merge.git] / chrome_frame / custom_sync_call_context.h
blob28812ef2e3c403687476dbaffeb966c9d26ecdb7
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_
7 #include <vector>
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"
13 // TODO(ananta)
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 {
21 public:
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_,
35 user_data_, res));
38 private:
39 scoped_refptr<ChromeFrameAutomationClient> client_;
40 FilePath crx_path_;
41 void* user_data_;
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 {
50 public:
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_;
68 void Completed(
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_));
76 private:
77 scoped_refptr<ChromeFrameAutomationClient> client_;
78 std::vector<FilePath>* extension_directories_;
79 void* user_data_;
82 // Class that maintains contextual information for the create and connect
83 // external tab operations.
84 class CreateExternalTabContext
85 : public SyncMessageReplyDispatcher::SyncMessageCallContext {
86 public:
87 typedef Tuple3<HWND, HWND, int> output_type;
88 explicit CreateExternalTabContext(ChromeFrameAutomationClient* client)
89 : client_(client) {
92 void Completed(HWND chrome_window, HWND tab_window, int tab_handle) {
93 AutomationLaunchResult launch_result =
94 client_->CreateExternalTabComplete(chrome_window, tab_window,
95 tab_handle);
96 client_->PostTask(FROM_HERE,
97 NewRunnableMethod(
98 client_.get(),
99 &ChromeFrameAutomationClient::InitializeComplete,
100 launch_result));
103 private:
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 {
111 public:
112 explicit BeginNavigateContext(ChromeFrameAutomationClient* client)
113 : client_(client) {}
115 typedef Tuple1<AutomationMsg_NavigationResponseValues> output_type;
117 void Completed(AutomationMsg_NavigationResponseValues response) {
118 client_->BeginNavigateCompleted(response);
121 private:
122 scoped_refptr<ChromeFrameAutomationClient> client_;
125 #endif // CHROME_FRAME_CUSTOM_SYNC_CALL_CONTEXT_H_