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

Side by Side Diff: chrome/browser/extensions/api/automation_internal/automation_internal_api.cc

Issue 667713006: Implement automatic load of composed/embedded automation trees (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: Created 6 years, 1 month 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/extensions/api/automation_internal/automation_internal_ api.h" 5 #include "chrome/browser/extensions/api/automation_internal/automation_internal_ api.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "chrome/browser/extensions/api/automation_internal/automation_action_ad apter.h" 10 #include "chrome/browser/extensions/api/automation_internal/automation_action_ad apter.h"
11 #include "chrome/browser/extensions/api/automation_internal/automation_util.h" 11 #include "chrome/browser/extensions/api/automation_internal/automation_util.h"
12 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" 12 #include "chrome/browser/extensions/api/tabs/tabs_constants.h"
13 #include "chrome/browser/extensions/extension_tab_util.h" 13 #include "chrome/browser/extensions/extension_tab_util.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/tabs/tab_strip_model.h" 16 #include "chrome/browser/ui/tabs/tab_strip_model.h"
17 #include "chrome/common/extensions/api/automation_internal.h" 17 #include "chrome/common/extensions/api/automation_internal.h"
18 #include "chrome/common/extensions/manifest_handlers/automation.h" 18 #include "chrome/common/extensions/manifest_handlers/automation.h"
19 #include "content/public/browser/browser_accessibility_state.h"
19 #include "content/public/browser/ax_event_notification_details.h" 20 #include "content/public/browser/ax_event_notification_details.h"
20 #include "content/public/browser/render_frame_host.h" 21 #include "content/public/browser/render_frame_host.h"
21 #include "content/public/browser/render_process_host.h" 22 #include "content/public/browser/render_process_host.h"
22 #include "content/public/browser/render_widget_host.h" 23 #include "content/public/browser/render_widget_host.h"
23 #include "content/public/browser/render_widget_host_view.h" 24 #include "content/public/browser/render_widget_host_view.h"
24 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
25 #include "extensions/common/permissions/permissions_data.h" 26 #include "extensions/common/permissions/permissions_data.h"
26 27
27 #if defined(OS_CHROMEOS) 28 #if defined(OS_CHROMEOS)
28 #include "chrome/browser/ui/ash/accessibility/automation_manager_ash.h" 29 #include "chrome/browser/ui/ash/accessibility/automation_manager_ash.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 161
161 if (!CanRequestAutomation(extension(), automation_info, contents)) { 162 if (!CanRequestAutomation(extension(), automation_info, contents)) {
162 return RespondNow( 163 return RespondNow(
163 Error(kCannotRequestAutomationOnPage, contents->GetURL().spec())); 164 Error(kCannotRequestAutomationOnPage, contents->GetURL().spec()));
164 } 165 }
165 AutomationWebContentsObserver::CreateForWebContents(contents); 166 AutomationWebContentsObserver::CreateForWebContents(contents);
166 contents->EnableTreeOnlyAccessibilityMode(); 167 contents->EnableTreeOnlyAccessibilityMode();
167 return RespondNow( 168 return RespondNow(
168 ArgumentList(api::automation_internal::EnableTab::Results::Create( 169 ArgumentList(api::automation_internal::EnableTab::Results::Create(
169 rfh->GetProcess()->GetID(), rfh->GetRoutingID()))); 170 rfh->GetProcess()->GetID(), rfh->GetRoutingID())));
170 } 171 }
172
173 ExtensionFunction::ResponseAction
174 AutomationInternalEnableRendererFunction::Run() {
175 using api::automation_internal::EnableRenderer::Params;
176 scoped_ptr<Params> params(Params::Create(*args_));
177 EXTENSION_FUNCTION_VALIDATE(params.get());
178 content::RenderFrameHost* rfh =
179 content::RenderFrameHost::FromID(params->process_id,
dmazzoni 2014/10/29 06:53:30 I think this is what we want eventually, but aren'
180 params->routing_id);
181 if (!rfh)
182 return RespondNow(Error("unable to load tab"));
183
184 content::WebContents* contents =
dmazzoni 2014/10/29 06:53:30 nit: indent
185 content::WebContents::FromRenderFrameHost(rfh);
186 AutomationWebContentsObserver::CreateForWebContents(contents);
187 contents->EnableTreeOnlyAccessibilityMode();
188
189 return RespondNow(NoArguments());
190 }
171 191
172 ExtensionFunction::ResponseAction 192 ExtensionFunction::ResponseAction
173 AutomationInternalPerformActionFunction::Run() { 193 AutomationInternalPerformActionFunction::Run() {
174 const AutomationInfo* automation_info = AutomationInfo::Get(extension()); 194 const AutomationInfo* automation_info = AutomationInfo::Get(extension());
175 EXTENSION_FUNCTION_VALIDATE(automation_info && automation_info->interact); 195 EXTENSION_FUNCTION_VALIDATE(automation_info && automation_info->interact);
176 196
177 using api::automation_internal::PerformAction::Params; 197 using api::automation_internal::PerformAction::Params;
178 scoped_ptr<Params> params(Params::Create(*args_)); 198 scoped_ptr<Params> params(Params::Create(*args_));
179 EXTENSION_FUNCTION_VALIDATE(params.get()); 199 EXTENSION_FUNCTION_VALIDATE(params.get());
180 200
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 return RespondNow(Error("desktop permission must be requested")); 265 return RespondNow(Error("desktop permission must be requested"));
246 266
247 AutomationManagerAsh::GetInstance()->Enable(browser_context()); 267 AutomationManagerAsh::GetInstance()->Enable(browser_context());
248 return RespondNow(NoArguments()); 268 return RespondNow(NoArguments());
249 #else 269 #else
250 return RespondNow(Error("getDesktop is unsupported by this platform")); 270 return RespondNow(Error("getDesktop is unsupported by this platform"));
251 #endif // defined(OS_CHROMEOS) 271 #endif // defined(OS_CHROMEOS)
252 } 272 }
253 273
254 } // namespace extensions 274 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698