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/browser/automation/automation_provider.h" | 5 #include "chrome/browser/automation/automation_provider.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
318 IPC_MESSAGE_HANDLER(AutomationMsg_PrintAsync, PrintAsync) | 318 IPC_MESSAGE_HANDLER(AutomationMsg_PrintAsync, PrintAsync) |
319 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_Find, HandleFindRequest) | 319 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_Find, HandleFindRequest) |
320 IPC_MESSAGE_HANDLER(AutomationMsg_OverrideEncoding, OverrideEncoding) | 320 IPC_MESSAGE_HANDLER(AutomationMsg_OverrideEncoding, OverrideEncoding) |
321 IPC_MESSAGE_HANDLER(AutomationMsg_SelectAll, SelectAll) | 321 IPC_MESSAGE_HANDLER(AutomationMsg_SelectAll, SelectAll) |
322 IPC_MESSAGE_HANDLER(AutomationMsg_Cut, Cut) | 322 IPC_MESSAGE_HANDLER(AutomationMsg_Cut, Cut) |
323 IPC_MESSAGE_HANDLER(AutomationMsg_Copy, Copy) | 323 IPC_MESSAGE_HANDLER(AutomationMsg_Copy, Copy) |
324 IPC_MESSAGE_HANDLER(AutomationMsg_Paste, Paste) | 324 IPC_MESSAGE_HANDLER(AutomationMsg_Paste, Paste) |
325 IPC_MESSAGE_HANDLER(AutomationMsg_ReloadAsync, ReloadAsync) | 325 IPC_MESSAGE_HANDLER(AutomationMsg_ReloadAsync, ReloadAsync) |
326 IPC_MESSAGE_HANDLER(AutomationMsg_StopAsync, StopAsync) | 326 IPC_MESSAGE_HANDLER(AutomationMsg_StopAsync, StopAsync) |
327 IPC_MESSAGE_HANDLER(AutomationMsg_SetPageFontSize, OnSetPageFontSize) | 327 IPC_MESSAGE_HANDLER(AutomationMsg_SetPageFontSize, OnSetPageFontSize) |
328 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForExtensionTestResult, | |
329 WaitForExtensionTestResult) | |
328 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_InstallExtension, | 330 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_InstallExtension, |
329 InstallExtension) | 331 InstallExtension) |
330 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForExtensionTestResult, | |
331 WaitForExtensionTestResult) | |
332 IPC_MESSAGE_HANDLER_DELAY_REPLY( | |
333 AutomationMsg_InstallExtensionAndGetHandle, | |
334 InstallExtensionAndGetHandle) | |
335 IPC_MESSAGE_HANDLER(AutomationMsg_UninstallExtension, | 332 IPC_MESSAGE_HANDLER(AutomationMsg_UninstallExtension, |
336 UninstallExtension) | 333 UninstallExtension) |
337 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_EnableExtension, | 334 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_EnableExtension, |
338 EnableExtension) | 335 EnableExtension) |
339 IPC_MESSAGE_HANDLER(AutomationMsg_DisableExtension, | 336 IPC_MESSAGE_HANDLER(AutomationMsg_DisableExtension, |
340 DisableExtension) | 337 DisableExtension) |
341 IPC_MESSAGE_HANDLER_DELAY_REPLY( | 338 IPC_MESSAGE_HANDLER_DELAY_REPLY( |
342 AutomationMsg_ExecuteExtensionActionInActiveTabAsync, | 339 AutomationMsg_ExecuteExtensionActionInActiveTabAsync, |
343 ExecuteExtensionActionInActiveTabAsync) | 340 ExecuteExtensionActionInActiveTabAsync) |
344 IPC_MESSAGE_HANDLER(AutomationMsg_MoveExtensionBrowserAction, | 341 IPC_MESSAGE_HANDLER(AutomationMsg_MoveExtensionBrowserAction, |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
756 return NULL; | 753 return NULL; |
757 } | 754 } |
758 | 755 |
759 RenderViewHost* view_host = tab_contents->render_view_host(); | 756 RenderViewHost* view_host = tab_contents->render_view_host(); |
760 return view_host; | 757 return view_host; |
761 } | 758 } |
762 | 759 |
763 return NULL; | 760 return NULL; |
764 } | 761 } |
765 | 762 |
766 void AutomationProvider::InstallExtension(const FilePath& crx_path, | |
767 IPC::Message* reply_message) { | |
768 ExtensionService* service = profile_->GetExtensionService(); | |
769 if (service) { | |
770 // The observer will delete itself when done. | |
771 new ExtensionInstallNotificationObserver(this, | |
772 AutomationMsg_InstallExtension::ID, | |
773 reply_message); | |
774 | |
775 // Pass NULL for a silent install with no UI. | |
776 scoped_refptr<CrxInstaller> installer(service->MakeCrxInstaller(NULL)); | |
777 installer->set_install_cause(extension_misc::INSTALL_CAUSE_AUTOMATION); | |
778 installer->InstallCrx(crx_path); | |
779 } else { | |
780 AutomationMsg_InstallExtension::WriteReplyParams( | |
781 reply_message, AUTOMATION_MSG_EXTENSION_INSTALL_FAILED); | |
782 Send(reply_message); | |
783 } | |
784 } | |
785 | |
786 void AutomationProvider::WaitForExtensionTestResult( | 763 void AutomationProvider::WaitForExtensionTestResult( |
787 IPC::Message* reply_message) { | 764 IPC::Message* reply_message) { |
788 DCHECK(!reply_message_); | 765 DCHECK(!reply_message_); |
789 reply_message_ = reply_message; | 766 reply_message_ = reply_message; |
790 // Call MaybeSendResult, because the result might have come in before | 767 // Call MaybeSendResult, because the result might have come in before |
791 // we were waiting on it. | 768 // we were waiting on it. |
792 extension_test_result_observer_->MaybeSendResult(); | 769 extension_test_result_observer_->MaybeSendResult(); |
793 } | 770 } |
794 | 771 |
795 void AutomationProvider::InstallExtensionAndGetHandle( | 772 void AutomationProvider::InstallExtension( |
796 const FilePath& crx_path, bool with_ui, IPC::Message* reply_message) { | 773 const std::string& extension_path, bool with_ui, |
774 IPC::Message* reply_message) { | |
775 const FilePath extension_file_path = FilePath(extension_path); | |
kkania
2011/08/03 16:01:56
this wont compile on windows
| |
797 ExtensionService* service = profile_->GetExtensionService(); | 776 ExtensionService* service = profile_->GetExtensionService(); |
798 ExtensionProcessManager* manager = profile_->GetExtensionProcessManager(); | 777 ExtensionProcessManager* manager = profile_->GetExtensionProcessManager(); |
799 if (service && manager) { | 778 if (service && manager) { |
800 // The observer will delete itself when done. | 779 // The observer will delete itself when done. |
801 new ExtensionReadyNotificationObserver( | 780 new ExtensionReadyNotificationObserver( |
802 manager, | 781 manager, |
803 this, | 782 this, |
804 AutomationMsg_InstallExtensionAndGetHandle::ID, | 783 AutomationMsg_InstallExtension::ID, |
805 reply_message); | 784 reply_message); |
806 | 785 |
807 if (crx_path.MatchesExtension(FILE_PATH_LITERAL(".crx"))) { | 786 if (extension_file_path.MatchesExtension(FILE_PATH_LITERAL(".crx"))) { |
808 ExtensionInstallUI* client = | 787 ExtensionInstallUI* client = |
809 (with_ui ? new ExtensionInstallUI(profile_) : NULL); | 788 (with_ui ? new ExtensionInstallUI(profile_) : NULL); |
810 scoped_refptr<CrxInstaller> installer(service->MakeCrxInstaller(client)); | 789 scoped_refptr<CrxInstaller> installer(service->MakeCrxInstaller(client)); |
811 if (!with_ui) | 790 if (!with_ui) |
812 installer->set_allow_silent_install(true); | 791 installer->set_allow_silent_install(true); |
813 installer->set_install_cause(extension_misc::INSTALL_CAUSE_AUTOMATION); | 792 installer->set_install_cause(extension_misc::INSTALL_CAUSE_AUTOMATION); |
814 installer->InstallCrx(crx_path); | 793 installer->InstallCrx(extension_file_path); |
815 } else { | 794 } else { |
816 service->LoadExtension(crx_path, with_ui); | 795 service->LoadExtension(extension_file_path, with_ui); |
817 } | 796 } |
818 } else { | 797 } else { |
819 AutomationMsg_InstallExtensionAndGetHandle::WriteReplyParams( | 798 AutomationMsg_InstallExtension::WriteReplyParams(reply_message, 0); |
820 reply_message, 0); | |
821 Send(reply_message); | 799 Send(reply_message); |
822 } | 800 } |
823 } | 801 } |
824 | 802 |
825 void AutomationProvider::UninstallExtension(int extension_handle, | 803 void AutomationProvider::UninstallExtension(int extension_handle, |
826 bool* success) { | 804 bool* success) { |
827 *success = false; | 805 *success = false; |
828 const Extension* extension = GetExtension(extension_handle); | 806 const Extension* extension = GetExtension(extension_handle); |
829 ExtensionService* service = profile_->GetExtensionService(); | 807 ExtensionService* service = profile_->GetExtensionService(); |
830 if (extension && service) { | 808 if (extension && service) { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
964 } | 942 } |
965 } | 943 } |
966 } | 944 } |
967 | 945 |
968 void AutomationProvider::SaveAsAsync(int tab_handle) { | 946 void AutomationProvider::SaveAsAsync(int tab_handle) { |
969 NavigationController* tab = NULL; | 947 NavigationController* tab = NULL; |
970 TabContents* tab_contents = GetTabContentsForHandle(tab_handle, &tab); | 948 TabContents* tab_contents = GetTabContentsForHandle(tab_handle, &tab); |
971 if (tab_contents) | 949 if (tab_contents) |
972 tab_contents->OnSavePage(); | 950 tab_contents->OnSavePage(); |
973 } | 951 } |
OLD | NEW |