Commit 2083dbc9 authored by Randy Rossi's avatar Randy Rossi Committed by Commit Bot

Use tab_id for ax_id in chromecast webview controller

The ax_tree_id retrieved from the main frame can change since the
main frame may be swapped by the webview due to navigation
requests.  This CL uses the cast web content's tab id to identify
the tab from which the current main frame can be retrieved and
(hence the ax tree id).

Bug: NONE
Test: Display assistant build with weather webview screen
Change-Id: I0e8a23a79271a853652b2dcf09dfcf4403f94b97
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2325030Reviewed-by: default avatarDaniel Nicoara <dnicoara@chromium.org>
Commit-Queue: Randy Rossi <rmrossi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#792788}
parent b8d1d886
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/json/json_writer.h" #include "base/json/json_writer.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chromecast/base/version.h" #include "chromecast/base/version.h"
#include "chromecast/browser/cast_web_contents_impl.h" #include "chromecast/browser/cast_web_contents_impl.h"
...@@ -75,7 +76,12 @@ WebviewController::WebviewController(content::BrowserContext* browser_context, ...@@ -75,7 +76,12 @@ WebviewController::WebviewController(content::BrowserContext* browser_context,
std::unique_ptr<webview::WebviewResponse> response = std::unique_ptr<webview::WebviewResponse> response =
std::make_unique<webview::WebviewResponse>(); std::make_unique<webview::WebviewResponse>();
auto ax_id = contents_->GetMainFrame()->GetAXTreeID().ToString(); // For webviews, set the ax_id to be the cast_web_contents' tab id rather than
// the ax tree id for the main frame. The main frame can be replaced after
// we've set this from navigation. Prefix the string with "T:" to tell the ax
// bridge to find the cast_web_contents by tab id. Then it can find the
// current ax tree id from that.
std::string ax_id = "T:" + base::NumberToString(cast_web_contents_->tab_id());
response->mutable_create_response() response->mutable_create_response()
->mutable_accessibility_info() ->mutable_accessibility_info()
->set_ax_tree_id(ax_id); ->set_ax_tree_id(ax_id);
......
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