| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 151 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
| 152 #include "ui/base/events/event_constants.h" | 152 #include "ui/base/events/event_constants.h" |
| 153 #include "ui/base/keycodes/keyboard_codes.h" | 153 #include "ui/base/keycodes/keyboard_codes.h" |
| 154 #include "ui/base/ui_base_types.h" | 154 #include "ui/base/ui_base_types.h" |
| 155 #include "ui/ui_controls/ui_controls.h" | 155 #include "ui/ui_controls/ui_controls.h" |
| 156 #include "webkit/glue/webdropdata.h" | 156 #include "webkit/glue/webdropdata.h" |
| 157 #include "webkit/plugins/webplugininfo.h" | 157 #include "webkit/plugins/webplugininfo.h" |
| 158 | 158 |
| 159 #if defined(ENABLE_CONFIGURATION_POLICY) | 159 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 160 #include "chrome/browser/policy/policy_service.h" | 160 #include "chrome/browser/policy/policy_service.h" |
| 161 #include "policy/policy_constants.h" | |
| 162 #endif | 161 #endif |
| 163 | 162 |
| 164 #if defined(OS_CHROMEOS) | 163 #if defined(OS_CHROMEOS) |
| 165 #include "chromeos/dbus/dbus_thread_manager.h" | 164 #include "chromeos/dbus/dbus_thread_manager.h" |
| 166 #endif | 165 #endif |
| 167 | 166 |
| 168 #if defined(OS_MACOSX) | 167 #if defined(OS_MACOSX) |
| 169 #include "base/mach_ipc_mac.h" | 168 #include "base/mach_ipc_mac.h" |
| 170 #endif | 169 #endif |
| 171 | 170 |
| (...skipping 1586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1758 handler_map_["GetTabCount"] = | 1757 handler_map_["GetTabCount"] = |
| 1759 &TestingAutomationProvider::GetTabCountJSON; | 1758 &TestingAutomationProvider::GetTabCountJSON; |
| 1760 handler_map_["OpenNewBrowserWindowWithNewProfile"] = | 1759 handler_map_["OpenNewBrowserWindowWithNewProfile"] = |
| 1761 &TestingAutomationProvider::OpenNewBrowserWindowWithNewProfile; | 1760 &TestingAutomationProvider::OpenNewBrowserWindowWithNewProfile; |
| 1762 handler_map_["GetMultiProfileInfo"] = | 1761 handler_map_["GetMultiProfileInfo"] = |
| 1763 &TestingAutomationProvider::GetMultiProfileInfo; | 1762 &TestingAutomationProvider::GetMultiProfileInfo; |
| 1764 handler_map_["OpenProfileWindow"] = | 1763 handler_map_["OpenProfileWindow"] = |
| 1765 &TestingAutomationProvider::OpenProfileWindow; | 1764 &TestingAutomationProvider::OpenProfileWindow; |
| 1766 handler_map_["GetProcessInfo"] = | 1765 handler_map_["GetProcessInfo"] = |
| 1767 &TestingAutomationProvider::GetProcessInfo; | 1766 &TestingAutomationProvider::GetProcessInfo; |
| 1768 handler_map_["GetPolicyDefinitionList"] = | |
| 1769 &TestingAutomationProvider::GetPolicyDefinitionList; | |
| 1770 handler_map_["RefreshPolicies"] = | 1767 handler_map_["RefreshPolicies"] = |
| 1771 &TestingAutomationProvider::RefreshPolicies; | 1768 &TestingAutomationProvider::RefreshPolicies; |
| 1772 handler_map_["InstallExtension"] = | 1769 handler_map_["InstallExtension"] = |
| 1773 &TestingAutomationProvider::InstallExtension; | 1770 &TestingAutomationProvider::InstallExtension; |
| 1774 handler_map_["GetExtensionsInfo"] = | 1771 handler_map_["GetExtensionsInfo"] = |
| 1775 &TestingAutomationProvider::GetExtensionsInfo; | 1772 &TestingAutomationProvider::GetExtensionsInfo; |
| 1776 handler_map_["UninstallExtensionById"] = | 1773 handler_map_["UninstallExtensionById"] = |
| 1777 &TestingAutomationProvider::UninstallExtensionById; | 1774 &TestingAutomationProvider::UninstallExtensionById; |
| 1778 handler_map_["SetExtensionStateById"] = | 1775 handler_map_["SetExtensionStateById"] = |
| 1779 &TestingAutomationProvider::SetExtensionStateById; | 1776 &TestingAutomationProvider::SetExtensionStateById; |
| (...skipping 3538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5318 WebContents* web_contents; | 5315 WebContents* web_contents; |
| 5319 std::string error; | 5316 std::string error; |
| 5320 if (!GetTabFromJSONArgs(args, &web_contents, &error)) { | 5317 if (!GetTabFromJSONArgs(args, &web_contents, &error)) { |
| 5321 AutomationJSONReply(this, reply_message).SendError(error); | 5318 AutomationJSONReply(this, reply_message).SendError(error); |
| 5322 return; | 5319 return; |
| 5323 } | 5320 } |
| 5324 NavigationController& controller = web_contents->GetController(); | 5321 NavigationController& controller = web_contents->GetController(); |
| 5325 new NavigationControllerRestoredObserver(this, &controller, reply_message); | 5322 new NavigationControllerRestoredObserver(this, &controller, reply_message); |
| 5326 } | 5323 } |
| 5327 | 5324 |
| 5328 void TestingAutomationProvider::GetPolicyDefinitionList( | |
| 5329 DictionaryValue* args, | |
| 5330 IPC::Message* reply_message) { | |
| 5331 AutomationJSONReply reply(this, reply_message); | |
| 5332 | |
| 5333 #if !defined(ENABLE_CONFIGURATION_POLICY) | |
| 5334 reply.SendError("Configuration Policy disabled"); | |
| 5335 #else | |
| 5336 DictionaryValue response; | |
| 5337 | |
| 5338 const policy::PolicyDefinitionList* list = | |
| 5339 policy::GetChromePolicyDefinitionList(); | |
| 5340 // Value::Type to python type. | |
| 5341 std::map<Value::Type, std::string> types; | |
| 5342 types[Value::TYPE_BOOLEAN] = "bool"; | |
| 5343 types[Value::TYPE_DICTIONARY] = "dict"; | |
| 5344 types[Value::TYPE_INTEGER] = "int"; | |
| 5345 types[Value::TYPE_LIST] = "list"; | |
| 5346 types[Value::TYPE_STRING] = "str"; | |
| 5347 | |
| 5348 const policy::PolicyDefinitionList::Entry* entry; | |
| 5349 for (entry = list->begin; entry != list->end; ++entry) { | |
| 5350 if (types.find(entry->value_type) == types.end()) { | |
| 5351 std::string error("Unrecognized policy type for policy "); | |
| 5352 reply.SendError(error + entry->name); | |
| 5353 return; | |
| 5354 } | |
| 5355 Value* type = Value::CreateStringValue(types[entry->value_type]); | |
| 5356 Value* device_policy = Value::CreateBooleanValue(entry->device_policy); | |
| 5357 ListValue* definition = new ListValue; | |
| 5358 definition->Append(type); | |
| 5359 definition->Append(device_policy); | |
| 5360 response.Set(entry->name, definition); | |
| 5361 } | |
| 5362 | |
| 5363 reply.SendSuccess(&response); | |
| 5364 #endif | |
| 5365 } | |
| 5366 | |
| 5367 void TestingAutomationProvider::RefreshPolicies( | 5325 void TestingAutomationProvider::RefreshPolicies( |
| 5368 base::DictionaryValue* args, | 5326 base::DictionaryValue* args, |
| 5369 IPC::Message* reply_message) { | 5327 IPC::Message* reply_message) { |
| 5370 #if !defined(ENABLE_CONFIGURATION_POLICY) | 5328 #if !defined(ENABLE_CONFIGURATION_POLICY) |
| 5371 AutomationJSONReply(this, reply_message).SendError( | 5329 AutomationJSONReply(this, reply_message).SendError( |
| 5372 "Configuration Policy disabled"); | 5330 "Configuration Policy disabled"); |
| 5373 #else | 5331 #else |
| 5374 // Some policies (e.g. URLBlacklist) post tasks to other message loops | 5332 // Some policies (e.g. URLBlacklist) post tasks to other message loops |
| 5375 // before they start enforcing updated policy values; make sure those tasks | 5333 // before they start enforcing updated policy values; make sure those tasks |
| 5376 // have finished after a policy update. | 5334 // have finished after a policy update. |
| (...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6425 void TestingAutomationProvider::OnRemoveProvider() { | 6383 void TestingAutomationProvider::OnRemoveProvider() { |
| 6426 if (g_browser_process) | 6384 if (g_browser_process) |
| 6427 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 6385 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
| 6428 } | 6386 } |
| 6429 | 6387 |
| 6430 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, | 6388 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, |
| 6431 WebContents* tab) { | 6389 WebContents* tab) { |
| 6432 if (chrome::GetActiveWebContents(browser) != tab) | 6390 if (chrome::GetActiveWebContents(browser) != tab) |
| 6433 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); | 6391 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); |
| 6434 } | 6392 } |
| OLD | NEW |