Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: chrome/browser/automation/testing_automation_provider.cc

Issue 10236003: Added RefreshPolicies to PolicyService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 #include "net/cookies/cookie_store.h" 143 #include "net/cookies/cookie_store.h"
144 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 144 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
145 #include "ui/base/events.h" 145 #include "ui/base/events.h"
146 #include "ui/base/keycodes/keyboard_codes.h" 146 #include "ui/base/keycodes/keyboard_codes.h"
147 #include "ui/base/ui_base_types.h" 147 #include "ui/base/ui_base_types.h"
148 #include "ui/ui_controls/ui_controls.h" 148 #include "ui/ui_controls/ui_controls.h"
149 #include "webkit/glue/webdropdata.h" 149 #include "webkit/glue/webdropdata.h"
150 #include "webkit/plugins/webplugininfo.h" 150 #include "webkit/plugins/webplugininfo.h"
151 151
152 #if defined(ENABLE_CONFIGURATION_POLICY) 152 #if defined(ENABLE_CONFIGURATION_POLICY)
153 #include "chrome/browser/policy/browser_policy_connector.h" 153 #include "chrome/browser/policy/policy_service.h"
154 #include "policy/policy_constants.h" 154 #include "policy/policy_constants.h"
155 #endif 155 #endif
156 156
157 #if defined(OS_CHROMEOS) 157 #if defined(OS_CHROMEOS)
158 #include "chromeos/dbus/dbus_thread_manager.h" 158 #include "chromeos/dbus/dbus_thread_manager.h"
159 #endif 159 #endif
160 160
161 #if defined(OS_MACOSX) 161 #if defined(OS_MACOSX)
162 #include "base/mach_ipc_mac.h" 162 #include "base/mach_ipc_mac.h"
163 #endif 163 #endif
(...skipping 15 matching lines...) Expand all
179 using content::NavigationEntry; 179 using content::NavigationEntry;
180 using content::PluginService; 180 using content::PluginService;
181 using content::OpenURLParams; 181 using content::OpenURLParams;
182 using content::Referrer; 182 using content::Referrer;
183 using content::RenderViewHost; 183 using content::RenderViewHost;
184 using content::SSLStatus; 184 using content::SSLStatus;
185 using content::WebContents; 185 using content::WebContents;
186 186
187 namespace { 187 namespace {
188 188
189 // Helper to reply asynchronously if |automation| is still valid.
190 void SendSuccessReply(base::WeakPtr<AutomationProvider> automation,
191 IPC::Message* reply_message) {
192 if (automation)
193 AutomationJSONReply(automation.get(), reply_message).SendSuccess(NULL);
194 }
195
189 void SendMouseClick(int flags) { 196 void SendMouseClick(int flags) {
190 ui_controls::MouseButton button = ui_controls::LEFT; 197 ui_controls::MouseButton button = ui_controls::LEFT;
191 if ((flags & ui::EF_LEFT_MOUSE_BUTTON) == 198 if ((flags & ui::EF_LEFT_MOUSE_BUTTON) ==
192 ui::EF_LEFT_MOUSE_BUTTON) { 199 ui::EF_LEFT_MOUSE_BUTTON) {
193 button = ui_controls::LEFT; 200 button = ui_controls::LEFT;
194 } else if ((flags & ui::EF_RIGHT_MOUSE_BUTTON) == 201 } else if ((flags & ui::EF_RIGHT_MOUSE_BUTTON) ==
195 ui::EF_RIGHT_MOUSE_BUTTON) { 202 ui::EF_RIGHT_MOUSE_BUTTON) {
196 button = ui_controls::RIGHT; 203 button = ui_controls::RIGHT;
197 } else if ((flags & ui::EF_MIDDLE_MOUSE_BUTTON) == 204 } else if ((flags & ui::EF_MIDDLE_MOUSE_BUTTON) ==
198 ui::EF_MIDDLE_MOUSE_BUTTON) { 205 ui::EF_MIDDLE_MOUSE_BUTTON) {
(...skipping 3541 matching lines...) Expand 10 before | Expand all | Expand 10 after
3740 return; 3747 return;
3741 } 3748 }
3742 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(browser->profile()); 3749 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(browser->profile());
3743 if (!plugin_prefs->CanEnablePlugin(true, FilePath(path))) { 3750 if (!plugin_prefs->CanEnablePlugin(true, FilePath(path))) {
3744 AutomationJSONReply(this, reply_message).SendError( 3751 AutomationJSONReply(this, reply_message).SendError(
3745 StringPrintf("Could not enable plugin for path %s.", path.c_str())); 3752 StringPrintf("Could not enable plugin for path %s.", path.c_str()));
3746 return; 3753 return;
3747 } 3754 }
3748 plugin_prefs->EnablePlugin( 3755 plugin_prefs->EnablePlugin(
3749 true, FilePath(path), 3756 true, FilePath(path),
3750 base::Bind(&TestingAutomationProvider::SendSuccessReply, this, 3757 base::Bind(SendSuccessReply, AsWeakPtr(), reply_message));
3751 reply_message));
3752 } 3758 }
3753 3759
3754 // Sample json input: 3760 // Sample json input:
3755 // { "command": "DisablePlugin", 3761 // { "command": "DisablePlugin",
3756 // "path": "/Library/Internet Plug-Ins/Flash Player.plugin" } 3762 // "path": "/Library/Internet Plug-Ins/Flash Player.plugin" }
3757 void TestingAutomationProvider::DisablePlugin(Browser* browser, 3763 void TestingAutomationProvider::DisablePlugin(Browser* browser,
3758 DictionaryValue* args, 3764 DictionaryValue* args,
3759 IPC::Message* reply_message) { 3765 IPC::Message* reply_message) {
3760 FilePath::StringType path; 3766 FilePath::StringType path;
3761 if (!args->GetString("path", &path)) { 3767 if (!args->GetString("path", &path)) {
3762 AutomationJSONReply(this, reply_message).SendError("path not specified."); 3768 AutomationJSONReply(this, reply_message).SendError("path not specified.");
3763 return; 3769 return;
3764 } 3770 }
3765 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(browser->profile()); 3771 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(browser->profile());
3766 if (!plugin_prefs->CanEnablePlugin(false, FilePath(path))) { 3772 if (!plugin_prefs->CanEnablePlugin(false, FilePath(path))) {
3767 AutomationJSONReply(this, reply_message).SendError( 3773 AutomationJSONReply(this, reply_message).SendError(
3768 StringPrintf("Could not disable plugin for path %s.", path.c_str())); 3774 StringPrintf("Could not disable plugin for path %s.", path.c_str()));
3769 return; 3775 return;
3770 } 3776 }
3771 plugin_prefs->EnablePlugin( 3777 plugin_prefs->EnablePlugin(
3772 false, FilePath(path), 3778 false, FilePath(path),
3773 base::Bind(&TestingAutomationProvider::SendSuccessReply, this, 3779 base::Bind(SendSuccessReply, AsWeakPtr(), reply_message));
3774 reply_message));
3775 } 3780 }
3776 3781
3777 // Sample json input: 3782 // Sample json input:
3778 // { "command": "SaveTabContents", 3783 // { "command": "SaveTabContents",
3779 // "tab_index": 0, 3784 // "tab_index": 0,
3780 // "filename": <a full pathname> } 3785 // "filename": <a full pathname> }
3781 // Sample json output: 3786 // Sample json output:
3782 // {} 3787 // {}
3783 void TestingAutomationProvider::SaveTabContents( 3788 void TestingAutomationProvider::SaveTabContents(
3784 Browser* browser, 3789 Browser* browser,
(...skipping 2065 matching lines...) Expand 10 before | Expand all | Expand 10 after
5850 return; 5855 return;
5851 } 5856 }
5852 5857
5853 bool control = !!(modifiers & automation::kControlKeyMask); 5858 bool control = !!(modifiers & automation::kControlKeyMask);
5854 bool shift = !!(modifiers & automation::kShiftKeyMask); 5859 bool shift = !!(modifiers & automation::kShiftKeyMask);
5855 bool alt = !!(modifiers & automation::kAltKeyMask); 5860 bool alt = !!(modifiers & automation::kAltKeyMask);
5856 bool meta = !!(modifiers & automation::kMetaKeyMask); 5861 bool meta = !!(modifiers & automation::kMetaKeyMask);
5857 if (!ui_controls::SendKeyPressNotifyWhenDone( 5862 if (!ui_controls::SendKeyPressNotifyWhenDone(
5858 window, static_cast<ui::KeyboardCode>(keycode), 5863 window, static_cast<ui::KeyboardCode>(keycode),
5859 control, shift, alt, meta, 5864 control, shift, alt, meta,
5860 base::Bind(&TestingAutomationProvider::SendSuccessReply, this, 5865 base::Bind(SendSuccessReply, AsWeakPtr(), reply_message))) {
5861 reply_message))) {
5862 AutomationJSONReply(this, reply_message) 5866 AutomationJSONReply(this, reply_message)
5863 .SendError("Could not send the native key event"); 5867 .SendError("Could not send the native key event");
5864 } 5868 }
5865 } 5869 }
5866 5870
5867 void TestingAutomationProvider::SendSuccessReply(IPC::Message* reply_message) {
5868 AutomationJSONReply(this, reply_message).SendSuccess(NULL);
5869 }
5870
5871 void TestingAutomationProvider::ProcessWebMouseEvent( 5871 void TestingAutomationProvider::ProcessWebMouseEvent(
5872 DictionaryValue* args, 5872 DictionaryValue* args,
5873 IPC::Message* reply_message) { 5873 IPC::Message* reply_message) {
5874 if (SendErrorIfModalDialogActive(this, reply_message)) 5874 if (SendErrorIfModalDialogActive(this, reply_message))
5875 return; 5875 return;
5876 5876
5877 RenderViewHost* view; 5877 RenderViewHost* view;
5878 std::string error; 5878 std::string error;
5879 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { 5879 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) {
5880 AutomationJSONReply(this, reply_message).SendError(error); 5880 AutomationJSONReply(this, reply_message).SendError(error);
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
6318 #endif 6318 #endif
6319 } 6319 }
6320 6320
6321 void TestingAutomationProvider::RefreshPolicies( 6321 void TestingAutomationProvider::RefreshPolicies(
6322 base::DictionaryValue* args, 6322 base::DictionaryValue* args,
6323 IPC::Message* reply_message) { 6323 IPC::Message* reply_message) {
6324 #if !defined(ENABLE_CONFIGURATION_POLICY) 6324 #if !defined(ENABLE_CONFIGURATION_POLICY)
6325 AutomationJSONReply(this, reply_message).SendError( 6325 AutomationJSONReply(this, reply_message).SendError(
6326 "Configuration Policy disabled"); 6326 "Configuration Policy disabled");
6327 #else 6327 #else
6328 policy::BrowserPolicyConnector* connector = 6328 g_browser_process->policy_service()->RefreshPolicies(
6329 g_browser_process->browser_policy_connector(); 6329 base::Bind(SendSuccessReply, AsWeakPtr(), reply_message));
6330 new PolicyUpdatesObserver(this, reply_message, connector);
6331 connector->RefreshPolicies();
6332 #endif 6330 #endif
6333 } 6331 }
6334 6332
6335 void TestingAutomationProvider::GetIndicesFromTab( 6333 void TestingAutomationProvider::GetIndicesFromTab(
6336 DictionaryValue* args, 6334 DictionaryValue* args,
6337 IPC::Message* reply_message) { 6335 IPC::Message* reply_message) {
6338 AutomationJSONReply reply(this, reply_message); 6336 AutomationJSONReply reply(this, reply_message);
6339 int id_or_handle = 0; 6337 int id_or_handle = 0;
6340 bool has_id = args->HasKey("tab_id"); 6338 bool has_id = args->HasKey("tab_id");
6341 bool has_handle = args->HasKey("tab_handle"); 6339 bool has_handle = args->HasKey("tab_handle");
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
7077 *browser_handle = browser_tracker_->Add(browser); 7075 *browser_handle = browser_tracker_->Add(browser);
7078 *success = true; 7076 *success = true;
7079 } 7077 }
7080 } 7078 }
7081 } 7079 }
7082 7080
7083 void TestingAutomationProvider::OnRemoveProvider() { 7081 void TestingAutomationProvider::OnRemoveProvider() {
7084 if (g_browser_process) 7082 if (g_browser_process)
7085 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); 7083 g_browser_process->GetAutomationProviderList()->RemoveProvider(this);
7086 } 7084 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698