| 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 #include "chrome_frame/cfproxy_private.h" | 5 #include "chrome_frame/cfproxy_private.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 #include "base/atomic_sequence_num.h" | 8 #include "base/atomic_sequence_num.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/process_util.h" | 11 #include "base/process_util.h" |
| 12 #include "chrome/common/automation_messages.h" | 12 #include "chrome/common/automation_messages.h" |
| 13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 14 #include "chrome_frame/chrome_launcher_utils.h" | 14 #include "chrome_frame/chrome_launcher_utils.h" |
| 15 #include "chrome_frame/utils.h" // for IsHeadlessMode(); | 15 #include "chrome_frame/utils.h" // for IsHeadlessMode(); |
| 16 | 16 |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 void DispatchReplyFail(uint32 type, | 19 void DispatchReplyFail(uint32 type, |
| 20 ChromeProxyDelegate* delegate, | 20 ChromeProxyDelegate* delegate, |
| 21 SyncMessageContext* ctx) { | 21 SyncMessageContext* ctx) { |
| 22 switch (type) { | 22 switch (type) { |
| 23 case AutomationMsg_CreateExternalTab::ID: | 23 case AutomationMsg_CreateExternalTab::ID: |
| 24 delegate->Completed_CreateTab(false, NULL, NULL, 0, 0); | 24 delegate->Completed_CreateTab(false, NULL, NULL, 0, 0); |
| 25 break; | 25 break; |
| 26 case AutomationMsg_ConnectExternalTab::ID: | 26 case AutomationMsg_ConnectExternalTab::ID: |
| 27 delegate->Completed_ConnectToTab(false, NULL, NULL, 0, 0); | 27 delegate->Completed_ConnectToTab(false, NULL, NULL, 0, 0); |
| 28 break; | 28 break; |
| 29 case AutomationMsg_InstallExtension::ID: | |
| 30 delegate->Completed_InstallExtension(false, | |
| 31 AUTOMATION_MSG_EXTENSION_INSTALL_FAILED, ctx); | |
| 32 break; | |
| 33 } | 29 } |
| 34 } | 30 } |
| 35 | 31 |
| 36 bool DispatchReplyOk(const IPC::Message* reply_msg, uint32 type, | 32 bool DispatchReplyOk(const IPC::Message* reply_msg, uint32 type, |
| 37 ChromeProxyDelegate* delegate, SyncMessageContext* ctx, | 33 ChromeProxyDelegate* delegate, SyncMessageContext* ctx, |
| 38 TabsMap* tab2delegate) { | 34 TabsMap* tab2delegate) { |
| 39 void* iter = IPC::SyncMessage::GetDataIterator(reply_msg); | 35 void* iter = IPC::SyncMessage::GetDataIterator(reply_msg); |
| 40 switch (type) { | 36 switch (type) { |
| 41 case AutomationMsg_CreateExternalTab::ID: { | 37 case AutomationMsg_CreateExternalTab::ID: { |
| 42 // Tuple4<HWND, HWND, int, int> out; | 38 // Tuple4<HWND, HWND, int, int> out; |
| 43 TupleTypes<AutomationMsg_CreateExternalTab::ReplyParam>::ValueTuple out; | 39 TupleTypes<AutomationMsg_CreateExternalTab::ReplyParam>::ValueTuple out; |
| 44 if (ReadParam(reply_msg, &iter, &out)) { | 40 if (ReadParam(reply_msg, &iter, &out)) { |
| 45 DCHECK(tab2delegate->find(out.c) == tab2delegate->end()); | 41 DCHECK(tab2delegate->find(out.c) == tab2delegate->end()); |
| 46 (*tab2delegate)[out.c] = delegate; | 42 (*tab2delegate)[out.c] = delegate; |
| 47 delegate->Completed_CreateTab(true, out.a, out.b, out.c, out.d); | 43 delegate->Completed_CreateTab(true, out.a, out.b, out.c, out.d); |
| 48 } | 44 } |
| 49 return true; | 45 return true; |
| 50 } | 46 } |
| 51 | 47 |
| 52 case AutomationMsg_ConnectExternalTab::ID: { | 48 case AutomationMsg_ConnectExternalTab::ID: { |
| 53 // Tuple4<HWND, HWND, int, int> out; | 49 // Tuple4<HWND, HWND, int, int> out; |
| 54 TupleTypes<AutomationMsg_ConnectExternalTab::ReplyParam>::ValueTuple out; | 50 TupleTypes<AutomationMsg_ConnectExternalTab::ReplyParam>::ValueTuple out; |
| 55 if (ReadParam(reply_msg, &iter, &out)) { | 51 if (ReadParam(reply_msg, &iter, &out)) { |
| 56 DCHECK(tab2delegate->find(out.c) == tab2delegate->end()); | 52 DCHECK(tab2delegate->find(out.c) == tab2delegate->end()); |
| 57 (*tab2delegate)[out.c] = delegate; | 53 (*tab2delegate)[out.c] = delegate; |
| 58 delegate->Completed_ConnectToTab(true, out.a, out.b, out.c, out.d); | 54 delegate->Completed_ConnectToTab(true, out.a, out.b, out.c, out.d); |
| 59 } | 55 } |
| 60 return true; | 56 return true; |
| 61 } | 57 } |
| 62 | |
| 63 case AutomationMsg_InstallExtension::ID: { | |
| 64 // Tuple1<AutomationMsg_ExtensionResponseValues> out; | |
| 65 TupleTypes<AutomationMsg_InstallExtension::ReplyParam>::ValueTuple out; | |
| 66 if (ReadParam(reply_msg, &iter, &out)) | |
| 67 delegate->Completed_InstallExtension(true, out.a, ctx); | |
| 68 return true; | |
| 69 } | |
| 70 | |
| 71 case AutomationMsg_LoadExpandedExtension::ID: { | |
| 72 // Tuple1<AutomationMsg_ExtensionResponseValues> out; | |
| 73 TupleTypes<AutomationMsg_LoadExpandedExtension::ReplyParam>::ValueTuple | |
| 74 out; | |
| 75 if (ReadParam(reply_msg, &iter, &out)) | |
| 76 delegate->Completed_LoadExpandedExtension(true, out.a, ctx); | |
| 77 break; | |
| 78 } | |
| 79 | |
| 80 case AutomationMsg_GetEnabledExtensions::ID: { | |
| 81 // Tuple1<std::vector<FilePath> > | |
| 82 TupleTypes<AutomationMsg_GetEnabledExtensions::ReplyParam>::ValueTuple | |
| 83 out; | |
| 84 if (ReadParam(reply_msg, &iter, &out)) | |
| 85 delegate->Completed_GetEnabledExtensions(true, &out.a); | |
| 86 break; | |
| 87 } | |
| 88 } // switch | 58 } // switch |
| 89 | 59 |
| 90 return false; | 60 return false; |
| 91 } | 61 } |
| 92 } // namespace | 62 } // namespace |
| 93 | 63 |
| 94 // Itf2IPCMessage | 64 // Itf2IPCMessage |
| 95 // Converts and sends trivial messages. | 65 // Converts and sends trivial messages. |
| 96 void Interface2IPCMessage::RemoveBrowsingData(int mask) { | 66 void Interface2IPCMessage::RemoveBrowsingData(int mask) { |
| 97 sender_->Send(new AutomationMsg_RemoveBrowsingData(mask)); | 67 sender_->Send(new AutomationMsg_RemoveBrowsingData(mask)); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 143 |
| 174 void Interface2IPCMessage::Tab_ProcessAccelerator(int tab, const MSG& msg) { | 144 void Interface2IPCMessage::Tab_ProcessAccelerator(int tab, const MSG& msg) { |
| 175 sender_->Send(new AutomationMsg_ProcessUnhandledAccelerator(tab, msg)); | 145 sender_->Send(new AutomationMsg_ProcessUnhandledAccelerator(tab, msg)); |
| 176 } | 146 } |
| 177 | 147 |
| 178 // Misc. | 148 // Misc. |
| 179 void Interface2IPCMessage::Tab_OnHostMoved(int tab) { | 149 void Interface2IPCMessage::Tab_OnHostMoved(int tab) { |
| 180 sender_->Send(new AutomationMsg_BrowserMove(tab)); | 150 sender_->Send(new AutomationMsg_BrowserMove(tab)); |
| 181 } | 151 } |
| 182 | 152 |
| 183 void Interface2IPCMessage::Tab_SetEnableExtensionAutomation(int tab, | |
| 184 const std::vector<std::string>& functions_enabled) { | |
| 185 sender_->Send(new AutomationMsg_SetEnableExtensionAutomation(tab, | |
| 186 functions_enabled)); | |
| 187 } | |
| 188 | |
| 189 void DelegateHolder::AddDelegate(ChromeProxyDelegate* p) { | 153 void DelegateHolder::AddDelegate(ChromeProxyDelegate* p) { |
| 190 delegate_list_.insert(p); | 154 delegate_list_.insert(p); |
| 191 } | 155 } |
| 192 | 156 |
| 193 void DelegateHolder::RemoveDelegate(ChromeProxyDelegate* p) { | 157 void DelegateHolder::RemoveDelegate(ChromeProxyDelegate* p) { |
| 194 // DCHECK(CalledOnValidThread()); | 158 // DCHECK(CalledOnValidThread()); |
| 195 int tab_handle = p->tab_handle(); // Could be 0. | 159 int tab_handle = p->tab_handle(); // Could be 0. |
| 196 delegate_list_.erase(p); | 160 delegate_list_.erase(p); |
| 197 tab2delegate_.erase(tab_handle); | 161 tab2delegate_.erase(tab_handle); |
| 198 } | 162 } |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 | 300 |
| 337 command_line->AppendSwitchPath(switches::kUserDataDir, profile_path); | 301 command_line->AppendSwitchPath(switches::kUserDataDir, profile_path); |
| 338 | 302 |
| 339 std::wstring command_line_string(command_line->command_line_string()); | 303 std::wstring command_line_string(command_line->command_line_string()); |
| 340 if (!extra_args.empty()) { | 304 if (!extra_args.empty()) { |
| 341 command_line_string.append(L" "); | 305 command_line_string.append(L" "); |
| 342 command_line_string.append(extra_args); | 306 command_line_string.append(extra_args); |
| 343 } | 307 } |
| 344 return command_line_string; | 308 return command_line_string; |
| 345 } | 309 } |
| OLD | NEW |