Commit c834e9dc authored by Orin Jaworski's avatar Orin Jaworski Committed by Commit Bot

[chrome//omnibox] Save variation and path info in batch exports

This CL enhances the chrome://omnibox batch export data to include
variation and path info provided by VersionHandler.  It also cleans up
the use of private |loadTimeData.data_| by using |getValue| with an
explicit selection of relevant fields.

Bug: 964528
Change-Id: I531a001cdf2e4985b82b206fc52fcad28b0e05ba
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1725551
Auto-Submit: Orin Jaworski <orinj@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarmanuk hovanesian <manukh@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#682755}
parent 205911fa
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
<title>Omnibox Debug Page</title> <title>Omnibox Debug Page</title>
<link rel="stylesheet" href="chrome://resources/css/text_defaults.css"> <link rel="stylesheet" href="chrome://resources/css/text_defaults.css">
<link rel="stylesheet" href="omnibox.css"> <link rel="stylesheet" href="omnibox.css">
<script src="chrome://resources/js/promise_resolver.js"></script>
<script src="chrome://resources/js/cr.js"></script> <script src="chrome://resources/js/cr.js"></script>
<script src="chrome://resources/mojo/mojo/public/js/mojo_bindings_lite.js"></script> <script src="chrome://resources/mojo/mojo/public/js/mojo_bindings_lite.js"></script>
<script src="chrome://resources/js/load_time_data.js"></script> <script src="chrome://resources/js/load_time_data.js"></script>
......
...@@ -242,18 +242,29 @@ class ExportDelegate { ...@@ -242,18 +242,29 @@ class ExportDelegate {
}; };
batchExports.push(exportData); batchExports.push(exportData);
} }
const variationInfo =
await cr.sendWithPromise('requestVariationInfo', true);
const pathInfo = await cr.sendWithPromise('requestPathInfo');
const loadTimeDataKeys = ['cl', 'command_line', 'executable_path',
'language', 'official', 'os_type', 'profile_path', 'useragent',
'version', 'version_bitsize', 'version_modifier'];
const versionDetails = Object.fromEntries(
loadTimeDataKeys.map(key => [key, window.loadTimeData.getValue(key)]));
const now = new Date(); const now = new Date();
const fileName = `omnibox_batch_${ExportDelegate.getTimeStamp(now)}.json`; const fileName = `omnibox_batch_${ExportDelegate.getTimeStamp(now)}.json`;
// If this data format changes, please roll schemaVersion. // If this data format changes, please roll schemaVersion.
const batchData = { const batchData = {
schemaKind: 'Omnibox Batch Export', schemaKind: 'Omnibox Batch Export',
schemaVersion: 2, schemaVersion: 3,
dateCreated: now.toISOString(), dateCreated: now.toISOString(),
author: '', author: '',
description: '', description: '',
authorTool: 'chrome://omnibox', authorTool: 'chrome://omnibox',
batchName, batchName,
versionDetails: window.loadTimeData.data_, versionDetails,
variationInfo,
pathInfo,
appVersion: navigator.appVersion, appVersion: navigator.appVersion,
batchExports batchExports
}; };
...@@ -330,7 +341,7 @@ class ExportDelegate { ...@@ -330,7 +341,7 @@ class ExportDelegate {
a.click(); a.click();
} }
/** /**
* @param {Date=} date * @param {Date=} date
* @return {string} A sortable timestamp string for use in filenames. * @return {string} A sortable timestamp string for use in filenames.
*/ */
......
...@@ -1126,16 +1126,16 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreWebUI) { ...@@ -1126,16 +1126,16 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreWebUI) {
ui_test_utils::NavigateToURL(browser(), webui_url); ui_test_utils::NavigateToURL(browser(), webui_url);
content::WebContents* old_tab = content::WebContents* old_tab =
browser()->tab_strip_model()->GetActiveWebContents(); browser()->tab_strip_model()->GetActiveWebContents();
EXPECT_EQ(content::BINDINGS_POLICY_MOJO_WEB_UI, EXPECT_TRUE(content::BINDINGS_POLICY_MOJO_WEB_UI &
old_tab->GetMainFrame()->GetEnabledBindings()); old_tab->GetMainFrame()->GetEnabledBindings());
Browser* new_browser = QuitBrowserAndRestore(browser(), 1); Browser* new_browser = QuitBrowserAndRestore(browser(), 1);
ASSERT_EQ(1u, active_browser_list_->size()); ASSERT_EQ(1u, active_browser_list_->size());
content::WebContents* new_tab = content::WebContents* new_tab =
new_browser->tab_strip_model()->GetActiveWebContents(); new_browser->tab_strip_model()->GetActiveWebContents();
EXPECT_EQ(webui_url, new_tab->GetURL()); EXPECT_EQ(webui_url, new_tab->GetURL());
EXPECT_EQ(content::BINDINGS_POLICY_MOJO_WEB_UI, EXPECT_TRUE(content::BINDINGS_POLICY_MOJO_WEB_UI &
new_tab->GetMainFrame()->GetEnabledBindings()); new_tab->GetMainFrame()->GetEnabledBindings());
} }
// http://crbug.com/803510 : Flaky on dbg and ASan bots. // http://crbug.com/803510 : Flaky on dbg and ASan bots.
......
...@@ -1813,8 +1813,8 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, ReuseRVHWithWebUI) { ...@@ -1813,8 +1813,8 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, ReuseRVHWithWebUI) {
EXPECT_EQ(2, browser()->tab_strip_model()->count()); EXPECT_EQ(2, browser()->tab_strip_model()->count());
content::RenderViewHost* webui_rvh = popup->GetRenderViewHost(); content::RenderViewHost* webui_rvh = popup->GetRenderViewHost();
content::RenderFrameHost* webui_rfh = popup->GetMainFrame(); content::RenderFrameHost* webui_rfh = popup->GetMainFrame();
EXPECT_EQ(content::BINDINGS_POLICY_MOJO_WEB_UI, EXPECT_TRUE(content::BINDINGS_POLICY_MOJO_WEB_UI &
webui_rfh->GetEnabledBindings()); webui_rfh->GetEnabledBindings());
// Navigate to another page in the popup. // Navigate to another page in the popup.
GURL nonwebui_url(embedded_test_server()->GetURL("a.com", "/title1.html")); GURL nonwebui_url(embedded_test_server()->GetURL("a.com", "/title1.html"));
...@@ -1828,8 +1828,8 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, ReuseRVHWithWebUI) { ...@@ -1828,8 +1828,8 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, ReuseRVHWithWebUI) {
back_load_observer.Wait(); back_load_observer.Wait();
EXPECT_EQ(webui_rvh, popup->GetRenderViewHost()); EXPECT_EQ(webui_rvh, popup->GetRenderViewHost());
EXPECT_TRUE(webui_rvh->IsRenderViewLive()); EXPECT_TRUE(webui_rvh->IsRenderViewLive());
EXPECT_EQ(content::BINDINGS_POLICY_MOJO_WEB_UI, EXPECT_TRUE(content::BINDINGS_POLICY_MOJO_WEB_UI &
webui_rvh->GetMainFrame()->GetEnabledBindings()); webui_rvh->GetMainFrame()->GetEnabledBindings());
} }
// Test that main frame navigations generate a NavigationUIData with the // Test that main frame navigations generate a NavigationUIData with the
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/omnibox/omnibox_page_handler.h" #include "chrome/browser/ui/webui/omnibox/omnibox_page_handler.h"
#include "chrome/browser/ui/webui/version_handler.h"
#include "chrome/browser/ui/webui/version_ui.h" #include "chrome/browser/ui/webui/version_ui.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "chrome/grit/browser_resources.h" #include "chrome/grit/browser_resources.h"
...@@ -16,7 +17,8 @@ ...@@ -16,7 +17,8 @@
#include "content/public/browser/web_ui_controller.h" #include "content/public/browser/web_ui_controller.h"
#include "content/public/browser/web_ui_data_source.h" #include "content/public/browser/web_ui_data_source.h"
OmniboxUI::OmniboxUI(content::WebUI* web_ui) : ui::MojoWebUIController(web_ui) { OmniboxUI::OmniboxUI(content::WebUI* web_ui)
: ui::MojoWebUIController(web_ui, /*enable_chrome_send=*/true) {
// Set up the chrome://omnibox/ source. // Set up the chrome://omnibox/ source.
content::WebUIDataSource* source = content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUIOmniboxHost); content::WebUIDataSource::Create(chrome::kChromeUIOmniboxHost);
...@@ -43,6 +45,7 @@ OmniboxUI::OmniboxUI(content::WebUI* web_ui) : ui::MojoWebUIController(web_ui) { ...@@ -43,6 +45,7 @@ OmniboxUI::OmniboxUI(content::WebUI* web_ui) : ui::MojoWebUIController(web_ui) {
content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source); content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source);
AddHandlerToRegistry(base::BindRepeating(&OmniboxUI::BindOmniboxPageHandler, AddHandlerToRegistry(base::BindRepeating(&OmniboxUI::BindOmniboxPageHandler,
base::Unretained(this))); base::Unretained(this)));
web_ui->AddMessageHandler(std::make_unique<VersionHandler>());
} }
OmniboxUI::~OmniboxUI() {} OmniboxUI::~OmniboxUI() {}
......
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