| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 139 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
| 140 #include "ui/base/events.h" | 140 #include "ui/base/events.h" |
| 141 #include "ui/base/keycodes/keyboard_codes.h" | 141 #include "ui/base/keycodes/keyboard_codes.h" |
| 142 #include "ui/base/ui_base_types.h" | 142 #include "ui/base/ui_base_types.h" |
| 143 #include "ui/ui_controls/ui_controls.h" | 143 #include "ui/ui_controls/ui_controls.h" |
| 144 #include "webkit/glue/webdropdata.h" | 144 #include "webkit/glue/webdropdata.h" |
| 145 #include "webkit/plugins/webplugininfo.h" | 145 #include "webkit/plugins/webplugininfo.h" |
| 146 | 146 |
| 147 #if defined(ENABLE_CONFIGURATION_POLICY) | 147 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 148 #include "chrome/browser/policy/browser_policy_connector.h" | 148 #include "chrome/browser/policy/browser_policy_connector.h" |
| 149 #include "chrome/browser/policy/configuration_policy_provider.h" | |
| 150 #include "chrome/browser/policy/policy_map.h" | |
| 151 #include "policy/policy_constants.h" | 149 #include "policy/policy_constants.h" |
| 152 #endif | 150 #endif |
| 153 | 151 |
| 154 #if defined(OS_CHROMEOS) | 152 #if defined(OS_CHROMEOS) |
| 155 #include "chromeos/dbus/dbus_thread_manager.h" | 153 #include "chromeos/dbus/dbus_thread_manager.h" |
| 156 #endif | 154 #endif |
| 157 | 155 |
| 158 #if defined(OS_MACOSX) | 156 #if defined(OS_MACOSX) |
| 159 #include "base/mach_ipc_mac.h" | 157 #include "base/mach_ipc_mac.h" |
| 160 #endif | 158 #endif |
| (...skipping 2143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2304 handler_map["CreateNewAutomationProvider"] = | 2302 handler_map["CreateNewAutomationProvider"] = |
| 2305 &TestingAutomationProvider::CreateNewAutomationProvider; | 2303 &TestingAutomationProvider::CreateNewAutomationProvider; |
| 2306 handler_map["GetBrowserInfo"] = | 2304 handler_map["GetBrowserInfo"] = |
| 2307 &TestingAutomationProvider::GetBrowserInfo; | 2305 &TestingAutomationProvider::GetBrowserInfo; |
| 2308 handler_map["OpenNewBrowserWindowWithNewProfile"] = | 2306 handler_map["OpenNewBrowserWindowWithNewProfile"] = |
| 2309 &TestingAutomationProvider::OpenNewBrowserWindowWithNewProfile; | 2307 &TestingAutomationProvider::OpenNewBrowserWindowWithNewProfile; |
| 2310 handler_map["GetMultiProfileInfo"] = | 2308 handler_map["GetMultiProfileInfo"] = |
| 2311 &TestingAutomationProvider::GetMultiProfileInfo; | 2309 &TestingAutomationProvider::GetMultiProfileInfo; |
| 2312 handler_map["GetProcessInfo"] = | 2310 handler_map["GetProcessInfo"] = |
| 2313 &TestingAutomationProvider::GetProcessInfo; | 2311 &TestingAutomationProvider::GetProcessInfo; |
| 2314 handler_map["SetPolicies"] = | |
| 2315 &TestingAutomationProvider::SetPolicies; | |
| 2316 handler_map["GetPolicyDefinitionList"] = | 2312 handler_map["GetPolicyDefinitionList"] = |
| 2317 &TestingAutomationProvider::GetPolicyDefinitionList; | 2313 &TestingAutomationProvider::GetPolicyDefinitionList; |
| 2318 handler_map["RefreshPolicies"] = | 2314 handler_map["RefreshPolicies"] = |
| 2319 &TestingAutomationProvider::RefreshPolicies; | 2315 &TestingAutomationProvider::RefreshPolicies; |
| 2320 handler_map["InstallExtension"] = | 2316 handler_map["InstallExtension"] = |
| 2321 &TestingAutomationProvider::InstallExtension; | 2317 &TestingAutomationProvider::InstallExtension; |
| 2322 handler_map["GetExtensionsInfo"] = | 2318 handler_map["GetExtensionsInfo"] = |
| 2323 &TestingAutomationProvider::GetExtensionsInfo; | 2319 &TestingAutomationProvider::GetExtensionsInfo; |
| 2324 handler_map["UninstallExtensionById"] = | 2320 handler_map["UninstallExtensionById"] = |
| 2325 &TestingAutomationProvider::UninstallExtensionById; | 2321 &TestingAutomationProvider::UninstallExtensionById; |
| (...skipping 3883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6209 if (AppModalDialogQueue::GetInstance()->HasActiveDialog()) { | 6205 if (AppModalDialogQueue::GetInstance()->HasActiveDialog()) { |
| 6210 AutomationJSONReply(this, reply_message).SendSuccess(NULL); | 6206 AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
| 6211 return; | 6207 return; |
| 6212 } | 6208 } |
| 6213 | 6209 |
| 6214 // This class will send the message immediately if no tab is loading. | 6210 // This class will send the message immediately if no tab is loading. |
| 6215 new AllViewsStoppedLoadingObserver( | 6211 new AllViewsStoppedLoadingObserver( |
| 6216 this, reply_message, profile()->GetExtensionProcessManager()); | 6212 this, reply_message, profile()->GetExtensionProcessManager()); |
| 6217 } | 6213 } |
| 6218 | 6214 |
| 6219 void TestingAutomationProvider::SetPolicies( | |
| 6220 DictionaryValue* args, | |
| 6221 IPC::Message* reply_message) { | |
| 6222 scoped_ptr<AutomationJSONReply> reply( | |
| 6223 new AutomationJSONReply(this, reply_message)); | |
| 6224 | |
| 6225 #if !defined(ENABLE_CONFIGURATION_POLICY) || defined(OFFICIAL_BUILD) | |
| 6226 reply->SendError("Configuration Policy disabled"); | |
| 6227 #else | |
| 6228 policy::BrowserPolicyConnector* connector = | |
| 6229 g_browser_process->browser_policy_connector(); | |
| 6230 struct { | |
| 6231 std::string name; | |
| 6232 policy::ConfigurationPolicyProvider* provider; | |
| 6233 policy::PolicyLevel level; | |
| 6234 } providers[] = { | |
| 6235 { "managed_cloud", | |
| 6236 connector->GetManagedCloudProvider(), | |
| 6237 policy::POLICY_LEVEL_MANDATORY }, | |
| 6238 { "managed_platform", | |
| 6239 connector->GetManagedPlatformProvider(), | |
| 6240 policy::POLICY_LEVEL_MANDATORY }, | |
| 6241 { "recommended_cloud", | |
| 6242 connector->GetRecommendedCloudProvider(), | |
| 6243 policy::POLICY_LEVEL_RECOMMENDED }, | |
| 6244 { "recommended_platform", | |
| 6245 connector->GetRecommendedPlatformProvider(), | |
| 6246 policy::POLICY_LEVEL_RECOMMENDED }, | |
| 6247 }; | |
| 6248 // Verify if all the requested providers exist before changing anything. | |
| 6249 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(providers); ++i) { | |
| 6250 DictionaryValue* policies = NULL; | |
| 6251 if (args->GetDictionary(providers[i].name, &policies) && | |
| 6252 policies && | |
| 6253 !providers[i].provider) { | |
| 6254 reply->SendError("Provider not available: " + providers[i].name); | |
| 6255 return; | |
| 6256 } | |
| 6257 } | |
| 6258 // TODO(joaodasilva): POLICY_SCOPE_USER is currently hardcoded, and the | |
| 6259 // level is determined by the provider. Change this interface to support | |
| 6260 // per-policy level and scope once the PolicyService is ready. | |
| 6261 // http://crbug.com/110588 | |
| 6262 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(providers); ++i) { | |
| 6263 DictionaryValue* policies = NULL; | |
| 6264 if (args->GetDictionary(providers[i].name, &policies) && policies) { | |
| 6265 policy::PolicyMap* map = new policy::PolicyMap; | |
| 6266 map->LoadFrom(policies, providers[i].level, policy::POLICY_SCOPE_USER); | |
| 6267 providers[i].provider->OverridePolicies(map); | |
| 6268 } | |
| 6269 } | |
| 6270 | |
| 6271 // Make sure the policies are in effect before returning. This will go | |
| 6272 // away once all platforms rely on directly installing the policy files and | |
| 6273 // using RefreshPolicies, and SetPolicies is removed. | |
| 6274 PolicyUpdatesObserver::PostCallbackAfterPolicyUpdates( | |
| 6275 base::Bind(&AutomationJSONReply::SendSuccess, | |
| 6276 base::Owned(reply.release()), | |
| 6277 static_cast<const Value*>(NULL))); | |
| 6278 #endif // defined(OFFICIAL_BUILD) | |
| 6279 } | |
| 6280 | |
| 6281 void TestingAutomationProvider::GetPolicyDefinitionList( | 6215 void TestingAutomationProvider::GetPolicyDefinitionList( |
| 6282 DictionaryValue* args, | 6216 DictionaryValue* args, |
| 6283 IPC::Message* reply_message) { | 6217 IPC::Message* reply_message) { |
| 6284 AutomationJSONReply reply(this, reply_message); | 6218 AutomationJSONReply reply(this, reply_message); |
| 6285 | 6219 |
| 6286 #if !defined(ENABLE_CONFIGURATION_POLICY) | 6220 #if !defined(ENABLE_CONFIGURATION_POLICY) |
| 6287 reply.SendError("Configuration Policy disabled"); | 6221 reply.SendError("Configuration Policy disabled"); |
| 6288 #else | 6222 #else |
| 6289 DictionaryValue response; | 6223 DictionaryValue response; |
| 6290 | 6224 |
| (...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7052 *browser_handle = browser_tracker_->Add(browser); | 6986 *browser_handle = browser_tracker_->Add(browser); |
| 7053 *success = true; | 6987 *success = true; |
| 7054 } | 6988 } |
| 7055 } | 6989 } |
| 7056 } | 6990 } |
| 7057 | 6991 |
| 7058 void TestingAutomationProvider::OnRemoveProvider() { | 6992 void TestingAutomationProvider::OnRemoveProvider() { |
| 7059 if (g_browser_process) | 6993 if (g_browser_process) |
| 7060 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 6994 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
| 7061 } | 6995 } |
| OLD | NEW |