| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/testing_automation_provider.h" | 5 #include "chrome/browser/automation/testing_automation_provider.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 this, browser, command, reply_message, false)) { | 649 this, browser, command, reply_message, false)) { |
| 650 chrome::ExecuteCommand(browser, command); | 650 chrome::ExecuteCommand(browser, command); |
| 651 return; | 651 return; |
| 652 } | 652 } |
| 653 } | 653 } |
| 654 } | 654 } |
| 655 AutomationMsg_WindowExecuteCommand::WriteReplyParams(reply_message, false); | 655 AutomationMsg_WindowExecuteCommand::WriteReplyParams(reply_message, false); |
| 656 Send(reply_message); | 656 Send(reply_message); |
| 657 } | 657 } |
| 658 | 658 |
| 659 void TestingAutomationProvider::WebkitMouseClick(DictionaryValue* args, | 659 void TestingAutomationProvider::WebkitMouseClick(base::DictionaryValue* args, |
| 660 IPC::Message* reply_message) { | 660 IPC::Message* reply_message) { |
| 661 if (SendErrorIfModalDialogActive(this, reply_message)) | 661 if (SendErrorIfModalDialogActive(this, reply_message)) |
| 662 return; | 662 return; |
| 663 | 663 |
| 664 RenderViewHost* view; | 664 RenderViewHost* view; |
| 665 std::string error; | 665 std::string error; |
| 666 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { | 666 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { |
| 667 AutomationJSONReply(this, reply_message).SendError(error); | 667 AutomationJSONReply(this, reply_message).SendError(error); |
| 668 return; | 668 return; |
| 669 } | 669 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 699 | 699 |
| 700 view->ForwardMouseEvent(mouse_event); | 700 view->ForwardMouseEvent(mouse_event); |
| 701 | 701 |
| 702 mouse_event.type = blink::WebInputEvent::MouseUp; | 702 mouse_event.type = blink::WebInputEvent::MouseUp; |
| 703 new InputEventAckNotificationObserver(this, reply_message, mouse_event.type, | 703 new InputEventAckNotificationObserver(this, reply_message, mouse_event.type, |
| 704 1); | 704 1); |
| 705 view->ForwardMouseEvent(mouse_event); | 705 view->ForwardMouseEvent(mouse_event); |
| 706 } | 706 } |
| 707 | 707 |
| 708 void TestingAutomationProvider::WebkitMouseMove( | 708 void TestingAutomationProvider::WebkitMouseMove( |
| 709 DictionaryValue* args, IPC::Message* reply_message) { | 709 base::DictionaryValue* args, IPC::Message* reply_message) { |
| 710 if (SendErrorIfModalDialogActive(this, reply_message)) | 710 if (SendErrorIfModalDialogActive(this, reply_message)) |
| 711 return; | 711 return; |
| 712 | 712 |
| 713 RenderViewHost* view; | 713 RenderViewHost* view; |
| 714 std::string error; | 714 std::string error; |
| 715 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { | 715 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { |
| 716 AutomationJSONReply(this, reply_message).SendError(error); | 716 AutomationJSONReply(this, reply_message).SendError(error); |
| 717 return; | 717 return; |
| 718 } | 718 } |
| 719 | 719 |
| 720 blink::WebMouseEvent mouse_event; | 720 blink::WebMouseEvent mouse_event; |
| 721 if (!args->GetInteger("x", &mouse_event.x) || | 721 if (!args->GetInteger("x", &mouse_event.x) || |
| 722 !args->GetInteger("y", &mouse_event.y)) { | 722 !args->GetInteger("y", &mouse_event.y)) { |
| 723 AutomationJSONReply(this, reply_message) | 723 AutomationJSONReply(this, reply_message) |
| 724 .SendError("(X,Y) coordinates missing or invalid"); | 724 .SendError("(X,Y) coordinates missing or invalid"); |
| 725 return; | 725 return; |
| 726 } | 726 } |
| 727 | 727 |
| 728 mouse_event.type = blink::WebInputEvent::MouseMove; | 728 mouse_event.type = blink::WebInputEvent::MouseMove; |
| 729 new InputEventAckNotificationObserver(this, reply_message, mouse_event.type, | 729 new InputEventAckNotificationObserver(this, reply_message, mouse_event.type, |
| 730 1); | 730 1); |
| 731 view->ForwardMouseEvent(mouse_event); | 731 view->ForwardMouseEvent(mouse_event); |
| 732 } | 732 } |
| 733 | 733 |
| 734 void TestingAutomationProvider::WebkitMouseDrag(DictionaryValue* args, | 734 void TestingAutomationProvider::WebkitMouseDrag(base::DictionaryValue* args, |
| 735 IPC::Message* reply_message) { | 735 IPC::Message* reply_message) { |
| 736 if (SendErrorIfModalDialogActive(this, reply_message)) | 736 if (SendErrorIfModalDialogActive(this, reply_message)) |
| 737 return; | 737 return; |
| 738 | 738 |
| 739 RenderViewHost* view; | 739 RenderViewHost* view; |
| 740 std::string error; | 740 std::string error; |
| 741 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { | 741 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { |
| 742 AutomationJSONReply(this, reply_message).SendError(error); | 742 AutomationJSONReply(this, reply_message).SendError(error); |
| 743 return; | 743 return; |
| 744 } | 744 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 775 | 775 |
| 776 // Step 4 - Release the left mouse button. | 776 // Step 4 - Release the left mouse button. |
| 777 mouse_event.type = blink::WebInputEvent::MouseUp; | 777 mouse_event.type = blink::WebInputEvent::MouseUp; |
| 778 mouse_event.clickCount = 1; | 778 mouse_event.clickCount = 1; |
| 779 new InputEventAckNotificationObserver(this, reply_message, mouse_event.type, | 779 new InputEventAckNotificationObserver(this, reply_message, mouse_event.type, |
| 780 1); | 780 1); |
| 781 view->ForwardMouseEvent(mouse_event); | 781 view->ForwardMouseEvent(mouse_event); |
| 782 } | 782 } |
| 783 | 783 |
| 784 void TestingAutomationProvider::WebkitMouseButtonDown( | 784 void TestingAutomationProvider::WebkitMouseButtonDown( |
| 785 DictionaryValue* args, IPC::Message* reply_message) { | 785 base::DictionaryValue* args, IPC::Message* reply_message) { |
| 786 if (SendErrorIfModalDialogActive(this, reply_message)) | 786 if (SendErrorIfModalDialogActive(this, reply_message)) |
| 787 return; | 787 return; |
| 788 | 788 |
| 789 RenderViewHost* view; | 789 RenderViewHost* view; |
| 790 std::string error; | 790 std::string error; |
| 791 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { | 791 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { |
| 792 AutomationJSONReply(this, reply_message).SendError(error); | 792 AutomationJSONReply(this, reply_message).SendError(error); |
| 793 return; | 793 return; |
| 794 } | 794 } |
| 795 | 795 |
| 796 blink::WebMouseEvent mouse_event; | 796 blink::WebMouseEvent mouse_event; |
| 797 if (!args->GetInteger("x", &mouse_event.x) || | 797 if (!args->GetInteger("x", &mouse_event.x) || |
| 798 !args->GetInteger("y", &mouse_event.y)) { | 798 !args->GetInteger("y", &mouse_event.y)) { |
| 799 AutomationJSONReply(this, reply_message) | 799 AutomationJSONReply(this, reply_message) |
| 800 .SendError("(X,Y) coordinates missing or invalid"); | 800 .SendError("(X,Y) coordinates missing or invalid"); |
| 801 return; | 801 return; |
| 802 } | 802 } |
| 803 | 803 |
| 804 mouse_event.type = blink::WebInputEvent::MouseDown; | 804 mouse_event.type = blink::WebInputEvent::MouseDown; |
| 805 mouse_event.button = blink::WebMouseEvent::ButtonLeft; | 805 mouse_event.button = blink::WebMouseEvent::ButtonLeft; |
| 806 mouse_event.clickCount = 1; | 806 mouse_event.clickCount = 1; |
| 807 new InputEventAckNotificationObserver(this, reply_message, mouse_event.type, | 807 new InputEventAckNotificationObserver(this, reply_message, mouse_event.type, |
| 808 1); | 808 1); |
| 809 view->ForwardMouseEvent(mouse_event); | 809 view->ForwardMouseEvent(mouse_event); |
| 810 } | 810 } |
| 811 | 811 |
| 812 void TestingAutomationProvider::WebkitMouseButtonUp( | 812 void TestingAutomationProvider::WebkitMouseButtonUp( |
| 813 DictionaryValue* args, IPC::Message* reply_message) { | 813 base::DictionaryValue* args, IPC::Message* reply_message) { |
| 814 if (SendErrorIfModalDialogActive(this, reply_message)) | 814 if (SendErrorIfModalDialogActive(this, reply_message)) |
| 815 return; | 815 return; |
| 816 | 816 |
| 817 RenderViewHost* view; | 817 RenderViewHost* view; |
| 818 std::string error; | 818 std::string error; |
| 819 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { | 819 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { |
| 820 AutomationJSONReply(this, reply_message).SendError(error); | 820 AutomationJSONReply(this, reply_message).SendError(error); |
| 821 return; | 821 return; |
| 822 } | 822 } |
| 823 | 823 |
| 824 blink::WebMouseEvent mouse_event; | 824 blink::WebMouseEvent mouse_event; |
| 825 if (!args->GetInteger("x", &mouse_event.x) || | 825 if (!args->GetInteger("x", &mouse_event.x) || |
| 826 !args->GetInteger("y", &mouse_event.y)) { | 826 !args->GetInteger("y", &mouse_event.y)) { |
| 827 AutomationJSONReply(this, reply_message) | 827 AutomationJSONReply(this, reply_message) |
| 828 .SendError("(X,Y) coordinates missing or invalid"); | 828 .SendError("(X,Y) coordinates missing or invalid"); |
| 829 return; | 829 return; |
| 830 } | 830 } |
| 831 | 831 |
| 832 mouse_event.type = blink::WebInputEvent::MouseUp; | 832 mouse_event.type = blink::WebInputEvent::MouseUp; |
| 833 mouse_event.button = blink::WebMouseEvent::ButtonLeft; | 833 mouse_event.button = blink::WebMouseEvent::ButtonLeft; |
| 834 mouse_event.clickCount = 1; | 834 mouse_event.clickCount = 1; |
| 835 new InputEventAckNotificationObserver(this, reply_message, mouse_event.type, | 835 new InputEventAckNotificationObserver(this, reply_message, mouse_event.type, |
| 836 1); | 836 1); |
| 837 view->ForwardMouseEvent(mouse_event); | 837 view->ForwardMouseEvent(mouse_event); |
| 838 } | 838 } |
| 839 | 839 |
| 840 void TestingAutomationProvider::WebkitMouseDoubleClick( | 840 void TestingAutomationProvider::WebkitMouseDoubleClick( |
| 841 DictionaryValue* args, IPC::Message* reply_message) { | 841 base::DictionaryValue* args, IPC::Message* reply_message) { |
| 842 if (SendErrorIfModalDialogActive(this, reply_message)) | 842 if (SendErrorIfModalDialogActive(this, reply_message)) |
| 843 return; | 843 return; |
| 844 | 844 |
| 845 RenderViewHost* view; | 845 RenderViewHost* view; |
| 846 std::string error; | 846 std::string error; |
| 847 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { | 847 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { |
| 848 AutomationJSONReply(this, reply_message).SendError(error); | 848 AutomationJSONReply(this, reply_message).SendError(error); |
| 849 return; | 849 return; |
| 850 } | 850 } |
| 851 | 851 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 869 | 869 |
| 870 mouse_event.type = blink::WebInputEvent::MouseDown; | 870 mouse_event.type = blink::WebInputEvent::MouseDown; |
| 871 mouse_event.clickCount = 2; | 871 mouse_event.clickCount = 2; |
| 872 view->ForwardMouseEvent(mouse_event); | 872 view->ForwardMouseEvent(mouse_event); |
| 873 | 873 |
| 874 mouse_event.type = blink::WebInputEvent::MouseUp; | 874 mouse_event.type = blink::WebInputEvent::MouseUp; |
| 875 view->ForwardMouseEvent(mouse_event); | 875 view->ForwardMouseEvent(mouse_event); |
| 876 } | 876 } |
| 877 | 877 |
| 878 void TestingAutomationProvider::DragAndDropFilePaths( | 878 void TestingAutomationProvider::DragAndDropFilePaths( |
| 879 DictionaryValue* args, IPC::Message* reply_message) { | 879 base::DictionaryValue* args, IPC::Message* reply_message) { |
| 880 if (SendErrorIfModalDialogActive(this, reply_message)) | 880 if (SendErrorIfModalDialogActive(this, reply_message)) |
| 881 return; | 881 return; |
| 882 | 882 |
| 883 RenderViewHost* view; | 883 RenderViewHost* view; |
| 884 std::string error; | 884 std::string error; |
| 885 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { | 885 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { |
| 886 AutomationJSONReply(this, reply_message).SendError(error); | 886 AutomationJSONReply(this, reply_message).SendError(error); |
| 887 return; | 887 return; |
| 888 } | 888 } |
| 889 | 889 |
| 890 int x, y; | 890 int x, y; |
| 891 if (!args->GetInteger("x", &x) || !args->GetInteger("y", &y)) { | 891 if (!args->GetInteger("x", &x) || !args->GetInteger("y", &y)) { |
| 892 AutomationJSONReply(this, reply_message) | 892 AutomationJSONReply(this, reply_message) |
| 893 .SendError("(X,Y) coordinates missing or invalid"); | 893 .SendError("(X,Y) coordinates missing or invalid"); |
| 894 return; | 894 return; |
| 895 } | 895 } |
| 896 | 896 |
| 897 ListValue* paths = NULL; | 897 base::ListValue* paths = NULL; |
| 898 if (!args->GetList("paths", &paths)) { | 898 if (!args->GetList("paths", &paths)) { |
| 899 AutomationJSONReply(this, reply_message) | 899 AutomationJSONReply(this, reply_message) |
| 900 .SendError("'paths' missing or invalid"); | 900 .SendError("'paths' missing or invalid"); |
| 901 return; | 901 return; |
| 902 } | 902 } |
| 903 | 903 |
| 904 // Emulate drag and drop to set the file paths to the file upload control. | 904 // Emulate drag and drop to set the file paths to the file upload control. |
| 905 content::DropData drop_data; | 905 content::DropData drop_data; |
| 906 for (size_t path_index = 0; path_index < paths->GetSize(); ++path_index) { | 906 for (size_t path_index = 0; path_index < paths->GetSize(); ++path_index) { |
| 907 base::string16 path; | 907 base::string16 path; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1045 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 1045 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 1046 new BrowserOpenedWithNewProfileNotificationObserver(this, reply_message); | 1046 new BrowserOpenedWithNewProfileNotificationObserver(this, reply_message); |
| 1047 profile_manager->CreateMultiProfileAsync( | 1047 profile_manager->CreateMultiProfileAsync( |
| 1048 base::string16(), base::string16(), ProfileManager::CreateCallback(), std:
:string()); | 1048 base::string16(), base::string16(), ProfileManager::CreateCallback(), std:
:string()); |
| 1049 } | 1049 } |
| 1050 | 1050 |
| 1051 // Sample json input: { "command": "GetMultiProfileInfo" } | 1051 // Sample json input: { "command": "GetMultiProfileInfo" } |
| 1052 // See GetMultiProfileInfo() in pyauto.py for sample output. | 1052 // See GetMultiProfileInfo() in pyauto.py for sample output. |
| 1053 void TestingAutomationProvider::GetMultiProfileInfo( | 1053 void TestingAutomationProvider::GetMultiProfileInfo( |
| 1054 base::DictionaryValue* args, IPC::Message* reply_message) { | 1054 base::DictionaryValue* args, IPC::Message* reply_message) { |
| 1055 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 1055 scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue); |
| 1056 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 1056 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 1057 const ProfileInfoCache& profile_info_cache = | 1057 const ProfileInfoCache& profile_info_cache = |
| 1058 profile_manager->GetProfileInfoCache(); | 1058 profile_manager->GetProfileInfoCache(); |
| 1059 return_value->SetBoolean("enabled", profiles::IsMultipleProfilesEnabled()); | 1059 return_value->SetBoolean("enabled", profiles::IsMultipleProfilesEnabled()); |
| 1060 | 1060 |
| 1061 ListValue* profiles = new ListValue; | 1061 base::ListValue* profiles = new base::ListValue; |
| 1062 for (size_t index = 0; index < profile_info_cache.GetNumberOfProfiles(); | 1062 for (size_t index = 0; index < profile_info_cache.GetNumberOfProfiles(); |
| 1063 ++index) { | 1063 ++index) { |
| 1064 DictionaryValue* item = new DictionaryValue; | 1064 base::DictionaryValue* item = new base::DictionaryValue; |
| 1065 item->SetString("name", profile_info_cache.GetNameOfProfileAtIndex(index)); | 1065 item->SetString("name", profile_info_cache.GetNameOfProfileAtIndex(index)); |
| 1066 item->SetString("path", | 1066 item->SetString("path", |
| 1067 profile_info_cache.GetPathOfProfileAtIndex(index).value()); | 1067 profile_info_cache.GetPathOfProfileAtIndex(index).value()); |
| 1068 profiles->Append(item); | 1068 profiles->Append(item); |
| 1069 } | 1069 } |
| 1070 return_value->Set("profiles", profiles); | 1070 return_value->Set("profiles", profiles); |
| 1071 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); | 1071 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); |
| 1072 } | 1072 } |
| 1073 | 1073 |
| 1074 void TestingAutomationProvider::OpenNewBrowserWindowOfType( | 1074 void TestingAutomationProvider::OpenNewBrowserWindowOfType( |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1098 Browser::CreateParams(Browser::TYPE_TABBED, profile_, | 1098 Browser::CreateParams(Browser::TYPE_TABBED, profile_, |
| 1099 chrome::HOST_DESKTOP_TYPE_NATIVE)); | 1099 chrome::HOST_DESKTOP_TYPE_NATIVE)); |
| 1100 chrome::AddTabAt(browser, GURL(), -1, true); | 1100 chrome::AddTabAt(browser, GURL(), -1, true); |
| 1101 if (show) | 1101 if (show) |
| 1102 browser->window()->Show(); | 1102 browser->window()->Show(); |
| 1103 } | 1103 } |
| 1104 | 1104 |
| 1105 void TestingAutomationProvider::GetBrowserWindowCountJSON( | 1105 void TestingAutomationProvider::GetBrowserWindowCountJSON( |
| 1106 base::DictionaryValue* args, | 1106 base::DictionaryValue* args, |
| 1107 IPC::Message* reply_message) { | 1107 IPC::Message* reply_message) { |
| 1108 DictionaryValue dict; | 1108 base::DictionaryValue dict; |
| 1109 // The automation layer doesn't support non-native desktops. | 1109 // The automation layer doesn't support non-native desktops. |
| 1110 dict.SetInteger("count", | 1110 dict.SetInteger("count", |
| 1111 static_cast<int>(BrowserList::GetInstance( | 1111 static_cast<int>(BrowserList::GetInstance( |
| 1112 chrome::HOST_DESKTOP_TYPE_NATIVE)->size())); | 1112 chrome::HOST_DESKTOP_TYPE_NATIVE)->size())); |
| 1113 AutomationJSONReply(this, reply_message).SendSuccess(&dict); | 1113 AutomationJSONReply(this, reply_message).SendSuccess(&dict); |
| 1114 } | 1114 } |
| 1115 | 1115 |
| 1116 void TestingAutomationProvider::CloseBrowserWindow( | 1116 void TestingAutomationProvider::CloseBrowserWindow( |
| 1117 base::DictionaryValue* args, | 1117 base::DictionaryValue* args, |
| 1118 IPC::Message* reply_message) { | 1118 IPC::Message* reply_message) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1197 if (browser) { | 1197 if (browser) { |
| 1198 FindBarTesting* find_bar = | 1198 FindBarTesting* find_bar = |
| 1199 browser->GetFindBarController()->find_bar()->GetFindBarTesting(); | 1199 browser->GetFindBarController()->find_bar()->GetFindBarTesting(); |
| 1200 find_bar->GetFindBarWindowInfo(NULL, visible); | 1200 find_bar->GetFindBarWindowInfo(NULL, visible); |
| 1201 } | 1201 } |
| 1202 } | 1202 } |
| 1203 | 1203 |
| 1204 // Bookmark bar visibility is based on the pref (e.g. is it in the toolbar). | 1204 // Bookmark bar visibility is based on the pref (e.g. is it in the toolbar). |
| 1205 // Presence in the NTP is signalled in |detached|. | 1205 // Presence in the NTP is signalled in |detached|. |
| 1206 void TestingAutomationProvider::GetBookmarkBarStatus( | 1206 void TestingAutomationProvider::GetBookmarkBarStatus( |
| 1207 DictionaryValue* args, | 1207 base::DictionaryValue* args, |
| 1208 IPC::Message* reply_message) { | 1208 IPC::Message* reply_message) { |
| 1209 AutomationJSONReply reply(this, reply_message); | 1209 AutomationJSONReply reply(this, reply_message); |
| 1210 Browser* browser; | 1210 Browser* browser; |
| 1211 std::string error_msg; | 1211 std::string error_msg; |
| 1212 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { | 1212 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { |
| 1213 reply.SendError(error_msg); | 1213 reply.SendError(error_msg); |
| 1214 return; | 1214 return; |
| 1215 } | 1215 } |
| 1216 // browser->window()->IsBookmarkBarVisible() is not consistent across | 1216 // browser->window()->IsBookmarkBarVisible() is not consistent across |
| 1217 // platforms. bookmark_bar_state() also follows prefs::kShowBookmarkBar | 1217 // platforms. bookmark_bar_state() also follows prefs::kShowBookmarkBar |
| 1218 // and has a shared implementation on all platforms. | 1218 // and has a shared implementation on all platforms. |
| 1219 DictionaryValue dict; | 1219 base::DictionaryValue dict; |
| 1220 dict.SetBoolean("visible", | 1220 dict.SetBoolean("visible", |
| 1221 browser->bookmark_bar_state() == BookmarkBar::SHOW); | 1221 browser->bookmark_bar_state() == BookmarkBar::SHOW); |
| 1222 dict.SetBoolean("animating", browser->window()->IsBookmarkBarAnimating()); | 1222 dict.SetBoolean("animating", browser->window()->IsBookmarkBarAnimating()); |
| 1223 dict.SetBoolean("detached", | 1223 dict.SetBoolean("detached", |
| 1224 browser->bookmark_bar_state() == BookmarkBar::DETACHED); | 1224 browser->bookmark_bar_state() == BookmarkBar::DETACHED); |
| 1225 reply.SendSuccess(&dict); | 1225 reply.SendSuccess(&dict); |
| 1226 } | 1226 } |
| 1227 | 1227 |
| 1228 void TestingAutomationProvider::GetBookmarksAsJSON( | 1228 void TestingAutomationProvider::GetBookmarksAsJSON( |
| 1229 DictionaryValue* args, | 1229 base::DictionaryValue* args, |
| 1230 IPC::Message* reply_message) { | 1230 IPC::Message* reply_message) { |
| 1231 AutomationJSONReply reply(this, reply_message); | 1231 AutomationJSONReply reply(this, reply_message); |
| 1232 Browser* browser; | 1232 Browser* browser; |
| 1233 std::string error_msg, bookmarks_as_json; | 1233 std::string error_msg, bookmarks_as_json; |
| 1234 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { | 1234 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { |
| 1235 reply.SendError(error_msg); | 1235 reply.SendError(error_msg); |
| 1236 return; | 1236 return; |
| 1237 } | 1237 } |
| 1238 BookmarkModel* bookmark_model = | 1238 BookmarkModel* bookmark_model = |
| 1239 BookmarkModelFactory::GetForProfile(browser->profile()); | 1239 BookmarkModelFactory::GetForProfile(browser->profile()); |
| 1240 if (!bookmark_model->loaded()) { | 1240 if (!bookmark_model->loaded()) { |
| 1241 reply.SendError("Bookmark model is not loaded"); | 1241 reply.SendError("Bookmark model is not loaded"); |
| 1242 return; | 1242 return; |
| 1243 } | 1243 } |
| 1244 scoped_refptr<BookmarkStorage> storage( | 1244 scoped_refptr<BookmarkStorage> storage( |
| 1245 new BookmarkStorage(browser->profile(), | 1245 new BookmarkStorage(browser->profile(), |
| 1246 bookmark_model, | 1246 bookmark_model, |
| 1247 browser->profile()->GetIOTaskRunner().get())); | 1247 browser->profile()->GetIOTaskRunner().get())); |
| 1248 if (!storage->SerializeData(&bookmarks_as_json)) { | 1248 if (!storage->SerializeData(&bookmarks_as_json)) { |
| 1249 reply.SendError("Failed to serialize bookmarks"); | 1249 reply.SendError("Failed to serialize bookmarks"); |
| 1250 return; | 1250 return; |
| 1251 } | 1251 } |
| 1252 DictionaryValue dict; | 1252 base::DictionaryValue dict; |
| 1253 dict.SetString("bookmarks_as_json", bookmarks_as_json); | 1253 dict.SetString("bookmarks_as_json", bookmarks_as_json); |
| 1254 reply.SendSuccess(&dict); | 1254 reply.SendSuccess(&dict); |
| 1255 } | 1255 } |
| 1256 | 1256 |
| 1257 void TestingAutomationProvider::WaitForBookmarkModelToLoad( | 1257 void TestingAutomationProvider::WaitForBookmarkModelToLoad( |
| 1258 int handle, | 1258 int handle, |
| 1259 IPC::Message* reply_message) { | 1259 IPC::Message* reply_message) { |
| 1260 if (browser_tracker_->ContainsHandle(handle)) { | 1260 if (browser_tracker_->ContainsHandle(handle)) { |
| 1261 Browser* browser = browser_tracker_->GetResource(handle); | 1261 Browser* browser = browser_tracker_->GetResource(handle); |
| 1262 BookmarkModel* model = | 1262 BookmarkModel* model = |
| 1263 BookmarkModelFactory::GetForProfile(browser->profile()); | 1263 BookmarkModelFactory::GetForProfile(browser->profile()); |
| 1264 AutomationProviderBookmarkModelObserver* observer = | 1264 AutomationProviderBookmarkModelObserver* observer = |
| 1265 new AutomationProviderBookmarkModelObserver(this, reply_message, | 1265 new AutomationProviderBookmarkModelObserver(this, reply_message, |
| 1266 model, false); | 1266 model, false); |
| 1267 if (model->loaded()) { | 1267 if (model->loaded()) { |
| 1268 observer->ReleaseReply(); | 1268 observer->ReleaseReply(); |
| 1269 delete observer; | 1269 delete observer; |
| 1270 AutomationMsg_WaitForBookmarkModelToLoad::WriteReplyParams( | 1270 AutomationMsg_WaitForBookmarkModelToLoad::WriteReplyParams( |
| 1271 reply_message, true); | 1271 reply_message, true); |
| 1272 Send(reply_message); | 1272 Send(reply_message); |
| 1273 } | 1273 } |
| 1274 } | 1274 } |
| 1275 } | 1275 } |
| 1276 | 1276 |
| 1277 void TestingAutomationProvider::WaitForBookmarkModelToLoadJSON( | 1277 void TestingAutomationProvider::WaitForBookmarkModelToLoadJSON( |
| 1278 DictionaryValue* args, | 1278 base::DictionaryValue* args, |
| 1279 IPC::Message* reply_message) { | 1279 IPC::Message* reply_message) { |
| 1280 Browser* browser; | 1280 Browser* browser; |
| 1281 std::string error_msg; | 1281 std::string error_msg; |
| 1282 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { | 1282 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { |
| 1283 AutomationJSONReply(this, reply_message).SendError(error_msg); | 1283 AutomationJSONReply(this, reply_message).SendError(error_msg); |
| 1284 return; | 1284 return; |
| 1285 } | 1285 } |
| 1286 BookmarkModel* model = | 1286 BookmarkModel* model = |
| 1287 BookmarkModelFactory::GetForProfile(browser->profile()); | 1287 BookmarkModelFactory::GetForProfile(browser->profile()); |
| 1288 AutomationProviderBookmarkModelObserver* observer = | 1288 AutomationProviderBookmarkModelObserver* observer = |
| 1289 new AutomationProviderBookmarkModelObserver(this, reply_message, model, | 1289 new AutomationProviderBookmarkModelObserver(this, reply_message, model, |
| 1290 true); | 1290 true); |
| 1291 if (model->loaded()) { | 1291 if (model->loaded()) { |
| 1292 observer->ReleaseReply(); | 1292 observer->ReleaseReply(); |
| 1293 delete observer; | 1293 delete observer; |
| 1294 AutomationJSONReply(this, reply_message).SendSuccess(NULL); | 1294 AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
| 1295 return; | 1295 return; |
| 1296 } | 1296 } |
| 1297 } | 1297 } |
| 1298 | 1298 |
| 1299 void TestingAutomationProvider::AddBookmark( | 1299 void TestingAutomationProvider::AddBookmark( |
| 1300 DictionaryValue* args, | 1300 base::DictionaryValue* args, |
| 1301 IPC::Message* reply_message) { | 1301 IPC::Message* reply_message) { |
| 1302 AutomationJSONReply reply(this, reply_message); | 1302 AutomationJSONReply reply(this, reply_message); |
| 1303 Browser* browser; | 1303 Browser* browser; |
| 1304 std::string error_msg, url; | 1304 std::string error_msg, url; |
| 1305 base::string16 title; | 1305 base::string16 title; |
| 1306 int parent_id, index; | 1306 int parent_id, index; |
| 1307 bool folder; | 1307 bool folder; |
| 1308 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { | 1308 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { |
| 1309 reply.SendError(error_msg); | 1309 reply.SendError(error_msg); |
| 1310 return; | 1310 return; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1346 } else { | 1346 } else { |
| 1347 child = model->AddURL(parent, index, title, GURL(url)); | 1347 child = model->AddURL(parent, index, title, GURL(url)); |
| 1348 } | 1348 } |
| 1349 if (!child) { | 1349 if (!child) { |
| 1350 reply.SendError("Failed to add bookmark"); | 1350 reply.SendError("Failed to add bookmark"); |
| 1351 return; | 1351 return; |
| 1352 } | 1352 } |
| 1353 reply.SendSuccess(NULL); | 1353 reply.SendSuccess(NULL); |
| 1354 } | 1354 } |
| 1355 | 1355 |
| 1356 void TestingAutomationProvider::ReparentBookmark(DictionaryValue* args, | 1356 void TestingAutomationProvider::ReparentBookmark(base::DictionaryValue* args, |
| 1357 IPC::Message* reply_message) { | 1357 IPC::Message* reply_message) { |
| 1358 AutomationJSONReply reply(this, reply_message); | 1358 AutomationJSONReply reply(this, reply_message); |
| 1359 Browser* browser; | 1359 Browser* browser; |
| 1360 std::string error_msg; | 1360 std::string error_msg; |
| 1361 int new_parent_id, id, index; | 1361 int new_parent_id, id, index; |
| 1362 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { | 1362 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { |
| 1363 reply.SendError(error_msg); | 1363 reply.SendError(error_msg); |
| 1364 return; | 1364 return; |
| 1365 } | 1365 } |
| 1366 if (!args->GetInteger("id", &id)) { | 1366 if (!args->GetInteger("id", &id)) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1388 return; | 1388 return; |
| 1389 } | 1389 } |
| 1390 if (!new_parent) { | 1390 if (!new_parent) { |
| 1391 reply.SendError("Failed to get new parent bookmark node"); | 1391 reply.SendError("Failed to get new parent bookmark node"); |
| 1392 return; | 1392 return; |
| 1393 } | 1393 } |
| 1394 model->Move(node, new_parent, index); | 1394 model->Move(node, new_parent, index); |
| 1395 reply.SendSuccess(NULL); | 1395 reply.SendSuccess(NULL); |
| 1396 } | 1396 } |
| 1397 | 1397 |
| 1398 void TestingAutomationProvider::SetBookmarkTitle(DictionaryValue* args, | 1398 void TestingAutomationProvider::SetBookmarkTitle(base::DictionaryValue* args, |
| 1399 IPC::Message* reply_message) { | 1399 IPC::Message* reply_message) { |
| 1400 AutomationJSONReply reply(this, reply_message); | 1400 AutomationJSONReply reply(this, reply_message); |
| 1401 Browser* browser; | 1401 Browser* browser; |
| 1402 std::string error_msg; | 1402 std::string error_msg; |
| 1403 base::string16 title; | 1403 base::string16 title; |
| 1404 int id; | 1404 int id; |
| 1405 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { | 1405 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { |
| 1406 reply.SendError(error_msg); | 1406 reply.SendError(error_msg); |
| 1407 return; | 1407 return; |
| 1408 } | 1408 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1422 } | 1422 } |
| 1423 const BookmarkNode* node = model->GetNodeByID(id); | 1423 const BookmarkNode* node = model->GetNodeByID(id); |
| 1424 if (!node) { | 1424 if (!node) { |
| 1425 reply.SendError("Failed to get bookmark node"); | 1425 reply.SendError("Failed to get bookmark node"); |
| 1426 return; | 1426 return; |
| 1427 } | 1427 } |
| 1428 model->SetTitle(node, title); | 1428 model->SetTitle(node, title); |
| 1429 reply.SendSuccess(NULL); | 1429 reply.SendSuccess(NULL); |
| 1430 } | 1430 } |
| 1431 | 1431 |
| 1432 void TestingAutomationProvider::SetBookmarkURL(DictionaryValue* args, | 1432 void TestingAutomationProvider::SetBookmarkURL(base::DictionaryValue* args, |
| 1433 IPC::Message* reply_message) { | 1433 IPC::Message* reply_message) { |
| 1434 AutomationJSONReply reply(this, reply_message); | 1434 AutomationJSONReply reply(this, reply_message); |
| 1435 Browser* browser; | 1435 Browser* browser; |
| 1436 std::string error_msg, url; | 1436 std::string error_msg, url; |
| 1437 int id; | 1437 int id; |
| 1438 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { | 1438 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { |
| 1439 reply.SendError(error_msg); | 1439 reply.SendError(error_msg); |
| 1440 return; | 1440 return; |
| 1441 } | 1441 } |
| 1442 if (!args->GetInteger("id", &id)) { | 1442 if (!args->GetInteger("id", &id)) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1455 } | 1455 } |
| 1456 const BookmarkNode* node = model->GetNodeByID(id); | 1456 const BookmarkNode* node = model->GetNodeByID(id); |
| 1457 if (!node) { | 1457 if (!node) { |
| 1458 reply.SendError("Failed to get bookmark node"); | 1458 reply.SendError("Failed to get bookmark node"); |
| 1459 return; | 1459 return; |
| 1460 } | 1460 } |
| 1461 model->SetURL(node, GURL(url)); | 1461 model->SetURL(node, GURL(url)); |
| 1462 reply.SendSuccess(NULL); | 1462 reply.SendSuccess(NULL); |
| 1463 } | 1463 } |
| 1464 | 1464 |
| 1465 void TestingAutomationProvider::RemoveBookmark(DictionaryValue* args, | 1465 void TestingAutomationProvider::RemoveBookmark(base::DictionaryValue* args, |
| 1466 IPC::Message* reply_message) { | 1466 IPC::Message* reply_message) { |
| 1467 AutomationJSONReply reply(this, reply_message); | 1467 AutomationJSONReply reply(this, reply_message); |
| 1468 Browser* browser; | 1468 Browser* browser; |
| 1469 std::string error_msg; | 1469 std::string error_msg; |
| 1470 int id; | 1470 int id; |
| 1471 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { | 1471 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { |
| 1472 reply.SendError(error_msg); | 1472 reply.SendError(error_msg); |
| 1473 return; | 1473 return; |
| 1474 } | 1474 } |
| 1475 if (!args->GetInteger("id", &id)) { | 1475 if (!args->GetInteger("id", &id)) { |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1864 browser_handler_map_["IsFullscreenBubbleDisplayed"] = | 1864 browser_handler_map_["IsFullscreenBubbleDisplayed"] = |
| 1865 &TestingAutomationProvider::IsFullscreenBubbleDisplayed; | 1865 &TestingAutomationProvider::IsFullscreenBubbleDisplayed; |
| 1866 browser_handler_map_["IsFullscreenBubbleDisplayingButtons"] = | 1866 browser_handler_map_["IsFullscreenBubbleDisplayingButtons"] = |
| 1867 &TestingAutomationProvider::IsFullscreenBubbleDisplayingButtons; | 1867 &TestingAutomationProvider::IsFullscreenBubbleDisplayingButtons; |
| 1868 browser_handler_map_["AcceptCurrentFullscreenOrMouseLockRequest"] = | 1868 browser_handler_map_["AcceptCurrentFullscreenOrMouseLockRequest"] = |
| 1869 &TestingAutomationProvider::AcceptCurrentFullscreenOrMouseLockRequest; | 1869 &TestingAutomationProvider::AcceptCurrentFullscreenOrMouseLockRequest; |
| 1870 browser_handler_map_["DenyCurrentFullscreenOrMouseLockRequest"] = | 1870 browser_handler_map_["DenyCurrentFullscreenOrMouseLockRequest"] = |
| 1871 &TestingAutomationProvider::DenyCurrentFullscreenOrMouseLockRequest; | 1871 &TestingAutomationProvider::DenyCurrentFullscreenOrMouseLockRequest; |
| 1872 } | 1872 } |
| 1873 | 1873 |
| 1874 scoped_ptr<DictionaryValue> TestingAutomationProvider::ParseJSONRequestCommand( | 1874 scoped_ptr<base::DictionaryValue> |
| 1875 TestingAutomationProvider::ParseJSONRequestCommand( |
| 1875 const std::string& json_request, | 1876 const std::string& json_request, |
| 1876 std::string* command, | 1877 std::string* command, |
| 1877 std::string* error) { | 1878 std::string* error) { |
| 1878 scoped_ptr<DictionaryValue> dict_value; | 1879 scoped_ptr<base::DictionaryValue> dict_value; |
| 1879 scoped_ptr<Value> values(base::JSONReader::ReadAndReturnError(json_request, | 1880 scoped_ptr<base::Value> values( |
| 1880 base::JSON_ALLOW_TRAILING_COMMAS, NULL, error)); | 1881 base::JSONReader::ReadAndReturnError(json_request, |
| 1882 base::JSON_ALLOW_TRAILING_COMMAS, NULL, error)); |
| 1881 if (values.get()) { | 1883 if (values.get()) { |
| 1882 // Make sure input is a dict with a string command. | 1884 // Make sure input is a dict with a string command. |
| 1883 if (values->GetType() != Value::TYPE_DICTIONARY) { | 1885 if (values->GetType() != base::Value::TYPE_DICTIONARY) { |
| 1884 *error = "Command dictionary is not a dictionary."; | 1886 *error = "Command dictionary is not a dictionary."; |
| 1885 } else { | 1887 } else { |
| 1886 dict_value.reset(static_cast<DictionaryValue*>(values.release())); | 1888 dict_value.reset(static_cast<base::DictionaryValue*>(values.release())); |
| 1887 if (!dict_value->GetStringASCII("command", command)) { | 1889 if (!dict_value->GetStringASCII("command", command)) { |
| 1888 *error = "Command key string missing from dictionary."; | 1890 *error = "Command key string missing from dictionary."; |
| 1889 dict_value.reset(NULL); | 1891 dict_value.reset(NULL); |
| 1890 } | 1892 } |
| 1891 } | 1893 } |
| 1892 } | 1894 } |
| 1893 return dict_value.Pass(); | 1895 return dict_value.Pass(); |
| 1894 } | 1896 } |
| 1895 | 1897 |
| 1896 void TestingAutomationProvider::SendJSONRequestWithBrowserHandle( | 1898 void TestingAutomationProvider::SendJSONRequestWithBrowserHandle( |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1918 "Browser window with index=%d does not exist.", index)); | 1920 "Browser window with index=%d does not exist.", index)); |
| 1919 } else { | 1921 } else { |
| 1920 SendJSONRequest(browser, json_request, reply_message); | 1922 SendJSONRequest(browser, json_request, reply_message); |
| 1921 } | 1923 } |
| 1922 } | 1924 } |
| 1923 | 1925 |
| 1924 void TestingAutomationProvider::SendJSONRequest(Browser* browser, | 1926 void TestingAutomationProvider::SendJSONRequest(Browser* browser, |
| 1925 const std::string& json_request, | 1927 const std::string& json_request, |
| 1926 IPC::Message* reply_message) { | 1928 IPC::Message* reply_message) { |
| 1927 std::string command, error_string; | 1929 std::string command, error_string; |
| 1928 scoped_ptr<DictionaryValue> dict_value( | 1930 scoped_ptr<base::DictionaryValue> dict_value( |
| 1929 ParseJSONRequestCommand(json_request, &command, &error_string)); | 1931 ParseJSONRequestCommand(json_request, &command, &error_string)); |
| 1930 if (!dict_value.get() || command.empty()) { | 1932 if (!dict_value.get() || command.empty()) { |
| 1931 AutomationJSONReply(this, reply_message).SendError(error_string); | 1933 AutomationJSONReply(this, reply_message).SendError(error_string); |
| 1932 return; | 1934 return; |
| 1933 } | 1935 } |
| 1934 | 1936 |
| 1935 if (handler_map_.empty() || browser_handler_map_.empty()) | 1937 if (handler_map_.empty() || browser_handler_map_.empty()) |
| 1936 BuildJSONHandlerMaps(); | 1938 BuildJSONHandlerMaps(); |
| 1937 | 1939 |
| 1938 // Look for command in handlers that take a Browser. | 1940 // Look for command in handlers that take a Browser. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1953 } | 1955 } |
| 1954 for (std::map<std::string, BrowserJsonHandler>::const_iterator it = | 1956 for (std::map<std::string, BrowserJsonHandler>::const_iterator it = |
| 1955 browser_handler_map_.begin(); it != browser_handler_map_.end(); ++it) { | 1957 browser_handler_map_.begin(); it != browser_handler_map_.end(); ++it) { |
| 1956 error_string += it->first + ", "; | 1958 error_string += it->first + ", "; |
| 1957 } | 1959 } |
| 1958 AutomationJSONReply(this, reply_message).SendError(error_string); | 1960 AutomationJSONReply(this, reply_message).SendError(error_string); |
| 1959 } | 1961 } |
| 1960 } | 1962 } |
| 1961 | 1963 |
| 1962 void TestingAutomationProvider::BringBrowserToFrontJSON( | 1964 void TestingAutomationProvider::BringBrowserToFrontJSON( |
| 1963 DictionaryValue* args, | 1965 base::DictionaryValue* args, |
| 1964 IPC::Message* reply_message) { | 1966 IPC::Message* reply_message) { |
| 1965 AutomationJSONReply reply(this, reply_message); | 1967 AutomationJSONReply reply(this, reply_message); |
| 1966 Browser* browser; | 1968 Browser* browser; |
| 1967 std::string error_msg; | 1969 std::string error_msg; |
| 1968 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { | 1970 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { |
| 1969 reply.SendError(error_msg); | 1971 reply.SendError(error_msg); |
| 1970 return; | 1972 return; |
| 1971 } | 1973 } |
| 1972 browser->window()->Activate(); | 1974 browser->window()->Activate(); |
| 1973 reply.SendSuccess(NULL); | 1975 reply.SendSuccess(NULL); |
| 1974 } | 1976 } |
| 1975 | 1977 |
| 1976 // Sample json input: { "command": "SetWindowDimensions", | 1978 // Sample json input: { "command": "SetWindowDimensions", |
| 1977 // "x": 20, # optional | 1979 // "x": 20, # optional |
| 1978 // "y": 20, # optional | 1980 // "y": 20, # optional |
| 1979 // "width": 800, # optional | 1981 // "width": 800, # optional |
| 1980 // "height": 600 } # optional | 1982 // "height": 600 } # optional |
| 1981 void TestingAutomationProvider::SetWindowDimensions( | 1983 void TestingAutomationProvider::SetWindowDimensions( |
| 1982 Browser* browser, | 1984 Browser* browser, |
| 1983 DictionaryValue* args, | 1985 base::DictionaryValue* args, |
| 1984 IPC::Message* reply_message) { | 1986 IPC::Message* reply_message) { |
| 1985 gfx::Rect rect = browser->window()->GetRestoredBounds(); | 1987 gfx::Rect rect = browser->window()->GetRestoredBounds(); |
| 1986 int x, y, width, height; | 1988 int x, y, width, height; |
| 1987 if (args->GetInteger("x", &x)) | 1989 if (args->GetInteger("x", &x)) |
| 1988 rect.set_x(x); | 1990 rect.set_x(x); |
| 1989 if (args->GetInteger("y", &y)) | 1991 if (args->GetInteger("y", &y)) |
| 1990 rect.set_y(y); | 1992 rect.set_y(y); |
| 1991 if (args->GetInteger("width", &width)) | 1993 if (args->GetInteger("width", &width)) |
| 1992 rect.set_width(width); | 1994 rect.set_width(width); |
| 1993 if (args->GetInteger("height", &height)) | 1995 if (args->GetInteger("height", &height)) |
| 1994 rect.set_height(height); | 1996 rect.set_height(height); |
| 1995 browser->window()->SetBounds(rect); | 1997 browser->window()->SetBounds(rect); |
| 1996 AutomationJSONReply(this, reply_message).SendSuccess(NULL); | 1998 AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
| 1997 } | 1999 } |
| 1998 | 2000 |
| 1999 ListValue* TestingAutomationProvider::GetInfobarsInfo(WebContents* wc) { | 2001 base::ListValue* TestingAutomationProvider::GetInfobarsInfo(WebContents* wc) { |
| 2000 // Each infobar may have different properties depending on the type. | 2002 // Each infobar may have different properties depending on the type. |
| 2001 ListValue* infobars = new ListValue; | 2003 base::ListValue* infobars = new base::ListValue; |
| 2002 InfoBarService* infobar_service = InfoBarService::FromWebContents(wc); | 2004 InfoBarService* infobar_service = InfoBarService::FromWebContents(wc); |
| 2003 for (size_t i = 0; i < infobar_service->infobar_count(); ++i) { | 2005 for (size_t i = 0; i < infobar_service->infobar_count(); ++i) { |
| 2004 DictionaryValue* infobar_item = new DictionaryValue; | 2006 base::DictionaryValue* infobar_item = new base::DictionaryValue; |
| 2005 InfoBarDelegate* infobar = infobar_service->infobar_at(i)->delegate(); | 2007 InfoBarDelegate* infobar = infobar_service->infobar_at(i)->delegate(); |
| 2006 switch (infobar->GetInfoBarAutomationType()) { | 2008 switch (infobar->GetInfoBarAutomationType()) { |
| 2007 case InfoBarDelegate::CONFIRM_INFOBAR: | 2009 case InfoBarDelegate::CONFIRM_INFOBAR: |
| 2008 infobar_item->SetString("type", "confirm_infobar"); | 2010 infobar_item->SetString("type", "confirm_infobar"); |
| 2009 break; | 2011 break; |
| 2010 case InfoBarDelegate::PASSWORD_INFOBAR: | 2012 case InfoBarDelegate::PASSWORD_INFOBAR: |
| 2011 infobar_item->SetString("type", "password_infobar"); | 2013 infobar_item->SetString("type", "password_infobar"); |
| 2012 break; | 2014 break; |
| 2013 case InfoBarDelegate::RPH_INFOBAR: | 2015 case InfoBarDelegate::RPH_INFOBAR: |
| 2014 infobar_item->SetString("type", "rph_infobar"); | 2016 infobar_item->SetString("type", "rph_infobar"); |
| 2015 break; | 2017 break; |
| 2016 case InfoBarDelegate::UNKNOWN_INFOBAR: | 2018 case InfoBarDelegate::UNKNOWN_INFOBAR: |
| 2017 infobar_item->SetString("type", "unknown_infobar"); | 2019 infobar_item->SetString("type", "unknown_infobar"); |
| 2018 break; | 2020 break; |
| 2019 } | 2021 } |
| 2020 if (infobar->AsConfirmInfoBarDelegate()) { | 2022 if (infobar->AsConfirmInfoBarDelegate()) { |
| 2021 // Also covers ThemeInstalledInfoBarDelegate. | 2023 // Also covers ThemeInstalledInfoBarDelegate. |
| 2022 ConfirmInfoBarDelegate* confirm_infobar = | 2024 ConfirmInfoBarDelegate* confirm_infobar = |
| 2023 infobar->AsConfirmInfoBarDelegate(); | 2025 infobar->AsConfirmInfoBarDelegate(); |
| 2024 infobar_item->SetString("text", confirm_infobar->GetMessageText()); | 2026 infobar_item->SetString("text", confirm_infobar->GetMessageText()); |
| 2025 infobar_item->SetString("link_text", confirm_infobar->GetLinkText()); | 2027 infobar_item->SetString("link_text", confirm_infobar->GetLinkText()); |
| 2026 ListValue* buttons_list = new ListValue; | 2028 base::ListValue* buttons_list = new base::ListValue; |
| 2027 int buttons = confirm_infobar->GetButtons(); | 2029 int buttons = confirm_infobar->GetButtons(); |
| 2028 if (buttons & ConfirmInfoBarDelegate::BUTTON_OK) { | 2030 if (buttons & ConfirmInfoBarDelegate::BUTTON_OK) { |
| 2029 StringValue* button_label = new StringValue( | 2031 base::StringValue* button_label = new base::StringValue( |
| 2030 confirm_infobar->GetButtonLabel( | 2032 confirm_infobar->GetButtonLabel( |
| 2031 ConfirmInfoBarDelegate::BUTTON_OK)); | 2033 ConfirmInfoBarDelegate::BUTTON_OK)); |
| 2032 buttons_list->Append(button_label); | 2034 buttons_list->Append(button_label); |
| 2033 } | 2035 } |
| 2034 if (buttons & ConfirmInfoBarDelegate::BUTTON_CANCEL) { | 2036 if (buttons & ConfirmInfoBarDelegate::BUTTON_CANCEL) { |
| 2035 StringValue* button_label = new StringValue( | 2037 base::StringValue* button_label = new base::StringValue( |
| 2036 confirm_infobar->GetButtonLabel( | 2038 confirm_infobar->GetButtonLabel( |
| 2037 ConfirmInfoBarDelegate::BUTTON_CANCEL)); | 2039 ConfirmInfoBarDelegate::BUTTON_CANCEL)); |
| 2038 buttons_list->Append(button_label); | 2040 buttons_list->Append(button_label); |
| 2039 } | 2041 } |
| 2040 infobar_item->Set("buttons", buttons_list); | 2042 infobar_item->Set("buttons", buttons_list); |
| 2041 } else if (infobar->AsExtensionInfoBarDelegate()) { | 2043 } else if (infobar->AsExtensionInfoBarDelegate()) { |
| 2042 infobar_item->SetString("type", "extension_infobar"); | 2044 infobar_item->SetString("type", "extension_infobar"); |
| 2043 } else { | 2045 } else { |
| 2044 infobar_item->SetString("type", "unknown_infobar"); | 2046 infobar_item->SetString("type", "unknown_infobar"); |
| 2045 } | 2047 } |
| 2046 infobars->Append(infobar_item); | 2048 infobars->Append(infobar_item); |
| 2047 } | 2049 } |
| 2048 return infobars; | 2050 return infobars; |
| 2049 } | 2051 } |
| 2050 | 2052 |
| 2051 // Sample json input: { "command": "PerformActionOnInfobar", | 2053 // Sample json input: { "command": "PerformActionOnInfobar", |
| 2052 // "action": "dismiss", | 2054 // "action": "dismiss", |
| 2053 // "infobar_index": 0, | 2055 // "infobar_index": 0, |
| 2054 // "tab_index": 0 } | 2056 // "tab_index": 0 } |
| 2055 // Sample output: {} | 2057 // Sample output: {} |
| 2056 void TestingAutomationProvider::PerformActionOnInfobar( | 2058 void TestingAutomationProvider::PerformActionOnInfobar( |
| 2057 Browser* browser, | 2059 Browser* browser, |
| 2058 DictionaryValue* args, | 2060 base::DictionaryValue* args, |
| 2059 IPC::Message* reply_message) { | 2061 IPC::Message* reply_message) { |
| 2060 AutomationJSONReply reply(this, reply_message); | 2062 AutomationJSONReply reply(this, reply_message); |
| 2061 int tab_index; | 2063 int tab_index; |
| 2062 int infobar_index_int; | 2064 int infobar_index_int; |
| 2063 std::string action; | 2065 std::string action; |
| 2064 if (!args->GetInteger("tab_index", &tab_index) || | 2066 if (!args->GetInteger("tab_index", &tab_index) || |
| 2065 !args->GetInteger("infobar_index", &infobar_index_int) || | 2067 !args->GetInteger("infobar_index", &infobar_index_int) || |
| 2066 !args->GetString("action", &action)) { | 2068 !args->GetString("action", &action)) { |
| 2067 reply.SendError("Invalid or missing args"); | 2069 reply.SendError("Invalid or missing args"); |
| 2068 return; | 2070 return; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2107 } | 2109 } |
| 2108 | 2110 |
| 2109 reply.SendError("Invalid action"); | 2111 reply.SendError("Invalid action"); |
| 2110 } | 2112 } |
| 2111 | 2113 |
| 2112 namespace { | 2114 namespace { |
| 2113 | 2115 |
| 2114 // Gets info about BrowserChildProcessHost. Must run on IO thread to | 2116 // Gets info about BrowserChildProcessHost. Must run on IO thread to |
| 2115 // honor the semantics of BrowserChildProcessHostIterator. | 2117 // honor the semantics of BrowserChildProcessHostIterator. |
| 2116 // Used by AutomationProvider::GetBrowserInfo(). | 2118 // Used by AutomationProvider::GetBrowserInfo(). |
| 2117 void GetChildProcessHostInfo(ListValue* child_processes) { | 2119 void GetChildProcessHostInfo(base::ListValue* child_processes) { |
| 2118 for (BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) { | 2120 for (BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) { |
| 2119 // Only add processes which are already started, since we need their handle. | 2121 // Only add processes which are already started, since we need their handle. |
| 2120 if (iter.GetData().handle == base::kNullProcessHandle) | 2122 if (iter.GetData().handle == base::kNullProcessHandle) |
| 2121 continue; | 2123 continue; |
| 2122 DictionaryValue* item = new DictionaryValue; | 2124 base::DictionaryValue* item = new base::DictionaryValue; |
| 2123 item->SetString("name", iter.GetData().name); | 2125 item->SetString("name", iter.GetData().name); |
| 2124 item->SetString( | 2126 item->SetString( |
| 2125 "type", | 2127 "type", |
| 2126 content::GetProcessTypeNameInEnglish(iter.GetData().process_type)); | 2128 content::GetProcessTypeNameInEnglish(iter.GetData().process_type)); |
| 2127 item->SetInteger("pid", base::GetProcId(iter.GetData().handle)); | 2129 item->SetInteger("pid", base::GetProcId(iter.GetData().handle)); |
| 2128 child_processes->Append(item); | 2130 child_processes->Append(item); |
| 2129 } | 2131 } |
| 2130 } | 2132 } |
| 2131 | 2133 |
| 2132 } // namespace | 2134 } // namespace |
| 2133 | 2135 |
| 2134 // Sample json input: { "command": "GetBrowserInfo" } | 2136 // Sample json input: { "command": "GetBrowserInfo" } |
| 2135 // Refer to GetBrowserInfo() in chrome/test/pyautolib/pyauto.py for | 2137 // Refer to GetBrowserInfo() in chrome/test/pyautolib/pyauto.py for |
| 2136 // sample json output. | 2138 // sample json output. |
| 2137 void TestingAutomationProvider::GetBrowserInfo( | 2139 void TestingAutomationProvider::GetBrowserInfo( |
| 2138 DictionaryValue* args, | 2140 base::DictionaryValue* args, |
| 2139 IPC::Message* reply_message) { | 2141 IPC::Message* reply_message) { |
| 2140 base::ThreadRestrictions::ScopedAllowIO allow_io; // needed for PathService | 2142 base::ThreadRestrictions::ScopedAllowIO allow_io; // needed for PathService |
| 2141 DictionaryValue* properties = new DictionaryValue; | 2143 base::DictionaryValue* properties = new base::DictionaryValue; |
| 2142 properties->SetString("ChromeVersion", chrome::kChromeVersion); | 2144 properties->SetString("ChromeVersion", chrome::kChromeVersion); |
| 2143 properties->SetString("BrowserProcessExecutableName", | 2145 properties->SetString("BrowserProcessExecutableName", |
| 2144 chrome::kBrowserProcessExecutableName); | 2146 chrome::kBrowserProcessExecutableName); |
| 2145 properties->SetString("HelperProcessExecutableName", | 2147 properties->SetString("HelperProcessExecutableName", |
| 2146 chrome::kHelperProcessExecutableName); | 2148 chrome::kHelperProcessExecutableName); |
| 2147 properties->SetString("BrowserProcessExecutablePath", | 2149 properties->SetString("BrowserProcessExecutablePath", |
| 2148 chrome::kBrowserProcessExecutablePath); | 2150 chrome::kBrowserProcessExecutablePath); |
| 2149 properties->SetString("HelperProcessExecutablePath", | 2151 properties->SetString("HelperProcessExecutablePath", |
| 2150 chrome::kHelperProcessExecutablePath); | 2152 chrome::kHelperProcessExecutablePath); |
| 2151 properties->SetString("command_line_string", | 2153 properties->SetString("command_line_string", |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2168 branding = "Unknown Branding"; | 2170 branding = "Unknown Branding"; |
| 2169 #endif | 2171 #endif |
| 2170 properties->SetString("branding", branding); | 2172 properties->SetString("branding", branding); |
| 2171 | 2173 |
| 2172 bool is_official_build = false; | 2174 bool is_official_build = false; |
| 2173 #if defined(OFFICIAL_BUILD) | 2175 #if defined(OFFICIAL_BUILD) |
| 2174 is_official_build = true; | 2176 is_official_build = true; |
| 2175 #endif | 2177 #endif |
| 2176 properties->SetBoolean("is_official", is_official_build); | 2178 properties->SetBoolean("is_official", is_official_build); |
| 2177 | 2179 |
| 2178 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 2180 scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue); |
| 2179 return_value->Set("properties", properties); | 2181 return_value->Set("properties", properties); |
| 2180 | 2182 |
| 2181 return_value->SetInteger("browser_pid", base::GetCurrentProcId()); | 2183 return_value->SetInteger("browser_pid", base::GetCurrentProcId()); |
| 2182 // Add info about all windows in a list of dictionaries, one dictionary | 2184 // Add info about all windows in a list of dictionaries, one dictionary |
| 2183 // item per window. | 2185 // item per window. |
| 2184 ListValue* windows = new ListValue; | 2186 base::ListValue* windows = new base::ListValue; |
| 2185 int windex = 0; | 2187 int windex = 0; |
| 2186 | 2188 |
| 2187 for (chrome::BrowserIterator it; !it.done(); it.Next(), ++windex) { | 2189 for (chrome::BrowserIterator it; !it.done(); it.Next(), ++windex) { |
| 2188 DictionaryValue* browser_item = new DictionaryValue; | 2190 base::DictionaryValue* browser_item = new base::DictionaryValue; |
| 2189 Browser* browser = *it; | 2191 Browser* browser = *it; |
| 2190 browser_item->SetInteger("index", windex); | 2192 browser_item->SetInteger("index", windex); |
| 2191 // Window properties | 2193 // Window properties |
| 2192 gfx::Rect rect = browser->window()->GetRestoredBounds(); | 2194 gfx::Rect rect = browser->window()->GetRestoredBounds(); |
| 2193 browser_item->SetInteger("x", rect.x()); | 2195 browser_item->SetInteger("x", rect.x()); |
| 2194 browser_item->SetInteger("y", rect.y()); | 2196 browser_item->SetInteger("y", rect.y()); |
| 2195 browser_item->SetInteger("width", rect.width()); | 2197 browser_item->SetInteger("width", rect.width()); |
| 2196 browser_item->SetInteger("height", rect.height()); | 2198 browser_item->SetInteger("height", rect.height()); |
| 2197 browser_item->SetBoolean("fullscreen", | 2199 browser_item->SetBoolean("fullscreen", |
| 2198 browser->window()->IsFullscreen()); | 2200 browser->window()->IsFullscreen()); |
| 2199 ListValue* visible_page_actions = new ListValue; | 2201 base::ListValue* visible_page_actions = new base::ListValue; |
| 2200 // Add info about all visible page actions. Skipped on panels, which do not | 2202 // Add info about all visible page actions. Skipped on panels, which do not |
| 2201 // have a location bar. | 2203 // have a location bar. |
| 2202 LocationBar* loc_bar = browser->window()->GetLocationBar(); | 2204 LocationBar* loc_bar = browser->window()->GetLocationBar(); |
| 2203 if (loc_bar) { | 2205 if (loc_bar) { |
| 2204 LocationBarTesting* loc_bar_test = | 2206 LocationBarTesting* loc_bar_test = |
| 2205 loc_bar->GetLocationBarForTesting(); | 2207 loc_bar->GetLocationBarForTesting(); |
| 2206 size_t page_action_visible_count = | 2208 size_t page_action_visible_count = |
| 2207 static_cast<size_t>(loc_bar_test->PageActionVisibleCount()); | 2209 static_cast<size_t>(loc_bar_test->PageActionVisibleCount()); |
| 2208 for (size_t i = 0; i < page_action_visible_count; ++i) { | 2210 for (size_t i = 0; i < page_action_visible_count; ++i) { |
| 2209 StringValue* extension_id = new StringValue( | 2211 base::StringValue* extension_id = new base::StringValue( |
| 2210 loc_bar_test->GetVisiblePageAction(i)->extension_id()); | 2212 loc_bar_test->GetVisiblePageAction(i)->extension_id()); |
| 2211 visible_page_actions->Append(extension_id); | 2213 visible_page_actions->Append(extension_id); |
| 2212 } | 2214 } |
| 2213 } | 2215 } |
| 2214 browser_item->Set("visible_page_actions", visible_page_actions); | 2216 browser_item->Set("visible_page_actions", visible_page_actions); |
| 2215 browser_item->SetInteger("selected_tab", | 2217 browser_item->SetInteger("selected_tab", |
| 2216 browser->tab_strip_model()->active_index()); | 2218 browser->tab_strip_model()->active_index()); |
| 2217 browser_item->SetBoolean("incognito", | 2219 browser_item->SetBoolean("incognito", |
| 2218 browser->profile()->IsOffTheRecord()); | 2220 browser->profile()->IsOffTheRecord()); |
| 2219 browser_item->SetString("profile_path", | 2221 browser_item->SetString("profile_path", |
| 2220 browser->profile()->GetPath().BaseName().MaybeAsASCII()); | 2222 browser->profile()->GetPath().BaseName().MaybeAsASCII()); |
| 2221 std::string type; | 2223 std::string type; |
| 2222 switch (browser->type()) { | 2224 switch (browser->type()) { |
| 2223 case Browser::TYPE_TABBED: | 2225 case Browser::TYPE_TABBED: |
| 2224 type = "tabbed"; | 2226 type = "tabbed"; |
| 2225 break; | 2227 break; |
| 2226 case Browser::TYPE_POPUP: | 2228 case Browser::TYPE_POPUP: |
| 2227 type = "popup"; | 2229 type = "popup"; |
| 2228 break; | 2230 break; |
| 2229 default: | 2231 default: |
| 2230 type = "unknown"; | 2232 type = "unknown"; |
| 2231 break; | 2233 break; |
| 2232 } | 2234 } |
| 2233 browser_item->SetString("type", type); | 2235 browser_item->SetString("type", type); |
| 2234 // For each window, add info about all tabs in a list of dictionaries, | 2236 // For each window, add info about all tabs in a list of dictionaries, |
| 2235 // one dictionary item per tab. | 2237 // one dictionary item per tab. |
| 2236 ListValue* tabs = new ListValue; | 2238 base::ListValue* tabs = new base::ListValue; |
| 2237 for (int i = 0; i < browser->tab_strip_model()->count(); ++i) { | 2239 for (int i = 0; i < browser->tab_strip_model()->count(); ++i) { |
| 2238 WebContents* wc = browser->tab_strip_model()->GetWebContentsAt(i); | 2240 WebContents* wc = browser->tab_strip_model()->GetWebContentsAt(i); |
| 2239 DictionaryValue* tab = new DictionaryValue; | 2241 base::DictionaryValue* tab = new base::DictionaryValue; |
| 2240 tab->SetInteger("index", i); | 2242 tab->SetInteger("index", i); |
| 2241 tab->SetString("url", wc->GetURL().spec()); | 2243 tab->SetString("url", wc->GetURL().spec()); |
| 2242 tab->SetInteger("renderer_pid", | 2244 tab->SetInteger("renderer_pid", |
| 2243 base::GetProcId(wc->GetRenderProcessHost()->GetHandle())); | 2245 base::GetProcId(wc->GetRenderProcessHost()->GetHandle())); |
| 2244 tab->Set("infobars", GetInfobarsInfo(wc)); | 2246 tab->Set("infobars", GetInfobarsInfo(wc)); |
| 2245 tab->SetBoolean("pinned", browser->tab_strip_model()->IsTabPinned(i)); | 2247 tab->SetBoolean("pinned", browser->tab_strip_model()->IsTabPinned(i)); |
| 2246 tabs->Append(tab); | 2248 tabs->Append(tab); |
| 2247 } | 2249 } |
| 2248 browser_item->Set("tabs", tabs); | 2250 browser_item->Set("tabs", tabs); |
| 2249 | 2251 |
| 2250 windows->Append(browser_item); | 2252 windows->Append(browser_item); |
| 2251 } | 2253 } |
| 2252 return_value->Set("windows", windows); | 2254 return_value->Set("windows", windows); |
| 2253 | 2255 |
| 2254 #if defined(OS_LINUX) | 2256 #if defined(OS_LINUX) |
| 2255 int flags = ChildProcessHost::CHILD_ALLOW_SELF; | 2257 int flags = ChildProcessHost::CHILD_ALLOW_SELF; |
| 2256 #else | 2258 #else |
| 2257 int flags = ChildProcessHost::CHILD_NORMAL; | 2259 int flags = ChildProcessHost::CHILD_NORMAL; |
| 2258 #endif | 2260 #endif |
| 2259 | 2261 |
| 2260 // Add all extension processes in a list of dictionaries, one dictionary | 2262 // Add all extension processes in a list of dictionaries, one dictionary |
| 2261 // item per extension process. | 2263 // item per extension process. |
| 2262 ListValue* extension_views = new ListValue; | 2264 base::ListValue* extension_views = new base::ListValue; |
| 2263 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 2265 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 2264 std::vector<Profile*> profiles(profile_manager->GetLoadedProfiles()); | 2266 std::vector<Profile*> profiles(profile_manager->GetLoadedProfiles()); |
| 2265 for (size_t i = 0; i < profiles.size(); ++i) { | 2267 for (size_t i = 0; i < profiles.size(); ++i) { |
| 2266 extensions::ProcessManager* process_manager = | 2268 extensions::ProcessManager* process_manager = |
| 2267 extensions::ExtensionSystem::Get(profiles[i])->process_manager(); | 2269 extensions::ExtensionSystem::Get(profiles[i])->process_manager(); |
| 2268 if (!process_manager) | 2270 if (!process_manager) |
| 2269 continue; | 2271 continue; |
| 2270 const extensions::ProcessManager::ViewSet view_set = | 2272 const extensions::ProcessManager::ViewSet view_set = |
| 2271 process_manager->GetAllViews(); | 2273 process_manager->GetAllViews(); |
| 2272 for (extensions::ProcessManager::ViewSet::const_iterator jt = | 2274 for (extensions::ProcessManager::ViewSet::const_iterator jt = |
| 2273 view_set.begin(); | 2275 view_set.begin(); |
| 2274 jt != view_set.end(); ++jt) { | 2276 jt != view_set.end(); ++jt) { |
| 2275 content::RenderViewHost* render_view_host = *jt; | 2277 content::RenderViewHost* render_view_host = *jt; |
| 2276 // Don't add dead extension processes. | 2278 // Don't add dead extension processes. |
| 2277 if (!render_view_host->IsRenderViewLive()) | 2279 if (!render_view_host->IsRenderViewLive()) |
| 2278 continue; | 2280 continue; |
| 2279 // Don't add views for which we can't obtain an extension. | 2281 // Don't add views for which we can't obtain an extension. |
| 2280 // TODO(benwells): work out why this happens. It only happens for one | 2282 // TODO(benwells): work out why this happens. It only happens for one |
| 2281 // test, and only on the bots. | 2283 // test, and only on the bots. |
| 2282 const Extension* extension = | 2284 const Extension* extension = |
| 2283 process_manager->GetExtensionForRenderViewHost(render_view_host); | 2285 process_manager->GetExtensionForRenderViewHost(render_view_host); |
| 2284 if (!extension) | 2286 if (!extension) |
| 2285 continue; | 2287 continue; |
| 2286 DictionaryValue* item = new DictionaryValue; | 2288 base::DictionaryValue* item = new base::DictionaryValue; |
| 2287 item->SetString("name", extension->name()); | 2289 item->SetString("name", extension->name()); |
| 2288 item->SetString("extension_id", extension->id()); | 2290 item->SetString("extension_id", extension->id()); |
| 2289 item->SetInteger( | 2291 item->SetInteger( |
| 2290 "pid", | 2292 "pid", |
| 2291 base::GetProcId(render_view_host->GetProcess()->GetHandle())); | 2293 base::GetProcId(render_view_host->GetProcess()->GetHandle())); |
| 2292 DictionaryValue* view = new DictionaryValue; | 2294 base::DictionaryValue* view = new base::DictionaryValue; |
| 2293 view->SetInteger( | 2295 view->SetInteger( |
| 2294 "render_process_id", | 2296 "render_process_id", |
| 2295 render_view_host->GetProcess()->GetID()); | 2297 render_view_host->GetProcess()->GetID()); |
| 2296 view->SetInteger( | 2298 view->SetInteger( |
| 2297 "render_view_id", | 2299 "render_view_id", |
| 2298 render_view_host->GetRoutingID()); | 2300 render_view_host->GetRoutingID()); |
| 2299 item->Set("view", view); | 2301 item->Set("view", view); |
| 2300 std::string type; | 2302 std::string type; |
| 2301 WebContents* web_contents = | 2303 WebContents* web_contents = |
| 2302 WebContents::FromRenderViewHost(render_view_host); | 2304 WebContents::FromRenderViewHost(render_view_host); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2330 extension_views->Append(item); | 2332 extension_views->Append(item); |
| 2331 } | 2333 } |
| 2332 } | 2334 } |
| 2333 return_value->Set("extension_views", extension_views); | 2335 return_value->Set("extension_views", extension_views); |
| 2334 | 2336 |
| 2335 return_value->SetString("child_process_path", | 2337 return_value->SetString("child_process_path", |
| 2336 ChildProcessHost::GetChildPath(flags).value()); | 2338 ChildProcessHost::GetChildPath(flags).value()); |
| 2337 // Child processes are the processes for plugins and other workers. | 2339 // Child processes are the processes for plugins and other workers. |
| 2338 // Add all child processes in a list of dictionaries, one dictionary item | 2340 // Add all child processes in a list of dictionaries, one dictionary item |
| 2339 // per child process. | 2341 // per child process. |
| 2340 ListValue* child_processes = new ListValue; | 2342 base::ListValue* child_processes = new base::ListValue; |
| 2341 return_value->Set("child_processes", child_processes); | 2343 return_value->Set("child_processes", child_processes); |
| 2342 BrowserThread::PostTaskAndReply( | 2344 BrowserThread::PostTaskAndReply( |
| 2343 BrowserThread::IO, FROM_HERE, | 2345 BrowserThread::IO, FROM_HERE, |
| 2344 base::Bind(&GetChildProcessHostInfo, child_processes), | 2346 base::Bind(&GetChildProcessHostInfo, child_processes), |
| 2345 base::Bind(&AutomationJSONReply::SendSuccess, | 2347 base::Bind(&AutomationJSONReply::SendSuccess, |
| 2346 base::Owned(new AutomationJSONReply(this, reply_message)), | 2348 base::Owned(new AutomationJSONReply(this, reply_message)), |
| 2347 base::Owned(return_value.release()))); | 2349 base::Owned(return_value.release()))); |
| 2348 } | 2350 } |
| 2349 | 2351 |
| 2350 // Sample json input: { "command": "GetProcessInfo" } | 2352 // Sample json input: { "command": "GetProcessInfo" } |
| 2351 // Refer to GetProcessInfo() in chrome/test/pyautolib/pyauto.py for | 2353 // Refer to GetProcessInfo() in chrome/test/pyautolib/pyauto.py for |
| 2352 // sample json output. | 2354 // sample json output. |
| 2353 void TestingAutomationProvider::GetProcessInfo( | 2355 void TestingAutomationProvider::GetProcessInfo( |
| 2354 DictionaryValue* args, | 2356 base::DictionaryValue* args, |
| 2355 IPC::Message* reply_message) { | 2357 IPC::Message* reply_message) { |
| 2356 scoped_refptr<ProcessInfoObserver> | 2358 scoped_refptr<ProcessInfoObserver> |
| 2357 proc_observer(new ProcessInfoObserver(this, reply_message)); | 2359 proc_observer(new ProcessInfoObserver(this, reply_message)); |
| 2358 // TODO(jamescook): Maybe this shouldn't update UMA stats? | 2360 // TODO(jamescook): Maybe this shouldn't update UMA stats? |
| 2359 proc_observer->StartFetch(MemoryDetails::UPDATE_USER_METRICS); | 2361 proc_observer->StartFetch(MemoryDetails::UPDATE_USER_METRICS); |
| 2360 } | 2362 } |
| 2361 | 2363 |
| 2362 // Sample json input: { "command": "GetNavigationInfo" } | 2364 // Sample json input: { "command": "GetNavigationInfo" } |
| 2363 // Refer to GetNavigationInfo() in chrome/test/pyautolib/pyauto.py for | 2365 // Refer to GetNavigationInfo() in chrome/test/pyautolib/pyauto.py for |
| 2364 // sample json output. | 2366 // sample json output. |
| 2365 void TestingAutomationProvider::GetNavigationInfo( | 2367 void TestingAutomationProvider::GetNavigationInfo( |
| 2366 Browser* browser, | 2368 Browser* browser, |
| 2367 DictionaryValue* args, | 2369 base::DictionaryValue* args, |
| 2368 IPC::Message* reply_message) { | 2370 IPC::Message* reply_message) { |
| 2369 AutomationJSONReply reply(this, reply_message); | 2371 AutomationJSONReply reply(this, reply_message); |
| 2370 int tab_index; | 2372 int tab_index; |
| 2371 WebContents* web_contents = NULL; | 2373 WebContents* web_contents = NULL; |
| 2372 if (!args->GetInteger("tab_index", &tab_index) || | 2374 if (!args->GetInteger("tab_index", &tab_index) || |
| 2373 !(web_contents = | 2375 !(web_contents = |
| 2374 browser->tab_strip_model()->GetWebContentsAt(tab_index))) { | 2376 browser->tab_strip_model()->GetWebContentsAt(tab_index))) { |
| 2375 reply.SendError("tab_index missing or invalid."); | 2377 reply.SendError("tab_index missing or invalid."); |
| 2376 return; | 2378 return; |
| 2377 } | 2379 } |
| 2378 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 2380 scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue); |
| 2379 const NavigationController& controller = web_contents->GetController(); | 2381 const NavigationController& controller = web_contents->GetController(); |
| 2380 NavigationEntry* nav_entry = controller.GetActiveEntry(); | 2382 NavigationEntry* nav_entry = controller.GetActiveEntry(); |
| 2381 DCHECK(nav_entry); | 2383 DCHECK(nav_entry); |
| 2382 | 2384 |
| 2383 // Security info. | 2385 // Security info. |
| 2384 DictionaryValue* ssl = new DictionaryValue; | 2386 base::DictionaryValue* ssl = new base::DictionaryValue; |
| 2385 std::map<content::SecurityStyle, std::string> style_to_string; | 2387 std::map<content::SecurityStyle, std::string> style_to_string; |
| 2386 style_to_string[content::SECURITY_STYLE_UNKNOWN] = "SECURITY_STYLE_UNKNOWN"; | 2388 style_to_string[content::SECURITY_STYLE_UNKNOWN] = "SECURITY_STYLE_UNKNOWN"; |
| 2387 style_to_string[content::SECURITY_STYLE_UNAUTHENTICATED] = | 2389 style_to_string[content::SECURITY_STYLE_UNAUTHENTICATED] = |
| 2388 "SECURITY_STYLE_UNAUTHENTICATED"; | 2390 "SECURITY_STYLE_UNAUTHENTICATED"; |
| 2389 style_to_string[content::SECURITY_STYLE_AUTHENTICATION_BROKEN] = | 2391 style_to_string[content::SECURITY_STYLE_AUTHENTICATION_BROKEN] = |
| 2390 "SECURITY_STYLE_AUTHENTICATION_BROKEN"; | 2392 "SECURITY_STYLE_AUTHENTICATION_BROKEN"; |
| 2391 style_to_string[content::SECURITY_STYLE_AUTHENTICATED] = | 2393 style_to_string[content::SECURITY_STYLE_AUTHENTICATED] = |
| 2392 "SECURITY_STYLE_AUTHENTICATED"; | 2394 "SECURITY_STYLE_AUTHENTICATED"; |
| 2393 | 2395 |
| 2394 SSLStatus ssl_status = nav_entry->GetSSL(); | 2396 SSLStatus ssl_status = nav_entry->GetSSL(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2410 pagetype_to_string[nav_entry->GetPageType()]); | 2412 pagetype_to_string[nav_entry->GetPageType()]); |
| 2411 | 2413 |
| 2412 return_value->SetString("favicon_url", nav_entry->GetFavicon().url.spec()); | 2414 return_value->SetString("favicon_url", nav_entry->GetFavicon().url.spec()); |
| 2413 reply.SendSuccess(return_value.get()); | 2415 reply.SendSuccess(return_value.get()); |
| 2414 } | 2416 } |
| 2415 | 2417 |
| 2416 // Sample json input: { "command": "GetHistoryInfo", | 2418 // Sample json input: { "command": "GetHistoryInfo", |
| 2417 // "search_text": "some text" } | 2419 // "search_text": "some text" } |
| 2418 // Refer chrome/test/pyautolib/history_info.py for sample json output. | 2420 // Refer chrome/test/pyautolib/history_info.py for sample json output. |
| 2419 void TestingAutomationProvider::GetHistoryInfo(Browser* browser, | 2421 void TestingAutomationProvider::GetHistoryInfo(Browser* browser, |
| 2420 DictionaryValue* args, | 2422 base::DictionaryValue* args, |
| 2421 IPC::Message* reply_message) { | 2423 IPC::Message* reply_message) { |
| 2422 consumer_.CancelAllRequests(); | 2424 consumer_.CancelAllRequests(); |
| 2423 | 2425 |
| 2424 base::string16 search_text; | 2426 base::string16 search_text; |
| 2425 args->GetString("search_text", &search_text); | 2427 args->GetString("search_text", &search_text); |
| 2426 | 2428 |
| 2427 // Fetch history. | 2429 // Fetch history. |
| 2428 HistoryService* hs = HistoryServiceFactory::GetForProfile( | 2430 HistoryService* hs = HistoryServiceFactory::GetForProfile( |
| 2429 browser->profile(), Profile::EXPLICIT_ACCESS); | 2431 browser->profile(), Profile::EXPLICIT_ACCESS); |
| 2430 history::QueryOptions options; | 2432 history::QueryOptions options; |
| 2431 // The observer owns itself. It deletes itself after it fetches history. | 2433 // The observer owns itself. It deletes itself after it fetches history. |
| 2432 AutomationProviderHistoryObserver* history_observer = | 2434 AutomationProviderHistoryObserver* history_observer = |
| 2433 new AutomationProviderHistoryObserver(this, reply_message); | 2435 new AutomationProviderHistoryObserver(this, reply_message); |
| 2434 hs->QueryHistory( | 2436 hs->QueryHistory( |
| 2435 search_text, | 2437 search_text, |
| 2436 options, | 2438 options, |
| 2437 &consumer_, | 2439 &consumer_, |
| 2438 base::Bind(&AutomationProviderHistoryObserver::HistoryQueryComplete, | 2440 base::Bind(&AutomationProviderHistoryObserver::HistoryQueryComplete, |
| 2439 base::Unretained(history_observer))); | 2441 base::Unretained(history_observer))); |
| 2440 } | 2442 } |
| 2441 | 2443 |
| 2442 // Sample json input: { "command": "GetDownloadsInfo" } | 2444 // Sample json input: { "command": "GetDownloadsInfo" } |
| 2443 // Refer chrome/test/pyautolib/download_info.py for sample json output. | 2445 // Refer chrome/test/pyautolib/download_info.py for sample json output. |
| 2444 void TestingAutomationProvider::GetDownloadsInfo(Browser* browser, | 2446 void TestingAutomationProvider::GetDownloadsInfo(Browser* browser, |
| 2445 DictionaryValue* args, | 2447 base::DictionaryValue* args, |
| 2446 IPC::Message* reply_message) { | 2448 IPC::Message* reply_message) { |
| 2447 AutomationJSONReply reply(this, reply_message); | 2449 AutomationJSONReply reply(this, reply_message); |
| 2448 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 2450 scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue); |
| 2449 ListValue* list_of_downloads = new ListValue; | 2451 base::ListValue* list_of_downloads = new base::ListValue; |
| 2450 | 2452 |
| 2451 DownloadService* download_service( | 2453 DownloadService* download_service( |
| 2452 DownloadServiceFactory::GetForBrowserContext(browser->profile())); | 2454 DownloadServiceFactory::GetForBrowserContext(browser->profile())); |
| 2453 | 2455 |
| 2454 if (download_service->HasCreatedDownloadManager()) { | 2456 if (download_service->HasCreatedDownloadManager()) { |
| 2455 std::vector<DownloadItem*> downloads; | 2457 std::vector<DownloadItem*> downloads; |
| 2456 BrowserContext::GetDownloadManager(browser->profile())->GetAllDownloads( | 2458 BrowserContext::GetDownloadManager(browser->profile())->GetAllDownloads( |
| 2457 &downloads); | 2459 &downloads); |
| 2458 | 2460 |
| 2459 for (std::vector<DownloadItem*>::iterator it = downloads.begin(); | 2461 for (std::vector<DownloadItem*>::iterator it = downloads.begin(); |
| 2460 it != downloads.end(); | 2462 it != downloads.end(); |
| 2461 it++) { // Fill info about each download item. | 2463 it++) { // Fill info about each download item. |
| 2462 list_of_downloads->Append(GetDictionaryFromDownloadItem( | 2464 list_of_downloads->Append(GetDictionaryFromDownloadItem( |
| 2463 *it, browser->profile()->IsOffTheRecord())); | 2465 *it, browser->profile()->IsOffTheRecord())); |
| 2464 } | 2466 } |
| 2465 } | 2467 } |
| 2466 return_value->Set("downloads", list_of_downloads); | 2468 return_value->Set("downloads", list_of_downloads); |
| 2467 reply.SendSuccess(return_value.get()); | 2469 reply.SendSuccess(return_value.get()); |
| 2468 } | 2470 } |
| 2469 | 2471 |
| 2470 void TestingAutomationProvider::WaitForAllDownloadsToComplete( | 2472 void TestingAutomationProvider::WaitForAllDownloadsToComplete( |
| 2471 Browser* browser, | 2473 Browser* browser, |
| 2472 DictionaryValue* args, | 2474 base::DictionaryValue* args, |
| 2473 IPC::Message* reply_message) { | 2475 IPC::Message* reply_message) { |
| 2474 ListValue* pre_download_ids = NULL; | 2476 base::ListValue* pre_download_ids = NULL; |
| 2475 | 2477 |
| 2476 if (!args->GetList("pre_download_ids", &pre_download_ids)) { | 2478 if (!args->GetList("pre_download_ids", &pre_download_ids)) { |
| 2477 AutomationJSONReply(this, reply_message) | 2479 AutomationJSONReply(this, reply_message) |
| 2478 .SendError( | 2480 .SendError( |
| 2479 base::StringPrintf("List of IDs of previous downloads required.")); | 2481 base::StringPrintf("List of IDs of previous downloads required.")); |
| 2480 return; | 2482 return; |
| 2481 } | 2483 } |
| 2482 | 2484 |
| 2483 DownloadService* download_service = | 2485 DownloadService* download_service = |
| 2484 DownloadServiceFactory::GetForBrowserContext(browser->profile()); | 2486 DownloadServiceFactory::GetForBrowserContext(browser->profile()); |
| 2485 if (!download_service->HasCreatedDownloadManager()) { | 2487 if (!download_service->HasCreatedDownloadManager()) { |
| 2486 // No download manager, so no downloads to wait for. | 2488 // No download manager, so no downloads to wait for. |
| 2487 AutomationJSONReply(this, reply_message).SendSuccess(NULL); | 2489 AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
| 2488 return; | 2490 return; |
| 2489 } | 2491 } |
| 2490 | 2492 |
| 2491 // This observer will delete itself. | 2493 // This observer will delete itself. |
| 2492 new AllDownloadsCompleteObserver( | 2494 new AllDownloadsCompleteObserver( |
| 2493 this, reply_message, | 2495 this, reply_message, |
| 2494 BrowserContext::GetDownloadManager(browser->profile()), | 2496 BrowserContext::GetDownloadManager(browser->profile()), |
| 2495 pre_download_ids); | 2497 pre_download_ids); |
| 2496 } | 2498 } |
| 2497 | 2499 |
| 2498 // See PerformActionOnDownload() in chrome/test/pyautolib/pyauto.py for sample | 2500 // See PerformActionOnDownload() in chrome/test/pyautolib/pyauto.py for sample |
| 2499 // json input and output. | 2501 // json input and output. |
| 2500 void TestingAutomationProvider::PerformActionOnDownload( | 2502 void TestingAutomationProvider::PerformActionOnDownload( |
| 2501 Browser* browser, | 2503 Browser* browser, |
| 2502 DictionaryValue* args, | 2504 base::DictionaryValue* args, |
| 2503 IPC::Message* reply_message) { | 2505 IPC::Message* reply_message) { |
| 2504 int id; | 2506 int id; |
| 2505 std::string action; | 2507 std::string action; |
| 2506 | 2508 |
| 2507 DownloadService* download_service = | 2509 DownloadService* download_service = |
| 2508 DownloadServiceFactory::GetForBrowserContext(browser->profile()); | 2510 DownloadServiceFactory::GetForBrowserContext(browser->profile()); |
| 2509 if (!download_service->HasCreatedDownloadManager()) { | 2511 if (!download_service->HasCreatedDownloadManager()) { |
| 2510 AutomationJSONReply(this, reply_message).SendError("No download manager."); | 2512 AutomationJSONReply(this, reply_message).SendError("No download manager."); |
| 2511 return; | 2513 return; |
| 2512 } | 2514 } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2590 this, reply_message, false, browser->profile()->IsOffTheRecord())); | 2592 this, reply_message, false, browser->profile()->IsOffTheRecord())); |
| 2591 selected_item->Cancel(true); | 2593 selected_item->Cancel(true); |
| 2592 } else { | 2594 } else { |
| 2593 AutomationJSONReply(this, reply_message) | 2595 AutomationJSONReply(this, reply_message) |
| 2594 .SendError( | 2596 .SendError( |
| 2595 base::StringPrintf("Invalid action '%s' given.", action.c_str())); | 2597 base::StringPrintf("Invalid action '%s' given.", action.c_str())); |
| 2596 } | 2598 } |
| 2597 } | 2599 } |
| 2598 | 2600 |
| 2599 void TestingAutomationProvider::SetDownloadShelfVisibleJSON( | 2601 void TestingAutomationProvider::SetDownloadShelfVisibleJSON( |
| 2600 DictionaryValue* args, | 2602 base::DictionaryValue* args, |
| 2601 IPC::Message* reply_message) { | 2603 IPC::Message* reply_message) { |
| 2602 AutomationJSONReply reply(this, reply_message); | 2604 AutomationJSONReply reply(this, reply_message); |
| 2603 Browser* browser; | 2605 Browser* browser; |
| 2604 std::string error_msg; | 2606 std::string error_msg; |
| 2605 bool is_visible; | 2607 bool is_visible; |
| 2606 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { | 2608 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { |
| 2607 reply.SendError(error_msg); | 2609 reply.SendError(error_msg); |
| 2608 return; | 2610 return; |
| 2609 } | 2611 } |
| 2610 if (!args->GetBoolean("is_visible", &is_visible)) { | 2612 if (!args->GetBoolean("is_visible", &is_visible)) { |
| 2611 reply.SendError("'is_visible' missing or invalid."); | 2613 reply.SendError("'is_visible' missing or invalid."); |
| 2612 return; | 2614 return; |
| 2613 } | 2615 } |
| 2614 if (is_visible) { | 2616 if (is_visible) { |
| 2615 browser->window()->GetDownloadShelf()->Show(); | 2617 browser->window()->GetDownloadShelf()->Show(); |
| 2616 } else { | 2618 } else { |
| 2617 browser->window()->GetDownloadShelf()->Close(DownloadShelf::AUTOMATIC); | 2619 browser->window()->GetDownloadShelf()->Close(DownloadShelf::AUTOMATIC); |
| 2618 } | 2620 } |
| 2619 reply.SendSuccess(NULL); | 2621 reply.SendSuccess(NULL); |
| 2620 } | 2622 } |
| 2621 | 2623 |
| 2622 void TestingAutomationProvider::IsDownloadShelfVisibleJSON( | 2624 void TestingAutomationProvider::IsDownloadShelfVisibleJSON( |
| 2623 DictionaryValue* args, | 2625 base::DictionaryValue* args, |
| 2624 IPC::Message* reply_message) { | 2626 IPC::Message* reply_message) { |
| 2625 AutomationJSONReply reply(this, reply_message); | 2627 AutomationJSONReply reply(this, reply_message); |
| 2626 Browser* browser; | 2628 Browser* browser; |
| 2627 std::string error_msg; | 2629 std::string error_msg; |
| 2628 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { | 2630 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { |
| 2629 reply.SendError(error_msg); | 2631 reply.SendError(error_msg); |
| 2630 return; | 2632 return; |
| 2631 } | 2633 } |
| 2632 DictionaryValue dict; | 2634 base::DictionaryValue dict; |
| 2633 dict.SetBoolean("is_visible", browser->window()->IsDownloadShelfVisible()); | 2635 dict.SetBoolean("is_visible", browser->window()->IsDownloadShelfVisible()); |
| 2634 reply.SendSuccess(&dict); | 2636 reply.SendSuccess(&dict); |
| 2635 } | 2637 } |
| 2636 | 2638 |
| 2637 void TestingAutomationProvider::GetDownloadDirectoryJSON( | 2639 void TestingAutomationProvider::GetDownloadDirectoryJSON( |
| 2638 DictionaryValue* args, | 2640 base::DictionaryValue* args, |
| 2639 IPC::Message* reply_message) { | 2641 IPC::Message* reply_message) { |
| 2640 AutomationJSONReply reply(this, reply_message); | 2642 AutomationJSONReply reply(this, reply_message); |
| 2641 WebContents* web_contents; | 2643 WebContents* web_contents; |
| 2642 std::string error; | 2644 std::string error; |
| 2643 if (!GetTabFromJSONArgs(args, &web_contents, &error)) { | 2645 if (!GetTabFromJSONArgs(args, &web_contents, &error)) { |
| 2644 reply.SendError(error); | 2646 reply.SendError(error); |
| 2645 return; | 2647 return; |
| 2646 } | 2648 } |
| 2647 DownloadManager* dlm = | 2649 DownloadManager* dlm = |
| 2648 BrowserContext::GetDownloadManager( | 2650 BrowserContext::GetDownloadManager( |
| 2649 web_contents->GetController().GetBrowserContext()); | 2651 web_contents->GetController().GetBrowserContext()); |
| 2650 DictionaryValue dict; | 2652 base::DictionaryValue dict; |
| 2651 dict.SetString("path", | 2653 dict.SetString("path", |
| 2652 DownloadPrefs::FromDownloadManager(dlm)->DownloadPath().value()); | 2654 DownloadPrefs::FromDownloadManager(dlm)->DownloadPath().value()); |
| 2653 reply.SendSuccess(&dict); | 2655 reply.SendSuccess(&dict); |
| 2654 } | 2656 } |
| 2655 | 2657 |
| 2656 // Sample JSON input { "command": "LoadSearchEngineInfo" } | 2658 // Sample JSON input { "command": "LoadSearchEngineInfo" } |
| 2657 void TestingAutomationProvider::LoadSearchEngineInfo( | 2659 void TestingAutomationProvider::LoadSearchEngineInfo( |
| 2658 Browser* browser, | 2660 Browser* browser, |
| 2659 DictionaryValue* args, | 2661 base::DictionaryValue* args, |
| 2660 IPC::Message* reply_message) { | 2662 IPC::Message* reply_message) { |
| 2661 TemplateURLService* url_model = | 2663 TemplateURLService* url_model = |
| 2662 TemplateURLServiceFactory::GetForProfile(browser->profile()); | 2664 TemplateURLServiceFactory::GetForProfile(browser->profile()); |
| 2663 if (url_model->loaded()) { | 2665 if (url_model->loaded()) { |
| 2664 AutomationJSONReply(this, reply_message).SendSuccess(NULL); | 2666 AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
| 2665 return; | 2667 return; |
| 2666 } | 2668 } |
| 2667 url_model->AddObserver(new AutomationProviderSearchEngineObserver( | 2669 url_model->AddObserver(new AutomationProviderSearchEngineObserver( |
| 2668 this, browser->profile(), reply_message)); | 2670 this, browser->profile(), reply_message)); |
| 2669 url_model->Load(); | 2671 url_model->Load(); |
| 2670 } | 2672 } |
| 2671 | 2673 |
| 2672 // Sample JSON input { "command": "GetSearchEngineInfo" } | 2674 // Sample JSON input { "command": "GetSearchEngineInfo" } |
| 2673 // Refer to pyauto.py for sample output. | 2675 // Refer to pyauto.py for sample output. |
| 2674 void TestingAutomationProvider::GetSearchEngineInfo( | 2676 void TestingAutomationProvider::GetSearchEngineInfo( |
| 2675 Browser* browser, | 2677 Browser* browser, |
| 2676 DictionaryValue* args, | 2678 base::DictionaryValue* args, |
| 2677 IPC::Message* reply_message) { | 2679 IPC::Message* reply_message) { |
| 2678 TemplateURLService* url_model = | 2680 TemplateURLService* url_model = |
| 2679 TemplateURLServiceFactory::GetForProfile(browser->profile()); | 2681 TemplateURLServiceFactory::GetForProfile(browser->profile()); |
| 2680 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 2682 scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue); |
| 2681 ListValue* search_engines = new ListValue; | 2683 base::ListValue* search_engines = new base::ListValue; |
| 2682 TemplateURLService::TemplateURLVector template_urls = | 2684 TemplateURLService::TemplateURLVector template_urls = |
| 2683 url_model->GetTemplateURLs(); | 2685 url_model->GetTemplateURLs(); |
| 2684 for (TemplateURLService::TemplateURLVector::const_iterator it = | 2686 for (TemplateURLService::TemplateURLVector::const_iterator it = |
| 2685 template_urls.begin(); it != template_urls.end(); ++it) { | 2687 template_urls.begin(); it != template_urls.end(); ++it) { |
| 2686 DictionaryValue* search_engine = new DictionaryValue; | 2688 base::DictionaryValue* search_engine = new base::DictionaryValue; |
| 2687 search_engine->SetString("short_name", UTF16ToUTF8((*it)->short_name())); | 2689 search_engine->SetString("short_name", UTF16ToUTF8((*it)->short_name())); |
| 2688 search_engine->SetString("keyword", UTF16ToUTF8((*it)->keyword())); | 2690 search_engine->SetString("keyword", UTF16ToUTF8((*it)->keyword())); |
| 2689 search_engine->SetBoolean("in_default_list", (*it)->ShowInDefaultList()); | 2691 search_engine->SetBoolean("in_default_list", (*it)->ShowInDefaultList()); |
| 2690 search_engine->SetBoolean("is_default", | 2692 search_engine->SetBoolean("is_default", |
| 2691 (*it) == url_model->GetDefaultSearchProvider()); | 2693 (*it) == url_model->GetDefaultSearchProvider()); |
| 2692 search_engine->SetBoolean("is_valid", (*it)->url_ref().IsValid()); | 2694 search_engine->SetBoolean("is_valid", (*it)->url_ref().IsValid()); |
| 2693 search_engine->SetBoolean("supports_replacement", | 2695 search_engine->SetBoolean("supports_replacement", |
| 2694 (*it)->url_ref().SupportsReplacement()); | 2696 (*it)->url_ref().SupportsReplacement()); |
| 2695 search_engine->SetString("url", (*it)->url()); | 2697 search_engine->SetString("url", (*it)->url()); |
| 2696 search_engine->SetString("host", (*it)->url_ref().GetHost()); | 2698 search_engine->SetString("host", (*it)->url_ref().GetHost()); |
| 2697 search_engine->SetString("path", (*it)->url_ref().GetPath()); | 2699 search_engine->SetString("path", (*it)->url_ref().GetPath()); |
| 2698 search_engine->SetString("display_url", | 2700 search_engine->SetString("display_url", |
| 2699 UTF16ToUTF8((*it)->url_ref().DisplayURL())); | 2701 UTF16ToUTF8((*it)->url_ref().DisplayURL())); |
| 2700 search_engines->Append(search_engine); | 2702 search_engines->Append(search_engine); |
| 2701 } | 2703 } |
| 2702 return_value->Set("search_engines", search_engines); | 2704 return_value->Set("search_engines", search_engines); |
| 2703 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); | 2705 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); |
| 2704 } | 2706 } |
| 2705 | 2707 |
| 2706 // Refer to pyauto.py for sample JSON input. | 2708 // Refer to pyauto.py for sample JSON input. |
| 2707 void TestingAutomationProvider::AddOrEditSearchEngine( | 2709 void TestingAutomationProvider::AddOrEditSearchEngine( |
| 2708 Browser* browser, | 2710 Browser* browser, |
| 2709 DictionaryValue* args, | 2711 base::DictionaryValue* args, |
| 2710 IPC::Message* reply_message) { | 2712 IPC::Message* reply_message) { |
| 2711 TemplateURLService* url_model = | 2713 TemplateURLService* url_model = |
| 2712 TemplateURLServiceFactory::GetForProfile(browser->profile()); | 2714 TemplateURLServiceFactory::GetForProfile(browser->profile()); |
| 2713 base::string16 new_title; | 2715 base::string16 new_title; |
| 2714 base::string16 new_keyword; | 2716 base::string16 new_keyword; |
| 2715 std::string new_url; | 2717 std::string new_url; |
| 2716 std::string keyword; | 2718 std::string keyword; |
| 2717 if (!args->GetString("new_title", &new_title) || | 2719 if (!args->GetString("new_title", &new_title) || |
| 2718 !args->GetString("new_keyword", &new_keyword) || | 2720 !args->GetString("new_keyword", &new_keyword) || |
| 2719 !args->GetString("new_url", &new_url)) { | 2721 !args->GetString("new_url", &new_url)) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2741 url_model->AddObserver(new AutomationProviderSearchEngineObserver( | 2743 url_model->AddObserver(new AutomationProviderSearchEngineObserver( |
| 2742 this, browser->profile(), reply_message)); | 2744 this, browser->profile(), reply_message)); |
| 2743 controller->AddTemplateURL(new_title, new_keyword, new_ref_url); | 2745 controller->AddTemplateURL(new_title, new_keyword, new_ref_url); |
| 2744 } | 2746 } |
| 2745 } | 2747 } |
| 2746 | 2748 |
| 2747 // Sample json input: { "command": "PerformActionOnSearchEngine", | 2749 // Sample json input: { "command": "PerformActionOnSearchEngine", |
| 2748 // "keyword": keyword, "action": action } | 2750 // "keyword": keyword, "action": action } |
| 2749 void TestingAutomationProvider::PerformActionOnSearchEngine( | 2751 void TestingAutomationProvider::PerformActionOnSearchEngine( |
| 2750 Browser* browser, | 2752 Browser* browser, |
| 2751 DictionaryValue* args, | 2753 base::DictionaryValue* args, |
| 2752 IPC::Message* reply_message) { | 2754 IPC::Message* reply_message) { |
| 2753 TemplateURLService* url_model = | 2755 TemplateURLService* url_model = |
| 2754 TemplateURLServiceFactory::GetForProfile(browser->profile()); | 2756 TemplateURLServiceFactory::GetForProfile(browser->profile()); |
| 2755 std::string keyword; | 2757 std::string keyword; |
| 2756 std::string action; | 2758 std::string action; |
| 2757 if (!args->GetString("keyword", &keyword) || | 2759 if (!args->GetString("keyword", &keyword) || |
| 2758 !args->GetString("action", &action)) { | 2760 !args->GetString("action", &action)) { |
| 2759 AutomationJSONReply(this, reply_message).SendError( | 2761 AutomationJSONReply(this, reply_message).SendError( |
| 2760 "One or more inputs invalid"); | 2762 "One or more inputs invalid"); |
| 2761 return; | 2763 return; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2777 url_model->SetDefaultSearchProvider(template_url); | 2779 url_model->SetDefaultSearchProvider(template_url); |
| 2778 } else { | 2780 } else { |
| 2779 AutomationJSONReply(this, reply_message).SendError( | 2781 AutomationJSONReply(this, reply_message).SendError( |
| 2780 "Invalid action: " + action); | 2782 "Invalid action: " + action); |
| 2781 } | 2783 } |
| 2782 } | 2784 } |
| 2783 | 2785 |
| 2784 // Sample json input: { "command": "GetLocalStatePrefsInfo" } | 2786 // Sample json input: { "command": "GetLocalStatePrefsInfo" } |
| 2785 // Refer chrome/test/pyautolib/prefs_info.py for sample json output. | 2787 // Refer chrome/test/pyautolib/prefs_info.py for sample json output. |
| 2786 void TestingAutomationProvider::GetLocalStatePrefsInfo( | 2788 void TestingAutomationProvider::GetLocalStatePrefsInfo( |
| 2787 DictionaryValue* args, | 2789 base::DictionaryValue* args, |
| 2788 IPC::Message* reply_message) { | 2790 IPC::Message* reply_message) { |
| 2789 scoped_ptr<DictionaryValue> items( | 2791 scoped_ptr<base::DictionaryValue> items( |
| 2790 g_browser_process->local_state()->GetPreferenceValues()); | 2792 g_browser_process->local_state()->GetPreferenceValues()); |
| 2791 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 2793 scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue); |
| 2792 return_value->Set("prefs", items.release()); // return_value owns items. | 2794 return_value->Set("prefs", items.release()); // return_value owns items. |
| 2793 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); | 2795 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); |
| 2794 } | 2796 } |
| 2795 | 2797 |
| 2796 // Sample json input: { "command": "SetLocalStatePrefs", "path": path, | 2798 // Sample json input: { "command": "SetLocalStatePrefs", "path": path, |
| 2797 // "value": value } | 2799 // "value": value } |
| 2798 void TestingAutomationProvider::SetLocalStatePrefs( | 2800 void TestingAutomationProvider::SetLocalStatePrefs( |
| 2799 DictionaryValue* args, | 2801 base::DictionaryValue* args, |
| 2800 IPC::Message* reply_message) { | 2802 IPC::Message* reply_message) { |
| 2801 std::string path; | 2803 std::string path; |
| 2802 Value* val = NULL; | 2804 base::Value* val = NULL; |
| 2803 AutomationJSONReply reply(this, reply_message); | 2805 AutomationJSONReply reply(this, reply_message); |
| 2804 if (args->GetString("path", &path) && args->Get("value", &val)) { | 2806 if (args->GetString("path", &path) && args->Get("value", &val)) { |
| 2805 PrefService* pref_service = g_browser_process->local_state(); | 2807 PrefService* pref_service = g_browser_process->local_state(); |
| 2806 const PrefService::Preference* pref = | 2808 const PrefService::Preference* pref = |
| 2807 pref_service->FindPreference(path.c_str()); | 2809 pref_service->FindPreference(path.c_str()); |
| 2808 if (!pref) { // Not a registered pref. | 2810 if (!pref) { // Not a registered pref. |
| 2809 reply.SendError("pref not registered."); | 2811 reply.SendError("pref not registered."); |
| 2810 return; | 2812 return; |
| 2811 } else if (pref->IsManaged()) { // Do not attempt to change a managed pref. | 2813 } else if (pref->IsManaged()) { // Do not attempt to change a managed pref. |
| 2812 reply.SendError("pref is managed. cannot be changed."); | 2814 reply.SendError("pref is managed. cannot be changed."); |
| 2813 return; | 2815 return; |
| 2814 } else { // Set the pref. | 2816 } else { // Set the pref. |
| 2815 pref_service->Set(path.c_str(), *val); | 2817 pref_service->Set(path.c_str(), *val); |
| 2816 } | 2818 } |
| 2817 } else { | 2819 } else { |
| 2818 reply.SendError("no pref path or value given."); | 2820 reply.SendError("no pref path or value given."); |
| 2819 return; | 2821 return; |
| 2820 } | 2822 } |
| 2821 | 2823 |
| 2822 reply.SendSuccess(NULL); | 2824 reply.SendSuccess(NULL); |
| 2823 } | 2825 } |
| 2824 | 2826 |
| 2825 // Sample json input: { "command": "GetPrefsInfo", "windex": 0 } | 2827 // Sample json input: { "command": "GetPrefsInfo", "windex": 0 } |
| 2826 // Refer chrome/test/pyautolib/prefs_info.py for sample json output. | 2828 // Refer chrome/test/pyautolib/prefs_info.py for sample json output. |
| 2827 void TestingAutomationProvider::GetPrefsInfo(DictionaryValue* args, | 2829 void TestingAutomationProvider::GetPrefsInfo(base::DictionaryValue* args, |
| 2828 IPC::Message* reply_message) { | 2830 IPC::Message* reply_message) { |
| 2829 AutomationJSONReply reply(this, reply_message); | 2831 AutomationJSONReply reply(this, reply_message); |
| 2830 Browser* browser; | 2832 Browser* browser; |
| 2831 std::string error_msg; | 2833 std::string error_msg; |
| 2832 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { | 2834 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { |
| 2833 reply.SendError(error_msg); | 2835 reply.SendError(error_msg); |
| 2834 return; | 2836 return; |
| 2835 } | 2837 } |
| 2836 scoped_ptr<DictionaryValue> items( | 2838 scoped_ptr<base::DictionaryValue> items( |
| 2837 browser->profile()->GetPrefs()->GetPreferenceValues()); | 2839 browser->profile()->GetPrefs()->GetPreferenceValues()); |
| 2838 | 2840 |
| 2839 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 2841 scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue); |
| 2840 return_value->Set("prefs", items.release()); // return_value owns items. | 2842 return_value->Set("prefs", items.release()); // return_value owns items. |
| 2841 reply.SendSuccess(return_value.get()); | 2843 reply.SendSuccess(return_value.get()); |
| 2842 } | 2844 } |
| 2843 | 2845 |
| 2844 // Sample json input: | 2846 // Sample json input: |
| 2845 // { "command": "SetPrefs", | 2847 // { "command": "SetPrefs", |
| 2846 // "windex": 0, | 2848 // "windex": 0, |
| 2847 // "path": path, | 2849 // "path": path, |
| 2848 // "value": value } | 2850 // "value": value } |
| 2849 void TestingAutomationProvider::SetPrefs(DictionaryValue* args, | 2851 void TestingAutomationProvider::SetPrefs(base::DictionaryValue* args, |
| 2850 IPC::Message* reply_message) { | 2852 IPC::Message* reply_message) { |
| 2851 AutomationJSONReply reply(this, reply_message); | 2853 AutomationJSONReply reply(this, reply_message); |
| 2852 Browser* browser; | 2854 Browser* browser; |
| 2853 std::string error_msg; | 2855 std::string error_msg; |
| 2854 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { | 2856 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { |
| 2855 reply.SendError(error_msg); | 2857 reply.SendError(error_msg); |
| 2856 return; | 2858 return; |
| 2857 } | 2859 } |
| 2858 std::string path; | 2860 std::string path; |
| 2859 Value* val = NULL; | 2861 base::Value* val = NULL; |
| 2860 if (args->GetString("path", &path) && args->Get("value", &val)) { | 2862 if (args->GetString("path", &path) && args->Get("value", &val)) { |
| 2861 PrefService* pref_service = browser->profile()->GetPrefs(); | 2863 PrefService* pref_service = browser->profile()->GetPrefs(); |
| 2862 const PrefService::Preference* pref = | 2864 const PrefService::Preference* pref = |
| 2863 pref_service->FindPreference(path.c_str()); | 2865 pref_service->FindPreference(path.c_str()); |
| 2864 if (!pref) { // Not a registered pref. | 2866 if (!pref) { // Not a registered pref. |
| 2865 reply.SendError("pref not registered."); | 2867 reply.SendError("pref not registered."); |
| 2866 return; | 2868 return; |
| 2867 } else if (pref->IsManaged()) { // Do not attempt to change a managed pref. | 2869 } else if (pref->IsManaged()) { // Do not attempt to change a managed pref. |
| 2868 reply.SendError("pref is managed. cannot be changed."); | 2870 reply.SendError("pref is managed. cannot be changed."); |
| 2869 return; | 2871 return; |
| 2870 } else { // Set the pref. | 2872 } else { // Set the pref. |
| 2871 pref_service->Set(path.c_str(), *val); | 2873 pref_service->Set(path.c_str(), *val); |
| 2872 } | 2874 } |
| 2873 } else { | 2875 } else { |
| 2874 reply.SendError("no pref path or value given."); | 2876 reply.SendError("no pref path or value given."); |
| 2875 return; | 2877 return; |
| 2876 } | 2878 } |
| 2877 | 2879 |
| 2878 reply.SendSuccess(NULL); | 2880 reply.SendSuccess(NULL); |
| 2879 } | 2881 } |
| 2880 | 2882 |
| 2881 // Sample json input: { "command": "GetOmniboxInfo" } | 2883 // Sample json input: { "command": "GetOmniboxInfo" } |
| 2882 // Refer chrome/test/pyautolib/omnibox_info.py for sample json output. | 2884 // Refer chrome/test/pyautolib/omnibox_info.py for sample json output. |
| 2883 void TestingAutomationProvider::GetOmniboxInfo(Browser* browser, | 2885 void TestingAutomationProvider::GetOmniboxInfo(Browser* browser, |
| 2884 DictionaryValue* args, | 2886 base::DictionaryValue* args, |
| 2885 IPC::Message* reply_message) { | 2887 IPC::Message* reply_message) { |
| 2886 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 2888 scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue); |
| 2887 AutomationJSONReply reply(this, reply_message); | 2889 AutomationJSONReply reply(this, reply_message); |
| 2888 | 2890 |
| 2889 LocationBar* loc_bar = browser->window()->GetLocationBar(); | 2891 LocationBar* loc_bar = browser->window()->GetLocationBar(); |
| 2890 if (!loc_bar) { | 2892 if (!loc_bar) { |
| 2891 reply.SendError("The specified browser does not have a location bar."); | 2893 reply.SendError("The specified browser does not have a location bar."); |
| 2892 return; | 2894 return; |
| 2893 } | 2895 } |
| 2894 const OmniboxView* omnibox_view = loc_bar->GetOmniboxView(); | 2896 const OmniboxView* omnibox_view = loc_bar->GetOmniboxView(); |
| 2895 const OmniboxEditModel* model = omnibox_view->model(); | 2897 const OmniboxEditModel* model = omnibox_view->model(); |
| 2896 | 2898 |
| 2897 // Fill up matches. | 2899 // Fill up matches. |
| 2898 ListValue* matches = new ListValue; | 2900 base::ListValue* matches = new base::ListValue; |
| 2899 const AutocompleteResult& result = model->result(); | 2901 const AutocompleteResult& result = model->result(); |
| 2900 for (AutocompleteResult::const_iterator i(result.begin()); i != result.end(); | 2902 for (AutocompleteResult::const_iterator i(result.begin()); i != result.end(); |
| 2901 ++i) { | 2903 ++i) { |
| 2902 const AutocompleteMatch& match = *i; | 2904 const AutocompleteMatch& match = *i; |
| 2903 DictionaryValue* item = new DictionaryValue; // owned by return_value | 2905 base::DictionaryValue* item = |
| 2906 new base::DictionaryValue; // owned by return_value |
| 2904 item->SetString("type", AutocompleteMatchType::ToString(match.type)); | 2907 item->SetString("type", AutocompleteMatchType::ToString(match.type)); |
| 2905 item->SetBoolean("starred", match.starred); | 2908 item->SetBoolean("starred", match.starred); |
| 2906 item->SetString("destination_url", match.destination_url.spec()); | 2909 item->SetString("destination_url", match.destination_url.spec()); |
| 2907 item->SetString("contents", match.contents); | 2910 item->SetString("contents", match.contents); |
| 2908 item->SetString("description", match.description); | 2911 item->SetString("description", match.description); |
| 2909 matches->Append(item); | 2912 matches->Append(item); |
| 2910 } | 2913 } |
| 2911 return_value->Set("matches", matches); | 2914 return_value->Set("matches", matches); |
| 2912 | 2915 |
| 2913 // Fill up other properties. | 2916 // Fill up other properties. |
| 2914 DictionaryValue* properties = new DictionaryValue; // owned by return_value | 2917 base::DictionaryValue* properties = |
| 2918 new base::DictionaryValue; // owned by return_value |
| 2915 properties->SetBoolean("has_focus", model->has_focus()); | 2919 properties->SetBoolean("has_focus", model->has_focus()); |
| 2916 properties->SetBoolean("query_in_progress", | 2920 properties->SetBoolean("query_in_progress", |
| 2917 !model->autocomplete_controller()->done()); | 2921 !model->autocomplete_controller()->done()); |
| 2918 properties->SetString("keyword", model->keyword()); | 2922 properties->SetString("keyword", model->keyword()); |
| 2919 properties->SetString("text", omnibox_view->GetText()); | 2923 properties->SetString("text", omnibox_view->GetText()); |
| 2920 return_value->Set("properties", properties); | 2924 return_value->Set("properties", properties); |
| 2921 | 2925 |
| 2922 reply.SendSuccess(return_value.get()); | 2926 reply.SendSuccess(return_value.get()); |
| 2923 } | 2927 } |
| 2924 | 2928 |
| 2925 // Sample json input: { "command": "SetOmniboxText", | 2929 // Sample json input: { "command": "SetOmniboxText", |
| 2926 // "text": "goog" } | 2930 // "text": "goog" } |
| 2927 void TestingAutomationProvider::SetOmniboxText(Browser* browser, | 2931 void TestingAutomationProvider::SetOmniboxText(Browser* browser, |
| 2928 DictionaryValue* args, | 2932 base::DictionaryValue* args, |
| 2929 IPC::Message* reply_message) { | 2933 IPC::Message* reply_message) { |
| 2930 base::string16 text; | 2934 base::string16 text; |
| 2931 AutomationJSONReply reply(this, reply_message); | 2935 AutomationJSONReply reply(this, reply_message); |
| 2932 if (!args->GetString("text", &text)) { | 2936 if (!args->GetString("text", &text)) { |
| 2933 reply.SendError("text missing"); | 2937 reply.SendError("text missing"); |
| 2934 return; | 2938 return; |
| 2935 } | 2939 } |
| 2936 chrome::FocusLocationBar(browser); | 2940 chrome::FocusLocationBar(browser); |
| 2937 LocationBar* loc_bar = browser->window()->GetLocationBar(); | 2941 LocationBar* loc_bar = browser->window()->GetLocationBar(); |
| 2938 if (!loc_bar) { | 2942 if (!loc_bar) { |
| 2939 reply.SendError("The specified browser does not have a location bar."); | 2943 reply.SendError("The specified browser does not have a location bar."); |
| 2940 return; | 2944 return; |
| 2941 } | 2945 } |
| 2942 OmniboxView* omnibox_view = loc_bar->GetOmniboxView(); | 2946 OmniboxView* omnibox_view = loc_bar->GetOmniboxView(); |
| 2943 omnibox_view->model()->OnSetFocus(false); | 2947 omnibox_view->model()->OnSetFocus(false); |
| 2944 omnibox_view->SetUserText(text); | 2948 omnibox_view->SetUserText(text); |
| 2945 reply.SendSuccess(NULL); | 2949 reply.SendSuccess(NULL); |
| 2946 } | 2950 } |
| 2947 | 2951 |
| 2948 // Sample json input: { "command": "OmniboxMovePopupSelection", | 2952 // Sample json input: { "command": "OmniboxMovePopupSelection", |
| 2949 // "count": 1 } | 2953 // "count": 1 } |
| 2950 // Negative count implies up, positive implies down. Count values will be | 2954 // Negative count implies up, positive implies down. Count values will be |
| 2951 // capped by the size of the popup list. | 2955 // capped by the size of the popup list. |
| 2952 void TestingAutomationProvider::OmniboxMovePopupSelection( | 2956 void TestingAutomationProvider::OmniboxMovePopupSelection( |
| 2953 Browser* browser, | 2957 Browser* browser, |
| 2954 DictionaryValue* args, | 2958 base::DictionaryValue* args, |
| 2955 IPC::Message* reply_message) { | 2959 IPC::Message* reply_message) { |
| 2956 int count; | 2960 int count; |
| 2957 AutomationJSONReply reply(this, reply_message); | 2961 AutomationJSONReply reply(this, reply_message); |
| 2958 if (!args->GetInteger("count", &count)) { | 2962 if (!args->GetInteger("count", &count)) { |
| 2959 reply.SendError("count missing"); | 2963 reply.SendError("count missing"); |
| 2960 return; | 2964 return; |
| 2961 } | 2965 } |
| 2962 LocationBar* loc_bar = browser->window()->GetLocationBar(); | 2966 LocationBar* loc_bar = browser->window()->GetLocationBar(); |
| 2963 if (!loc_bar) { | 2967 if (!loc_bar) { |
| 2964 reply.SendError("The specified browser does not have a location bar."); | 2968 reply.SendError("The specified browser does not have a location bar."); |
| 2965 return; | 2969 return; |
| 2966 } | 2970 } |
| 2967 loc_bar->GetOmniboxView()->model()->OnUpOrDownKeyPressed(count); | 2971 loc_bar->GetOmniboxView()->model()->OnUpOrDownKeyPressed(count); |
| 2968 reply.SendSuccess(NULL); | 2972 reply.SendSuccess(NULL); |
| 2969 } | 2973 } |
| 2970 | 2974 |
| 2971 // Sample json input: { "command": "OmniboxAcceptInput" } | 2975 // Sample json input: { "command": "OmniboxAcceptInput" } |
| 2972 void TestingAutomationProvider::OmniboxAcceptInput( | 2976 void TestingAutomationProvider::OmniboxAcceptInput( |
| 2973 Browser* browser, | 2977 Browser* browser, |
| 2974 DictionaryValue* args, | 2978 base::DictionaryValue* args, |
| 2975 IPC::Message* reply_message) { | 2979 IPC::Message* reply_message) { |
| 2976 NavigationController& controller = | 2980 NavigationController& controller = |
| 2977 browser->tab_strip_model()->GetActiveWebContents()->GetController(); | 2981 browser->tab_strip_model()->GetActiveWebContents()->GetController(); |
| 2978 LocationBar* loc_bar = browser->window()->GetLocationBar(); | 2982 LocationBar* loc_bar = browser->window()->GetLocationBar(); |
| 2979 if (!loc_bar) { | 2983 if (!loc_bar) { |
| 2980 AutomationJSONReply(this, reply_message).SendError( | 2984 AutomationJSONReply(this, reply_message).SendError( |
| 2981 "The specified browser does not have a location bar."); | 2985 "The specified browser does not have a location bar."); |
| 2982 return; | 2986 return; |
| 2983 } | 2987 } |
| 2984 new OmniboxAcceptNotificationObserver(&controller, this, reply_message); | 2988 new OmniboxAcceptNotificationObserver(&controller, this, reply_message); |
| 2985 loc_bar->AcceptInput(); | 2989 loc_bar->AcceptInput(); |
| 2986 } | 2990 } |
| 2987 | 2991 |
| 2988 // Sample json input: { "command": "GetInitialLoadTimes" } | 2992 // Sample json input: { "command": "GetInitialLoadTimes" } |
| 2989 // Refer to InitialLoadObserver::GetTimingInformation() for sample output. | 2993 // Refer to InitialLoadObserver::GetTimingInformation() for sample output. |
| 2990 void TestingAutomationProvider::GetInitialLoadTimes( | 2994 void TestingAutomationProvider::GetInitialLoadTimes( |
| 2991 Browser*, | 2995 Browser*, |
| 2992 DictionaryValue*, | 2996 base::DictionaryValue*, |
| 2993 IPC::Message* reply_message) { | 2997 IPC::Message* reply_message) { |
| 2994 scoped_ptr<DictionaryValue> return_value( | 2998 scoped_ptr<base::DictionaryValue> return_value( |
| 2995 initial_load_observer_->GetTimingInformation()); | 2999 initial_load_observer_->GetTimingInformation()); |
| 2996 | 3000 |
| 2997 std::string json_return; | 3001 std::string json_return; |
| 2998 base::JSONWriter::Write(return_value.get(), &json_return); | 3002 base::JSONWriter::Write(return_value.get(), &json_return); |
| 2999 AutomationMsg_SendJSONRequest::WriteReplyParams( | 3003 AutomationMsg_SendJSONRequest::WriteReplyParams( |
| 3000 reply_message, json_return, true); | 3004 reply_message, json_return, true); |
| 3001 Send(reply_message); | 3005 Send(reply_message); |
| 3002 } | 3006 } |
| 3003 | 3007 |
| 3004 // Sample json input: { "command": "GetPluginsInfo" } | 3008 // Sample json input: { "command": "GetPluginsInfo" } |
| 3005 // Refer chrome/test/pyautolib/plugins_info.py for sample json output. | 3009 // Refer chrome/test/pyautolib/plugins_info.py for sample json output. |
| 3006 void TestingAutomationProvider::GetPluginsInfo( | 3010 void TestingAutomationProvider::GetPluginsInfo( |
| 3007 Browser* browser, | 3011 Browser* browser, |
| 3008 DictionaryValue* args, | 3012 base::DictionaryValue* args, |
| 3009 IPC::Message* reply_message) { | 3013 IPC::Message* reply_message) { |
| 3010 PluginService::GetInstance()->GetPlugins( | 3014 PluginService::GetInstance()->GetPlugins( |
| 3011 base::Bind(&TestingAutomationProvider::GetPluginsInfoCallback, | 3015 base::Bind(&TestingAutomationProvider::GetPluginsInfoCallback, |
| 3012 this, browser, args, reply_message)); | 3016 this, browser, args, reply_message)); |
| 3013 } | 3017 } |
| 3014 | 3018 |
| 3015 void TestingAutomationProvider::GetPluginsInfoCallback( | 3019 void TestingAutomationProvider::GetPluginsInfoCallback( |
| 3016 Browser* browser, | 3020 Browser* browser, |
| 3017 DictionaryValue* args, | 3021 base::DictionaryValue* args, |
| 3018 IPC::Message* reply_message, | 3022 IPC::Message* reply_message, |
| 3019 const std::vector<content::WebPluginInfo>& plugins) { | 3023 const std::vector<content::WebPluginInfo>& plugins) { |
| 3020 PluginPrefs* plugin_prefs = | 3024 PluginPrefs* plugin_prefs = |
| 3021 PluginPrefs::GetForProfile(browser->profile()).get(); | 3025 PluginPrefs::GetForProfile(browser->profile()).get(); |
| 3022 ListValue* items = new ListValue; | 3026 base::ListValue* items = new base::ListValue; |
| 3023 for (std::vector<content::WebPluginInfo>::const_iterator it = | 3027 for (std::vector<content::WebPluginInfo>::const_iterator it = |
| 3024 plugins.begin(); | 3028 plugins.begin(); |
| 3025 it != plugins.end(); | 3029 it != plugins.end(); |
| 3026 ++it) { | 3030 ++it) { |
| 3027 DictionaryValue* item = new DictionaryValue; | 3031 base::DictionaryValue* item = new base::DictionaryValue; |
| 3028 item->SetString("name", it->name); | 3032 item->SetString("name", it->name); |
| 3029 item->SetString("path", it->path.value()); | 3033 item->SetString("path", it->path.value()); |
| 3030 item->SetString("version", it->version); | 3034 item->SetString("version", it->version); |
| 3031 item->SetString("desc", it->desc); | 3035 item->SetString("desc", it->desc); |
| 3032 item->SetBoolean("enabled", plugin_prefs->IsPluginEnabled(*it)); | 3036 item->SetBoolean("enabled", plugin_prefs->IsPluginEnabled(*it)); |
| 3033 // Add info about mime types. | 3037 // Add info about mime types. |
| 3034 ListValue* mime_types = new ListValue(); | 3038 base::ListValue* mime_types = new base::ListValue(); |
| 3035 for (std::vector<content::WebPluginMimeType>::const_iterator type_it = | 3039 for (std::vector<content::WebPluginMimeType>::const_iterator type_it = |
| 3036 it->mime_types.begin(); | 3040 it->mime_types.begin(); |
| 3037 type_it != it->mime_types.end(); | 3041 type_it != it->mime_types.end(); |
| 3038 ++type_it) { | 3042 ++type_it) { |
| 3039 DictionaryValue* mime_type = new DictionaryValue(); | 3043 base::DictionaryValue* mime_type = new base::DictionaryValue(); |
| 3040 mime_type->SetString("mimeType", type_it->mime_type); | 3044 mime_type->SetString("mimeType", type_it->mime_type); |
| 3041 mime_type->SetString("description", type_it->description); | 3045 mime_type->SetString("description", type_it->description); |
| 3042 | 3046 |
| 3043 ListValue* file_extensions = new ListValue(); | 3047 base::ListValue* file_extensions = new base::ListValue(); |
| 3044 for (std::vector<std::string>::const_iterator ext_it = | 3048 for (std::vector<std::string>::const_iterator ext_it = |
| 3045 type_it->file_extensions.begin(); | 3049 type_it->file_extensions.begin(); |
| 3046 ext_it != type_it->file_extensions.end(); | 3050 ext_it != type_it->file_extensions.end(); |
| 3047 ++ext_it) { | 3051 ++ext_it) { |
| 3048 file_extensions->Append(new StringValue(*ext_it)); | 3052 file_extensions->Append(new base::StringValue(*ext_it)); |
| 3049 } | 3053 } |
| 3050 mime_type->Set("fileExtensions", file_extensions); | 3054 mime_type->Set("fileExtensions", file_extensions); |
| 3051 | 3055 |
| 3052 mime_types->Append(mime_type); | 3056 mime_types->Append(mime_type); |
| 3053 } | 3057 } |
| 3054 item->Set("mimeTypes", mime_types); | 3058 item->Set("mimeTypes", mime_types); |
| 3055 items->Append(item); | 3059 items->Append(item); |
| 3056 } | 3060 } |
| 3057 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 3061 scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue); |
| 3058 return_value->Set("plugins", items); // return_value owns items. | 3062 return_value->Set("plugins", items); // return_value owns items. |
| 3059 | 3063 |
| 3060 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); | 3064 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); |
| 3061 } | 3065 } |
| 3062 | 3066 |
| 3063 // Sample json input: | 3067 // Sample json input: |
| 3064 // { "command": "EnablePlugin", | 3068 // { "command": "EnablePlugin", |
| 3065 // "path": "/Library/Internet Plug-Ins/Flash Player.plugin" } | 3069 // "path": "/Library/Internet Plug-Ins/Flash Player.plugin" } |
| 3066 void TestingAutomationProvider::EnablePlugin(Browser* browser, | 3070 void TestingAutomationProvider::EnablePlugin(Browser* browser, |
| 3067 DictionaryValue* args, | 3071 base::DictionaryValue* args, |
| 3068 IPC::Message* reply_message) { | 3072 IPC::Message* reply_message) { |
| 3069 base::FilePath::StringType path; | 3073 base::FilePath::StringType path; |
| 3070 if (!args->GetString("path", &path)) { | 3074 if (!args->GetString("path", &path)) { |
| 3071 AutomationJSONReply(this, reply_message).SendError("path not specified."); | 3075 AutomationJSONReply(this, reply_message).SendError("path not specified."); |
| 3072 return; | 3076 return; |
| 3073 } | 3077 } |
| 3074 PluginPrefs* plugin_prefs = | 3078 PluginPrefs* plugin_prefs = |
| 3075 PluginPrefs::GetForProfile(browser->profile()).get(); | 3079 PluginPrefs::GetForProfile(browser->profile()).get(); |
| 3076 plugin_prefs->EnablePlugin( | 3080 plugin_prefs->EnablePlugin( |
| 3077 true, | 3081 true, |
| 3078 base::FilePath(path), | 3082 base::FilePath(path), |
| 3079 base::Bind(&DidEnablePlugin, | 3083 base::Bind(&DidEnablePlugin, |
| 3080 AsWeakPtr(), | 3084 AsWeakPtr(), |
| 3081 reply_message, | 3085 reply_message, |
| 3082 path, | 3086 path, |
| 3083 "Could not enable plugin for path %s.")); | 3087 "Could not enable plugin for path %s.")); |
| 3084 } | 3088 } |
| 3085 | 3089 |
| 3086 // Sample json input: | 3090 // Sample json input: |
| 3087 // { "command": "DisablePlugin", | 3091 // { "command": "DisablePlugin", |
| 3088 // "path": "/Library/Internet Plug-Ins/Flash Player.plugin" } | 3092 // "path": "/Library/Internet Plug-Ins/Flash Player.plugin" } |
| 3089 void TestingAutomationProvider::DisablePlugin(Browser* browser, | 3093 void TestingAutomationProvider::DisablePlugin(Browser* browser, |
| 3090 DictionaryValue* args, | 3094 base::DictionaryValue* args, |
| 3091 IPC::Message* reply_message) { | 3095 IPC::Message* reply_message) { |
| 3092 base::FilePath::StringType path; | 3096 base::FilePath::StringType path; |
| 3093 if (!args->GetString("path", &path)) { | 3097 if (!args->GetString("path", &path)) { |
| 3094 AutomationJSONReply(this, reply_message).SendError("path not specified."); | 3098 AutomationJSONReply(this, reply_message).SendError("path not specified."); |
| 3095 return; | 3099 return; |
| 3096 } | 3100 } |
| 3097 PluginPrefs* plugin_prefs = | 3101 PluginPrefs* plugin_prefs = |
| 3098 PluginPrefs::GetForProfile(browser->profile()).get(); | 3102 PluginPrefs::GetForProfile(browser->profile()).get(); |
| 3099 plugin_prefs->EnablePlugin( | 3103 plugin_prefs->EnablePlugin( |
| 3100 false, | 3104 false, |
| 3101 base::FilePath(path), | 3105 base::FilePath(path), |
| 3102 base::Bind(&DidEnablePlugin, | 3106 base::Bind(&DidEnablePlugin, |
| 3103 AsWeakPtr(), | 3107 AsWeakPtr(), |
| 3104 reply_message, | 3108 reply_message, |
| 3105 path, | 3109 path, |
| 3106 "Could not disable plugin for path %s.")); | 3110 "Could not disable plugin for path %s.")); |
| 3107 } | 3111 } |
| 3108 | 3112 |
| 3109 // Sample json input: | 3113 // Sample json input: |
| 3110 // { "command": "SaveTabContents", | 3114 // { "command": "SaveTabContents", |
| 3111 // "tab_index": 0, | 3115 // "tab_index": 0, |
| 3112 // "filename": <a full pathname> } | 3116 // "filename": <a full pathname> } |
| 3113 // Sample json output: | 3117 // Sample json output: |
| 3114 // {} | 3118 // {} |
| 3115 void TestingAutomationProvider::SaveTabContents( | 3119 void TestingAutomationProvider::SaveTabContents( |
| 3116 Browser* browser, | 3120 Browser* browser, |
| 3117 DictionaryValue* args, | 3121 base::DictionaryValue* args, |
| 3118 IPC::Message* reply_message) { | 3122 IPC::Message* reply_message) { |
| 3119 int tab_index = 0; | 3123 int tab_index = 0; |
| 3120 base::FilePath::StringType filename; | 3124 base::FilePath::StringType filename; |
| 3121 base::FilePath::StringType parent_directory; | 3125 base::FilePath::StringType parent_directory; |
| 3122 WebContents* web_contents = NULL; | 3126 WebContents* web_contents = NULL; |
| 3123 | 3127 |
| 3124 if (!args->GetInteger("tab_index", &tab_index) || | 3128 if (!args->GetInteger("tab_index", &tab_index) || |
| 3125 !args->GetString("filename", &filename)) { | 3129 !args->GetString("filename", &filename)) { |
| 3126 AutomationJSONReply(this, reply_message) | 3130 AutomationJSONReply(this, reply_message) |
| 3127 .SendError("tab_index or filename param missing"); | 3131 .SendError("tab_index or filename param missing"); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3147 // The observer will delete itself when done. | 3151 // The observer will delete itself when done. |
| 3148 new SavePackageNotificationObserver( | 3152 new SavePackageNotificationObserver( |
| 3149 BrowserContext::GetDownloadManager(browser->profile()), | 3153 BrowserContext::GetDownloadManager(browser->profile()), |
| 3150 this, reply_message); | 3154 this, reply_message); |
| 3151 } | 3155 } |
| 3152 | 3156 |
| 3153 namespace { | 3157 namespace { |
| 3154 | 3158 |
| 3155 // Translates a dictionary password to a PasswordForm struct. | 3159 // Translates a dictionary password to a PasswordForm struct. |
| 3156 autofill::PasswordForm GetPasswordFormFromDict( | 3160 autofill::PasswordForm GetPasswordFormFromDict( |
| 3157 const DictionaryValue& password_dict) { | 3161 const base::DictionaryValue& password_dict) { |
| 3158 | 3162 |
| 3159 // If the time is specified, change time to the specified time. | 3163 // If the time is specified, change time to the specified time. |
| 3160 base::Time time = base::Time::Now(); | 3164 base::Time time = base::Time::Now(); |
| 3161 int it; | 3165 int it; |
| 3162 double dt; | 3166 double dt; |
| 3163 if (password_dict.GetInteger("time", &it)) | 3167 if (password_dict.GetInteger("time", &it)) |
| 3164 time = base::Time::FromTimeT(it); | 3168 time = base::Time::FromTimeT(it); |
| 3165 else if (password_dict.GetDouble("time", &dt)) | 3169 else if (password_dict.GetDouble("time", &dt)) |
| 3166 time = base::Time::FromDoubleT(dt); | 3170 time = base::Time::FromDoubleT(dt); |
| 3167 | 3171 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3208 return password_form; | 3212 return password_form; |
| 3209 } | 3213 } |
| 3210 | 3214 |
| 3211 } // namespace | 3215 } // namespace |
| 3212 | 3216 |
| 3213 // See AddSavedPassword() in chrome/test/functional/pyauto.py for sample json | 3217 // See AddSavedPassword() in chrome/test/functional/pyauto.py for sample json |
| 3214 // input. | 3218 // input. |
| 3215 // Sample json output: { "password_added": true } | 3219 // Sample json output: { "password_added": true } |
| 3216 void TestingAutomationProvider::AddSavedPassword( | 3220 void TestingAutomationProvider::AddSavedPassword( |
| 3217 Browser* browser, | 3221 Browser* browser, |
| 3218 DictionaryValue* args, | 3222 base::DictionaryValue* args, |
| 3219 IPC::Message* reply_message) { | 3223 IPC::Message* reply_message) { |
| 3220 DictionaryValue* password_dict = NULL; | 3224 base::DictionaryValue* password_dict = NULL; |
| 3221 if (!args->GetDictionary("password", &password_dict)) { | 3225 if (!args->GetDictionary("password", &password_dict)) { |
| 3222 AutomationJSONReply(this, reply_message).SendError( | 3226 AutomationJSONReply(this, reply_message).SendError( |
| 3223 "Must specify a password dictionary."); | 3227 "Must specify a password dictionary."); |
| 3224 return; | 3228 return; |
| 3225 } | 3229 } |
| 3226 | 3230 |
| 3227 // The "signon realm" is effectively the primary key and must be included. | 3231 // The "signon realm" is effectively the primary key and must be included. |
| 3228 // Check here before calling GetPasswordFormFromDict. | 3232 // Check here before calling GetPasswordFormFromDict. |
| 3229 if (!password_dict->HasKey("signon_realm")) { | 3233 if (!password_dict->HasKey("signon_realm")) { |
| 3230 AutomationJSONReply(this, reply_message).SendError( | 3234 AutomationJSONReply(this, reply_message).SendError( |
| 3231 "Password must include a value for 'signon_realm.'"); | 3235 "Password must include a value for 'signon_realm.'"); |
| 3232 return; | 3236 return; |
| 3233 } | 3237 } |
| 3234 | 3238 |
| 3235 autofill::PasswordForm new_password = | 3239 autofill::PasswordForm new_password = |
| 3236 GetPasswordFormFromDict(*password_dict); | 3240 GetPasswordFormFromDict(*password_dict); |
| 3237 | 3241 |
| 3238 // Use IMPLICIT_ACCESS since new passwords aren't added in incognito mode. | 3242 // Use IMPLICIT_ACCESS since new passwords aren't added in incognito mode. |
| 3239 PasswordStore* password_store = PasswordStoreFactory::GetForProfile( | 3243 PasswordStore* password_store = PasswordStoreFactory::GetForProfile( |
| 3240 browser->profile(), Profile::IMPLICIT_ACCESS).get(); | 3244 browser->profile(), Profile::IMPLICIT_ACCESS).get(); |
| 3241 | 3245 |
| 3242 // The password store does not exist for an incognito window. | 3246 // The password store does not exist for an incognito window. |
| 3243 if (password_store == NULL) { | 3247 if (password_store == NULL) { |
| 3244 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 3248 scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue); |
| 3245 return_value->SetBoolean("password_added", false); | 3249 return_value->SetBoolean("password_added", false); |
| 3246 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); | 3250 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); |
| 3247 return; | 3251 return; |
| 3248 } | 3252 } |
| 3249 | 3253 |
| 3250 // This observer will delete itself. | 3254 // This observer will delete itself. |
| 3251 PasswordStoreLoginsChangedObserver* observer = | 3255 PasswordStoreLoginsChangedObserver* observer = |
| 3252 new PasswordStoreLoginsChangedObserver(this, reply_message, | 3256 new PasswordStoreLoginsChangedObserver(this, reply_message, |
| 3253 PasswordStoreChange::ADD, | 3257 PasswordStoreChange::ADD, |
| 3254 "password_added"); | 3258 "password_added"); |
| 3255 observer->Init(); | 3259 observer->Init(); |
| 3256 password_store->AddLogin(new_password); | 3260 password_store->AddLogin(new_password); |
| 3257 } | 3261 } |
| 3258 | 3262 |
| 3259 // See RemoveSavedPassword() in chrome/test/functional/pyauto.py for sample | 3263 // See RemoveSavedPassword() in chrome/test/functional/pyauto.py for sample |
| 3260 // json input. | 3264 // json input. |
| 3261 // Sample json output: {} | 3265 // Sample json output: {} |
| 3262 void TestingAutomationProvider::RemoveSavedPassword( | 3266 void TestingAutomationProvider::RemoveSavedPassword( |
| 3263 Browser* browser, | 3267 Browser* browser, |
| 3264 DictionaryValue* args, | 3268 base::DictionaryValue* args, |
| 3265 IPC::Message* reply_message) { | 3269 IPC::Message* reply_message) { |
| 3266 DictionaryValue* password_dict = NULL; | 3270 base::DictionaryValue* password_dict = NULL; |
| 3267 | 3271 |
| 3268 if (!args->GetDictionary("password", &password_dict)) { | 3272 if (!args->GetDictionary("password", &password_dict)) { |
| 3269 AutomationJSONReply(this, reply_message).SendError( | 3273 AutomationJSONReply(this, reply_message).SendError( |
| 3270 "Must specify a password dictionary."); | 3274 "Must specify a password dictionary."); |
| 3271 return; | 3275 return; |
| 3272 } | 3276 } |
| 3273 | 3277 |
| 3274 // The "signon realm" is effectively the primary key and must be included. | 3278 // The "signon realm" is effectively the primary key and must be included. |
| 3275 // Check here before calling GetPasswordFormFromDict. | 3279 // Check here before calling GetPasswordFormFromDict. |
| 3276 if (!password_dict->HasKey("signon_realm")) { | 3280 if (!password_dict->HasKey("signon_realm")) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 3297 observer->Init(); | 3301 observer->Init(); |
| 3298 | 3302 |
| 3299 password_store->RemoveLogin(to_remove); | 3303 password_store->RemoveLogin(to_remove); |
| 3300 } | 3304 } |
| 3301 | 3305 |
| 3302 // Sample json input: { "command": "GetSavedPasswords" } | 3306 // Sample json input: { "command": "GetSavedPasswords" } |
| 3303 // Refer to GetSavedPasswords() in chrome/test/pyautolib/pyauto.py for sample | 3307 // Refer to GetSavedPasswords() in chrome/test/pyautolib/pyauto.py for sample |
| 3304 // json output. | 3308 // json output. |
| 3305 void TestingAutomationProvider::GetSavedPasswords( | 3309 void TestingAutomationProvider::GetSavedPasswords( |
| 3306 Browser* browser, | 3310 Browser* browser, |
| 3307 DictionaryValue* args, | 3311 base::DictionaryValue* args, |
| 3308 IPC::Message* reply_message) { | 3312 IPC::Message* reply_message) { |
| 3309 // Use EXPLICIT_ACCESS since saved passwords can be retrieved in | 3313 // Use EXPLICIT_ACCESS since saved passwords can be retrieved in |
| 3310 // incognito mode. | 3314 // incognito mode. |
| 3311 PasswordStore* password_store = PasswordStoreFactory::GetForProfile( | 3315 PasswordStore* password_store = PasswordStoreFactory::GetForProfile( |
| 3312 browser->profile(), Profile::EXPLICIT_ACCESS).get(); | 3316 browser->profile(), Profile::EXPLICIT_ACCESS).get(); |
| 3313 | 3317 |
| 3314 if (password_store == NULL) { | 3318 if (password_store == NULL) { |
| 3315 AutomationJSONReply reply(this, reply_message); | 3319 AutomationJSONReply reply(this, reply_message); |
| 3316 reply.SendError("Unable to get password store."); | 3320 reply.SendError("Unable to get password store."); |
| 3317 return; | 3321 return; |
| 3318 } | 3322 } |
| 3319 password_store->GetAutofillableLogins( | 3323 password_store->GetAutofillableLogins( |
| 3320 new AutomationProviderGetPasswordsObserver(this, reply_message)); | 3324 new AutomationProviderGetPasswordsObserver(this, reply_message)); |
| 3321 // Observer deletes itself after sending the result. | 3325 // Observer deletes itself after sending the result. |
| 3322 } | 3326 } |
| 3323 | 3327 |
| 3324 namespace { | 3328 namespace { |
| 3325 | 3329 |
| 3326 // Get the WebContents from a dictionary of arguments. | 3330 // Get the WebContents from a dictionary of arguments. |
| 3327 WebContents* GetWebContentsFromDict(const Browser* browser, | 3331 WebContents* GetWebContentsFromDict(const Browser* browser, |
| 3328 const DictionaryValue* args, | 3332 const base::DictionaryValue* args, |
| 3329 std::string* error_message) { | 3333 std::string* error_message) { |
| 3330 int tab_index; | 3334 int tab_index; |
| 3331 if (!args->GetInteger("tab_index", &tab_index)) { | 3335 if (!args->GetInteger("tab_index", &tab_index)) { |
| 3332 *error_message = "Must include tab_index."; | 3336 *error_message = "Must include tab_index."; |
| 3333 return NULL; | 3337 return NULL; |
| 3334 } | 3338 } |
| 3335 | 3339 |
| 3336 WebContents* web_contents = | 3340 WebContents* web_contents = |
| 3337 browser->tab_strip_model()->GetWebContentsAt(tab_index); | 3341 browser->tab_strip_model()->GetWebContentsAt(tab_index); |
| 3338 if (!web_contents) { | 3342 if (!web_contents) { |
| 3339 *error_message = base::StringPrintf("No tab at index %d.", tab_index); | 3343 *error_message = base::StringPrintf("No tab at index %d.", tab_index); |
| 3340 return NULL; | 3344 return NULL; |
| 3341 } | 3345 } |
| 3342 return web_contents; | 3346 return web_contents; |
| 3343 } | 3347 } |
| 3344 | 3348 |
| 3345 } // namespace | 3349 } // namespace |
| 3346 | 3350 |
| 3347 void TestingAutomationProvider::FindInPage( | 3351 void TestingAutomationProvider::FindInPage( |
| 3348 Browser* browser, | 3352 Browser* browser, |
| 3349 DictionaryValue* args, | 3353 base::DictionaryValue* args, |
| 3350 IPC::Message* reply_message) { | 3354 IPC::Message* reply_message) { |
| 3351 std::string error_message; | 3355 std::string error_message; |
| 3352 WebContents* web_contents = | 3356 WebContents* web_contents = |
| 3353 GetWebContentsFromDict(browser, args, &error_message); | 3357 GetWebContentsFromDict(browser, args, &error_message); |
| 3354 if (!web_contents) { | 3358 if (!web_contents) { |
| 3355 AutomationJSONReply(this, reply_message).SendError(error_message); | 3359 AutomationJSONReply(this, reply_message).SendError(error_message); |
| 3356 return; | 3360 return; |
| 3357 } | 3361 } |
| 3358 base::string16 search_string; | 3362 base::string16 search_string; |
| 3359 bool forward; | 3363 bool forward; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 3382 SendFindRequest(web_contents, | 3386 SendFindRequest(web_contents, |
| 3383 true, | 3387 true, |
| 3384 search_string, | 3388 search_string, |
| 3385 forward, | 3389 forward, |
| 3386 match_case, | 3390 match_case, |
| 3387 find_next, | 3391 find_next, |
| 3388 reply_message); | 3392 reply_message); |
| 3389 } | 3393 } |
| 3390 | 3394 |
| 3391 void TestingAutomationProvider::OpenFindInPage( | 3395 void TestingAutomationProvider::OpenFindInPage( |
| 3392 DictionaryValue* args, | 3396 base::DictionaryValue* args, |
| 3393 IPC::Message* reply_message) { | 3397 IPC::Message* reply_message) { |
| 3394 AutomationJSONReply reply(this, reply_message); | 3398 AutomationJSONReply reply(this, reply_message); |
| 3395 Browser* browser; | 3399 Browser* browser; |
| 3396 std::string error_msg; | 3400 std::string error_msg; |
| 3397 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { | 3401 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { |
| 3398 reply.SendError(error_msg); | 3402 reply.SendError(error_msg); |
| 3399 return; | 3403 return; |
| 3400 } | 3404 } |
| 3401 chrome::FindInPage(browser, false, false); | 3405 chrome::FindInPage(browser, false, false); |
| 3402 reply.SendSuccess(NULL); | 3406 reply.SendSuccess(NULL); |
| 3403 } | 3407 } |
| 3404 | 3408 |
| 3405 void TestingAutomationProvider::IsFindInPageVisible( | 3409 void TestingAutomationProvider::IsFindInPageVisible( |
| 3406 DictionaryValue* args, | 3410 base::DictionaryValue* args, |
| 3407 IPC::Message* reply_message) { | 3411 IPC::Message* reply_message) { |
| 3408 AutomationJSONReply reply(this, reply_message); | 3412 AutomationJSONReply reply(this, reply_message); |
| 3409 bool visible; | 3413 bool visible; |
| 3410 Browser* browser; | 3414 Browser* browser; |
| 3411 std::string error_msg; | 3415 std::string error_msg; |
| 3412 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { | 3416 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { |
| 3413 reply.SendError(error_msg); | 3417 reply.SendError(error_msg); |
| 3414 return; | 3418 return; |
| 3415 } | 3419 } |
| 3416 FindBarTesting* find_bar = | 3420 FindBarTesting* find_bar = |
| 3417 browser->GetFindBarController()->find_bar()->GetFindBarTesting(); | 3421 browser->GetFindBarController()->find_bar()->GetFindBarTesting(); |
| 3418 find_bar->GetFindBarWindowInfo(NULL, &visible); | 3422 find_bar->GetFindBarWindowInfo(NULL, &visible); |
| 3419 DictionaryValue dict; | 3423 base::DictionaryValue dict; |
| 3420 dict.SetBoolean("is_visible", visible); | 3424 dict.SetBoolean("is_visible", visible); |
| 3421 reply.SendSuccess(&dict); | 3425 reply.SendSuccess(&dict); |
| 3422 } | 3426 } |
| 3423 | 3427 |
| 3424 void TestingAutomationProvider::InstallExtension( | 3428 void TestingAutomationProvider::InstallExtension( |
| 3425 DictionaryValue* args, IPC::Message* reply_message) { | 3429 base::DictionaryValue* args, IPC::Message* reply_message) { |
| 3426 base::FilePath::StringType path_string; | 3430 base::FilePath::StringType path_string; |
| 3427 bool with_ui; | 3431 bool with_ui; |
| 3428 bool from_webstore = false; | 3432 bool from_webstore = false; |
| 3429 Browser* browser; | 3433 Browser* browser; |
| 3430 content::WebContents* tab; | 3434 content::WebContents* tab; |
| 3431 std::string error_msg; | 3435 std::string error_msg; |
| 3432 if (!GetBrowserAndTabFromJSONArgs(args, &browser, &tab, &error_msg)) { | 3436 if (!GetBrowserAndTabFromJSONArgs(args, &browser, &tab, &error_msg)) { |
| 3433 AutomationJSONReply(this, reply_message).SendError(error_msg); | 3437 AutomationJSONReply(this, reply_message).SendError(error_msg); |
| 3434 return; | 3438 return; |
| 3435 } | 3439 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3478 installer->Load(extension_path); | 3482 installer->Load(extension_path); |
| 3479 } | 3483 } |
| 3480 } else { | 3484 } else { |
| 3481 AutomationJSONReply(this, reply_message).SendError( | 3485 AutomationJSONReply(this, reply_message).SendError( |
| 3482 "Extensions service/process manager is not available"); | 3486 "Extensions service/process manager is not available"); |
| 3483 } | 3487 } |
| 3484 } | 3488 } |
| 3485 | 3489 |
| 3486 namespace { | 3490 namespace { |
| 3487 | 3491 |
| 3488 ListValue* GetHostPermissions(const Extension* ext, bool effective_perm) { | 3492 base::ListValue* GetHostPermissions(const Extension* ext, bool effective_perm) { |
| 3489 extensions::URLPatternSet pattern_set; | 3493 extensions::URLPatternSet pattern_set; |
| 3490 if (effective_perm) { | 3494 if (effective_perm) { |
| 3491 pattern_set = | 3495 pattern_set = |
| 3492 extensions::PermissionsData::GetEffectiveHostPermissions(ext); | 3496 extensions::PermissionsData::GetEffectiveHostPermissions(ext); |
| 3493 } else { | 3497 } else { |
| 3494 pattern_set = ext->GetActivePermissions()->explicit_hosts(); | 3498 pattern_set = ext->GetActivePermissions()->explicit_hosts(); |
| 3495 } | 3499 } |
| 3496 | 3500 |
| 3497 ListValue* permissions = new ListValue; | 3501 base::ListValue* permissions = new base::ListValue; |
| 3498 for (extensions::URLPatternSet::const_iterator perm = pattern_set.begin(); | 3502 for (extensions::URLPatternSet::const_iterator perm = pattern_set.begin(); |
| 3499 perm != pattern_set.end(); ++perm) { | 3503 perm != pattern_set.end(); ++perm) { |
| 3500 permissions->Append(new StringValue(perm->GetAsString())); | 3504 permissions->Append(new base::StringValue(perm->GetAsString())); |
| 3501 } | 3505 } |
| 3502 | 3506 |
| 3503 return permissions; | 3507 return permissions; |
| 3504 } | 3508 } |
| 3505 | 3509 |
| 3506 ListValue* GetAPIPermissions(const Extension* ext) { | 3510 base::ListValue* GetAPIPermissions(const Extension* ext) { |
| 3507 ListValue* permissions = new ListValue; | 3511 base::ListValue* permissions = new base::ListValue; |
| 3508 std::set<std::string> perm_list = | 3512 std::set<std::string> perm_list = |
| 3509 ext->GetActivePermissions()->GetAPIsAsStrings(); | 3513 ext->GetActivePermissions()->GetAPIsAsStrings(); |
| 3510 for (std::set<std::string>::const_iterator perm = perm_list.begin(); | 3514 for (std::set<std::string>::const_iterator perm = perm_list.begin(); |
| 3511 perm != perm_list.end(); ++perm) { | 3515 perm != perm_list.end(); ++perm) { |
| 3512 permissions->Append(new StringValue(perm->c_str())); | 3516 permissions->Append(new base::StringValue(perm->c_str())); |
| 3513 } | 3517 } |
| 3514 return permissions; | 3518 return permissions; |
| 3515 } | 3519 } |
| 3516 | 3520 |
| 3517 } // namespace | 3521 } // namespace |
| 3518 | 3522 |
| 3519 // Sample json input: { "command": "GetExtensionsInfo" } | 3523 // Sample json input: { "command": "GetExtensionsInfo" } |
| 3520 // See GetExtensionsInfo() in chrome/test/pyautolib/pyauto.py for sample json | 3524 // See GetExtensionsInfo() in chrome/test/pyautolib/pyauto.py for sample json |
| 3521 // output. | 3525 // output. |
| 3522 void TestingAutomationProvider::GetExtensionsInfo(DictionaryValue* args, | 3526 void TestingAutomationProvider::GetExtensionsInfo(base::DictionaryValue* args, |
| 3523 IPC::Message* reply_message) { | 3527 IPC::Message* reply_message) { |
| 3524 AutomationJSONReply reply(this, reply_message); | 3528 AutomationJSONReply reply(this, reply_message); |
| 3525 Browser* browser; | 3529 Browser* browser; |
| 3526 std::string error_msg; | 3530 std::string error_msg; |
| 3527 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { | 3531 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { |
| 3528 reply.SendError(error_msg); | 3532 reply.SendError(error_msg); |
| 3529 return; | 3533 return; |
| 3530 } | 3534 } |
| 3531 ExtensionService* service = extensions::ExtensionSystem::Get( | 3535 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 3532 browser->profile())->extension_service(); | 3536 browser->profile())->extension_service(); |
| 3533 if (!service) { | 3537 if (!service) { |
| 3534 reply.SendError("No extensions service."); | 3538 reply.SendError("No extensions service."); |
| 3535 return; | 3539 return; |
| 3536 } | 3540 } |
| 3537 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 3541 scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue); |
| 3538 ListValue* extensions_values = new ListValue; | 3542 base::ListValue* extensions_values = new base::ListValue; |
| 3539 const extensions::ExtensionSet* extensions = service->extensions(); | 3543 const extensions::ExtensionSet* extensions = service->extensions(); |
| 3540 const extensions::ExtensionSet* disabled_extensions = | 3544 const extensions::ExtensionSet* disabled_extensions = |
| 3541 service->disabled_extensions(); | 3545 service->disabled_extensions(); |
| 3542 ExtensionList all; | 3546 ExtensionList all; |
| 3543 all.insert(all.end(), | 3547 all.insert(all.end(), |
| 3544 extensions->begin(), | 3548 extensions->begin(), |
| 3545 extensions->end()); | 3549 extensions->end()); |
| 3546 all.insert(all.end(), | 3550 all.insert(all.end(), |
| 3547 disabled_extensions->begin(), | 3551 disabled_extensions->begin(), |
| 3548 disabled_extensions->end()); | 3552 disabled_extensions->end()); |
| 3549 ExtensionActionManager* extension_action_manager = | 3553 ExtensionActionManager* extension_action_manager = |
| 3550 ExtensionActionManager::Get(browser->profile()); | 3554 ExtensionActionManager::Get(browser->profile()); |
| 3551 for (ExtensionList::const_iterator it = all.begin(); | 3555 for (ExtensionList::const_iterator it = all.begin(); |
| 3552 it != all.end(); ++it) { | 3556 it != all.end(); ++it) { |
| 3553 const Extension* extension = it->get(); | 3557 const Extension* extension = it->get(); |
| 3554 std::string id = extension->id(); | 3558 std::string id = extension->id(); |
| 3555 DictionaryValue* extension_value = new DictionaryValue; | 3559 base::DictionaryValue* extension_value = new base::DictionaryValue; |
| 3556 extension_value->SetString("id", id); | 3560 extension_value->SetString("id", id); |
| 3557 extension_value->SetString("version", extension->VersionString()); | 3561 extension_value->SetString("version", extension->VersionString()); |
| 3558 extension_value->SetString("name", extension->name()); | 3562 extension_value->SetString("name", extension->name()); |
| 3559 extension_value->SetString("public_key", extension->public_key()); | 3563 extension_value->SetString("public_key", extension->public_key()); |
| 3560 extension_value->SetString("description", extension->description()); | 3564 extension_value->SetString("description", extension->description()); |
| 3561 extension_value->SetString( | 3565 extension_value->SetString( |
| 3562 "background_url", | 3566 "background_url", |
| 3563 extensions::BackgroundInfo::GetBackgroundURL(extension).spec()); | 3567 extensions::BackgroundInfo::GetBackgroundURL(extension).spec()); |
| 3564 extension_value->SetString("options_url", | 3568 extension_value->SetString("options_url", |
| 3565 extensions::ManifestURL::GetOptionsPage(extension).spec()); | 3569 extensions::ManifestURL::GetOptionsPage(extension).spec()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3585 extensions_values->Append(extension_value); | 3589 extensions_values->Append(extension_value); |
| 3586 } | 3590 } |
| 3587 return_value->Set("extensions", extensions_values); | 3591 return_value->Set("extensions", extensions_values); |
| 3588 reply.SendSuccess(return_value.get()); | 3592 reply.SendSuccess(return_value.get()); |
| 3589 } | 3593 } |
| 3590 | 3594 |
| 3591 // See UninstallExtensionById() in chrome/test/pyautolib/pyauto.py for sample | 3595 // See UninstallExtensionById() in chrome/test/pyautolib/pyauto.py for sample |
| 3592 // json input. | 3596 // json input. |
| 3593 // Sample json output: {} | 3597 // Sample json output: {} |
| 3594 void TestingAutomationProvider::UninstallExtensionById( | 3598 void TestingAutomationProvider::UninstallExtensionById( |
| 3595 DictionaryValue* args, | 3599 base::DictionaryValue* args, |
| 3596 IPC::Message* reply_message) { | 3600 IPC::Message* reply_message) { |
| 3597 const Extension* extension; | 3601 const Extension* extension; |
| 3598 std::string error; | 3602 std::string error; |
| 3599 Browser* browser; | 3603 Browser* browser; |
| 3600 if (!GetBrowserFromJSONArgs(args, &browser, &error)) { | 3604 if (!GetBrowserFromJSONArgs(args, &browser, &error)) { |
| 3601 AutomationJSONReply(this, reply_message).SendError(error); | 3605 AutomationJSONReply(this, reply_message).SendError(error); |
| 3602 return; | 3606 return; |
| 3603 } | 3607 } |
| 3604 if (!GetExtensionFromJSONArgs( | 3608 if (!GetExtensionFromJSONArgs( |
| 3605 args, "id", browser->profile(), &extension, &error)) { | 3609 args, "id", browser->profile(), &extension, &error)) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 3616 | 3620 |
| 3617 // Wait for a notification indicating that the extension with the given ID | 3621 // Wait for a notification indicating that the extension with the given ID |
| 3618 // has been uninstalled. This observer will delete itself. | 3622 // has been uninstalled. This observer will delete itself. |
| 3619 new ExtensionUninstallObserver(this, reply_message, extension->id()); | 3623 new ExtensionUninstallObserver(this, reply_message, extension->id()); |
| 3620 service->UninstallExtension(extension->id(), false, NULL); | 3624 service->UninstallExtension(extension->id(), false, NULL); |
| 3621 } | 3625 } |
| 3622 | 3626 |
| 3623 // See SetExtensionStateById() in chrome/test/pyautolib/pyauto.py | 3627 // See SetExtensionStateById() in chrome/test/pyautolib/pyauto.py |
| 3624 // for sample json input. | 3628 // for sample json input. |
| 3625 void TestingAutomationProvider::SetExtensionStateById( | 3629 void TestingAutomationProvider::SetExtensionStateById( |
| 3626 DictionaryValue* args, | 3630 base::DictionaryValue* args, |
| 3627 IPC::Message* reply_message) { | 3631 IPC::Message* reply_message) { |
| 3628 const Extension* extension; | 3632 const Extension* extension; |
| 3629 std::string error; | 3633 std::string error; |
| 3630 Browser* browser; | 3634 Browser* browser; |
| 3631 if (!GetBrowserFromJSONArgs(args, &browser, &error)) { | 3635 if (!GetBrowserFromJSONArgs(args, &browser, &error)) { |
| 3632 AutomationJSONReply(this, reply_message).SendError(error); | 3636 AutomationJSONReply(this, reply_message).SendError(error); |
| 3633 return; | 3637 return; |
| 3634 } | 3638 } |
| 3635 if (!GetExtensionFromJSONArgs( | 3639 if (!GetExtensionFromJSONArgs( |
| 3636 args, "id", browser->profile(), &extension, &error)) { | 3640 args, "id", browser->profile(), &extension, &error)) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3686 AutomationJSONReply(this, reply_message).SendSuccess(NULL); | 3690 AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
| 3687 } | 3691 } |
| 3688 | 3692 |
| 3689 extension_util::SetIsIncognitoEnabled( | 3693 extension_util::SetIsIncognitoEnabled( |
| 3690 extension->id(), service, allow_in_incognito); | 3694 extension->id(), service, allow_in_incognito); |
| 3691 } | 3695 } |
| 3692 | 3696 |
| 3693 // See TriggerPageActionById() in chrome/test/pyautolib/pyauto.py | 3697 // See TriggerPageActionById() in chrome/test/pyautolib/pyauto.py |
| 3694 // for sample json input. | 3698 // for sample json input. |
| 3695 void TestingAutomationProvider::TriggerPageActionById( | 3699 void TestingAutomationProvider::TriggerPageActionById( |
| 3696 DictionaryValue* args, | 3700 base::DictionaryValue* args, |
| 3697 IPC::Message* reply_message) { | 3701 IPC::Message* reply_message) { |
| 3698 std::string error; | 3702 std::string error; |
| 3699 Browser* browser; | 3703 Browser* browser; |
| 3700 WebContents* tab; | 3704 WebContents* tab; |
| 3701 if (!GetBrowserAndTabFromJSONArgs(args, &browser, &tab, &error)) { | 3705 if (!GetBrowserAndTabFromJSONArgs(args, &browser, &tab, &error)) { |
| 3702 AutomationJSONReply(this, reply_message).SendError(error); | 3706 AutomationJSONReply(this, reply_message).SendError(error); |
| 3703 return; | 3707 return; |
| 3704 } | 3708 } |
| 3705 const Extension* extension; | 3709 const Extension* extension; |
| 3706 if (!GetEnabledExtensionFromJSONArgs( | 3710 if (!GetEnabledExtensionFromJSONArgs( |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3741 new ExtensionPopupObserver( | 3745 new ExtensionPopupObserver( |
| 3742 this, reply_message, extension->id()); | 3746 this, reply_message, extension->id()); |
| 3743 } else { | 3747 } else { |
| 3744 AutomationJSONReply(this, reply_message).SendSuccess(NULL); | 3748 AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
| 3745 } | 3749 } |
| 3746 } | 3750 } |
| 3747 | 3751 |
| 3748 // See TriggerBrowserActionById() in chrome/test/pyautolib/pyauto.py | 3752 // See TriggerBrowserActionById() in chrome/test/pyautolib/pyauto.py |
| 3749 // for sample json input. | 3753 // for sample json input. |
| 3750 void TestingAutomationProvider::TriggerBrowserActionById( | 3754 void TestingAutomationProvider::TriggerBrowserActionById( |
| 3751 DictionaryValue* args, | 3755 base::DictionaryValue* args, |
| 3752 IPC::Message* reply_message) { | 3756 IPC::Message* reply_message) { |
| 3753 std::string error; | 3757 std::string error; |
| 3754 Browser* browser; | 3758 Browser* browser; |
| 3755 WebContents* tab; | 3759 WebContents* tab; |
| 3756 if (!GetBrowserAndTabFromJSONArgs(args, &browser, &tab, &error)) { | 3760 if (!GetBrowserAndTabFromJSONArgs(args, &browser, &tab, &error)) { |
| 3757 AutomationJSONReply(this, reply_message).SendError(error); | 3761 AutomationJSONReply(this, reply_message).SendError(error); |
| 3758 return; | 3762 return; |
| 3759 } | 3763 } |
| 3760 const Extension* extension; | 3764 const Extension* extension; |
| 3761 if (!GetEnabledExtensionFromJSONArgs( | 3765 if (!GetEnabledExtensionFromJSONArgs( |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3805 if (action->HasPopup(extensions::ExtensionTabUtil::GetTabId(tab))) { | 3809 if (action->HasPopup(extensions::ExtensionTabUtil::GetTabId(tab))) { |
| 3806 // This observer will delete itself. | 3810 // This observer will delete itself. |
| 3807 new ExtensionPopupObserver( | 3811 new ExtensionPopupObserver( |
| 3808 this, reply_message, extension->id()); | 3812 this, reply_message, extension->id()); |
| 3809 } else { | 3813 } else { |
| 3810 AutomationJSONReply(this, reply_message).SendSuccess(NULL); | 3814 AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
| 3811 } | 3815 } |
| 3812 } | 3816 } |
| 3813 | 3817 |
| 3814 void TestingAutomationProvider::ActionOnSSLBlockingPage( | 3818 void TestingAutomationProvider::ActionOnSSLBlockingPage( |
| 3815 DictionaryValue* args, | 3819 base::DictionaryValue* args, |
| 3816 IPC::Message* reply_message) { | 3820 IPC::Message* reply_message) { |
| 3817 WebContents* web_contents; | 3821 WebContents* web_contents; |
| 3818 bool proceed; | 3822 bool proceed; |
| 3819 std::string error; | 3823 std::string error; |
| 3820 if (!GetTabFromJSONArgs(args, &web_contents, &error)) { | 3824 if (!GetTabFromJSONArgs(args, &web_contents, &error)) { |
| 3821 AutomationJSONReply(this, reply_message).SendError(error); | 3825 AutomationJSONReply(this, reply_message).SendError(error); |
| 3822 return; | 3826 return; |
| 3823 } | 3827 } |
| 3824 if (!args->GetBoolean("proceed", &proceed)) { | 3828 if (!args->GetBoolean("proceed", &proceed)) { |
| 3825 AutomationJSONReply(this, reply_message).SendError( | 3829 AutomationJSONReply(this, reply_message).SendError( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3839 return; | 3843 return; |
| 3840 } | 3844 } |
| 3841 ssl_blocking_page->DontProceed(); | 3845 ssl_blocking_page->DontProceed(); |
| 3842 AutomationJSONReply(this, reply_message).SendSuccess(NULL); | 3846 AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
| 3843 return; | 3847 return; |
| 3844 } | 3848 } |
| 3845 } | 3849 } |
| 3846 AutomationJSONReply(this, reply_message).SendError(error); | 3850 AutomationJSONReply(this, reply_message).SendError(error); |
| 3847 } | 3851 } |
| 3848 | 3852 |
| 3849 void TestingAutomationProvider::GetSecurityState(DictionaryValue* args, | 3853 void TestingAutomationProvider::GetSecurityState(base::DictionaryValue* args, |
| 3850 IPC::Message* reply_message) { | 3854 IPC::Message* reply_message) { |
| 3851 AutomationJSONReply reply(this, reply_message); | 3855 AutomationJSONReply reply(this, reply_message); |
| 3852 WebContents* web_contents; | 3856 WebContents* web_contents; |
| 3853 std::string error; | 3857 std::string error; |
| 3854 if (!GetTabFromJSONArgs(args, &web_contents, &error)) { | 3858 if (!GetTabFromJSONArgs(args, &web_contents, &error)) { |
| 3855 reply.SendError(error); | 3859 reply.SendError(error); |
| 3856 return; | 3860 return; |
| 3857 } | 3861 } |
| 3858 NavigationEntry* entry = web_contents->GetController().GetActiveEntry(); | 3862 NavigationEntry* entry = web_contents->GetController().GetActiveEntry(); |
| 3859 DictionaryValue dict; | 3863 base::DictionaryValue dict; |
| 3860 dict.SetInteger("security_style", | 3864 dict.SetInteger("security_style", |
| 3861 static_cast<int>(entry->GetSSL().security_style)); | 3865 static_cast<int>(entry->GetSSL().security_style)); |
| 3862 dict.SetInteger("ssl_cert_status", | 3866 dict.SetInteger("ssl_cert_status", |
| 3863 static_cast<int>(entry->GetSSL().cert_status)); | 3867 static_cast<int>(entry->GetSSL().cert_status)); |
| 3864 dict.SetInteger("insecure_content_status", | 3868 dict.SetInteger("insecure_content_status", |
| 3865 static_cast<int>(entry->GetSSL().content_status)); | 3869 static_cast<int>(entry->GetSSL().content_status)); |
| 3866 reply.SendSuccess(&dict); | 3870 reply.SendSuccess(&dict); |
| 3867 } | 3871 } |
| 3868 | 3872 |
| 3869 // Sample json input: { "command": "UpdateExtensionsNow" } | 3873 // Sample json input: { "command": "UpdateExtensionsNow" } |
| 3870 // Sample json output: {} | 3874 // Sample json output: {} |
| 3871 void TestingAutomationProvider::UpdateExtensionsNow( | 3875 void TestingAutomationProvider::UpdateExtensionsNow( |
| 3872 DictionaryValue* args, | 3876 base::DictionaryValue* args, |
| 3873 IPC::Message* reply_message) { | 3877 IPC::Message* reply_message) { |
| 3874 std::string error; | 3878 std::string error; |
| 3875 Browser* browser; | 3879 Browser* browser; |
| 3876 if (!GetBrowserFromJSONArgs(args, &browser, &error)) { | 3880 if (!GetBrowserFromJSONArgs(args, &browser, &error)) { |
| 3877 AutomationJSONReply(this, reply_message).SendError(error); | 3881 AutomationJSONReply(this, reply_message).SendError(error); |
| 3878 return; | 3882 return; |
| 3879 } | 3883 } |
| 3880 ExtensionService* service = extensions::ExtensionSystem::Get( | 3884 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 3881 browser->profile())->extension_service(); | 3885 browser->profile())->extension_service(); |
| 3882 if (!service) { | 3886 if (!service) { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3943 | 3947 |
| 3944 content::GeolocationProvider::OverrideLocationForTesting( | 3948 content::GeolocationProvider::OverrideLocationForTesting( |
| 3945 position, | 3949 position, |
| 3946 base::Bind(&SendSuccessIfAlive, AsWeakPtr(), reply_message)); | 3950 base::Bind(&SendSuccessIfAlive, AsWeakPtr(), reply_message)); |
| 3947 } | 3951 } |
| 3948 | 3952 |
| 3949 // Refer to GetAllNotifications() in chrome/test/pyautolib/pyauto.py for | 3953 // Refer to GetAllNotifications() in chrome/test/pyautolib/pyauto.py for |
| 3950 // sample json input/output. | 3954 // sample json input/output. |
| 3951 void TestingAutomationProvider::GetAllNotifications( | 3955 void TestingAutomationProvider::GetAllNotifications( |
| 3952 Browser* browser, | 3956 Browser* browser, |
| 3953 DictionaryValue* args, | 3957 base::DictionaryValue* args, |
| 3954 IPC::Message* reply_message) { | 3958 IPC::Message* reply_message) { |
| 3955 new GetAllNotificationsObserver(this, reply_message); | 3959 new GetAllNotificationsObserver(this, reply_message); |
| 3956 } | 3960 } |
| 3957 | 3961 |
| 3958 // Refer to CloseNotification() in chrome/test/pyautolib/pyauto.py for | 3962 // Refer to CloseNotification() in chrome/test/pyautolib/pyauto.py for |
| 3959 // sample json input. | 3963 // sample json input. |
| 3960 // Returns empty json message. | 3964 // Returns empty json message. |
| 3961 void TestingAutomationProvider::CloseNotification( | 3965 void TestingAutomationProvider::CloseNotification( |
| 3962 Browser* browser, | 3966 Browser* browser, |
| 3963 DictionaryValue* args, | 3967 base::DictionaryValue* args, |
| 3964 IPC::Message* reply_message) { | 3968 IPC::Message* reply_message) { |
| 3965 int index; | 3969 int index; |
| 3966 if (!args->GetInteger("index", &index)) { | 3970 if (!args->GetInteger("index", &index)) { |
| 3967 AutomationJSONReply(this, reply_message) | 3971 AutomationJSONReply(this, reply_message) |
| 3968 .SendError("'index' missing or invalid."); | 3972 .SendError("'index' missing or invalid."); |
| 3969 return; | 3973 return; |
| 3970 } | 3974 } |
| 3971 BalloonNotificationUIManager* manager = | 3975 BalloonNotificationUIManager* manager = |
| 3972 BalloonNotificationUIManager::GetInstanceForTesting(); | 3976 BalloonNotificationUIManager::GetInstanceForTesting(); |
| 3973 BalloonCollection* collection = manager->balloon_collection(); | 3977 BalloonCollection* collection = manager->balloon_collection(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3987 new NewNotificationBalloonObserver(this, reply_message); | 3991 new NewNotificationBalloonObserver(this, reply_message); |
| 3988 } | 3992 } |
| 3989 manager->CancelById(balloons[index]->notification().notification_id()); | 3993 manager->CancelById(balloons[index]->notification().notification_id()); |
| 3990 } | 3994 } |
| 3991 | 3995 |
| 3992 // Refer to WaitForNotificationCount() in chrome/test/pyautolib/pyauto.py for | 3996 // Refer to WaitForNotificationCount() in chrome/test/pyautolib/pyauto.py for |
| 3993 // sample json input. | 3997 // sample json input. |
| 3994 // Returns empty json message. | 3998 // Returns empty json message. |
| 3995 void TestingAutomationProvider::WaitForNotificationCount( | 3999 void TestingAutomationProvider::WaitForNotificationCount( |
| 3996 Browser* browser, | 4000 Browser* browser, |
| 3997 DictionaryValue* args, | 4001 base::DictionaryValue* args, |
| 3998 IPC::Message* reply_message) { | 4002 IPC::Message* reply_message) { |
| 3999 int count; | 4003 int count; |
| 4000 if (!args->GetInteger("count", &count)) { | 4004 if (!args->GetInteger("count", &count)) { |
| 4001 AutomationJSONReply(this, reply_message) | 4005 AutomationJSONReply(this, reply_message) |
| 4002 .SendError("'count' missing or invalid."); | 4006 .SendError("'count' missing or invalid."); |
| 4003 return; | 4007 return; |
| 4004 } | 4008 } |
| 4005 // This will delete itself when finished. | 4009 // This will delete itself when finished. |
| 4006 new OnNotificationBalloonCountObserver(this, reply_message, count); | 4010 new OnNotificationBalloonCountObserver(this, reply_message, count); |
| 4007 } | 4011 } |
| 4008 | 4012 |
| 4009 // Sample JSON input: { "command": "GetNTPInfo" } | 4013 // Sample JSON input: { "command": "GetNTPInfo" } |
| 4010 // For output, refer to chrome/test/pyautolib/ntp_model.py. | 4014 // For output, refer to chrome/test/pyautolib/ntp_model.py. |
| 4011 void TestingAutomationProvider::GetNTPInfo( | 4015 void TestingAutomationProvider::GetNTPInfo( |
| 4012 Browser* browser, | 4016 Browser* browser, |
| 4013 DictionaryValue* args, | 4017 base::DictionaryValue* args, |
| 4014 IPC::Message* reply_message) { | 4018 IPC::Message* reply_message) { |
| 4015 // This observer will delete itself. | 4019 // This observer will delete itself. |
| 4016 new NTPInfoObserver(this, reply_message); | 4020 new NTPInfoObserver(this, reply_message); |
| 4017 } | 4021 } |
| 4018 | 4022 |
| 4019 void TestingAutomationProvider::RemoveNTPMostVisitedThumbnail( | 4023 void TestingAutomationProvider::RemoveNTPMostVisitedThumbnail( |
| 4020 Browser* browser, | 4024 Browser* browser, |
| 4021 DictionaryValue* args, | 4025 base::DictionaryValue* args, |
| 4022 IPC::Message* reply_message) { | 4026 IPC::Message* reply_message) { |
| 4023 AutomationJSONReply reply(this, reply_message); | 4027 AutomationJSONReply reply(this, reply_message); |
| 4024 std::string url; | 4028 std::string url; |
| 4025 if (!args->GetString("url", &url)) { | 4029 if (!args->GetString("url", &url)) { |
| 4026 reply.SendError("Missing or invalid 'url' key."); | 4030 reply.SendError("Missing or invalid 'url' key."); |
| 4027 return; | 4031 return; |
| 4028 } | 4032 } |
| 4029 history::TopSites* top_sites = browser->profile()->GetTopSites(); | 4033 history::TopSites* top_sites = browser->profile()->GetTopSites(); |
| 4030 if (!top_sites) { | 4034 if (!top_sites) { |
| 4031 reply.SendError("TopSites service is not initialized."); | 4035 reply.SendError("TopSites service is not initialized."); |
| 4032 return; | 4036 return; |
| 4033 } | 4037 } |
| 4034 top_sites->AddBlacklistedURL(GURL(url)); | 4038 top_sites->AddBlacklistedURL(GURL(url)); |
| 4035 reply.SendSuccess(NULL); | 4039 reply.SendSuccess(NULL); |
| 4036 } | 4040 } |
| 4037 | 4041 |
| 4038 void TestingAutomationProvider::RestoreAllNTPMostVisitedThumbnails( | 4042 void TestingAutomationProvider::RestoreAllNTPMostVisitedThumbnails( |
| 4039 Browser* browser, | 4043 Browser* browser, |
| 4040 DictionaryValue* args, | 4044 base::DictionaryValue* args, |
| 4041 IPC::Message* reply_message) { | 4045 IPC::Message* reply_message) { |
| 4042 AutomationJSONReply reply(this, reply_message); | 4046 AutomationJSONReply reply(this, reply_message); |
| 4043 history::TopSites* top_sites = browser->profile()->GetTopSites(); | 4047 history::TopSites* top_sites = browser->profile()->GetTopSites(); |
| 4044 if (!top_sites) { | 4048 if (!top_sites) { |
| 4045 reply.SendError("TopSites service is not initialized."); | 4049 reply.SendError("TopSites service is not initialized."); |
| 4046 return; | 4050 return; |
| 4047 } | 4051 } |
| 4048 top_sites->ClearBlacklistedURLs(); | 4052 top_sites->ClearBlacklistedURLs(); |
| 4049 reply.SendSuccess(NULL); | 4053 reply.SendSuccess(NULL); |
| 4050 } | 4054 } |
| 4051 | 4055 |
| 4052 void TestingAutomationProvider::KillRendererProcess( | 4056 void TestingAutomationProvider::KillRendererProcess( |
| 4053 Browser* browser, | 4057 Browser* browser, |
| 4054 DictionaryValue* args, | 4058 base::DictionaryValue* args, |
| 4055 IPC::Message* reply_message) { | 4059 IPC::Message* reply_message) { |
| 4056 int pid; | 4060 int pid; |
| 4057 uint32 kAccessFlags = base::kProcessAccessTerminate | | 4061 uint32 kAccessFlags = base::kProcessAccessTerminate | |
| 4058 base::kProcessAccessWaitForTermination | | 4062 base::kProcessAccessWaitForTermination | |
| 4059 base::kProcessAccessQueryInformation; | 4063 base::kProcessAccessQueryInformation; |
| 4060 | 4064 |
| 4061 if (!args->GetInteger("pid", &pid)) { | 4065 if (!args->GetInteger("pid", &pid)) { |
| 4062 AutomationJSONReply(this, reply_message) | 4066 AutomationJSONReply(this, reply_message) |
| 4063 .SendError("'pid' key missing or invalid."); | 4067 .SendError("'pid' key missing or invalid."); |
| 4064 return; | 4068 return; |
| 4065 } | 4069 } |
| 4066 base::ProcessHandle process; | 4070 base::ProcessHandle process; |
| 4067 if (!base::OpenProcessHandleWithAccess(static_cast<base::ProcessId>(pid), | 4071 if (!base::OpenProcessHandleWithAccess(static_cast<base::ProcessId>(pid), |
| 4068 kAccessFlags, | 4072 kAccessFlags, |
| 4069 &process)) { | 4073 &process)) { |
| 4070 AutomationJSONReply(this, reply_message).SendError(base::StringPrintf( | 4074 AutomationJSONReply(this, reply_message).SendError(base::StringPrintf( |
| 4071 "Failed to open process handle for pid %d", pid)); | 4075 "Failed to open process handle for pid %d", pid)); |
| 4072 return; | 4076 return; |
| 4073 } | 4077 } |
| 4074 new RendererProcessClosedObserver(this, reply_message); | 4078 new RendererProcessClosedObserver(this, reply_message); |
| 4075 base::KillProcess(process, 0, false); | 4079 base::KillProcess(process, 0, false); |
| 4076 base::CloseProcessHandle(process); | 4080 base::CloseProcessHandle(process); |
| 4077 } | 4081 } |
| 4078 | 4082 |
| 4079 bool TestingAutomationProvider::BuildWebKeyEventFromArgs( | 4083 bool TestingAutomationProvider::BuildWebKeyEventFromArgs( |
| 4080 DictionaryValue* args, | 4084 base::DictionaryValue* args, |
| 4081 std::string* error, | 4085 std::string* error, |
| 4082 NativeWebKeyboardEvent* event) { | 4086 NativeWebKeyboardEvent* event) { |
| 4083 int type, modifiers; | 4087 int type, modifiers; |
| 4084 bool is_system_key; | 4088 bool is_system_key; |
| 4085 base::string16 unmodified_text, text; | 4089 base::string16 unmodified_text, text; |
| 4086 std::string key_identifier; | 4090 std::string key_identifier; |
| 4087 if (!args->GetInteger("type", &type)) { | 4091 if (!args->GetInteger("type", &type)) { |
| 4088 *error = "'type' missing or invalid."; | 4092 *error = "'type' missing or invalid."; |
| 4089 return false; | 4093 return false; |
| 4090 } | 4094 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4153 if (modifiers & automation::kMetaKeyMask) | 4157 if (modifiers & automation::kMetaKeyMask) |
| 4154 event->modifiers |= blink::WebInputEvent::MetaKey; | 4158 event->modifiers |= blink::WebInputEvent::MetaKey; |
| 4155 | 4159 |
| 4156 event->isSystemKey = is_system_key; | 4160 event->isSystemKey = is_system_key; |
| 4157 event->timeStampSeconds = base::Time::Now().ToDoubleT(); | 4161 event->timeStampSeconds = base::Time::Now().ToDoubleT(); |
| 4158 event->skip_in_browser = true; | 4162 event->skip_in_browser = true; |
| 4159 return true; | 4163 return true; |
| 4160 } | 4164 } |
| 4161 | 4165 |
| 4162 void TestingAutomationProvider::SendWebkitKeyEvent( | 4166 void TestingAutomationProvider::SendWebkitKeyEvent( |
| 4163 DictionaryValue* args, | 4167 base::DictionaryValue* args, |
| 4164 IPC::Message* reply_message) { | 4168 IPC::Message* reply_message) { |
| 4165 if (SendErrorIfModalDialogActive(this, reply_message)) | 4169 if (SendErrorIfModalDialogActive(this, reply_message)) |
| 4166 return; | 4170 return; |
| 4167 | 4171 |
| 4168 NativeWebKeyboardEvent event; | 4172 NativeWebKeyboardEvent event; |
| 4169 // In the event of an error, BuildWebKeyEventFromArgs handles telling what | 4173 // In the event of an error, BuildWebKeyEventFromArgs handles telling what |
| 4170 // went wrong and sending the reply message; if it fails, we just have to | 4174 // went wrong and sending the reply message; if it fails, we just have to |
| 4171 // stop here. | 4175 // stop here. |
| 4172 std::string error; | 4176 std::string error; |
| 4173 if (!BuildWebKeyEventFromArgs(args, &error, &event)) { | 4177 if (!BuildWebKeyEventFromArgs(args, &error, &event)) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 4194 !dialog_queue->active_dialog()->IsJavaScriptModalDialog()) { | 4198 !dialog_queue->active_dialog()->IsJavaScriptModalDialog()) { |
| 4195 *error_msg = "No JavaScriptModalDialog open"; | 4199 *error_msg = "No JavaScriptModalDialog open"; |
| 4196 return NULL; | 4200 return NULL; |
| 4197 } | 4201 } |
| 4198 return static_cast<JavaScriptAppModalDialog*>(dialog_queue->active_dialog()); | 4202 return static_cast<JavaScriptAppModalDialog*>(dialog_queue->active_dialog()); |
| 4199 } | 4203 } |
| 4200 | 4204 |
| 4201 } // namespace | 4205 } // namespace |
| 4202 | 4206 |
| 4203 void TestingAutomationProvider::GetAppModalDialogMessage( | 4207 void TestingAutomationProvider::GetAppModalDialogMessage( |
| 4204 DictionaryValue* args, IPC::Message* reply_message) { | 4208 base::DictionaryValue* args, IPC::Message* reply_message) { |
| 4205 AutomationJSONReply reply(this, reply_message); | 4209 AutomationJSONReply reply(this, reply_message); |
| 4206 std::string error_msg; | 4210 std::string error_msg; |
| 4207 JavaScriptAppModalDialog* dialog = GetActiveJavaScriptModalDialog(&error_msg); | 4211 JavaScriptAppModalDialog* dialog = GetActiveJavaScriptModalDialog(&error_msg); |
| 4208 if (!dialog) { | 4212 if (!dialog) { |
| 4209 reply.SendError(error_msg); | 4213 reply.SendError(error_msg); |
| 4210 return; | 4214 return; |
| 4211 } | 4215 } |
| 4212 DictionaryValue result_dict; | 4216 base::DictionaryValue result_dict; |
| 4213 result_dict.SetString("message", UTF16ToUTF8(dialog->message_text())); | 4217 result_dict.SetString("message", UTF16ToUTF8(dialog->message_text())); |
| 4214 reply.SendSuccess(&result_dict); | 4218 reply.SendSuccess(&result_dict); |
| 4215 } | 4219 } |
| 4216 | 4220 |
| 4217 void TestingAutomationProvider::AcceptOrDismissAppModalDialog( | 4221 void TestingAutomationProvider::AcceptOrDismissAppModalDialog( |
| 4218 DictionaryValue* args, IPC::Message* reply_message) { | 4222 base::DictionaryValue* args, IPC::Message* reply_message) { |
| 4219 AutomationJSONReply reply(this, reply_message); | 4223 AutomationJSONReply reply(this, reply_message); |
| 4220 bool accept; | 4224 bool accept; |
| 4221 if (!args->GetBoolean("accept", &accept)) { | 4225 if (!args->GetBoolean("accept", &accept)) { |
| 4222 reply.SendError("Missing or invalid 'accept'"); | 4226 reply.SendError("Missing or invalid 'accept'"); |
| 4223 return; | 4227 return; |
| 4224 } | 4228 } |
| 4225 | 4229 |
| 4226 std::string error_msg; | 4230 std::string error_msg; |
| 4227 JavaScriptAppModalDialog* dialog = GetActiveJavaScriptModalDialog(&error_msg); | 4231 JavaScriptAppModalDialog* dialog = GetActiveJavaScriptModalDialog(&error_msg); |
| 4228 if (!dialog) { | 4232 if (!dialog) { |
| 4229 reply.SendError(error_msg); | 4233 reply.SendError(error_msg); |
| 4230 return; | 4234 return; |
| 4231 } | 4235 } |
| 4232 if (accept) { | 4236 if (accept) { |
| 4233 std::string prompt_text; | 4237 std::string prompt_text; |
| 4234 if (args->GetString("prompt_text", &prompt_text)) | 4238 if (args->GetString("prompt_text", &prompt_text)) |
| 4235 dialog->SetOverridePromptText(UTF8ToUTF16(prompt_text)); | 4239 dialog->SetOverridePromptText(UTF8ToUTF16(prompt_text)); |
| 4236 dialog->native_dialog()->AcceptAppModalDialog(); | 4240 dialog->native_dialog()->AcceptAppModalDialog(); |
| 4237 } else { | 4241 } else { |
| 4238 dialog->native_dialog()->CancelAppModalDialog(); | 4242 dialog->native_dialog()->CancelAppModalDialog(); |
| 4239 } | 4243 } |
| 4240 reply.SendSuccess(NULL); | 4244 reply.SendSuccess(NULL); |
| 4241 } | 4245 } |
| 4242 | 4246 |
| 4243 // Sample JSON input: { "command": "LaunchApp", | 4247 // Sample JSON input: { "command": "LaunchApp", |
| 4244 // "id": "ahfgeienlihckogmohjhadlkjgocpleb" } | 4248 // "id": "ahfgeienlihckogmohjhadlkjgocpleb" } |
| 4245 // Sample JSON output: {} | 4249 // Sample JSON output: {} |
| 4246 void TestingAutomationProvider::LaunchApp( | 4250 void TestingAutomationProvider::LaunchApp( |
| 4247 Browser* browser, | 4251 Browser* browser, |
| 4248 DictionaryValue* args, | 4252 base::DictionaryValue* args, |
| 4249 IPC::Message* reply_message) { | 4253 IPC::Message* reply_message) { |
| 4250 std::string id; | 4254 std::string id; |
| 4251 if (!args->GetString("id", &id)) { | 4255 if (!args->GetString("id", &id)) { |
| 4252 AutomationJSONReply(this, reply_message).SendError( | 4256 AutomationJSONReply(this, reply_message).SendError( |
| 4253 "Must include string id."); | 4257 "Must include string id."); |
| 4254 return; | 4258 return; |
| 4255 } | 4259 } |
| 4256 | 4260 |
| 4257 ExtensionService* service = extensions::ExtensionSystem::Get( | 4261 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 4258 browser->profile())->extension_service(); | 4262 browser->profile())->extension_service(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 4286 launch_params.container); | 4290 launch_params.container); |
| 4287 OpenApplication(launch_params); | 4291 OpenApplication(launch_params); |
| 4288 } | 4292 } |
| 4289 | 4293 |
| 4290 // Sample JSON input: { "command": "SetAppLaunchType", | 4294 // Sample JSON input: { "command": "SetAppLaunchType", |
| 4291 // "id": "ahfgeienlihckogmohjhadlkjgocpleb", | 4295 // "id": "ahfgeienlihckogmohjhadlkjgocpleb", |
| 4292 // "launch_type": "pinned" } | 4296 // "launch_type": "pinned" } |
| 4293 // Sample JSON output: {} | 4297 // Sample JSON output: {} |
| 4294 void TestingAutomationProvider::SetAppLaunchType( | 4298 void TestingAutomationProvider::SetAppLaunchType( |
| 4295 Browser* browser, | 4299 Browser* browser, |
| 4296 DictionaryValue* args, | 4300 base::DictionaryValue* args, |
| 4297 IPC::Message* reply_message) { | 4301 IPC::Message* reply_message) { |
| 4298 AutomationJSONReply reply(this, reply_message); | 4302 AutomationJSONReply reply(this, reply_message); |
| 4299 | 4303 |
| 4300 std::string id; | 4304 std::string id; |
| 4301 if (!args->GetString("id", &id)) { | 4305 if (!args->GetString("id", &id)) { |
| 4302 reply.SendError("Must include string id."); | 4306 reply.SendError("Must include string id."); |
| 4303 return; | 4307 return; |
| 4304 } | 4308 } |
| 4305 | 4309 |
| 4306 std::string launch_type_str; | 4310 std::string launch_type_str; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4343 service->extension_prefs(), extension->id(), launch_type); | 4347 service->extension_prefs(), extension->id(), launch_type); |
| 4344 reply.SendSuccess(NULL); | 4348 reply.SendSuccess(NULL); |
| 4345 } | 4349 } |
| 4346 | 4350 |
| 4347 // Sample json input: { "command": "GetV8HeapStats", | 4351 // Sample json input: { "command": "GetV8HeapStats", |
| 4348 // "tab_index": 0 } | 4352 // "tab_index": 0 } |
| 4349 // Refer to GetV8HeapStats() in chrome/test/pyautolib/pyauto.py for | 4353 // Refer to GetV8HeapStats() in chrome/test/pyautolib/pyauto.py for |
| 4350 // sample json output. | 4354 // sample json output. |
| 4351 void TestingAutomationProvider::GetV8HeapStats( | 4355 void TestingAutomationProvider::GetV8HeapStats( |
| 4352 Browser* browser, | 4356 Browser* browser, |
| 4353 DictionaryValue* args, | 4357 base::DictionaryValue* args, |
| 4354 IPC::Message* reply_message) { | 4358 IPC::Message* reply_message) { |
| 4355 WebContents* web_contents; | 4359 WebContents* web_contents; |
| 4356 int tab_index; | 4360 int tab_index; |
| 4357 | 4361 |
| 4358 if (!args->GetInteger("tab_index", &tab_index)) { | 4362 if (!args->GetInteger("tab_index", &tab_index)) { |
| 4359 AutomationJSONReply(this, reply_message).SendError( | 4363 AutomationJSONReply(this, reply_message).SendError( |
| 4360 "Missing 'tab_index' argument."); | 4364 "Missing 'tab_index' argument."); |
| 4361 return; | 4365 return; |
| 4362 } | 4366 } |
| 4363 | 4367 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 4376 base::GetProcId(render_view->GetProcess()->GetHandle())); | 4380 base::GetProcId(render_view->GetProcess()->GetHandle())); |
| 4377 render_view->Send(new ChromeViewMsg_GetV8HeapStats); | 4381 render_view->Send(new ChromeViewMsg_GetV8HeapStats); |
| 4378 } | 4382 } |
| 4379 | 4383 |
| 4380 // Sample json input: { "command": "GetFPS", | 4384 // Sample json input: { "command": "GetFPS", |
| 4381 // "tab_index": 0 } | 4385 // "tab_index": 0 } |
| 4382 // Refer to GetFPS() in chrome/test/pyautolib/pyauto.py for | 4386 // Refer to GetFPS() in chrome/test/pyautolib/pyauto.py for |
| 4383 // sample json output. | 4387 // sample json output. |
| 4384 void TestingAutomationProvider::GetFPS( | 4388 void TestingAutomationProvider::GetFPS( |
| 4385 Browser* browser, | 4389 Browser* browser, |
| 4386 DictionaryValue* args, | 4390 base::DictionaryValue* args, |
| 4387 IPC::Message* reply_message) { | 4391 IPC::Message* reply_message) { |
| 4388 WebContents* web_contents; | 4392 WebContents* web_contents; |
| 4389 int tab_index; | 4393 int tab_index; |
| 4390 | 4394 |
| 4391 if (!args->GetInteger("tab_index", &tab_index)) { | 4395 if (!args->GetInteger("tab_index", &tab_index)) { |
| 4392 AutomationJSONReply(this, reply_message).SendError( | 4396 AutomationJSONReply(this, reply_message).SendError( |
| 4393 "Missing 'tab_index' argument."); | 4397 "Missing 'tab_index' argument."); |
| 4394 return; | 4398 return; |
| 4395 } | 4399 } |
| 4396 | 4400 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 4408 new FPSObserver( | 4412 new FPSObserver( |
| 4409 this, reply_message, | 4413 this, reply_message, |
| 4410 base::GetProcId(render_view->GetProcess()->GetHandle()), | 4414 base::GetProcId(render_view->GetProcess()->GetHandle()), |
| 4411 routing_id); | 4415 routing_id); |
| 4412 render_view->Send(new ChromeViewMsg_GetFPS(routing_id)); | 4416 render_view->Send(new ChromeViewMsg_GetFPS(routing_id)); |
| 4413 } | 4417 } |
| 4414 | 4418 |
| 4415 void TestingAutomationProvider::IsFullscreenForBrowser(Browser* browser, | 4419 void TestingAutomationProvider::IsFullscreenForBrowser(Browser* browser, |
| 4416 base::DictionaryValue* args, | 4420 base::DictionaryValue* args, |
| 4417 IPC::Message* reply_message) { | 4421 IPC::Message* reply_message) { |
| 4418 DictionaryValue dict; | 4422 base::DictionaryValue dict; |
| 4419 dict.SetBoolean("result", | 4423 dict.SetBoolean("result", |
| 4420 browser->fullscreen_controller()->IsFullscreenForBrowser()); | 4424 browser->fullscreen_controller()->IsFullscreenForBrowser()); |
| 4421 AutomationJSONReply(this, reply_message).SendSuccess(&dict); | 4425 AutomationJSONReply(this, reply_message).SendSuccess(&dict); |
| 4422 } | 4426 } |
| 4423 | 4427 |
| 4424 void TestingAutomationProvider::IsFullscreenForTab(Browser* browser, | 4428 void TestingAutomationProvider::IsFullscreenForTab(Browser* browser, |
| 4425 base::DictionaryValue* args, | 4429 base::DictionaryValue* args, |
| 4426 IPC::Message* reply_message) { | 4430 IPC::Message* reply_message) { |
| 4427 DictionaryValue dict; | 4431 base::DictionaryValue dict; |
| 4428 dict.SetBoolean("result", | 4432 dict.SetBoolean("result", |
| 4429 browser->fullscreen_controller()->IsFullscreenForTabOrPending()); | 4433 browser->fullscreen_controller()->IsFullscreenForTabOrPending()); |
| 4430 AutomationJSONReply(this, reply_message).SendSuccess(&dict); | 4434 AutomationJSONReply(this, reply_message).SendSuccess(&dict); |
| 4431 } | 4435 } |
| 4432 | 4436 |
| 4433 void TestingAutomationProvider::IsMouseLocked(Browser* browser, | 4437 void TestingAutomationProvider::IsMouseLocked(Browser* browser, |
| 4434 base::DictionaryValue* args, | 4438 base::DictionaryValue* args, |
| 4435 IPC::Message* reply_message) { | 4439 IPC::Message* reply_message) { |
| 4436 DictionaryValue dict; | 4440 base::DictionaryValue dict; |
| 4437 dict.SetBoolean("result", browser->tab_strip_model()->GetActiveWebContents()-> | 4441 dict.SetBoolean("result", browser->tab_strip_model()->GetActiveWebContents()-> |
| 4438 GetRenderViewHost()->GetView()->IsMouseLocked()); | 4442 GetRenderViewHost()->GetView()->IsMouseLocked()); |
| 4439 AutomationJSONReply(this, reply_message).SendSuccess(&dict); | 4443 AutomationJSONReply(this, reply_message).SendSuccess(&dict); |
| 4440 } | 4444 } |
| 4441 | 4445 |
| 4442 void TestingAutomationProvider::IsMouseLockPermissionRequested( | 4446 void TestingAutomationProvider::IsMouseLockPermissionRequested( |
| 4443 Browser* browser, | 4447 Browser* browser, |
| 4444 base::DictionaryValue* args, | 4448 base::DictionaryValue* args, |
| 4445 IPC::Message* reply_message) { | 4449 IPC::Message* reply_message) { |
| 4446 FullscreenExitBubbleType type = | 4450 FullscreenExitBubbleType type = |
| 4447 browser->fullscreen_controller()->GetFullscreenExitBubbleType(); | 4451 browser->fullscreen_controller()->GetFullscreenExitBubbleType(); |
| 4448 bool mouse_lock = false; | 4452 bool mouse_lock = false; |
| 4449 fullscreen_bubble::PermissionRequestedByType(type, NULL, &mouse_lock); | 4453 fullscreen_bubble::PermissionRequestedByType(type, NULL, &mouse_lock); |
| 4450 DictionaryValue dict; | 4454 base::DictionaryValue dict; |
| 4451 dict.SetBoolean("result", mouse_lock); | 4455 dict.SetBoolean("result", mouse_lock); |
| 4452 AutomationJSONReply(this, reply_message).SendSuccess(&dict); | 4456 AutomationJSONReply(this, reply_message).SendSuccess(&dict); |
| 4453 } | 4457 } |
| 4454 | 4458 |
| 4455 void TestingAutomationProvider::IsFullscreenPermissionRequested( | 4459 void TestingAutomationProvider::IsFullscreenPermissionRequested( |
| 4456 Browser* browser, | 4460 Browser* browser, |
| 4457 base::DictionaryValue* args, | 4461 base::DictionaryValue* args, |
| 4458 IPC::Message* reply_message) { | 4462 IPC::Message* reply_message) { |
| 4459 FullscreenExitBubbleType type = | 4463 FullscreenExitBubbleType type = |
| 4460 browser->fullscreen_controller()->GetFullscreenExitBubbleType(); | 4464 browser->fullscreen_controller()->GetFullscreenExitBubbleType(); |
| 4461 bool fullscreen = false; | 4465 bool fullscreen = false; |
| 4462 fullscreen_bubble::PermissionRequestedByType(type, &fullscreen, NULL); | 4466 fullscreen_bubble::PermissionRequestedByType(type, &fullscreen, NULL); |
| 4463 DictionaryValue dict; | 4467 base::DictionaryValue dict; |
| 4464 dict.SetBoolean("result", fullscreen); | 4468 dict.SetBoolean("result", fullscreen); |
| 4465 AutomationJSONReply(this, reply_message).SendSuccess(&dict); | 4469 AutomationJSONReply(this, reply_message).SendSuccess(&dict); |
| 4466 } | 4470 } |
| 4467 | 4471 |
| 4468 void TestingAutomationProvider::IsFullscreenBubbleDisplayed(Browser* browser, | 4472 void TestingAutomationProvider::IsFullscreenBubbleDisplayed(Browser* browser, |
| 4469 base::DictionaryValue* args, | 4473 base::DictionaryValue* args, |
| 4470 IPC::Message* reply_message) { | 4474 IPC::Message* reply_message) { |
| 4471 FullscreenExitBubbleType type = | 4475 FullscreenExitBubbleType type = |
| 4472 browser->fullscreen_controller()->GetFullscreenExitBubbleType(); | 4476 browser->fullscreen_controller()->GetFullscreenExitBubbleType(); |
| 4473 DictionaryValue dict; | 4477 base::DictionaryValue dict; |
| 4474 dict.SetBoolean("result", | 4478 dict.SetBoolean("result", |
| 4475 type != FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION); | 4479 type != FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION); |
| 4476 AutomationJSONReply(this, reply_message).SendSuccess(&dict); | 4480 AutomationJSONReply(this, reply_message).SendSuccess(&dict); |
| 4477 } | 4481 } |
| 4478 | 4482 |
| 4479 void TestingAutomationProvider::IsFullscreenBubbleDisplayingButtons( | 4483 void TestingAutomationProvider::IsFullscreenBubbleDisplayingButtons( |
| 4480 Browser* browser, | 4484 Browser* browser, |
| 4481 base::DictionaryValue* args, | 4485 base::DictionaryValue* args, |
| 4482 IPC::Message* reply_message) { | 4486 IPC::Message* reply_message) { |
| 4483 FullscreenExitBubbleType type = | 4487 FullscreenExitBubbleType type = |
| 4484 browser->fullscreen_controller()->GetFullscreenExitBubbleType(); | 4488 browser->fullscreen_controller()->GetFullscreenExitBubbleType(); |
| 4485 DictionaryValue dict; | 4489 base::DictionaryValue dict; |
| 4486 dict.SetBoolean("result", fullscreen_bubble::ShowButtonsForType(type)); | 4490 dict.SetBoolean("result", fullscreen_bubble::ShowButtonsForType(type)); |
| 4487 AutomationJSONReply(this, reply_message).SendSuccess(&dict); | 4491 AutomationJSONReply(this, reply_message).SendSuccess(&dict); |
| 4488 } | 4492 } |
| 4489 | 4493 |
| 4490 void TestingAutomationProvider::AcceptCurrentFullscreenOrMouseLockRequest( | 4494 void TestingAutomationProvider::AcceptCurrentFullscreenOrMouseLockRequest( |
| 4491 Browser* browser, | 4495 Browser* browser, |
| 4492 base::DictionaryValue* args, | 4496 base::DictionaryValue* args, |
| 4493 IPC::Message* reply_message) { | 4497 IPC::Message* reply_message) { |
| 4494 browser->fullscreen_controller()->OnAcceptFullscreenPermission(); | 4498 browser->fullscreen_controller()->OnAcceptFullscreenPermission(); |
| 4495 AutomationJSONReply(this, reply_message).SendSuccess(NULL); | 4499 AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
| 4496 } | 4500 } |
| 4497 | 4501 |
| 4498 void TestingAutomationProvider::DenyCurrentFullscreenOrMouseLockRequest( | 4502 void TestingAutomationProvider::DenyCurrentFullscreenOrMouseLockRequest( |
| 4499 Browser* browser, | 4503 Browser* browser, |
| 4500 base::DictionaryValue* args, | 4504 base::DictionaryValue* args, |
| 4501 IPC::Message* reply_message) { | 4505 IPC::Message* reply_message) { |
| 4502 browser->fullscreen_controller()->OnDenyFullscreenPermission(); | 4506 browser->fullscreen_controller()->OnDenyFullscreenPermission(); |
| 4503 AutomationJSONReply(this, reply_message).SendSuccess(NULL); | 4507 AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
| 4504 } | 4508 } |
| 4505 | 4509 |
| 4506 void TestingAutomationProvider::WaitForTabToBeRestored( | 4510 void TestingAutomationProvider::WaitForTabToBeRestored( |
| 4507 DictionaryValue* args, | 4511 base::DictionaryValue* args, |
| 4508 IPC::Message* reply_message) { | 4512 IPC::Message* reply_message) { |
| 4509 WebContents* web_contents; | 4513 WebContents* web_contents; |
| 4510 std::string error; | 4514 std::string error; |
| 4511 if (!GetTabFromJSONArgs(args, &web_contents, &error)) { | 4515 if (!GetTabFromJSONArgs(args, &web_contents, &error)) { |
| 4512 AutomationJSONReply(this, reply_message).SendError(error); | 4516 AutomationJSONReply(this, reply_message).SendError(error); |
| 4513 return; | 4517 return; |
| 4514 } | 4518 } |
| 4515 NavigationController& controller = web_contents->GetController(); | 4519 NavigationController& controller = web_contents->GetController(); |
| 4516 new NavigationControllerRestoredObserver(this, &controller, reply_message); | 4520 new NavigationControllerRestoredObserver(this, &controller, reply_message); |
| 4517 } | 4521 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4549 | 4553 |
| 4550 // Send the reply while we can. | 4554 // Send the reply while we can. |
| 4551 AutomationJSONReply(this, reply_message).SendSuccess(NULL); | 4555 AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
| 4552 | 4556 |
| 4553 // Cause Address Sanitizer to abort this process. | 4557 // Cause Address Sanitizer to abort this process. |
| 4554 volatile int index = 5; | 4558 volatile int index = 5; |
| 4555 AccessArray(testarray, &index); | 4559 AccessArray(testarray, &index); |
| 4556 } | 4560 } |
| 4557 | 4561 |
| 4558 void TestingAutomationProvider::GetIndicesFromTab( | 4562 void TestingAutomationProvider::GetIndicesFromTab( |
| 4559 DictionaryValue* args, | 4563 base::DictionaryValue* args, |
| 4560 IPC::Message* reply_message) { | 4564 IPC::Message* reply_message) { |
| 4561 AutomationJSONReply reply(this, reply_message); | 4565 AutomationJSONReply reply(this, reply_message); |
| 4562 int id_or_handle = 0; | 4566 int id_or_handle = 0; |
| 4563 bool has_id = args->HasKey("tab_id"); | 4567 bool has_id = args->HasKey("tab_id"); |
| 4564 bool has_handle = args->HasKey("tab_handle"); | 4568 bool has_handle = args->HasKey("tab_handle"); |
| 4565 if (has_id && has_handle) { | 4569 if (has_id && has_handle) { |
| 4566 reply.SendError( | 4570 reply.SendError( |
| 4567 "Both 'tab_id' and 'tab_handle' were specified. Only one is allowed"); | 4571 "Both 'tab_id' and 'tab_handle' were specified. Only one is allowed"); |
| 4568 return; | 4572 return; |
| 4569 } else if (!has_id && !has_handle) { | 4573 } else if (!has_id && !has_handle) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 4591 for (; !it.done(); it.Next(), ++browser_index) { | 4595 for (; !it.done(); it.Next(), ++browser_index) { |
| 4592 Browser* browser = *it; | 4596 Browser* browser = *it; |
| 4593 for (int tab_index = 0; | 4597 for (int tab_index = 0; |
| 4594 tab_index < browser->tab_strip_model()->count(); | 4598 tab_index < browser->tab_strip_model()->count(); |
| 4595 ++tab_index) { | 4599 ++tab_index) { |
| 4596 WebContents* tab = | 4600 WebContents* tab = |
| 4597 browser->tab_strip_model()->GetWebContentsAt(tab_index); | 4601 browser->tab_strip_model()->GetWebContentsAt(tab_index); |
| 4598 SessionTabHelper* session_tab_helper = | 4602 SessionTabHelper* session_tab_helper = |
| 4599 SessionTabHelper::FromWebContents(tab); | 4603 SessionTabHelper::FromWebContents(tab); |
| 4600 if (session_tab_helper->session_id().id() == id) { | 4604 if (session_tab_helper->session_id().id() == id) { |
| 4601 DictionaryValue dict; | 4605 base::DictionaryValue dict; |
| 4602 dict.SetInteger("windex", browser_index); | 4606 dict.SetInteger("windex", browser_index); |
| 4603 dict.SetInteger("tab_index", tab_index); | 4607 dict.SetInteger("tab_index", tab_index); |
| 4604 reply.SendSuccess(&dict); | 4608 reply.SendSuccess(&dict); |
| 4605 return; | 4609 return; |
| 4606 } | 4610 } |
| 4607 } | 4611 } |
| 4608 } | 4612 } |
| 4609 reply.SendError("Could not find tab among current browser windows"); | 4613 reply.SendError("Could not find tab among current browser windows"); |
| 4610 } | 4614 } |
| 4611 | 4615 |
| 4612 void TestingAutomationProvider::NavigateToURL( | 4616 void TestingAutomationProvider::NavigateToURL( |
| 4613 DictionaryValue* args, | 4617 base::DictionaryValue* args, |
| 4614 IPC::Message* reply_message) { | 4618 IPC::Message* reply_message) { |
| 4615 if (SendErrorIfModalDialogActive(this, reply_message)) | 4619 if (SendErrorIfModalDialogActive(this, reply_message)) |
| 4616 return; | 4620 return; |
| 4617 | 4621 |
| 4618 int navigation_count; | 4622 int navigation_count; |
| 4619 std::string url, error; | 4623 std::string url, error; |
| 4620 Browser* browser; | 4624 Browser* browser; |
| 4621 WebContents* web_contents; | 4625 WebContents* web_contents; |
| 4622 if (!GetBrowserAndTabFromJSONArgs(args, &browser, &web_contents, &error)) { | 4626 if (!GetBrowserAndTabFromJSONArgs(args, &browser, &web_contents, &error)) { |
| 4623 AutomationJSONReply(this, reply_message).SendError(error); | 4627 AutomationJSONReply(this, reply_message).SendError(error); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 4643 OpenURLParams params( | 4647 OpenURLParams params( |
| 4644 GURL(url), content::Referrer(), CURRENT_TAB, | 4648 GURL(url), content::Referrer(), CURRENT_TAB, |
| 4645 content::PageTransitionFromInt( | 4649 content::PageTransitionFromInt( |
| 4646 content::PAGE_TRANSITION_TYPED | | 4650 content::PAGE_TRANSITION_TYPED | |
| 4647 content::PAGE_TRANSITION_FROM_ADDRESS_BAR), | 4651 content::PAGE_TRANSITION_FROM_ADDRESS_BAR), |
| 4648 false); | 4652 false); |
| 4649 browser->OpenURLFromTab(web_contents, params); | 4653 browser->OpenURLFromTab(web_contents, params); |
| 4650 } | 4654 } |
| 4651 | 4655 |
| 4652 void TestingAutomationProvider::GetActiveTabIndexJSON( | 4656 void TestingAutomationProvider::GetActiveTabIndexJSON( |
| 4653 DictionaryValue* args, | 4657 base::DictionaryValue* args, |
| 4654 IPC::Message* reply_message) { | 4658 IPC::Message* reply_message) { |
| 4655 AutomationJSONReply reply(this, reply_message); | 4659 AutomationJSONReply reply(this, reply_message); |
| 4656 Browser* browser; | 4660 Browser* browser; |
| 4657 std::string error_msg; | 4661 std::string error_msg; |
| 4658 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { | 4662 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { |
| 4659 reply.SendError(error_msg); | 4663 reply.SendError(error_msg); |
| 4660 return; | 4664 return; |
| 4661 } | 4665 } |
| 4662 int tab_index = browser->tab_strip_model()->active_index(); | 4666 int tab_index = browser->tab_strip_model()->active_index(); |
| 4663 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 4667 scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue); |
| 4664 return_value->SetInteger("tab_index", tab_index); | 4668 return_value->SetInteger("tab_index", tab_index); |
| 4665 reply.SendSuccess(return_value.get()); | 4669 reply.SendSuccess(return_value.get()); |
| 4666 } | 4670 } |
| 4667 | 4671 |
| 4668 void TestingAutomationProvider::AppendTabJSON(DictionaryValue* args, | 4672 void TestingAutomationProvider::AppendTabJSON(base::DictionaryValue* args, |
| 4669 IPC::Message* reply_message) { | 4673 IPC::Message* reply_message) { |
| 4670 TabAppendedNotificationObserver* observer = NULL; | 4674 TabAppendedNotificationObserver* observer = NULL; |
| 4671 int append_tab_response = -1; | 4675 int append_tab_response = -1; |
| 4672 Browser* browser; | 4676 Browser* browser; |
| 4673 std::string error_msg, url; | 4677 std::string error_msg, url; |
| 4674 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { | 4678 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { |
| 4675 AutomationJSONReply(this, reply_message).SendError(error_msg); | 4679 AutomationJSONReply(this, reply_message).SendError(error_msg); |
| 4676 return; | 4680 return; |
| 4677 } | 4681 } |
| 4678 if (!args->GetString("url", &url)) { | 4682 if (!args->GetString("url", &url)) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 4693 if (!contents || append_tab_response < 0) { | 4697 if (!contents || append_tab_response < 0) { |
| 4694 if (observer) { | 4698 if (observer) { |
| 4695 observer->ReleaseReply(); | 4699 observer->ReleaseReply(); |
| 4696 delete observer; | 4700 delete observer; |
| 4697 } | 4701 } |
| 4698 AutomationJSONReply(this, reply_message).SendError("Failed to append tab."); | 4702 AutomationJSONReply(this, reply_message).SendError("Failed to append tab."); |
| 4699 } | 4703 } |
| 4700 } | 4704 } |
| 4701 | 4705 |
| 4702 void TestingAutomationProvider::WaitUntilNavigationCompletes( | 4706 void TestingAutomationProvider::WaitUntilNavigationCompletes( |
| 4703 DictionaryValue* args, | 4707 base::DictionaryValue* args, |
| 4704 IPC::Message* reply_message) { | 4708 IPC::Message* reply_message) { |
| 4705 if (SendErrorIfModalDialogActive(this, reply_message)) | 4709 if (SendErrorIfModalDialogActive(this, reply_message)) |
| 4706 return; | 4710 return; |
| 4707 | 4711 |
| 4708 std::string error; | 4712 std::string error; |
| 4709 Browser* browser; | 4713 Browser* browser; |
| 4710 WebContents* web_contents; | 4714 WebContents* web_contents; |
| 4711 if (!GetBrowserAndTabFromJSONArgs(args, &browser, &web_contents, &error)) { | 4715 if (!GetBrowserAndTabFromJSONArgs(args, &browser, &web_contents, &error)) { |
| 4712 AutomationJSONReply(this, reply_message).SendError(error); | 4716 AutomationJSONReply(this, reply_message).SendError(error); |
| 4713 return; | 4717 return; |
| 4714 } | 4718 } |
| 4715 NavigationNotificationObserver* observer = | 4719 NavigationNotificationObserver* observer = |
| 4716 new NavigationNotificationObserver(&web_contents->GetController(), this, | 4720 new NavigationNotificationObserver(&web_contents->GetController(), this, |
| 4717 reply_message, 1, true, true); | 4721 reply_message, 1, true, true); |
| 4718 if (!web_contents->IsLoading()) { | 4722 if (!web_contents->IsLoading()) { |
| 4719 observer->ConditionMet(AUTOMATION_MSG_NAVIGATION_SUCCESS); | 4723 observer->ConditionMet(AUTOMATION_MSG_NAVIGATION_SUCCESS); |
| 4720 return; | 4724 return; |
| 4721 } | 4725 } |
| 4722 } | 4726 } |
| 4723 | 4727 |
| 4724 void TestingAutomationProvider::ExecuteJavascriptJSON( | 4728 void TestingAutomationProvider::ExecuteJavascriptJSON( |
| 4725 DictionaryValue* args, | 4729 base::DictionaryValue* args, |
| 4726 IPC::Message* reply_message) { | 4730 IPC::Message* reply_message) { |
| 4727 if (SendErrorIfModalDialogActive(this, reply_message)) | 4731 if (SendErrorIfModalDialogActive(this, reply_message)) |
| 4728 return; | 4732 return; |
| 4729 | 4733 |
| 4730 base::string16 frame_xpath, javascript; | 4734 base::string16 frame_xpath, javascript; |
| 4731 std::string error; | 4735 std::string error; |
| 4732 RenderViewHost* render_view; | 4736 RenderViewHost* render_view; |
| 4733 if (!GetRenderViewFromJSONArgs(args, profile(), &render_view, &error)) { | 4737 if (!GetRenderViewFromJSONArgs(args, profile(), &render_view, &error)) { |
| 4734 AutomationJSONReply(this, reply_message).SendError(error); | 4738 AutomationJSONReply(this, reply_message).SendError(error); |
| 4735 return; | 4739 return; |
| 4736 } | 4740 } |
| 4737 if (!args->GetString("frame_xpath", &frame_xpath)) { | 4741 if (!args->GetString("frame_xpath", &frame_xpath)) { |
| 4738 AutomationJSONReply(this, reply_message) | 4742 AutomationJSONReply(this, reply_message) |
| 4739 .SendError("'frame_xpath' missing or invalid"); | 4743 .SendError("'frame_xpath' missing or invalid"); |
| 4740 return; | 4744 return; |
| 4741 } | 4745 } |
| 4742 if (!args->GetString("javascript", &javascript)) { | 4746 if (!args->GetString("javascript", &javascript)) { |
| 4743 AutomationJSONReply(this, reply_message) | 4747 AutomationJSONReply(this, reply_message) |
| 4744 .SendError("'javascript' missing or invalid"); | 4748 .SendError("'javascript' missing or invalid"); |
| 4745 return; | 4749 return; |
| 4746 } | 4750 } |
| 4747 | 4751 |
| 4748 new DomOperationMessageSender(this, reply_message, true); | 4752 new DomOperationMessageSender(this, reply_message, true); |
| 4749 ExecuteJavascriptInRenderViewFrame(frame_xpath, javascript, reply_message, | 4753 ExecuteJavascriptInRenderViewFrame(frame_xpath, javascript, reply_message, |
| 4750 render_view); | 4754 render_view); |
| 4751 } | 4755 } |
| 4752 | 4756 |
| 4753 void TestingAutomationProvider::ExecuteJavascriptInRenderView( | 4757 void TestingAutomationProvider::ExecuteJavascriptInRenderView( |
| 4754 DictionaryValue* args, | 4758 base::DictionaryValue* args, |
| 4755 IPC::Message* reply_message) { | 4759 IPC::Message* reply_message) { |
| 4756 base::string16 frame_xpath, javascript, extension_id, url_text; | 4760 base::string16 frame_xpath, javascript, extension_id, url_text; |
| 4757 int render_process_id, render_view_id; | 4761 int render_process_id, render_view_id; |
| 4758 if (!args->GetString("frame_xpath", &frame_xpath)) { | 4762 if (!args->GetString("frame_xpath", &frame_xpath)) { |
| 4759 AutomationJSONReply(this, reply_message) | 4763 AutomationJSONReply(this, reply_message) |
| 4760 .SendError("'frame_xpath' missing or invalid"); | 4764 .SendError("'frame_xpath' missing or invalid"); |
| 4761 return; | 4765 return; |
| 4762 } | 4766 } |
| 4763 if (!args->GetString("javascript", &javascript)) { | 4767 if (!args->GetString("javascript", &javascript)) { |
| 4764 AutomationJSONReply(this, reply_message) | 4768 AutomationJSONReply(this, reply_message) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 4783 "A RenderViewHost object was not found with the given view ID."); | 4787 "A RenderViewHost object was not found with the given view ID."); |
| 4784 return; | 4788 return; |
| 4785 } | 4789 } |
| 4786 | 4790 |
| 4787 new DomOperationMessageSender(this, reply_message, true); | 4791 new DomOperationMessageSender(this, reply_message, true); |
| 4788 ExecuteJavascriptInRenderViewFrame(frame_xpath, javascript, reply_message, | 4792 ExecuteJavascriptInRenderViewFrame(frame_xpath, javascript, reply_message, |
| 4789 rvh); | 4793 rvh); |
| 4790 } | 4794 } |
| 4791 | 4795 |
| 4792 void TestingAutomationProvider::AddDomEventObserver( | 4796 void TestingAutomationProvider::AddDomEventObserver( |
| 4793 DictionaryValue* args, | 4797 base::DictionaryValue* args, |
| 4794 IPC::Message* reply_message) { | 4798 IPC::Message* reply_message) { |
| 4795 if (SendErrorIfModalDialogActive(this, reply_message)) | 4799 if (SendErrorIfModalDialogActive(this, reply_message)) |
| 4796 return; | 4800 return; |
| 4797 | 4801 |
| 4798 AutomationJSONReply reply(this, reply_message); | 4802 AutomationJSONReply reply(this, reply_message); |
| 4799 std::string event_name; | 4803 std::string event_name; |
| 4800 int automation_id; | 4804 int automation_id; |
| 4801 bool recurring; | 4805 bool recurring; |
| 4802 if (!args->GetString("event_name", &event_name)) { | 4806 if (!args->GetString("event_name", &event_name)) { |
| 4803 reply.SendError("'event_name' missing or invalid"); | 4807 reply.SendError("'event_name' missing or invalid"); |
| 4804 return; | 4808 return; |
| 4805 } | 4809 } |
| 4806 if (!args->GetInteger("automation_id", &automation_id)) { | 4810 if (!args->GetInteger("automation_id", &automation_id)) { |
| 4807 reply.SendError("'automation_id' missing or invalid"); | 4811 reply.SendError("'automation_id' missing or invalid"); |
| 4808 return; | 4812 return; |
| 4809 } | 4813 } |
| 4810 if (!args->GetBoolean("recurring", &recurring)) { | 4814 if (!args->GetBoolean("recurring", &recurring)) { |
| 4811 reply.SendError("'recurring' missing or invalid"); | 4815 reply.SendError("'recurring' missing or invalid"); |
| 4812 return; | 4816 return; |
| 4813 } | 4817 } |
| 4814 | 4818 |
| 4815 if (!automation_event_queue_.get()) | 4819 if (!automation_event_queue_.get()) |
| 4816 automation_event_queue_.reset(new AutomationEventQueue); | 4820 automation_event_queue_.reset(new AutomationEventQueue); |
| 4817 | 4821 |
| 4818 int observer_id = automation_event_queue_->AddObserver( | 4822 int observer_id = automation_event_queue_->AddObserver( |
| 4819 new DomEventObserver(automation_event_queue_.get(), event_name, | 4823 new DomEventObserver(automation_event_queue_.get(), event_name, |
| 4820 automation_id, recurring)); | 4824 automation_id, recurring)); |
| 4821 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 4825 scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue); |
| 4822 return_value->SetInteger("observer_id", observer_id); | 4826 return_value->SetInteger("observer_id", observer_id); |
| 4823 reply.SendSuccess(return_value.get()); | 4827 reply.SendSuccess(return_value.get()); |
| 4824 } | 4828 } |
| 4825 | 4829 |
| 4826 void TestingAutomationProvider::RemoveEventObserver( | 4830 void TestingAutomationProvider::RemoveEventObserver( |
| 4827 DictionaryValue* args, | 4831 base::DictionaryValue* args, |
| 4828 IPC::Message* reply_message) { | 4832 IPC::Message* reply_message) { |
| 4829 AutomationJSONReply reply(this, reply_message); | 4833 AutomationJSONReply reply(this, reply_message); |
| 4830 int observer_id; | 4834 int observer_id; |
| 4831 if (!args->GetInteger("observer_id", &observer_id) || | 4835 if (!args->GetInteger("observer_id", &observer_id) || |
| 4832 !automation_event_queue_.get()) { | 4836 !automation_event_queue_.get()) { |
| 4833 reply.SendError("'observer_id' missing or invalid"); | 4837 reply.SendError("'observer_id' missing or invalid"); |
| 4834 return; | 4838 return; |
| 4835 } | 4839 } |
| 4836 if (automation_event_queue_->RemoveObserver(observer_id)) { | 4840 if (automation_event_queue_->RemoveObserver(observer_id)) { |
| 4837 reply.SendSuccess(NULL); | 4841 reply.SendSuccess(NULL); |
| 4838 return; | 4842 return; |
| 4839 } | 4843 } |
| 4840 reply.SendError("Invalid observer id."); | 4844 reply.SendError("Invalid observer id."); |
| 4841 } | 4845 } |
| 4842 | 4846 |
| 4843 void TestingAutomationProvider::ClearEventQueue( | 4847 void TestingAutomationProvider::ClearEventQueue( |
| 4844 DictionaryValue* args, | 4848 base::DictionaryValue* args, |
| 4845 IPC::Message* reply_message) { | 4849 IPC::Message* reply_message) { |
| 4846 automation_event_queue_.reset(); | 4850 automation_event_queue_.reset(); |
| 4847 AutomationJSONReply(this, reply_message).SendSuccess(NULL); | 4851 AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
| 4848 } | 4852 } |
| 4849 | 4853 |
| 4850 void TestingAutomationProvider::GetNextEvent( | 4854 void TestingAutomationProvider::GetNextEvent( |
| 4851 DictionaryValue* args, | 4855 base::DictionaryValue* args, |
| 4852 IPC::Message* reply_message) { | 4856 IPC::Message* reply_message) { |
| 4853 scoped_ptr<AutomationJSONReply> reply( | 4857 scoped_ptr<AutomationJSONReply> reply( |
| 4854 new AutomationJSONReply(this, reply_message)); | 4858 new AutomationJSONReply(this, reply_message)); |
| 4855 int observer_id; | 4859 int observer_id; |
| 4856 bool blocking; | 4860 bool blocking; |
| 4857 if (!args->GetInteger("observer_id", &observer_id)) { | 4861 if (!args->GetInteger("observer_id", &observer_id)) { |
| 4858 reply->SendError("'observer_id' missing or invalid"); | 4862 reply->SendError("'observer_id' missing or invalid"); |
| 4859 return; | 4863 return; |
| 4860 } | 4864 } |
| 4861 if (!args->GetBoolean("blocking", &blocking)) { | 4865 if (!args->GetBoolean("blocking", &blocking)) { |
| 4862 reply->SendError("'blocking' missing or invalid"); | 4866 reply->SendError("'blocking' missing or invalid"); |
| 4863 return; | 4867 return; |
| 4864 } | 4868 } |
| 4865 if (!automation_event_queue_.get()) { | 4869 if (!automation_event_queue_.get()) { |
| 4866 reply->SendError( | 4870 reply->SendError( |
| 4867 "No observers are attached to the queue. Did you create any?"); | 4871 "No observers are attached to the queue. Did you create any?"); |
| 4868 return; | 4872 return; |
| 4869 } | 4873 } |
| 4870 | 4874 |
| 4871 // The reply will be freed once a matching event is added to the queue. | 4875 // The reply will be freed once a matching event is added to the queue. |
| 4872 automation_event_queue_->GetNextEvent(reply.release(), observer_id, blocking); | 4876 automation_event_queue_->GetNextEvent(reply.release(), observer_id, blocking); |
| 4873 } | 4877 } |
| 4874 | 4878 |
| 4875 void TestingAutomationProvider::GoForward( | 4879 void TestingAutomationProvider::GoForward( |
| 4876 DictionaryValue* args, | 4880 base::DictionaryValue* args, |
| 4877 IPC::Message* reply_message) { | 4881 IPC::Message* reply_message) { |
| 4878 if (SendErrorIfModalDialogActive(this, reply_message)) | 4882 if (SendErrorIfModalDialogActive(this, reply_message)) |
| 4879 return; | 4883 return; |
| 4880 | 4884 |
| 4881 WebContents* web_contents; | 4885 WebContents* web_contents; |
| 4882 std::string error; | 4886 std::string error; |
| 4883 if (!GetTabFromJSONArgs(args, &web_contents, &error)) { | 4887 if (!GetTabFromJSONArgs(args, &web_contents, &error)) { |
| 4884 AutomationJSONReply(this, reply_message).SendError(error); | 4888 AutomationJSONReply(this, reply_message).SendError(error); |
| 4885 return; | 4889 return; |
| 4886 } | 4890 } |
| 4887 NavigationController& controller = web_contents->GetController(); | 4891 NavigationController& controller = web_contents->GetController(); |
| 4888 if (!controller.CanGoForward()) { | 4892 if (!controller.CanGoForward()) { |
| 4889 DictionaryValue dict; | 4893 base::DictionaryValue dict; |
| 4890 dict.SetBoolean("did_go_forward", false); | 4894 dict.SetBoolean("did_go_forward", false); |
| 4891 AutomationJSONReply(this, reply_message).SendSuccess(&dict); | 4895 AutomationJSONReply(this, reply_message).SendSuccess(&dict); |
| 4892 return; | 4896 return; |
| 4893 } | 4897 } |
| 4894 new NavigationNotificationObserver(&controller, this, reply_message, | 4898 new NavigationNotificationObserver(&controller, this, reply_message, |
| 4895 1, false, true); | 4899 1, false, true); |
| 4896 controller.GoForward(); | 4900 controller.GoForward(); |
| 4897 } | 4901 } |
| 4898 | 4902 |
| 4899 void TestingAutomationProvider::ExecuteBrowserCommandAsyncJSON( | 4903 void TestingAutomationProvider::ExecuteBrowserCommandAsyncJSON( |
| 4900 DictionaryValue* args, | 4904 base::DictionaryValue* args, |
| 4901 IPC::Message* reply_message) { | 4905 IPC::Message* reply_message) { |
| 4902 AutomationJSONReply reply(this, reply_message); | 4906 AutomationJSONReply reply(this, reply_message); |
| 4903 int command; | 4907 int command; |
| 4904 Browser* browser; | 4908 Browser* browser; |
| 4905 std::string error; | 4909 std::string error; |
| 4906 if (!GetBrowserFromJSONArgs(args, &browser, &error)) { | 4910 if (!GetBrowserFromJSONArgs(args, &browser, &error)) { |
| 4907 reply.SendError(error); | 4911 reply.SendError(error); |
| 4908 return; | 4912 return; |
| 4909 } | 4913 } |
| 4910 if (!args->GetInteger("accelerator", &command)) { | 4914 if (!args->GetInteger("accelerator", &command)) { |
| 4911 reply.SendError("'accelerator' missing or invalid."); | 4915 reply.SendError("'accelerator' missing or invalid."); |
| 4912 return; | 4916 return; |
| 4913 } | 4917 } |
| 4914 if (!chrome::SupportsCommand(browser, command)) { | 4918 if (!chrome::SupportsCommand(browser, command)) { |
| 4915 reply.SendError(base::StringPrintf("Browser does not support command=%d.", | 4919 reply.SendError(base::StringPrintf("Browser does not support command=%d.", |
| 4916 command)); | 4920 command)); |
| 4917 return; | 4921 return; |
| 4918 } | 4922 } |
| 4919 if (!chrome::IsCommandEnabled(browser, command)) { | 4923 if (!chrome::IsCommandEnabled(browser, command)) { |
| 4920 reply.SendError(base::StringPrintf( | 4924 reply.SendError(base::StringPrintf( |
| 4921 "Browser command=%d not enabled.", command)); | 4925 "Browser command=%d not enabled.", command)); |
| 4922 return; | 4926 return; |
| 4923 } | 4927 } |
| 4924 chrome::ExecuteCommand(browser, command); | 4928 chrome::ExecuteCommand(browser, command); |
| 4925 reply.SendSuccess(NULL); | 4929 reply.SendSuccess(NULL); |
| 4926 } | 4930 } |
| 4927 | 4931 |
| 4928 void TestingAutomationProvider::ExecuteBrowserCommandJSON( | 4932 void TestingAutomationProvider::ExecuteBrowserCommandJSON( |
| 4929 DictionaryValue* args, | 4933 base::DictionaryValue* args, |
| 4930 IPC::Message* reply_message) { | 4934 IPC::Message* reply_message) { |
| 4931 int command; | 4935 int command; |
| 4932 Browser* browser; | 4936 Browser* browser; |
| 4933 std::string error; | 4937 std::string error; |
| 4934 if (!GetBrowserFromJSONArgs(args, &browser, &error)) { | 4938 if (!GetBrowserFromJSONArgs(args, &browser, &error)) { |
| 4935 AutomationJSONReply(this, reply_message).SendError(error); | 4939 AutomationJSONReply(this, reply_message).SendError(error); |
| 4936 return; | 4940 return; |
| 4937 } | 4941 } |
| 4938 if (!args->GetInteger("accelerator", &command)) { | 4942 if (!args->GetInteger("accelerator", &command)) { |
| 4939 AutomationJSONReply(this, reply_message).SendError( | 4943 AutomationJSONReply(this, reply_message).SendError( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 4962 if (ExecuteBrowserCommandObserver::CreateAndRegisterObserver( | 4966 if (ExecuteBrowserCommandObserver::CreateAndRegisterObserver( |
| 4963 this, browser, command, reply_message, true)) { | 4967 this, browser, command, reply_message, true)) { |
| 4964 chrome::ExecuteCommand(browser, command); | 4968 chrome::ExecuteCommand(browser, command); |
| 4965 return; | 4969 return; |
| 4966 } | 4970 } |
| 4967 AutomationJSONReply(this, reply_message).SendError(base::StringPrintf( | 4971 AutomationJSONReply(this, reply_message).SendError(base::StringPrintf( |
| 4968 "Unable to register observer for browser command=%d.", command)); | 4972 "Unable to register observer for browser command=%d.", command)); |
| 4969 } | 4973 } |
| 4970 | 4974 |
| 4971 void TestingAutomationProvider::IsMenuCommandEnabledJSON( | 4975 void TestingAutomationProvider::IsMenuCommandEnabledJSON( |
| 4972 DictionaryValue* args, | 4976 base::DictionaryValue* args, |
| 4973 IPC::Message* reply_message) { | 4977 IPC::Message* reply_message) { |
| 4974 int command; | 4978 int command; |
| 4975 Browser* browser; | 4979 Browser* browser; |
| 4976 std::string error; | 4980 std::string error; |
| 4977 if (!GetBrowserFromJSONArgs(args, &browser, &error)) { | 4981 if (!GetBrowserFromJSONArgs(args, &browser, &error)) { |
| 4978 AutomationJSONReply(this, reply_message).SendError(error); | 4982 AutomationJSONReply(this, reply_message).SendError(error); |
| 4979 return; | 4983 return; |
| 4980 } | 4984 } |
| 4981 if (!args->GetInteger("accelerator", &command)) { | 4985 if (!args->GetInteger("accelerator", &command)) { |
| 4982 AutomationJSONReply(this, reply_message).SendError( | 4986 AutomationJSONReply(this, reply_message).SendError( |
| 4983 "'accelerator' missing or invalid."); | 4987 "'accelerator' missing or invalid."); |
| 4984 return; | 4988 return; |
| 4985 } | 4989 } |
| 4986 DictionaryValue dict; | 4990 base::DictionaryValue dict; |
| 4987 dict.SetBoolean("enabled", chrome::IsCommandEnabled(browser, command)); | 4991 dict.SetBoolean("enabled", chrome::IsCommandEnabled(browser, command)); |
| 4988 AutomationJSONReply(this, reply_message).SendSuccess(&dict); | 4992 AutomationJSONReply(this, reply_message).SendSuccess(&dict); |
| 4989 } | 4993 } |
| 4990 | 4994 |
| 4991 void TestingAutomationProvider::GetTabInfo( | 4995 void TestingAutomationProvider::GetTabInfo( |
| 4992 DictionaryValue* args, | 4996 base::DictionaryValue* args, |
| 4993 IPC::Message* reply_message) { | 4997 IPC::Message* reply_message) { |
| 4994 AutomationJSONReply reply(this, reply_message); | 4998 AutomationJSONReply reply(this, reply_message); |
| 4995 Browser* browser; | 4999 Browser* browser; |
| 4996 WebContents* tab; | 5000 WebContents* tab; |
| 4997 std::string error; | 5001 std::string error; |
| 4998 if (GetBrowserAndTabFromJSONArgs(args, &browser, &tab, &error)) { | 5002 if (GetBrowserAndTabFromJSONArgs(args, &browser, &tab, &error)) { |
| 4999 NavigationEntry* entry = tab->GetController().GetActiveEntry(); | 5003 NavigationEntry* entry = tab->GetController().GetActiveEntry(); |
| 5000 if (!entry) { | 5004 if (!entry) { |
| 5001 reply.SendError("Unable to get active navigation entry"); | 5005 reply.SendError("Unable to get active navigation entry"); |
| 5002 return; | 5006 return; |
| 5003 } | 5007 } |
| 5004 DictionaryValue dict; | 5008 base::DictionaryValue dict; |
| 5005 dict.SetString("title", entry->GetTitleForDisplay(std::string())); | 5009 dict.SetString("title", entry->GetTitleForDisplay(std::string())); |
| 5006 dict.SetString("url", entry->GetVirtualURL().spec()); | 5010 dict.SetString("url", entry->GetVirtualURL().spec()); |
| 5007 reply.SendSuccess(&dict); | 5011 reply.SendSuccess(&dict); |
| 5008 } else { | 5012 } else { |
| 5009 reply.SendError(error); | 5013 reply.SendError(error); |
| 5010 } | 5014 } |
| 5011 } | 5015 } |
| 5012 | 5016 |
| 5013 void TestingAutomationProvider::GetTabCountJSON( | 5017 void TestingAutomationProvider::GetTabCountJSON( |
| 5014 DictionaryValue* args, | 5018 base::DictionaryValue* args, |
| 5015 IPC::Message* reply_message) { | 5019 IPC::Message* reply_message) { |
| 5016 AutomationJSONReply reply(this, reply_message); | 5020 AutomationJSONReply reply(this, reply_message); |
| 5017 Browser* browser; | 5021 Browser* browser; |
| 5018 std::string error; | 5022 std::string error; |
| 5019 if (!GetBrowserFromJSONArgs(args, &browser, &error)) { | 5023 if (!GetBrowserFromJSONArgs(args, &browser, &error)) { |
| 5020 reply.SendError(error); | 5024 reply.SendError(error); |
| 5021 return; | 5025 return; |
| 5022 } | 5026 } |
| 5023 DictionaryValue dict; | 5027 base::DictionaryValue dict; |
| 5024 dict.SetInteger("tab_count", browser->tab_strip_model()->count()); | 5028 dict.SetInteger("tab_count", browser->tab_strip_model()->count()); |
| 5025 reply.SendSuccess(&dict); | 5029 reply.SendSuccess(&dict); |
| 5026 } | 5030 } |
| 5027 | 5031 |
| 5028 void TestingAutomationProvider::GoBack( | 5032 void TestingAutomationProvider::GoBack( |
| 5029 DictionaryValue* args, | 5033 base::DictionaryValue* args, |
| 5030 IPC::Message* reply_message) { | 5034 IPC::Message* reply_message) { |
| 5031 if (SendErrorIfModalDialogActive(this, reply_message)) | 5035 if (SendErrorIfModalDialogActive(this, reply_message)) |
| 5032 return; | 5036 return; |
| 5033 | 5037 |
| 5034 WebContents* web_contents; | 5038 WebContents* web_contents; |
| 5035 std::string error; | 5039 std::string error; |
| 5036 if (!GetTabFromJSONArgs(args, &web_contents, &error)) { | 5040 if (!GetTabFromJSONArgs(args, &web_contents, &error)) { |
| 5037 AutomationJSONReply(this, reply_message).SendError(error); | 5041 AutomationJSONReply(this, reply_message).SendError(error); |
| 5038 return; | 5042 return; |
| 5039 } | 5043 } |
| 5040 NavigationController& controller = web_contents->GetController(); | 5044 NavigationController& controller = web_contents->GetController(); |
| 5041 if (!controller.CanGoBack()) { | 5045 if (!controller.CanGoBack()) { |
| 5042 DictionaryValue dict; | 5046 base::DictionaryValue dict; |
| 5043 dict.SetBoolean("did_go_back", false); | 5047 dict.SetBoolean("did_go_back", false); |
| 5044 AutomationJSONReply(this, reply_message).SendSuccess(&dict); | 5048 AutomationJSONReply(this, reply_message).SendSuccess(&dict); |
| 5045 return; | 5049 return; |
| 5046 } | 5050 } |
| 5047 new NavigationNotificationObserver(&controller, this, reply_message, | 5051 new NavigationNotificationObserver(&controller, this, reply_message, |
| 5048 1, false, true); | 5052 1, false, true); |
| 5049 controller.GoBack(); | 5053 controller.GoBack(); |
| 5050 } | 5054 } |
| 5051 | 5055 |
| 5052 void TestingAutomationProvider::ReloadJSON( | 5056 void TestingAutomationProvider::ReloadJSON( |
| 5053 DictionaryValue* args, | 5057 base::DictionaryValue* args, |
| 5054 IPC::Message* reply_message) { | 5058 IPC::Message* reply_message) { |
| 5055 if (SendErrorIfModalDialogActive(this, reply_message)) | 5059 if (SendErrorIfModalDialogActive(this, reply_message)) |
| 5056 return; | 5060 return; |
| 5057 | 5061 |
| 5058 WebContents* web_contents; | 5062 WebContents* web_contents; |
| 5059 std::string error; | 5063 std::string error; |
| 5060 if (!GetTabFromJSONArgs(args, &web_contents, &error)) { | 5064 if (!GetTabFromJSONArgs(args, &web_contents, &error)) { |
| 5061 AutomationJSONReply(this, reply_message).SendError(error); | 5065 AutomationJSONReply(this, reply_message).SendError(error); |
| 5062 return; | 5066 return; |
| 5063 } | 5067 } |
| 5064 NavigationController& controller = web_contents->GetController(); | 5068 NavigationController& controller = web_contents->GetController(); |
| 5065 new NavigationNotificationObserver(&controller, this, reply_message, | 5069 new NavigationNotificationObserver(&controller, this, reply_message, |
| 5066 1, false, true); | 5070 1, false, true); |
| 5067 controller.Reload(false); | 5071 controller.Reload(false); |
| 5068 } | 5072 } |
| 5069 | 5073 |
| 5070 void TestingAutomationProvider::GetCookiesJSON( | 5074 void TestingAutomationProvider::GetCookiesJSON( |
| 5071 DictionaryValue* args, IPC::Message* reply_message) { | 5075 base::DictionaryValue* args, IPC::Message* reply_message) { |
| 5072 automation_util::GetCookiesJSON(this, args, reply_message); | 5076 automation_util::GetCookiesJSON(this, args, reply_message); |
| 5073 } | 5077 } |
| 5074 | 5078 |
| 5075 void TestingAutomationProvider::DeleteCookieJSON( | 5079 void TestingAutomationProvider::DeleteCookieJSON( |
| 5076 DictionaryValue* args, IPC::Message* reply_message) { | 5080 base::DictionaryValue* args, IPC::Message* reply_message) { |
| 5077 automation_util::DeleteCookieJSON(this, args, reply_message); | 5081 automation_util::DeleteCookieJSON(this, args, reply_message); |
| 5078 } | 5082 } |
| 5079 | 5083 |
| 5080 void TestingAutomationProvider::SetCookieJSON( | 5084 void TestingAutomationProvider::SetCookieJSON( |
| 5081 DictionaryValue* args, IPC::Message* reply_message) { | 5085 base::DictionaryValue* args, IPC::Message* reply_message) { |
| 5082 automation_util::SetCookieJSON(this, args, reply_message); | 5086 automation_util::SetCookieJSON(this, args, reply_message); |
| 5083 } | 5087 } |
| 5084 | 5088 |
| 5085 void TestingAutomationProvider::GetCookiesInBrowserContext( | 5089 void TestingAutomationProvider::GetCookiesInBrowserContext( |
| 5086 DictionaryValue* args, | 5090 base::DictionaryValue* args, |
| 5087 IPC::Message* reply_message) { | 5091 IPC::Message* reply_message) { |
| 5088 AutomationJSONReply reply(this, reply_message); | 5092 AutomationJSONReply reply(this, reply_message); |
| 5089 WebContents* web_contents; | 5093 WebContents* web_contents; |
| 5090 std::string value, url_string; | 5094 std::string value, url_string; |
| 5091 int windex, value_size; | 5095 int windex, value_size; |
| 5092 if (!args->GetInteger("windex", &windex)) { | 5096 if (!args->GetInteger("windex", &windex)) { |
| 5093 reply.SendError("'windex' missing or invalid."); | 5097 reply.SendError("'windex' missing or invalid."); |
| 5094 return; | 5098 return; |
| 5095 } | 5099 } |
| 5096 web_contents = automation_util::GetWebContentsAt(windex, 0); | 5100 web_contents = automation_util::GetWebContentsAt(windex, 0); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 5107 reply.SendError("Invalid url."); | 5111 reply.SendError("Invalid url."); |
| 5108 return; | 5112 return; |
| 5109 } | 5113 } |
| 5110 automation_util::GetCookies(url, web_contents, &value_size, &value); | 5114 automation_util::GetCookies(url, web_contents, &value_size, &value); |
| 5111 if (value_size == -1) { | 5115 if (value_size == -1) { |
| 5112 reply.SendError( | 5116 reply.SendError( |
| 5113 base::StringPrintf("Unable to retrieve cookies for url=%s.", | 5117 base::StringPrintf("Unable to retrieve cookies for url=%s.", |
| 5114 url_string.c_str())); | 5118 url_string.c_str())); |
| 5115 return; | 5119 return; |
| 5116 } | 5120 } |
| 5117 DictionaryValue dict; | 5121 base::DictionaryValue dict; |
| 5118 dict.SetString("cookies", value); | 5122 dict.SetString("cookies", value); |
| 5119 reply.SendSuccess(&dict); | 5123 reply.SendSuccess(&dict); |
| 5120 } | 5124 } |
| 5121 | 5125 |
| 5122 void TestingAutomationProvider::DeleteCookieInBrowserContext( | 5126 void TestingAutomationProvider::DeleteCookieInBrowserContext( |
| 5123 DictionaryValue* args, | 5127 base::DictionaryValue* args, |
| 5124 IPC::Message* reply_message) { | 5128 IPC::Message* reply_message) { |
| 5125 AutomationJSONReply reply(this, reply_message); | 5129 AutomationJSONReply reply(this, reply_message); |
| 5126 WebContents* web_contents; | 5130 WebContents* web_contents; |
| 5127 std::string cookie_name, url_string; | 5131 std::string cookie_name, url_string; |
| 5128 int windex; | 5132 int windex; |
| 5129 bool success = false; | 5133 bool success = false; |
| 5130 if (!args->GetInteger("windex", &windex)) { | 5134 if (!args->GetInteger("windex", &windex)) { |
| 5131 reply.SendError("'windex' missing or invalid."); | 5135 reply.SendError("'windex' missing or invalid."); |
| 5132 return; | 5136 return; |
| 5133 } | 5137 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 5153 if (!success) { | 5157 if (!success) { |
| 5154 reply.SendError( | 5158 reply.SendError( |
| 5155 base::StringPrintf("Failed to delete cookie with name=%s for url=%s.", | 5159 base::StringPrintf("Failed to delete cookie with name=%s for url=%s.", |
| 5156 cookie_name.c_str(), url_string.c_str())); | 5160 cookie_name.c_str(), url_string.c_str())); |
| 5157 return; | 5161 return; |
| 5158 } | 5162 } |
| 5159 reply.SendSuccess(NULL); | 5163 reply.SendSuccess(NULL); |
| 5160 } | 5164 } |
| 5161 | 5165 |
| 5162 void TestingAutomationProvider::SetCookieInBrowserContext( | 5166 void TestingAutomationProvider::SetCookieInBrowserContext( |
| 5163 DictionaryValue* args, | 5167 base::DictionaryValue* args, |
| 5164 IPC::Message* reply_message) { | 5168 IPC::Message* reply_message) { |
| 5165 AutomationJSONReply reply(this, reply_message); | 5169 AutomationJSONReply reply(this, reply_message); |
| 5166 WebContents* web_contents; | 5170 WebContents* web_contents; |
| 5167 std::string value, url_string; | 5171 std::string value, url_string; |
| 5168 int windex, response_value = -1; | 5172 int windex, response_value = -1; |
| 5169 if (!args->GetInteger("windex", &windex)) { | 5173 if (!args->GetInteger("windex", &windex)) { |
| 5170 reply.SendError("'windex' missing or invalid."); | 5174 reply.SendError("'windex' missing or invalid."); |
| 5171 return; | 5175 return; |
| 5172 } | 5176 } |
| 5173 web_contents = automation_util::GetWebContentsAt(windex, 0); | 5177 web_contents = automation_util::GetWebContentsAt(windex, 0); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 5191 automation_util::SetCookie(url, value, web_contents, &response_value); | 5195 automation_util::SetCookie(url, value, web_contents, &response_value); |
| 5192 if (response_value != 1) { | 5196 if (response_value != 1) { |
| 5193 reply.SendError(base::StringPrintf( | 5197 reply.SendError(base::StringPrintf( |
| 5194 "Unable set cookie for url=%s.", url_string.c_str())); | 5198 "Unable set cookie for url=%s.", url_string.c_str())); |
| 5195 return; | 5199 return; |
| 5196 } | 5200 } |
| 5197 reply.SendSuccess(NULL); | 5201 reply.SendSuccess(NULL); |
| 5198 } | 5202 } |
| 5199 | 5203 |
| 5200 void TestingAutomationProvider::GetTabIds( | 5204 void TestingAutomationProvider::GetTabIds( |
| 5201 DictionaryValue* args, IPC::Message* reply_message) { | 5205 base::DictionaryValue* args, IPC::Message* reply_message) { |
| 5202 ListValue* id_list = new ListValue(); | 5206 base::ListValue* id_list = new base::ListValue(); |
| 5203 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | 5207 for (chrome::BrowserIterator it; !it.done(); it.Next()) { |
| 5204 Browser* browser = *it; | 5208 Browser* browser = *it; |
| 5205 for (int i = 0; i < browser->tab_strip_model()->count(); ++i) { | 5209 for (int i = 0; i < browser->tab_strip_model()->count(); ++i) { |
| 5206 int id = SessionTabHelper::FromWebContents( | 5210 int id = SessionTabHelper::FromWebContents( |
| 5207 browser->tab_strip_model()->GetWebContentsAt(i))->session_id().id(); | 5211 browser->tab_strip_model()->GetWebContentsAt(i))->session_id().id(); |
| 5208 id_list->Append(Value::CreateIntegerValue(id)); | 5212 id_list->Append(base::Value::CreateIntegerValue(id)); |
| 5209 } | 5213 } |
| 5210 } | 5214 } |
| 5211 DictionaryValue dict; | 5215 base::DictionaryValue dict; |
| 5212 dict.Set("ids", id_list); | 5216 dict.Set("ids", id_list); |
| 5213 AutomationJSONReply(this, reply_message).SendSuccess(&dict); | 5217 AutomationJSONReply(this, reply_message).SendSuccess(&dict); |
| 5214 } | 5218 } |
| 5215 | 5219 |
| 5216 void TestingAutomationProvider::IsTabIdValid( | 5220 void TestingAutomationProvider::IsTabIdValid( |
| 5217 DictionaryValue* args, IPC::Message* reply_message) { | 5221 base::DictionaryValue* args, IPC::Message* reply_message) { |
| 5218 AutomationJSONReply reply(this, reply_message); | 5222 AutomationJSONReply reply(this, reply_message); |
| 5219 int id; | 5223 int id; |
| 5220 if (!args->GetInteger("id", &id)) { | 5224 if (!args->GetInteger("id", &id)) { |
| 5221 reply.SendError("'id' missing or invalid"); | 5225 reply.SendError("'id' missing or invalid"); |
| 5222 return; | 5226 return; |
| 5223 } | 5227 } |
| 5224 bool is_valid = false; | 5228 bool is_valid = false; |
| 5225 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | 5229 for (chrome::BrowserIterator it; !it.done(); it.Next()) { |
| 5226 Browser* browser = *it; | 5230 Browser* browser = *it; |
| 5227 for (int i = 0; i < browser->tab_strip_model()->count(); ++i) { | 5231 for (int i = 0; i < browser->tab_strip_model()->count(); ++i) { |
| 5228 WebContents* tab = browser->tab_strip_model()->GetWebContentsAt(i); | 5232 WebContents* tab = browser->tab_strip_model()->GetWebContentsAt(i); |
| 5229 SessionTabHelper* session_tab_helper = | 5233 SessionTabHelper* session_tab_helper = |
| 5230 SessionTabHelper::FromWebContents(tab); | 5234 SessionTabHelper::FromWebContents(tab); |
| 5231 if (session_tab_helper->session_id().id() == id) { | 5235 if (session_tab_helper->session_id().id() == id) { |
| 5232 is_valid = true; | 5236 is_valid = true; |
| 5233 break; | 5237 break; |
| 5234 } | 5238 } |
| 5235 } | 5239 } |
| 5236 } | 5240 } |
| 5237 DictionaryValue dict; | 5241 base::DictionaryValue dict; |
| 5238 dict.SetBoolean("is_valid", is_valid); | 5242 dict.SetBoolean("is_valid", is_valid); |
| 5239 reply.SendSuccess(&dict); | 5243 reply.SendSuccess(&dict); |
| 5240 } | 5244 } |
| 5241 | 5245 |
| 5242 void TestingAutomationProvider::CloseTabJSON( | 5246 void TestingAutomationProvider::CloseTabJSON( |
| 5243 DictionaryValue* args, IPC::Message* reply_message) { | 5247 base::DictionaryValue* args, IPC::Message* reply_message) { |
| 5244 Browser* browser; | 5248 Browser* browser; |
| 5245 WebContents* tab; | 5249 WebContents* tab; |
| 5246 std::string error; | 5250 std::string error; |
| 5247 bool wait_until_closed = false; // ChromeDriver does not use this. | 5251 bool wait_until_closed = false; // ChromeDriver does not use this. |
| 5248 args->GetBoolean("wait_until_closed", &wait_until_closed); | 5252 args->GetBoolean("wait_until_closed", &wait_until_closed); |
| 5249 // Close tabs synchronously. | 5253 // Close tabs synchronously. |
| 5250 if (GetBrowserAndTabFromJSONArgs(args, &browser, &tab, &error)) { | 5254 if (GetBrowserAndTabFromJSONArgs(args, &browser, &tab, &error)) { |
| 5251 if (wait_until_closed) { | 5255 if (wait_until_closed) { |
| 5252 new TabClosedNotificationObserver(this, wait_until_closed, reply_message, | 5256 new TabClosedNotificationObserver(this, wait_until_closed, reply_message, |
| 5253 true); | 5257 true); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5311 | 5315 |
| 5312 browser->window()->Maximize(); | 5316 browser->window()->Maximize(); |
| 5313 | 5317 |
| 5314 #if !defined(OS_LINUX) | 5318 #if !defined(OS_LINUX) |
| 5315 // Send success reply right away for OS's with synchronous maximize command. | 5319 // Send success reply right away for OS's with synchronous maximize command. |
| 5316 AutomationJSONReply(this, reply_message).SendSuccess(NULL); | 5320 AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
| 5317 #endif // !defined(OS_LINUX) | 5321 #endif // !defined(OS_LINUX) |
| 5318 } | 5322 } |
| 5319 | 5323 |
| 5320 void TestingAutomationProvider::ActivateTabJSON( | 5324 void TestingAutomationProvider::ActivateTabJSON( |
| 5321 DictionaryValue* args, | 5325 base::DictionaryValue* args, |
| 5322 IPC::Message* reply_message) { | 5326 IPC::Message* reply_message) { |
| 5323 if (SendErrorIfModalDialogActive(this, reply_message)) | 5327 if (SendErrorIfModalDialogActive(this, reply_message)) |
| 5324 return; | 5328 return; |
| 5325 | 5329 |
| 5326 AutomationJSONReply reply(this, reply_message); | 5330 AutomationJSONReply reply(this, reply_message); |
| 5327 Browser* browser; | 5331 Browser* browser; |
| 5328 WebContents* web_contents; | 5332 WebContents* web_contents; |
| 5329 std::string error; | 5333 std::string error; |
| 5330 if (!GetBrowserAndTabFromJSONArgs(args, &browser, &web_contents, &error)) { | 5334 if (!GetBrowserAndTabFromJSONArgs(args, &browser, &web_contents, &error)) { |
| 5331 reply.SendError(error); | 5335 reply.SendError(error); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5372 LocationBarTesting* loc_bar = | 5376 LocationBarTesting* loc_bar = |
| 5373 browser->window()->GetLocationBar()->GetLocationBarForTesting(); | 5377 browser->window()->GetLocationBar()->GetLocationBarForTesting(); |
| 5374 size_t page_action_visible_count = | 5378 size_t page_action_visible_count = |
| 5375 static_cast<size_t>(loc_bar->PageActionVisibleCount()); | 5379 static_cast<size_t>(loc_bar->PageActionVisibleCount()); |
| 5376 for (size_t i = 0; i < page_action_visible_count; ++i) { | 5380 for (size_t i = 0; i < page_action_visible_count; ++i) { |
| 5377 if (loc_bar->GetVisiblePageAction(i) == page_action) { | 5381 if (loc_bar->GetVisiblePageAction(i) == page_action) { |
| 5378 is_visible = true; | 5382 is_visible = true; |
| 5379 break; | 5383 break; |
| 5380 } | 5384 } |
| 5381 } | 5385 } |
| 5382 DictionaryValue dict; | 5386 base::DictionaryValue dict; |
| 5383 dict.SetBoolean("is_visible", is_visible); | 5387 dict.SetBoolean("is_visible", is_visible); |
| 5384 reply.SendSuccess(&dict); | 5388 reply.SendSuccess(&dict); |
| 5385 } | 5389 } |
| 5386 | 5390 |
| 5387 void TestingAutomationProvider::CreateNewAutomationProvider( | 5391 void TestingAutomationProvider::CreateNewAutomationProvider( |
| 5388 DictionaryValue* args, | 5392 base::DictionaryValue* args, |
| 5389 IPC::Message* reply_message) { | 5393 IPC::Message* reply_message) { |
| 5390 AutomationJSONReply reply(this, reply_message); | 5394 AutomationJSONReply reply(this, reply_message); |
| 5391 std::string channel_id; | 5395 std::string channel_id; |
| 5392 if (!args->GetString("channel_id", &channel_id)) { | 5396 if (!args->GetString("channel_id", &channel_id)) { |
| 5393 reply.SendError("'channel_id' missing or invalid"); | 5397 reply.SendError("'channel_id' missing or invalid"); |
| 5394 return; | 5398 return; |
| 5395 } | 5399 } |
| 5396 | 5400 |
| 5397 AutomationProvider* provider = new TestingAutomationProvider(profile_); | 5401 AutomationProvider* provider = new TestingAutomationProvider(profile_); |
| 5398 provider->DisableInitialLoadObservers(); | 5402 provider->DisableInitialLoadObservers(); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5458 if (g_browser_process) | 5462 if (g_browser_process) |
| 5459 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 5463 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
| 5460 } | 5464 } |
| 5461 | 5465 |
| 5462 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, | 5466 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, |
| 5463 WebContents* tab) { | 5467 WebContents* tab) { |
| 5464 TabStripModel* tab_strip = browser->tab_strip_model(); | 5468 TabStripModel* tab_strip = browser->tab_strip_model(); |
| 5465 if (tab_strip->GetActiveWebContents() != tab) | 5469 if (tab_strip->GetActiveWebContents() != tab) |
| 5466 tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(tab), true); | 5470 tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(tab), true); |
| 5467 } | 5471 } |
| OLD | NEW |