| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_FRAME_CUSTOM_SYNC_CALL_CONTEXT_H_ | 5 #ifndef CHROME_FRAME_CUSTOM_SYNC_CALL_CONTEXT_H_ |
| 6 #define CHROME_FRAME_CUSTOM_SYNC_CALL_CONTEXT_H_ | 6 #define CHROME_FRAME_CUSTOM_SYNC_CALL_CONTEXT_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | |
| 11 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 12 #include "base/synchronization/waitable_event.h" | 11 #include "base/synchronization/waitable_event.h" |
| 13 #include "chrome_frame/sync_msg_reply_dispatcher.h" | 12 #include "chrome_frame/sync_msg_reply_dispatcher.h" |
| 14 #include "chrome_frame/chrome_frame_automation.h" | 13 #include "chrome_frame/chrome_frame_automation.h" |
| 15 #include "ipc/ipc_sync_message.h" | 14 #include "ipc/ipc_sync_message.h" |
| 16 | 15 |
| 17 // TODO(ananta) | |
| 18 // Move the implementations of these classes to the source file. | |
| 19 | |
| 20 // Class that maintains contextual information for the create and connect | 16 // Class that maintains contextual information for the create and connect |
| 21 // external tab operations. | 17 // external tab operations. |
| 22 class CreateExternalTabContext | 18 class CreateExternalTabContext |
| 23 : public SyncMessageReplyDispatcher::SyncMessageCallContext { | 19 : public SyncMessageReplyDispatcher::SyncMessageCallContext { |
| 24 public: | 20 public: |
| 25 typedef Tuple4<HWND, HWND, int, int> output_type; | 21 typedef Tuple4<HWND, HWND, int, int> output_type; |
| 26 explicit CreateExternalTabContext(ChromeFrameAutomationClient* client) | 22 explicit CreateExternalTabContext(ChromeFrameAutomationClient* client); |
| 27 : client_(client) { | |
| 28 } | |
| 29 | 23 |
| 30 void Completed(HWND chrome_window, HWND tab_window, int tab_handle, | 24 void Completed(HWND chrome_window, HWND tab_window, int tab_handle, |
| 31 int session_id) { | 25 int session_id); |
| 32 AutomationLaunchResult launch_result = | |
| 33 client_->CreateExternalTabComplete(chrome_window, tab_window, | |
| 34 tab_handle, session_id); | |
| 35 client_->PostTask( | |
| 36 FROM_HERE, base::Bind(&ChromeFrameAutomationClient::InitializeComplete, | |
| 37 client_.get(), launch_result)); | |
| 38 } | |
| 39 | 26 |
| 40 private: | 27 private: |
| 41 scoped_refptr<ChromeFrameAutomationClient> client_; | 28 scoped_refptr<ChromeFrameAutomationClient> client_; |
| 42 }; | 29 }; |
| 43 | 30 |
| 44 // This class maintains context information for the BeginNavigate operations | 31 // This class maintains context information for the BeginNavigate operations |
| 45 // pertaining to the external tab. | 32 // pertaining to the external tab. |
| 46 class BeginNavigateContext | 33 class BeginNavigateContext |
| 47 : public SyncMessageReplyDispatcher::SyncMessageCallContext { | 34 : public SyncMessageReplyDispatcher::SyncMessageCallContext { |
| 48 public: | 35 public: |
| 49 explicit BeginNavigateContext(ChromeFrameAutomationClient* client) | 36 explicit BeginNavigateContext(ChromeFrameAutomationClient* client); |
| 50 : client_(client) {} | |
| 51 | 37 |
| 52 typedef Tuple1<AutomationMsg_NavigationResponseValues> output_type; | 38 typedef Tuple1<AutomationMsg_NavigationResponseValues> output_type; |
| 53 | 39 |
| 54 void Completed(AutomationMsg_NavigationResponseValues response) { | 40 void Completed(AutomationMsg_NavigationResponseValues response); |
| 55 client_->BeginNavigateCompleted(response); | |
| 56 } | |
| 57 | 41 |
| 58 private: | 42 private: |
| 59 scoped_refptr<ChromeFrameAutomationClient> client_; | 43 scoped_refptr<ChromeFrameAutomationClient> client_; |
| 60 }; | 44 }; |
| 61 | 45 |
| 62 // Class that maintains contextual information for the unload operation, i.e. | 46 // Class that maintains contextual information for the unload operation, i.e. |
| 63 // when the user attempts to navigate away from a page rendered in ChromeFrame. | 47 // when the user attempts to navigate away from a page rendered in ChromeFrame. |
| 64 class UnloadContext | 48 class UnloadContext |
| 65 : public SyncMessageReplyDispatcher::SyncMessageCallContext { | 49 : public SyncMessageReplyDispatcher::SyncMessageCallContext { |
| 66 public: | 50 public: |
| 67 typedef Tuple1<bool> output_type; | 51 typedef Tuple1<bool> output_type; |
| 68 UnloadContext(base::WaitableEvent* unload_done, bool* should_unload) | 52 UnloadContext(base::WaitableEvent* unload_done, bool* should_unload); |
| 69 : should_unload_(should_unload), | |
| 70 unload_done_(unload_done) { | |
| 71 } | |
| 72 | 53 |
| 73 void Completed(bool should_unload) { | 54 void Completed(bool should_unload); |
| 74 *should_unload_ = should_unload; | |
| 75 unload_done_->Signal(); | |
| 76 should_unload_ = NULL; | |
| 77 unload_done_ = NULL; | |
| 78 // This object will be destroyed after this. Cannot access any members | |
| 79 // on returning from this function. | |
| 80 } | |
| 81 | 55 |
| 82 private: | 56 private: |
| 83 base::WaitableEvent* unload_done_; | 57 base::WaitableEvent* unload_done_; |
| 84 bool* should_unload_; | 58 bool* should_unload_; |
| 85 }; | 59 }; |
| 86 | 60 |
| 87 #endif // CHROME_FRAME_CUSTOM_SYNC_CALL_CONTEXT_H_ | 61 #endif // CHROME_FRAME_CUSTOM_SYNC_CALL_CONTEXT_H_ |
| OLD | NEW |