| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 #include "chrome/browser/protector/protector_service.h" | 80 #include "chrome/browser/protector/protector_service.h" |
| 81 #include "chrome/browser/protector/protector_service_factory.h" | 81 #include "chrome/browser/protector/protector_service_factory.h" |
| 82 #include "chrome/browser/protector/protector_utils.h" | 82 #include "chrome/browser/protector/protector_utils.h" |
| 83 #include "chrome/browser/search_engines/template_url.h" | 83 #include "chrome/browser/search_engines/template_url.h" |
| 84 #include "chrome/browser/search_engines/template_url_service.h" | 84 #include "chrome/browser/search_engines/template_url_service.h" |
| 85 #include "chrome/browser/search_engines/template_url_service_factory.h" | 85 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 86 #include "chrome/browser/sessions/session_service_factory.h" | 86 #include "chrome/browser/sessions/session_service_factory.h" |
| 87 #include "chrome/browser/sessions/session_tab_helper.h" | 87 #include "chrome/browser/sessions/session_tab_helper.h" |
| 88 #include "chrome/browser/sync/profile_sync_service.h" | 88 #include "chrome/browser/sync/profile_sync_service.h" |
| 89 #include "chrome/browser/sync/profile_sync_service_factory.h" | 89 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 90 #include "chrome/browser/themes/theme_service.h" | |
| 91 #include "chrome/browser/themes/theme_service_factory.h" | |
| 92 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" | 90 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" |
| 93 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" | 91 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" |
| 94 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h" | 92 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h" |
| 95 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" | 93 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" |
| 96 #include "chrome/browser/ui/bookmarks/bookmark_bar.h" | 94 #include "chrome/browser/ui/bookmarks/bookmark_bar.h" |
| 97 #include "chrome/browser/ui/browser_commands.h" | 95 #include "chrome/browser/ui/browser_commands.h" |
| 98 #include "chrome/browser/ui/browser_finder.h" | 96 #include "chrome/browser/ui/browser_finder.h" |
| 99 #include "chrome/browser/ui/browser_instant_controller.h" | 97 #include "chrome/browser/ui/browser_instant_controller.h" |
| 100 #include "chrome/browser/ui/browser_list.h" | 98 #include "chrome/browser/ui/browser_list.h" |
| 101 #include "chrome/browser/ui/browser_tabstrip.h" | 99 #include "chrome/browser/ui/browser_tabstrip.h" |
| (...skipping 1839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1941 browser_handler_map_["ImportSettings"] = | 1939 browser_handler_map_["ImportSettings"] = |
| 1942 &TestingAutomationProvider::ImportSettings; | 1940 &TestingAutomationProvider::ImportSettings; |
| 1943 | 1941 |
| 1944 browser_handler_map_["AddSavedPassword"] = | 1942 browser_handler_map_["AddSavedPassword"] = |
| 1945 &TestingAutomationProvider::AddSavedPassword; | 1943 &TestingAutomationProvider::AddSavedPassword; |
| 1946 browser_handler_map_["RemoveSavedPassword"] = | 1944 browser_handler_map_["RemoveSavedPassword"] = |
| 1947 &TestingAutomationProvider::RemoveSavedPassword; | 1945 &TestingAutomationProvider::RemoveSavedPassword; |
| 1948 browser_handler_map_["GetSavedPasswords"] = | 1946 browser_handler_map_["GetSavedPasswords"] = |
| 1949 &TestingAutomationProvider::GetSavedPasswords; | 1947 &TestingAutomationProvider::GetSavedPasswords; |
| 1950 | 1948 |
| 1951 handler_map_["ResetToDefaultTheme"] = | |
| 1952 &TestingAutomationProvider::ResetToDefaultTheme; | |
| 1953 | |
| 1954 // SetTheme() implemented using InstallExtension(). | |
| 1955 browser_handler_map_["GetThemeInfo"] = | |
| 1956 &TestingAutomationProvider::GetThemeInfo; | |
| 1957 | |
| 1958 browser_handler_map_["FindInPage"] = &TestingAutomationProvider::FindInPage; | 1949 browser_handler_map_["FindInPage"] = &TestingAutomationProvider::FindInPage; |
| 1959 | 1950 |
| 1960 browser_handler_map_["GetAllNotifications"] = | 1951 browser_handler_map_["GetAllNotifications"] = |
| 1961 &TestingAutomationProvider::GetAllNotifications; | 1952 &TestingAutomationProvider::GetAllNotifications; |
| 1962 browser_handler_map_["CloseNotification"] = | 1953 browser_handler_map_["CloseNotification"] = |
| 1963 &TestingAutomationProvider::CloseNotification; | 1954 &TestingAutomationProvider::CloseNotification; |
| 1964 browser_handler_map_["WaitForNotificationCount"] = | 1955 browser_handler_map_["WaitForNotificationCount"] = |
| 1965 &TestingAutomationProvider::WaitForNotificationCount; | 1956 &TestingAutomationProvider::WaitForNotificationCount; |
| 1966 | 1957 |
| 1967 browser_handler_map_["SignInToSync"] = | 1958 browser_handler_map_["SignInToSync"] = |
| (...skipping 1718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3686 return; | 3677 return; |
| 3687 } | 3678 } |
| 3688 FindBarTesting* find_bar = | 3679 FindBarTesting* find_bar = |
| 3689 browser->GetFindBarController()->find_bar()->GetFindBarTesting(); | 3680 browser->GetFindBarController()->find_bar()->GetFindBarTesting(); |
| 3690 find_bar->GetFindBarWindowInfo(NULL, &visible); | 3681 find_bar->GetFindBarWindowInfo(NULL, &visible); |
| 3691 DictionaryValue dict; | 3682 DictionaryValue dict; |
| 3692 dict.SetBoolean("is_visible", visible); | 3683 dict.SetBoolean("is_visible", visible); |
| 3693 reply.SendSuccess(&dict); | 3684 reply.SendSuccess(&dict); |
| 3694 } | 3685 } |
| 3695 | 3686 |
| 3696 // Sample json input: { "command": "GetThemeInfo" } | |
| 3697 // Refer GetThemeInfo() in chrome/test/pyautolib/pyauto.py for sample output. | |
| 3698 void TestingAutomationProvider::GetThemeInfo( | |
| 3699 Browser* browser, | |
| 3700 DictionaryValue* args, | |
| 3701 IPC::Message* reply_message) { | |
| 3702 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | |
| 3703 const Extension* theme = ThemeServiceFactory::GetThemeForProfile(profile()); | |
| 3704 if (theme) { | |
| 3705 return_value->SetString("name", theme->name()); | |
| 3706 return_value->Set("images", theme->GetThemeImages()->DeepCopy()); | |
| 3707 return_value->Set("colors", theme->GetThemeColors()->DeepCopy()); | |
| 3708 return_value->Set("tints", theme->GetThemeTints()->DeepCopy()); | |
| 3709 } | |
| 3710 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); | |
| 3711 } | |
| 3712 | |
| 3713 void TestingAutomationProvider::InstallExtension( | 3687 void TestingAutomationProvider::InstallExtension( |
| 3714 DictionaryValue* args, IPC::Message* reply_message) { | 3688 DictionaryValue* args, IPC::Message* reply_message) { |
| 3715 FilePath::StringType path_string; | 3689 FilePath::StringType path_string; |
| 3716 bool with_ui; | 3690 bool with_ui; |
| 3717 bool from_webstore = false; | 3691 bool from_webstore = false; |
| 3718 Browser* browser; | 3692 Browser* browser; |
| 3719 std::string error_msg; | 3693 std::string error_msg; |
| 3720 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { | 3694 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { |
| 3721 AutomationJSONReply(this, reply_message).SendError(error_msg); | 3695 AutomationJSONReply(this, reply_message).SendError(error_msg); |
| 3722 return; | 3696 return; |
| (...skipping 2555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6278 std::string error; | 6252 std::string error; |
| 6279 if (!GetBrowserAndTabFromJSONArgs(args, &browser, &web_contents, &error)) { | 6253 if (!GetBrowserAndTabFromJSONArgs(args, &browser, &web_contents, &error)) { |
| 6280 reply.SendError(error); | 6254 reply.SendError(error); |
| 6281 return; | 6255 return; |
| 6282 } | 6256 } |
| 6283 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, web_contents), | 6257 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, web_contents), |
| 6284 true); | 6258 true); |
| 6285 reply.SendSuccess(NULL); | 6259 reply.SendSuccess(NULL); |
| 6286 } | 6260 } |
| 6287 | 6261 |
| 6288 void TestingAutomationProvider::ResetToDefaultTheme( | |
| 6289 base::DictionaryValue* args, | |
| 6290 IPC::Message* reply_message) { | |
| 6291 AutomationJSONReply reply(this, reply_message); | |
| 6292 Browser* browser; | |
| 6293 std::string error_msg; | |
| 6294 if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { | |
| 6295 reply.SendError(error_msg); | |
| 6296 return; | |
| 6297 } | |
| 6298 ThemeServiceFactory::GetForProfile(browser->profile())->UseDefaultTheme(); | |
| 6299 reply.SendSuccess(NULL); | |
| 6300 } | |
| 6301 | |
| 6302 void TestingAutomationProvider::IsPageActionVisible( | 6262 void TestingAutomationProvider::IsPageActionVisible( |
| 6303 base::DictionaryValue* args, | 6263 base::DictionaryValue* args, |
| 6304 IPC::Message* reply_message) { | 6264 IPC::Message* reply_message) { |
| 6305 AutomationJSONReply reply(this, reply_message); | 6265 AutomationJSONReply reply(this, reply_message); |
| 6306 | 6266 |
| 6307 WebContents* tab; | 6267 WebContents* tab; |
| 6308 std::string error; | 6268 std::string error; |
| 6309 if (!GetTabFromJSONArgs(args, &tab, &error)) { | 6269 if (!GetTabFromJSONArgs(args, &tab, &error)) { |
| 6310 reply.SendError(error); | 6270 reply.SendError(error); |
| 6311 return; | 6271 return; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6425 void TestingAutomationProvider::OnRemoveProvider() { | 6385 void TestingAutomationProvider::OnRemoveProvider() { |
| 6426 if (g_browser_process) | 6386 if (g_browser_process) |
| 6427 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 6387 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
| 6428 } | 6388 } |
| 6429 | 6389 |
| 6430 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, | 6390 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, |
| 6431 WebContents* tab) { | 6391 WebContents* tab) { |
| 6432 if (chrome::GetActiveWebContents(browser) != tab) | 6392 if (chrome::GetActiveWebContents(browser) != tab) |
| 6433 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); | 6393 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); |
| 6434 } | 6394 } |
| OLD | NEW |