Commit da3f8fd8 authored by Randy Rossi's avatar Randy Rossi Committed by Commit Bot

Copy aura ax classes from chrome for automation

Part of ongoing effort to get automation tree working
in chromecast.

PS 1 is baseline for copied files.  Modifications on top
of that in PS >= 2. Duplicated code will be refactored
into common /extensions later.

Bug: b/73383411
Test: None
Change-Id: I33c032e1b8d0a78b14797b26e021e0b612f0b5ec
Reviewed-on: https://chromium-review.googlesource.com/1044278
Commit-Queue: Randy Rossi <rmrossi@chromium.org>
Reviewed-by: default avatarAlex Sakhartchouk <alexst@chromium.org>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Reviewed-by: default avatarJochen Eisinger <jochen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558287}
parent 858a132b
...@@ -258,6 +258,18 @@ cast_source_set("browser") { ...@@ -258,6 +258,18 @@ cast_source_set("browser") {
"extensions/cast_prefs.h", "extensions/cast_prefs.h",
"extensions/stub_storage_monitor.cc", "extensions/stub_storage_monitor.cc",
] ]
if (use_aura) {
sources += [
"ui/aura/accessibility/automation_manager_aura.cc",
"ui/aura/accessibility/automation_manager_aura.h",
"ui/aura/accessibility/ax_root_obj_wrapper.cc",
"ui/aura/accessibility/ax_root_obj_wrapper.h",
"ui/aura/accessibility/ax_tree_source_aura.cc",
"ui/aura/accessibility/ax_tree_source_aura.h",
"cast_web_view_extension.h",
"cast_web_view_extension.h",
]
}
deps += [ deps += [
"//chromecast/common/extensions_api:api_registration_bundle_generator_registration", "//chromecast/common/extensions_api:api_registration_bundle_generator_registration",
...@@ -272,6 +284,7 @@ cast_source_set("browser") { ...@@ -272,6 +284,7 @@ cast_source_set("browser") {
"//extensions/common", "//extensions/common",
"//extensions/common/api", "//extensions/common/api",
"//google_apis:google_apis", "//google_apis:google_apis",
"//ui/views:views",
] ]
} }
......
...@@ -46,6 +46,7 @@ include_rules = [ ...@@ -46,6 +46,7 @@ include_rules = [
"+ui/gl", "+ui/gl",
"+ui/display", "+ui/display",
"+ui/ozone", "+ui/ozone",
"+ui/views",
# TODO(sanfin): Remove this by fixing the crash handler on android. # TODO(sanfin): Remove this by fixing the crash handler on android.
"!chromecast/app", "!chromecast/app",
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "chromecast/common/extensions_api/automation.h" #include "chromecast/common/extensions_api/automation.h"
#include "chromecast/common/extensions_api/automation_api_constants.h" #include "chromecast/common/extensions_api/automation_api_constants.h"
#include "chromecast/common/extensions_api/automation_internal.h" #include "chromecast/common/extensions_api/automation_internal.h"
#include "chromecast/common/extensions_api/cast_extension_messages.h"
#include "content/public/browser/ax_event_notification_details.h" #include "content/public/browser/ax_event_notification_details.h"
#include "content/public/browser/browser_accessibility_state.h" #include "content/public/browser/browser_accessibility_state.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
...@@ -163,18 +164,43 @@ class AutomationWebContentsObserver ...@@ -163,18 +164,43 @@ class AutomationWebContentsObserver
void AccessibilityEventReceived( void AccessibilityEventReceived(
const std::vector<content::AXEventNotificationDetails>& details) const std::vector<content::AXEventNotificationDetails>& details)
override { override {
// TODO(rmrossi) Temporary stub. std::vector<ExtensionMsg_AccessibilityEventParams> events;
for (const auto& event : details) {
events.emplace_back();
ExtensionMsg_AccessibilityEventParams& params = events.back();
params.tree_id = event.ax_tree_id;
params.id = event.id;
params.event_type = event.event_type;
params.update = event.update;
params.event_from = event.event_from;
params.action_request_id = event.action_request_id;
#if defined(USE_AURA)
params.mouse_location = aura::Env::GetInstance()->last_mouse_location();
#endif
}
AutomationEventRouter* router = AutomationEventRouter::GetInstance();
router->DispatchAccessibilityEvents(events);
} }
void AccessibilityLocationChangesReceived( void AccessibilityLocationChangesReceived(
const std::vector<content::AXLocationChangeNotificationDetails>& details) const std::vector<content::AXLocationChangeNotificationDetails>& details)
override { override {
// TODO(rmrossi) Temporary stub. for (const auto& src : details) {
ExtensionMsg_AccessibilityLocationChangeParams dst;
dst.id = src.id;
dst.tree_id = src.ax_tree_id;
dst.new_location = src.new_location;
AutomationEventRouter* router = AutomationEventRouter::GetInstance();
router->DispatchAccessibilityLocationChange(dst);
}
} }
void RenderFrameDeleted( void RenderFrameDeleted(
content::RenderFrameHost* render_frame_host) override { content::RenderFrameHost* render_frame_host) override {
// TODO(rmrossi) Temporary stub. int tree_id = render_frame_host->GetAXTreeID();
AutomationEventRouter::GetInstance()->DispatchTreeDestroyedEvent(
tree_id,
browser_context_);
} }
void MediaStartedPlaying(const MediaPlayerInfo& video_type, void MediaStartedPlaying(const MediaPlayerInfo& video_type,
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromecast/browser/ui/aura/accessibility/automation_manager_aura.h"
#include <stddef.h>
#include "base/memory/singleton.h"
#include "build/build_config.h"
#include "chromecast/browser/extensions/api/automation_internal/automation_event_router.h"
#include "chromecast/common/extensions_api/automation_api_constants.h"
#include "chromecast/common/extensions_api/cast_extension_messages.h"
#include "content/public/browser/ax_event_notification_details.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/render_frame_host.h"
#include "ui/accessibility/ax_action_data.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_tree_id_registry.h"
#include "ui/accessibility/platform/aura_window_properties.h"
#include "ui/aura/env.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
#include "ui/views/accessibility/ax_aura_obj_wrapper.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
using content::BrowserContext;
using extensions::cast::AutomationEventRouter;
namespace {
// Returns default browser context for sending events in case it was not
// provided.
BrowserContext* GetDefaultEventContext() {
// TODO(rmrossi) Temporary stub
return nullptr;
}
} // namespace
// static
AutomationManagerAura* AutomationManagerAura::GetInstance() {
return base::Singleton<AutomationManagerAura>::get();
}
void AutomationManagerAura::Enable(BrowserContext* context) {
enabled_ = true;
Reset(false);
SendEvent(context, current_tree_->GetRoot(), ax::mojom::Event::kLoadComplete);
views::AXAuraObjCache::GetInstance()->SetDelegate(this);
}
void AutomationManagerAura::Disable() {
enabled_ = false;
Reset(true);
}
void AutomationManagerAura::HandleEvent(BrowserContext* context,
views::View* view,
ax::mojom::Event event_type) {
if (!enabled_)
return;
views::AXAuraObjWrapper* aura_obj = view ?
views::AXAuraObjCache::GetInstance()->GetOrCreate(view) :
current_tree_->GetRoot();
SendEvent(nullptr, aura_obj, event_type);
}
void AutomationManagerAura::HandleAlert(content::BrowserContext* context,
const std::string& text) {
if (!enabled_)
return;
views::AXAuraObjWrapper* obj =
static_cast<AXRootObjWrapper*>(current_tree_->GetRoot())
->GetAlertForText(text);
SendEvent(context, obj, ax::mojom::Event::kAlert);
}
void AutomationManagerAura::PerformAction(const ui::AXActionData& data) {
CHECK(enabled_);
current_tree_->HandleAccessibleAction(data);
}
void AutomationManagerAura::OnChildWindowRemoved(
views::AXAuraObjWrapper* parent) {
if (!enabled_)
return;
if (!parent)
parent = current_tree_->GetRoot();
SendEvent(nullptr, parent, ax::mojom::Event::kChildrenChanged);
}
void AutomationManagerAura::OnEvent(views::AXAuraObjWrapper* aura_obj,
ax::mojom::Event event_type) {
SendEvent(nullptr, aura_obj, event_type);
}
AutomationManagerAura::AutomationManagerAura()
: AXHostDelegate(extensions::api::automation::kDesktopTreeID),
enabled_(false),
processing_events_(false) {}
AutomationManagerAura::~AutomationManagerAura() {
}
void AutomationManagerAura::Reset(bool reset_serializer) {
if (!current_tree_)
current_tree_.reset(new AXTreeSourceAura());
reset_serializer ? current_tree_serializer_.reset()
: current_tree_serializer_.reset(
new AuraAXTreeSerializer(current_tree_.get()));
}
void AutomationManagerAura::SendEvent(BrowserContext* context,
views::AXAuraObjWrapper* aura_obj,
ax::mojom::Event event_type) {
if (!current_tree_serializer_)
return;
if (!context)
context = GetDefaultEventContext();
//if (!context) {
// LOG(WARNING) << "Accessibility notification but no browser context";
// return;
//}
if (processing_events_) {
pending_events_.push_back(std::make_pair(aura_obj, event_type));
return;
}
processing_events_ = true;
std::vector<ExtensionMsg_AccessibilityEventParams> events;
events.emplace_back(ExtensionMsg_AccessibilityEventParams());
ExtensionMsg_AccessibilityEventParams& params = events.back();
if (!current_tree_serializer_->SerializeChanges(aura_obj, &params.update)) {
LOG(ERROR) << "Unable to serialize one accessibility event.";
return;
}
// Make sure the focused node is serialized.
views::AXAuraObjWrapper* focus =
views::AXAuraObjCache::GetInstance()->GetFocus();
if (focus)
current_tree_serializer_->SerializeChanges(focus, &params.update);
params.tree_id = 0;
params.id = aura_obj->GetUniqueId().Get();
params.event_type = event_type;
params.mouse_location = aura::Env::GetInstance()->last_mouse_location();
AutomationEventRouter* router = AutomationEventRouter::GetInstance();
router->DispatchAccessibilityEvents(events);
processing_events_ = false;
auto pending_events_copy = pending_events_;
pending_events_.clear();
for (size_t i = 0; i < pending_events_copy.size(); ++i) {
SendEvent(context,
pending_events_copy[i].first,
pending_events_copy[i].second);
}
}
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMECAST_BROWSER_UI_AURA_ACCESSIBILITY_AUTOMATION_MANAGER_AURA_H_
#define CHROMECAST_BROWSER_UI_AURA_ACCESSIBILITY_AUTOMATION_MANAGER_AURA_H_
#include <stdint.h>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base/macros.h"
#include "chromecast/browser/ui/aura/accessibility/ax_tree_source_aura.h"
#include "ui/accessibility/ax_host_delegate.h"
#include "ui/accessibility/ax_tree_serializer.h"
#include "ui/views/accessibility/ax_aura_obj_cache.h"
namespace base {
template <typename T>
struct DefaultSingletonTraits;
} // namespace base
namespace content {
class BrowserContext;
} // namespace content
namespace views {
class AXAuraObjWrapper;
class View;
} // namespace views
using AuraAXTreeSerializer =
ui::AXTreeSerializer<views::AXAuraObjWrapper*,
ui::AXNodeData,
ui::AXTreeData>;
// Manages a tree of automation nodes.
class AutomationManagerAura : public ui::AXHostDelegate,
views::AXAuraObjCache::Delegate {
public:
// Get the single instance of this class.
static AutomationManagerAura* GetInstance();
// Enable automation support for views.
void Enable(content::BrowserContext* context);
// Disable automation support for views.
void Disable();
// Handle an event fired upon a |View|.
void HandleEvent(content::BrowserContext* context,
views::View* view,
ax::mojom::Event event_type);
void HandleAlert(content::BrowserContext* context, const std::string& text);
// AXHostDelegate implementation.
void PerformAction(const ui::AXActionData& data) override;
// views::AXAuraObjCache::Delegate implementation.
void OnChildWindowRemoved(views::AXAuraObjWrapper* parent) override;
void OnEvent(views::AXAuraObjWrapper* aura_obj,
ax::mojom::Event event_type) override;
protected:
AutomationManagerAura();
~AutomationManagerAura() override;
private:
friend struct base::DefaultSingletonTraits<AutomationManagerAura>;
FRIEND_TEST_ALL_PREFIXES(AutomationManagerAuraBrowserTest, WebAppearsOnce);
// Reset state in this manager. If |reset_serializer| is true, reset the
// serializer to save memory.
void Reset(bool reset_serializer);
void SendEvent(content::BrowserContext* context,
views::AXAuraObjWrapper* aura_obj,
ax::mojom::Event event_type);
// Whether automation support for views is enabled.
bool enabled_;
// Holds the active views-based accessibility tree. A tree currently consists
// of all views descendant to a |Widget| (see |AXTreeSourceViews|).
// A tree becomes active when an event is fired on a descendant view.
std::unique_ptr<AXTreeSourceAura> current_tree_;
// Serializes incremental updates on the currently active tree
// |current_tree_|.
std::unique_ptr<AuraAXTreeSerializer> current_tree_serializer_;
bool processing_events_;
std::vector<std::pair<views::AXAuraObjWrapper*, ax::mojom::Event>>
pending_events_;
DISALLOW_COPY_AND_ASSIGN(AutomationManagerAura);
};
#endif // CHROMECAST_BROWSER_UI_AURA_ACCESSIBILITY_AUTOMATION_MANAGER_AURA_H_
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromecast/browser/ui/aura/accessibility/ax_root_obj_wrapper.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/aura/window.h"
#include "ui/views/accessibility/ax_aura_obj_cache.h"
#include "ui/views/accessibility/ax_window_obj_wrapper.h"
AXRootObjWrapper::AXRootObjWrapper() : alert_window_(new aura::Window(NULL)) {
alert_window_->Init(ui::LAYER_NOT_DRAWN);
}
AXRootObjWrapper::~AXRootObjWrapper() {
if (alert_window_) {
delete alert_window_;
alert_window_ = NULL;
}
}
views::AXAuraObjWrapper* AXRootObjWrapper::GetAlertForText(
const std::string& text) {
alert_window_->SetTitle(base::UTF8ToUTF16((text)));
views::AXWindowObjWrapper* window_obj =
static_cast<views::AXWindowObjWrapper*>(
views::AXAuraObjCache::GetInstance()->GetOrCreate(alert_window_));
window_obj->set_is_alert(true);
return window_obj;
}
bool AXRootObjWrapper::HasChild(views::AXAuraObjWrapper* child) {
std::vector<views::AXAuraObjWrapper*> children;
GetChildren(&children);
return base::ContainsValue(children, child);
}
views::AXAuraObjWrapper* AXRootObjWrapper::GetParent() {
return NULL;
}
void AXRootObjWrapper::GetChildren(
std::vector<views::AXAuraObjWrapper*>* out_children) {
views::AXAuraObjCache::GetInstance()->GetTopLevelWindows(out_children);
out_children->push_back(
views::AXAuraObjCache::GetInstance()->GetOrCreate(alert_window_));
}
void AXRootObjWrapper::Serialize(ui::AXNodeData* out_node_data) {
out_node_data->id = unique_id_.Get();
out_node_data->role = ax::mojom::Role::kDesktop;
// TODO(rmrossi) : Find out of this can be removed
out_node_data->AddStringAttribute(ax::mojom::StringAttribute::kChromeChannel,
"");
}
const ui::AXUniqueId& AXRootObjWrapper::GetUniqueId() const {
return unique_id_;
}
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMECAST_BROWSER_UI_AURA_ACCESSIBILITY_AX_ROOT_OBJ_WRAPPER_H_
#define CHROMECAST_BROWSER_UI_AURA_ACCESSIBILITY_AX_ROOT_OBJ_WRAPPER_H_
#include <stdint.h>
#include <string>
#include "base/macros.h"
#include "ui/accessibility/platform/ax_unique_id.h"
#include "ui/views/accessibility/ax_aura_obj_wrapper.h"
namespace aura {
class Window;
} // namespace aura
class AXRootObjWrapper : public views::AXAuraObjWrapper {
public:
AXRootObjWrapper();
~AXRootObjWrapper() override;
// Returns an AXAuraObjWrapper for an alert window with title set to |text|.
views::AXAuraObjWrapper* GetAlertForText(const std::string& text);
// Convenience method to check for existence of a child.
bool HasChild(views::AXAuraObjWrapper* child);
// views::AXAuraObjWrapper overrides.
views::AXAuraObjWrapper* GetParent() override;
void GetChildren(
std::vector<views::AXAuraObjWrapper*>* out_children) override;
void Serialize(ui::AXNodeData* out_node_data) override;
const ui::AXUniqueId& GetUniqueId() const override;
private:
ui::AXUniqueId unique_id_;
aura::Window* alert_window_;
DISALLOW_COPY_AND_ASSIGN(AXRootObjWrapper);
};
#endif // CHROMECAST_BROWSER_UI_AURA_ACCESSIBILITY_AX_ROOT_OBJ_WRAPPER_H_
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromecast/browser/ui/aura/accessibility/ax_tree_source_aura.h"
#include <stddef.h>
#include <vector>
#include "chromecast/browser/ui/aura/accessibility/automation_manager_aura.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
#include "ui/views/accessibility/ax_aura_obj_cache.h"
#include "ui/views/accessibility/ax_aura_obj_wrapper.h"
#include "ui/views/accessibility/ax_view_obj_wrapper.h"
#if defined(TOOLKIT_VIEWS)
#include "ui/views/controls/webview/webview.h" // nogncheck
#endif
using views::AXAuraObjCache;
using views::AXAuraObjWrapper;
AXTreeSourceAura::AXTreeSourceAura() {
root_.reset(new AXRootObjWrapper());
}
AXTreeSourceAura::~AXTreeSourceAura() {
root_.reset();
}
bool AXTreeSourceAura::HandleAccessibleAction(const ui::AXActionData& action) {
int id = action.target_node_id;
// In Views, we only support setting the selection within a single node,
// not across multiple nodes like on the web.
if (action.action == ax::mojom::Action::kSetSelection) {
if (action.anchor_node_id != action.focus_node_id) {
NOTREACHED();
return false;
}
id = action.anchor_node_id;
}
AXAuraObjWrapper* obj = AXAuraObjCache::GetInstance()->Get(id);
if (obj)
return obj->HandleAccessibleAction(action);
return false;
}
bool AXTreeSourceAura::GetTreeData(ui::AXTreeData* tree_data) const {
tree_data->tree_id = 0;
tree_data->loaded = true;
tree_data->loading_progress = 1.0;
AXAuraObjWrapper* focus = AXAuraObjCache::GetInstance()->GetFocus();
if (focus)
tree_data->focus_id = focus->GetUniqueId().Get();
return true;
}
AXAuraObjWrapper* AXTreeSourceAura::GetRoot() const {
return root_.get();
}
AXAuraObjWrapper* AXTreeSourceAura::GetFromId(int32_t id) const {
if (id == root_->GetUniqueId().Get())
return root_.get();
return AXAuraObjCache::GetInstance()->Get(id);
}
int32_t AXTreeSourceAura::GetId(AXAuraObjWrapper* node) const {
return node->GetUniqueId().Get();
}
void AXTreeSourceAura::GetChildren(
AXAuraObjWrapper* node,
std::vector<AXAuraObjWrapper*>* out_children) const {
node->GetChildren(out_children);
}
AXAuraObjWrapper* AXTreeSourceAura::GetParent(AXAuraObjWrapper* node) const {
AXAuraObjWrapper* parent = node->GetParent();
if (!parent && node->GetUniqueId() != root_->GetUniqueId())
parent = root_.get();
return parent;
}
bool AXTreeSourceAura::IsValid(AXAuraObjWrapper* node) const {
return node != nullptr;
}
bool AXTreeSourceAura::IsEqual(AXAuraObjWrapper* node1,
AXAuraObjWrapper* node2) const {
if (!node1 || !node2)
return false;
return node1->GetUniqueId() == node2->GetUniqueId();
}
AXAuraObjWrapper* AXTreeSourceAura::GetNull() const {
return NULL;
}
void AXTreeSourceAura::SerializeNode(AXAuraObjWrapper* node,
ui::AXNodeData* out_data) const {
node->Serialize(out_data);
// Convert the global coordinates reported by each AXAuraObjWrapper
// into parent-relative coordinates to be used in the accessibility
// tree. That way when any Window, Widget, or View moves (and fires
// a location changed event), its descendants all move relative to
// it by default.
AXAuraObjWrapper* parent = node->GetParent();
if (parent) {
ui::AXNodeData parent_data;
parent->Serialize(&parent_data);
out_data->location.Offset(-parent_data.location.OffsetFromOrigin());
out_data->offset_container_id = parent->GetUniqueId().Get();
}
if (out_data->role == ax::mojom::Role::kWebView) {
// TODO(rmrossi) : Figure out whether this will ever be required
// for chromecast.
LOG(FATAL) << "Unhandled role";
} else if (out_data->role == ax::mojom::Role::kWindow ||
out_data->role == ax::mojom::Role::kDialog) {
// Add clips children flag by default to these roles.
out_data->AddBoolAttribute(ax::mojom::BoolAttribute::kClipsChildren, true);
}
}
std::string AXTreeSourceAura::ToString(AXAuraObjWrapper* root,
std::string prefix) {
ui::AXNodeData data;
root->Serialize(&data);
std::string output = prefix + data.ToString() + '\n';
std::vector<AXAuraObjWrapper*> children;
root->GetChildren(&children);
prefix += prefix[0];
for (size_t i = 0; i < children.size(); ++i)
output += ToString(children[i], prefix);
return output;
}
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMECAST_BROWSER_UI_AURA_ACCESSIBILITY_AX_TREE_SOURCE_AURA_H_
#define CHROMECAST_BROWSER_UI_AURA_ACCESSIBILITY_AX_TREE_SOURCE_AURA_H_
#include <stdint.h>
#include <map>
#include <memory>
#include "base/macros.h"
#include "chromecast/browser/ui/aura/accessibility/ax_root_obj_wrapper.h"
#include "ui/accessibility/ax_tree_data.h"
#include "ui/accessibility/ax_tree_source.h"
namespace ui {
struct AXActionData;
} // namespace ui
namespace views {
class AXAuraObjWrapper;
} // namespace views
// This class exposes the views hierarchy as an accessibility tree permitting
// use with other accessibility classes.
class AXTreeSourceAura
: public ui::AXTreeSource<views::AXAuraObjWrapper*,
ui::AXNodeData,
ui::AXTreeData> {
public:
AXTreeSourceAura();
~AXTreeSourceAura() override;
// Invoke actions on an Aura view.
bool HandleAccessibleAction(const ui::AXActionData& action);
// AXTreeSource implementation.
bool GetTreeData(ui::AXTreeData* data) const override;
views::AXAuraObjWrapper* GetRoot() const override;
views::AXAuraObjWrapper* GetFromId(int32_t id) const override;
int32_t GetId(views::AXAuraObjWrapper* node) const override;
void GetChildren(
views::AXAuraObjWrapper* node,
std::vector<views::AXAuraObjWrapper*>* out_children) const override;
views::AXAuraObjWrapper* GetParent(
views::AXAuraObjWrapper* node) const override;
bool IsValid(views::AXAuraObjWrapper* node) const override;
bool IsEqual(views::AXAuraObjWrapper* node1,
views::AXAuraObjWrapper* node2) const override;
views::AXAuraObjWrapper* GetNull() const override;
void SerializeNode(views::AXAuraObjWrapper* node,
ui::AXNodeData* out_data) const override;
// Useful for debugging.
std::string ToString(views::AXAuraObjWrapper* root, std::string prefix);
private:
std::unique_ptr<AXRootObjWrapper> root_;
DISALLOW_COPY_AND_ASSIGN(AXTreeSourceAura);
};
#endif // CHROMECAST_BROWSER_UI_AURA_ACCESSIBILITY_AX_TREE_SOURCE_AURA_H_
...@@ -81,6 +81,8 @@ cast_source_set("renderer") { ...@@ -81,6 +81,8 @@ cast_source_set("renderer") {
sources += [ sources += [
"cast_extensions_renderer_client.cc", "cast_extensions_renderer_client.cc",
"cast_extensions_renderer_client.h", "cast_extensions_renderer_client.h",
"cast_extensions_dispatcher_delegate.cc",
"cast_extensions_dispatcher_delegate.g",
"extensions/automation_ax_tree_wrapper.cc", "extensions/automation_ax_tree_wrapper.cc",
"extensions/automation_ax_tree_wrapper.h", "extensions/automation_ax_tree_wrapper.h",
"extensions/automation_internal_custom_bindings.cc", "extensions/automation_internal_custom_bindings.cc",
...@@ -90,6 +92,8 @@ cast_source_set("renderer") { ...@@ -90,6 +92,8 @@ cast_source_set("renderer") {
deps += [ deps += [
"//chromecast/common", "//chromecast/common",
"//chromecast/common/extensions_api:api", "//chromecast/common/extensions_api:api",
"//chromecast/renderer:extensions_resources",
"//components/version_info:version_info",
"//extensions/common", "//extensions/common",
"//extensions/renderer", "//extensions/renderer",
"//gin:gin", "//gin:gin",
......
...@@ -4,6 +4,7 @@ include_rules = [ ...@@ -4,6 +4,7 @@ include_rules = [
"+chromecast/media", "+chromecast/media",
"+components/cdm/renderer", "+components/cdm/renderer",
"+components/network_hints/renderer", "+components/network_hints/renderer",
"+components/version_info",
"+content/public/common", "+content/public/common",
"+content/public/renderer", "+content/public/renderer",
"+extensions/common", "+extensions/common",
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromecast/renderer/cast_extensions_dispatcher_delegate.h"
#include <memory>
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/sha1.h"
#include "base/strings/string_number_conversions.h"
#include "chromecast/renderer/grit/extensions_renderer_resources.h"
#include "chromecast/renderer/extensions/automation_internal_custom_bindings.h"
#include "components/version_info/version_info.h"
#include "content/public/common/content_switches.h"
#include "content/public/renderer/render_thread.h"
#include "content/public/renderer/render_view.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_features.h"
#include "extensions/common/features/feature_channel.h"
#include "extensions/common/permissions/manifest_permission_set.h"
#include "extensions/common/permissions/permission_set.h"
#include "extensions/common/permissions/permissions_data.h"
#include "extensions/common/switches.h"
#include "extensions/renderer/bindings/api_bindings_system.h"
#include "extensions/renderer/css_native_handler.h"
#include "extensions/renderer/dispatcher.h"
#include "extensions/renderer/i18n_custom_bindings.h"
#include "extensions/renderer/lazy_background_page_native_handler.h"
#include "extensions/renderer/native_extension_bindings_system.h"
#include "extensions/renderer/native_handler.h"
#include "extensions/renderer/resource_bundle_source_map.h"
#include "extensions/renderer/script_context.h"
#include "media/media_buildflags.h"
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/public/platform/web_url.h"
#include "third_party/blink/public/web/web_security_policy.h"
using extensions::NativeHandler;
CastExtensionsDispatcherDelegate::CastExtensionsDispatcherDelegate() {
}
CastExtensionsDispatcherDelegate::~CastExtensionsDispatcherDelegate() {
}
void CastExtensionsDispatcherDelegate::InitOriginPermissions(
const extensions::Extension* extension,
bool is_extension_active) {
// TODO(rmrossi): Stub
}
void CastExtensionsDispatcherDelegate::RegisterNativeHandlers(
extensions::Dispatcher* dispatcher,
extensions::ModuleSystem* module_system,
extensions::ExtensionBindingsSystem* bindings_system,
extensions::ScriptContext* context) {
module_system->RegisterNativeHandler(
"automationInternal",
std::make_unique<extensions::cast::AutomationInternalCustomBindings>(
context, bindings_system));
}
void CastExtensionsDispatcherDelegate::PopulateSourceMap(
extensions::ResourceBundleSourceMap* source_map) {
// Custom bindings.
source_map->RegisterSource("automation", IDR_AUTOMATION_CUSTOM_BINDINGS_JS);
source_map->RegisterSource("automationEvent", IDR_AUTOMATION_EVENT_JS);
source_map->RegisterSource("automationNode", IDR_AUTOMATION_NODE_JS);
}
void CastExtensionsDispatcherDelegate::RequireAdditionalModules(
extensions::ScriptContext* context) {
// TODO(rmrossi): Stub
}
void CastExtensionsDispatcherDelegate::OnActiveExtensionsUpdated(
const std::set<std::string>& extension_ids) {
// TODO(rmrossi): Stub
}
void CastExtensionsDispatcherDelegate::InitializeBindingsSystem(
extensions::Dispatcher* dispatcher,
extensions::NativeExtensionBindingsSystem* bindings_system) {
DCHECK(
base::FeatureList::IsEnabled(extensions::features::kNativeCrxBindings));
// TODO(rmrossi): Stub
}
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMECAST_RENDERER_CAST_EXTENSIONS_DISPATCHER_DELEGATE_H_
#define CHROMECAST_RENDERER_CAST_EXTENSIONS_DISPATCHER_DELEGATE_H_
#include "base/macros.h"
#include "extensions/renderer/dispatcher_delegate.h"
class CastExtensionsDispatcherDelegate
: public extensions::DispatcherDelegate {
public:
CastExtensionsDispatcherDelegate();
~CastExtensionsDispatcherDelegate() override;
private:
// extensions::DispatcherDelegate implementation.
void InitOriginPermissions(const extensions::Extension* extension,
bool is_extension_active) override;
void RegisterNativeHandlers(
extensions::Dispatcher* dispatcher,
extensions::ModuleSystem* module_system,
extensions::ExtensionBindingsSystem* bindings_system,
extensions::ScriptContext* context) override;
void PopulateSourceMap(
extensions::ResourceBundleSourceMap* source_map) override;
void RequireAdditionalModules(extensions::ScriptContext* context) override;
void OnActiveExtensionsUpdated(
const std::set<std::string>& extensions_ids) override;
void InitializeBindingsSystem(
extensions::Dispatcher* dispatcher,
extensions::NativeExtensionBindingsSystem* bindings_system) override;
DISALLOW_COPY_AND_ASSIGN(CastExtensionsDispatcherDelegate);
};
#endif // CHROMECAST_RENDERER_CAST_EXTENSIONS_DISPATCHER_DELEGATE_H_
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "chromecast/renderer/cast_extensions_renderer_client.h" #include "chromecast/renderer/cast_extensions_renderer_client.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "chromecast/renderer/cast_extensions_dispatcher_delegate.h"
#include "extensions/renderer/dispatcher.h" #include "extensions/renderer/dispatcher.h"
#include "extensions/renderer/dispatcher_delegate.h" #include "extensions/renderer/dispatcher_delegate.h"
...@@ -12,7 +13,7 @@ namespace extensions { ...@@ -12,7 +13,7 @@ namespace extensions {
CastExtensionsRendererClient::CastExtensionsRendererClient() CastExtensionsRendererClient::CastExtensionsRendererClient()
: dispatcher_(std::make_unique<Dispatcher>( : dispatcher_(std::make_unique<Dispatcher>(
std::make_unique<DispatcherDelegate>())) {} std::make_unique<CastExtensionsDispatcherDelegate>())) {}
CastExtensionsRendererClient::~CastExtensionsRendererClient() {} CastExtensionsRendererClient::~CastExtensionsRendererClient() {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment