OLD | NEW |
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/command_line.h" | 9 #include "base/command_line.h" |
10 #include "chrome/browser/extensions/api/automation_internal/automation_util.h" | 10 #include "chrome/browser/extensions/api/automation_internal/automation_util.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 | 52 |
53 content::BrowserContext* browser_context_; | 53 content::BrowserContext* browser_context_; |
54 | 54 |
55 DISALLOW_COPY_AND_ASSIGN(AutomationWebContentsObserver); | 55 DISALLOW_COPY_AND_ASSIGN(AutomationWebContentsObserver); |
56 }; | 56 }; |
57 | 57 |
58 // TODO(aboxhall/dtseng): ensure that the initial data is sent down for the tab | 58 // TODO(aboxhall/dtseng): ensure that the initial data is sent down for the tab |
59 // if this doesn't turn accessibility on for the first time (e.g. if a | 59 // if this doesn't turn accessibility on for the first time (e.g. if a |
60 // RendererAccessibility object existed already because a screenreader has been | 60 // RendererAccessibility object existed already because a screenreader has been |
61 // run at some point). | 61 // run at some point). |
62 bool AutomationInternalEnableCurrentTabFunction::RunImpl() { | 62 bool AutomationInternalEnableCurrentTabFunction::RunAsync() { |
63 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 63 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
64 switches::kEnableAutomationAPI)) { | 64 switches::kEnableAutomationAPI)) { |
65 return false; | 65 return false; |
66 } | 66 } |
67 | 67 |
68 Browser* current_browser = GetCurrentBrowser(); | 68 Browser* current_browser = GetCurrentBrowser(); |
69 TabStripModel* tab_strip = current_browser->tab_strip_model(); | 69 TabStripModel* tab_strip = current_browser->tab_strip_model(); |
70 content::WebContents* contents = | 70 content::WebContents* contents = |
71 tab_strip->GetWebContentsAt(tab_strip->active_index()); | 71 tab_strip->GetWebContentsAt(tab_strip->active_index()); |
72 if (!contents) | 72 if (!contents) |
73 return false; | 73 return false; |
74 content::RenderWidgetHost* rwh = | 74 content::RenderWidgetHost* rwh = |
75 contents->GetRenderWidgetHostView()->GetRenderWidgetHost(); | 75 contents->GetRenderWidgetHostView()->GetRenderWidgetHost(); |
76 if (!rwh) | 76 if (!rwh) |
77 return false; | 77 return false; |
78 | 78 |
79 results_ = api::automation_internal::EnableCurrentTab::Results::Create( | 79 results_ = api::automation_internal::EnableCurrentTab::Results::Create( |
80 rwh->GetProcess()->GetID(), rwh->GetRoutingID()); | 80 rwh->GetProcess()->GetID(), rwh->GetRoutingID()); |
81 | 81 |
82 SendResponse(true); | 82 SendResponse(true); |
83 | 83 |
84 AutomationWebContentsObserver::CreateForWebContents(contents); | 84 AutomationWebContentsObserver::CreateForWebContents(contents); |
85 | 85 |
86 rwh->EnableTreeOnlyAccessibilityMode(); | 86 rwh->EnableTreeOnlyAccessibilityMode(); |
87 | 87 |
88 return true; | 88 return true; |
89 } | 89 } |
90 | 90 |
91 bool AutomationInternalPerformActionFunction::RunImpl() { | 91 bool AutomationInternalPerformActionFunction::RunAsync() { |
92 using api::automation_internal::PerformAction::Params; | 92 using api::automation_internal::PerformAction::Params; |
93 scoped_ptr<Params> params(Params::Create(*args_)); | 93 scoped_ptr<Params> params(Params::Create(*args_)); |
94 EXTENSION_FUNCTION_VALIDATE(params.get()); | 94 EXTENSION_FUNCTION_VALIDATE(params.get()); |
95 | 95 |
96 content::RenderWidgetHost* rwh = | 96 content::RenderWidgetHost* rwh = |
97 content::RenderWidgetHost::FromID(params->args.process_id, | 97 content::RenderWidgetHost::FromID(params->args.process_id, |
98 params->args.routing_id); | 98 params->args.routing_id); |
99 | 99 |
100 switch (params->args.action_type) { | 100 switch (params->args.action_type) { |
101 case api::automation_internal::ACTION_TYPE_DO_DEFAULT: | 101 case api::automation_internal::ACTION_TYPE_DO_DEFAULT: |
(...skipping 16 matching lines...) Expand all Loading... |
118 selection_params.end_index); | 118 selection_params.end_index); |
119 break; | 119 break; |
120 } | 120 } |
121 default: | 121 default: |
122 NOTREACHED(); | 122 NOTREACHED(); |
123 } | 123 } |
124 return true; | 124 return true; |
125 } | 125 } |
126 | 126 |
127 } // namespace extensions | 127 } // namespace extensions |
OLD | NEW |