diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/chrome/browser/ui/webui/chromeos | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/chrome/browser/ui/webui/chromeos')
102 files changed, 1836 insertions, 1370 deletions
diff --git a/chromium/chrome/browser/ui/webui/chromeos/DEPS b/chromium/chrome/browser/ui/webui/chromeos/DEPS index c80e0efe1d0..a0bba8a28e5 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/DEPS +++ b/chromium/chrome/browser/ui/webui/chromeos/DEPS @@ -7,10 +7,3 @@ include_rules = [ "+services/device/public/mojom", "+services/network", ] - -specific_include_rules = { - "keyboard_overlay_ui\.cc": [ - # TODO(mash): Remove. http://crbug.com/770866 - "+ash/shell.h", - ], -} diff --git a/chromium/chrome/browser/ui/webui/chromeos/account_manager/OWNERS b/chromium/chrome/browser/ui/webui/chromeos/account_manager/OWNERS new file mode 100644 index 00000000000..4df9ab85cdc --- /dev/null +++ b/chromium/chrome/browser/ui/webui/chromeos/account_manager/OWNERS @@ -0,0 +1,2 @@ +anastasiian@chromium.org +sinhak@chromium.org diff --git a/chromium/chrome/browser/ui/webui/chromeos/account_manager_error_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/account_manager/account_manager_error_ui.cc index 83c0f366342..b329c687a33 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/account_manager_error_ui.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/account_manager/account_manager_error_ui.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ui/webui/chromeos/account_manager_error_ui.h" +#include "chrome/browser/ui/webui/chromeos/account_manager/account_manager_error_ui.h" #include "base/bind.h" #include "build/branding_buildflags.h" @@ -53,6 +53,10 @@ AccountManagerErrorUI::AccountManagerErrorUI(content::WebUI* web_ui) // Add required resources. html_source->AddResourcePath("account_manager_shared.css", IDR_ACCOUNT_MANAGER_SHARED_CSS); + html_source->AddResourcePath("account_manager_browser_proxy.html", + IDR_ACCOUNT_MANAGER_BROWSER_PROXY_HTML); + html_source->AddResourcePath("account_manager_browser_proxy.js", + IDR_ACCOUNT_MANAGER_BROWSER_PROXY_JS); html_source->AddResourcePath("account_manager_error.js", IDR_ACCOUNT_MANAGER_ERROR_JS); diff --git a/chromium/chrome/browser/ui/webui/chromeos/account_manager_error_ui.h b/chromium/chrome/browser/ui/webui/chromeos/account_manager/account_manager_error_ui.h index 95e8a498e36..f740e1bf35f 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/account_manager_error_ui.h +++ b/chromium/chrome/browser/ui/webui/chromeos/account_manager/account_manager_error_ui.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MANAGER_ERROR_UI_H_ -#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MANAGER_ERROR_UI_H_ +#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MANAGER_ACCOUNT_MANAGER_ERROR_UI_H_ +#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MANAGER_ACCOUNT_MANAGER_ERROR_UI_H_ #include "base/macros.h" #include "base/memory/weak_ptr.h" @@ -25,4 +25,4 @@ class AccountManagerErrorUI : public ui::WebDialogUI { } // namespace chromeos -#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MANAGER_ERROR_UI_H_ +#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MANAGER_ACCOUNT_MANAGER_ERROR_UI_H_ diff --git a/chromium/chrome/browser/ui/webui/chromeos/account_manager_welcome_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/account_manager/account_manager_welcome_dialog.cc index b17dd07fe5f..0765cfa96f0 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/account_manager_welcome_dialog.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/account_manager/account_manager_welcome_dialog.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ui/webui/chromeos/account_manager_welcome_dialog.h" +#include "chrome/browser/ui/webui/chromeos/account_manager/account_manager_welcome_dialog.h" #include <string> diff --git a/chromium/chrome/browser/ui/webui/chromeos/account_manager_welcome_dialog.h b/chromium/chrome/browser/ui/webui/chromeos/account_manager/account_manager_welcome_dialog.h index 67fea954e98..e92b754253c 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/account_manager_welcome_dialog.h +++ b/chromium/chrome/browser/ui/webui/chromeos/account_manager/account_manager_welcome_dialog.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MANAGER_WELCOME_DIALOG_H_ -#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MANAGER_WELCOME_DIALOG_H_ +#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MANAGER_ACCOUNT_MANAGER_WELCOME_DIALOG_H_ +#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MANAGER_ACCOUNT_MANAGER_WELCOME_DIALOG_H_ #include <string> @@ -37,4 +37,4 @@ class AccountManagerWelcomeDialog : public SystemWebDialogDelegate { } // namespace chromeos -#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MANAGER_WELCOME_DIALOG_H_ +#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MANAGER_ACCOUNT_MANAGER_WELCOME_DIALOG_H_ diff --git a/chromium/chrome/browser/ui/webui/chromeos/account_manager_welcome_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/account_manager/account_manager_welcome_ui.cc index 16a69c1d232..8248231f214 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/account_manager_welcome_ui.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/account_manager/account_manager_welcome_ui.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ui/webui/chromeos/account_manager_welcome_ui.h" +#include "chrome/browser/ui/webui/chromeos/account_manager/account_manager_welcome_ui.h" #include "base/bind.h" #include "base/strings/utf_string_conversions.h" @@ -45,6 +45,10 @@ AccountManagerWelcomeUI::AccountManagerWelcomeUI(content::WebUI* web_ui) IDR_ACCOUNT_MANAGER_SHARED_CSS); html_source->AddResourcePath("account_manager_welcome.js", IDR_ACCOUNT_MANAGER_WELCOME_JS); + html_source->AddResourcePath("account_manager_browser_proxy.html", + IDR_ACCOUNT_MANAGER_BROWSER_PROXY_HTML); + html_source->AddResourcePath("account_manager_browser_proxy.js", + IDR_ACCOUNT_MANAGER_BROWSER_PROXY_JS); #if BUILDFLAG(GOOGLE_CHROME_BRANDING) html_source->AddResourcePath("account_manager_welcome_1x.png", IDR_ACCOUNT_MANAGER_WELCOME_1X_PNG); diff --git a/chromium/chrome/browser/ui/webui/chromeos/account_manager_welcome_ui.h b/chromium/chrome/browser/ui/webui/chromeos/account_manager/account_manager_welcome_ui.h index ded176fe6df..9a68ddc6579 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/account_manager_welcome_ui.h +++ b/chromium/chrome/browser/ui/webui/chromeos/account_manager/account_manager_welcome_ui.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MANAGER_WELCOME_UI_H_ -#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MANAGER_WELCOME_UI_H_ +#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MANAGER_ACCOUNT_MANAGER_WELCOME_UI_H_ +#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MANAGER_ACCOUNT_MANAGER_WELCOME_UI_H_ #include "base/macros.h" #include "base/memory/weak_ptr.h" @@ -24,4 +24,4 @@ class AccountManagerWelcomeUI : public ui::WebDialogUI { } // namespace chromeos -#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MANAGER_WELCOME_UI_H_ +#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MANAGER_ACCOUNT_MANAGER_WELCOME_UI_H_ diff --git a/chromium/chrome/browser/ui/webui/chromeos/account_migration_welcome_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/account_manager/account_migration_welcome_dialog.cc index aeb9b5bfaa6..31504a89ca1 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/account_migration_welcome_dialog.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/account_manager/account_migration_welcome_dialog.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ui/webui/chromeos/account_migration_welcome_dialog.h" +#include "chrome/browser/ui/webui/chromeos/account_manager/account_migration_welcome_dialog.h" #include <string> @@ -10,7 +10,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/settings_window_manager_chromeos.h" -#include "chrome/browser/ui/webui/chromeos/account_migration_welcome_ui.h" +#include "chrome/browser/ui/webui/chromeos/account_manager/account_migration_welcome_ui.h" #include "chrome/common/pref_names.h" #include "chrome/common/webui_url_constants.h" #include "components/prefs/pref_service.h" diff --git a/chromium/chrome/browser/ui/webui/chromeos/account_migration_welcome_dialog.h b/chromium/chrome/browser/ui/webui/chromeos/account_manager/account_migration_welcome_dialog.h index 96670974836..6622d961508 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/account_migration_welcome_dialog.h +++ b/chromium/chrome/browser/ui/webui/chromeos/account_manager/account_migration_welcome_dialog.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MIGRATION_WELCOME_DIALOG_H_ -#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MIGRATION_WELCOME_DIALOG_H_ +#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MANAGER_ACCOUNT_MIGRATION_WELCOME_DIALOG_H_ +#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MANAGER_ACCOUNT_MIGRATION_WELCOME_DIALOG_H_ #include <string> @@ -42,4 +42,4 @@ class AccountMigrationWelcomeDialog : public SystemWebDialogDelegate { } // namespace chromeos -#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MIGRATION_WELCOME_DIALOG_H_ +#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MANAGER_ACCOUNT_MIGRATION_WELCOME_DIALOG_H_ diff --git a/chromium/chrome/browser/ui/webui/chromeos/account_migration_welcome_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/account_manager/account_migration_welcome_ui.cc index 12b79aaed4a..2d6596522c5 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/account_migration_welcome_ui.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/account_manager/account_migration_welcome_ui.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ui/webui/chromeos/account_migration_welcome_ui.h" +#include "chrome/browser/ui/webui/chromeos/account_manager/account_migration_welcome_ui.h" #include <memory> #include <string> @@ -12,7 +12,7 @@ #include "base/strings/utf_string_conversions.h" #include "build/branding_buildflags.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/ui/webui/signin/inline_login_handler_dialog_chromeos.h" +#include "chrome/browser/ui/webui/signin/inline_login_dialog_chromeos.h" #include "chrome/common/url_constants.h" #include "chrome/common/webui_url_constants.h" #include "chrome/grit/browser_resources.h" @@ -54,9 +54,9 @@ class MigrationMessageHandler : public content::WebUIMessageHandler { CHECK(!args->GetList().empty()); const std::string& account_email = args->GetList()[0].GetString(); - InlineLoginHandlerDialogChromeOS::Show( - account_email, InlineLoginHandlerDialogChromeOS::Source:: - kAccountManagerMigrationWelcomeScreen); + InlineLoginDialogChromeOS::Show(account_email, + InlineLoginDialogChromeOS::Source:: + kAccountManagerMigrationWelcomeScreen); HandleCloseDialog(args); } @@ -98,10 +98,10 @@ AccountMigrationWelcomeUI::AccountMigrationWelcomeUI(content::WebUI* web_ui) IDR_ACCOUNT_MANAGER_SHARED_CSS); html_source->AddResourcePath("account_migration_welcome.js", IDR_ACCOUNT_MIGRATION_WELCOME_JS); - html_source->AddResourcePath("account_migration_browser_proxy.html", - IDR_ACCOUNT_MIGRATION_BROWSER_PROXY_HTML); - html_source->AddResourcePath("account_migration_browser_proxy.js", - IDR_ACCOUNT_MIGRATION_BROWSER_PROXY_JS); + html_source->AddResourcePath("account_manager_browser_proxy.html", + IDR_ACCOUNT_MANAGER_BROWSER_PROXY_HTML); + html_source->AddResourcePath("account_manager_browser_proxy.js", + IDR_ACCOUNT_MANAGER_BROWSER_PROXY_JS); #if BUILDFLAG(GOOGLE_CHROME_BRANDING) html_source->AddResourcePath("account_manager_welcome_1x.png", IDR_ACCOUNT_MANAGER_WELCOME_1X_PNG); diff --git a/chromium/chrome/browser/ui/webui/chromeos/account_migration_welcome_ui.h b/chromium/chrome/browser/ui/webui/chromeos/account_manager/account_migration_welcome_ui.h index 24a0c7dd8be..3c7ec92e12d 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/account_migration_welcome_ui.h +++ b/chromium/chrome/browser/ui/webui/chromeos/account_manager/account_migration_welcome_ui.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MIGRATION_WELCOME_UI_H_ -#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MIGRATION_WELCOME_UI_H_ +#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MANAGER_ACCOUNT_MIGRATION_WELCOME_UI_H_ +#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MANAGER_ACCOUNT_MIGRATION_WELCOME_UI_H_ #include "base/macros.h" #include "base/memory/weak_ptr.h" @@ -26,4 +26,4 @@ class AccountMigrationWelcomeUI : public ui::WebDialogUI { } // namespace chromeos -#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MIGRATION_WELCOME_UI_H_ +#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MANAGER_ACCOUNT_MIGRATION_WELCOME_UI_H_ diff --git a/chromium/chrome/browser/ui/webui/chromeos/account_migration_proxy_test.js b/chromium/chrome/browser/ui/webui/chromeos/account_migration_proxy_test.js deleted file mode 100644 index a81f50bc8c0..00000000000 --- a/chromium/chrome/browser/ui/webui/chromeos/account_migration_proxy_test.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2019 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. - -/** @implements {account_migration.AccountMigrationBrowserProxy} */ -class TestAccountMigrationBrowserProxy extends TestBrowserProxy { - constructor() { - super([ - 'closeDialog', - 'reauthenticateAccount', - ]); - } - - /** @override */ - closeDialog() { - this.methodCalled('closeDialog'); - } - - /** @override */ - reauthenticateAccount(account_email) { - this.methodCalled('reauthenticateAccount', account_email); - } -} diff --git a/chromium/chrome/browser/ui/webui/chromeos/account_migration_welcome_test.js b/chromium/chrome/browser/ui/webui/chromeos/account_migration_welcome_test.js deleted file mode 100644 index 7c8a1f74674..00000000000 --- a/chromium/chrome/browser/ui/webui/chromeos/account_migration_welcome_test.js +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2019 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. - -GEN('#include "content/public/test/browser_test.h"'); - -/** - * Test fixture for generated tests. - * @extends {testing.Test} - */ -function AccountMigrationWelcomeUITest() {} -let testBrowserProxy = null; - -AccountMigrationWelcomeUITest.prototype = { - __proto__: testing.Test.prototype, - - /** - * Define the C++ fixture class and include it. - * @type {?string} - * @override - */ - typedefCppFixture: 'AccountMigrationWelcomeUITest', - - /** @override */ - extraLibraries: [ - '//chrome/test/data/webui/test_browser_proxy.js', - 'account_migration_proxy_test.js', - ], - - /** @override */ - setUp: function() { - testBrowserProxy = new TestAccountMigrationBrowserProxy(); - account_migration.AccountMigrationBrowserProxyImpl.instance_ = - testBrowserProxy; - testing.Test.prototype.setUp.call(this); - }, - - /** @override */ - testGenPreamble: function() { - GEN('ShowDialog();'); - }, - - /** - * Tests that the dialog opened to the correct URL. - */ - testDialogUrl: function() { - // Remove slash at the end of URL if present. - const url = window.location.href.replace(/\/$/, ''); - assertEquals(chrome.getVariableValue('expectedUrl'), url); - }, - - /** - * Tests that |closeDialog| function get called after clicking - * the cancel button - */ - testCloseDialog: function() { - $('cancel-button').click(); - assertEquals(1, testBrowserProxy.getCallCount('closeDialog')); - }, - - /** - * Tests that |reauthenticateAccount| function get called with expected email - * after clicking the migrate button. - */ - testReauthenticateAccount: function() { - $('migrate-button').click(); - assertEquals(1, testBrowserProxy.getCallCount('reauthenticateAccount')); - testBrowserProxy.whenCalled('reauthenticateAccount').then(email => { - assertEquals(chrome.getVariableValue('expectedEmail'), email); - }); - }, -}; - -GEN('#include "chrome/browser/ui/webui/chromeos/account_migration_welcome_ui_test.h"'); -GEN(''); - - -TEST_F('AccountMigrationWelcomeUITest', 'testDialogURL', function() { - this.testDialogUrl(); -}); - -TEST_F('AccountMigrationWelcomeUITest', 'testCloseDialog', function() { - this.testCloseDialog(); -}); - -TEST_F( - 'AccountMigrationWelcomeUITest', 'testReauthenticateAccount', function() { - this.testReauthenticateAccount(); - }); diff --git a/chromium/chrome/browser/ui/webui/chromeos/account_migration_welcome_ui_test.cc b/chromium/chrome/browser/ui/webui/chromeos/account_migration_welcome_ui_test.cc deleted file mode 100644 index a9b5b792260..00000000000 --- a/chromium/chrome/browser/ui/webui/chromeos/account_migration_welcome_ui_test.cc +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2019 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 "chrome/browser/ui/webui/chromeos/account_migration_welcome_ui_test.h" - -#include "base/macros.h" -#include "chrome/browser/ui/webui/chromeos/account_migration_welcome_dialog.h" -#include "chrome/common/url_constants.h" -#include "content/public/browser/render_view_host.h" -#include "content/public/browser/web_contents.h" -#include "content/public/browser/web_ui.h" -#include "content/public/browser/web_ui_message_handler.h" -#include "content/public/test/browser_test_utils.h" -#include "ui/web_dialogs/web_dialog_ui.h" - -AccountMigrationWelcomeUITest::AccountMigrationWelcomeUITest() = default; -AccountMigrationWelcomeUITest::~AccountMigrationWelcomeUITest() = default; - -void AccountMigrationWelcomeUITest::ShowDialog() { - auto* account_email = "test@example.com"; - auto* dialog = chromeos::AccountMigrationWelcomeDialog::Show(account_email); - auto* webui = dialog->GetWebUIForTest(); - auto* web_contents = webui->GetWebContents(); - content::WaitForLoadStop(web_contents); - web_contents->GetMainFrame()->SetWebUIProperty( - "expectedUrl", chrome::kChromeUIAccountMigrationWelcomeURL); - web_contents->GetMainFrame()->SetWebUIProperty("expectedEmail", - account_email); - SetWebUIInstance(webui); -} diff --git a/chromium/chrome/browser/ui/webui/chromeos/account_migration_welcome_ui_test.h b/chromium/chrome/browser/ui/webui/chromeos/account_migration_welcome_ui_test.h deleted file mode 100644 index 29ef97bf54a..00000000000 --- a/chromium/chrome/browser/ui/webui/chromeos/account_migration_welcome_ui_test.h +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2019 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 CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MIGRATION_WELCOME_UI_TEST_H_ -#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MIGRATION_WELCOME_UI_TEST_H_ - -#include "chrome/test/base/ui_test_utils.h" -#include "chrome/test/base/web_ui_browser_test.h" -// Test framework for -// chrome/browser/ui/webui/chromeos/account_migration_welcome_test.js -class AccountMigrationWelcomeUITest : public WebUIBrowserTest { - public: - AccountMigrationWelcomeUITest(); - ~AccountMigrationWelcomeUITest() override; - - protected: - void ShowDialog(); -}; - -#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MIGRATION_WELCOME_UI_TEST_H_ diff --git a/chromium/chrome/browser/ui/webui/chromeos/add_supervision/add_supervision_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/add_supervision/add_supervision_handler.cc index cc951296439..021040da4f5 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/add_supervision/add_supervision_handler.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/add_supervision/add_supervision_handler.cc @@ -20,7 +20,7 @@ #include "chrome/browser/ui/webui/chromeos/add_supervision/add_supervision.mojom.h" #include "chrome/browser/ui/webui/chromeos/add_supervision/add_supervision_handler_utils.h" #include "chrome/browser/ui/webui/chromeos/add_supervision/add_supervision_metrics_recorder.h" -#include "chrome/services/app_service/public/cpp/app_registry_cache.h" +#include "components/services/app_service/public/cpp/app_registry_cache.h" #include "components/signin/public/identity_manager/access_token_fetcher.h" #include "components/signin/public/identity_manager/access_token_info.h" #include "components/signin/public/identity_manager/consent_level.h" @@ -55,10 +55,16 @@ void AddSupervisionHandler::RequestClose(RequestCloseCallback callback) { void AddSupervisionHandler::GetInstalledArcApps( GetInstalledArcAppsCallback callback) { Profile* profile = Profile::FromWebUI(web_ui_); + if (!profile) { + DLOG(WARNING) << "Profile not found in WebUI"; + std::move(callback).Run({}); + return; + } + apps::AppServiceProxy* proxy = apps::AppServiceProxyFactory::GetForProfile(profile); - if (arc::ArcSessionManager::Get() == nullptr) { + if (!arc::ArcSessionManager::Get()) { DLOG(WARNING) << "No ArcSessionManager available"; std::move(callback).Run({}); return; @@ -71,15 +77,9 @@ void AddSupervisionHandler::GetInstalledArcApps( } std::vector<std::string> installed_arc_apps; - proxy->AppRegistryCache().ForEachApp( [&installed_arc_apps, profile](const apps::AppUpdate& update) { - // We don't include "sticky" ARC apps because they are system-required - // apps that should not be offered for uninstallation. TODO(danan): - // check for stickyness via the App Service instead when that is - // available. (https://crbug.com/948408). - if (ShouldIncludeAppUpdate(update) && - !arc::IsArcAppSticky(update.AppId(), profile)) { + if (ShouldIncludeAppUpdate(update)) { std::string package_name = arc::AppIdToArcPackageName(update.AppId(), profile); if (!package_name.empty()) diff --git a/chromium/chrome/browser/ui/webui/chromeos/add_supervision/add_supervision_handler_utils.cc b/chromium/chrome/browser/ui/webui/chromeos/add_supervision/add_supervision_handler_utils.cc index 0c7a610df3e..8bc9b023bb2 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/add_supervision/add_supervision_handler_utils.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/add_supervision/add_supervision_handler_utils.cc @@ -9,14 +9,12 @@ #include "chrome/browser/supervised_user/supervised_user_service.h" #include "chrome/browser/supervised_user/supervised_user_service_factory.h" #include "chrome/browser/ui/webui/chromeos/add_supervision/add_supervision_metrics_recorder.h" -#include "chrome/services/app_service/public/cpp/app_update.h" -#include "chrome/services/app_service/public/mojom/types.mojom.h" +#include "components/services/app_service/public/cpp/app_update.h" +#include "components/services/app_service/public/mojom/types.mojom.h" bool ShouldIncludeAppUpdate(const apps::AppUpdate& app_update) { - // TODO(danan): update this to only return sticky = true arc apps when that - // attribute is available via the App Service (https://crbug.com/948408). - - return app_update.AppType() == apps::mojom::AppType::kArc; + return app_update.AppType() == apps::mojom::AppType::kArc && + app_update.InstallSource() != apps::mojom::InstallSource::kSystem; } void LogOutHelper() { diff --git a/chromium/chrome/browser/ui/webui/chromeos/add_supervision/add_supervision_handler_utils_unittest.cc b/chromium/chrome/browser/ui/webui/chromeos/add_supervision/add_supervision_handler_utils_unittest.cc index 6236a41ff69..2640236a92b 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/add_supervision/add_supervision_handler_utils_unittest.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/add_supervision/add_supervision_handler_utils_unittest.cc @@ -3,7 +3,7 @@ // found in the LICENSE file. #include "chrome/browser/ui/webui/chromeos/add_supervision/add_supervision_handler_utils.h" -#include "chrome/services/app_service/public/cpp/app_update.h" +#include "components/services/app_service/public/cpp/app_update.h" #include "testing/gtest/include/gtest/gtest.h" using AddSupervisionHandlerUtilsTest = testing::Test; @@ -13,12 +13,13 @@ TEST_F(AddSupervisionHandlerUtilsTest, TestShouldIncludeAppUpdate) { // Return ARC apps. apps::mojom::App arc_state; arc_state.app_type = apps::mojom::AppType::kArc; - apps::AppUpdate arc_update(&arc_state, nullptr /* delta */); + apps::AppUpdate arc_update(&arc_state, nullptr /* delta */, EmptyAccountId()); EXPECT_TRUE(ShouldIncludeAppUpdate(arc_update)); // Don't return non-ARC apps. apps::mojom::App non_arc_state; non_arc_state.app_type = apps::mojom::AppType::kBuiltIn; - apps::AppUpdate non_arc_update(&non_arc_state, nullptr /* delta */); + apps::AppUpdate non_arc_update(&non_arc_state, nullptr /* delta */, + EmptyAccountId()); EXPECT_FALSE(ShouldIncludeAppUpdate(non_arc_update)); } diff --git a/chromium/chrome/browser/ui/webui/chromeos/add_supervision/add_supervision_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/chromeos/add_supervision/add_supervision_ui_browsertest.cc index 7e7fde7f98c..fa0110c7cf3 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/add_supervision/add_supervision_ui_browsertest.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/add_supervision/add_supervision_ui_browsertest.cc @@ -25,10 +25,6 @@ namespace chromeos { -// NOTE: This test is flaky and therefore disabled under MSAN: -// https://crbug.com/1002560 -#if !defined(MEMORY_SANITIZER) - namespace { const char kGetAddSupervisionUIElementJS[] = @@ -94,14 +90,7 @@ class AddSupervisionBrowserTest : public InProcessBrowserTest { DISALLOW_COPY_AND_ASSIGN(AddSupervisionBrowserTest); }; -// Disabled on ASan and LSAn builds, because it's very flaky. See -// crbug.com/1004237 -#if defined(ADDRESS_SANITIZER) || defined(LEAK_SANITIZER) -#define MAYBE_URLParameters DISABLED_URLParameters -#else -#define MAYBE_URLParameters URLParameters -#endif -IN_PROC_BROWSER_TEST_F(AddSupervisionBrowserTest, MAYBE_URLParameters) { +IN_PROC_BROWSER_TEST_F(AddSupervisionBrowserTest, URLParameters) { // Open the Add Supervision URL. ui_test_utils::NavigateToURL(browser(), add_supervision_webui_url()); content::WaitForLoadStop(contents()); @@ -172,15 +161,7 @@ IN_PROC_BROWSER_TEST_F(AddSupervisionBrowserTest, ShowOfflineScreen) { std::string(".webviewDiv"))); } -// Disabled on ASan and LSAn builds, because it's very flaky. See -// crbug.com/1004237 -#if defined(ADDRESS_SANITIZER) || defined(LEAK_SANITIZER) -#define MAYBE_ShowConfirmSignoutDialog DISABLED_ShowConfirmSignoutDialog -#else -#define MAYBE_ShowConfirmSignoutDialog ShowConfirmSignoutDialog -#endif -IN_PROC_BROWSER_TEST_F(AddSupervisionBrowserTest, - MAYBE_ShowConfirmSignoutDialog) { +IN_PROC_BROWSER_TEST_F(AddSupervisionBrowserTest, ShowConfirmSignoutDialog) { // Open the Add Supervision URL. ui_test_utils::NavigateToURL(browser(), add_supervision_webui_url()); content::WaitForLoadStop(contents()); @@ -206,14 +187,7 @@ IN_PROC_BROWSER_TEST_F(AddSupervisionBrowserTest, ASSERT_TRUE(ConfirmSignoutDialog::IsShowing()); } -// Disabled on ASan and LSAn builds, because it's very flaky. See -// crbug.com/1004237 -#if defined(ADDRESS_SANITIZER) || defined(LEAK_SANITIZER) -#define MAYBE_UMATest DISABLED_UMATest -#else -#define MAYBE_UMATest UMATest -#endif -IN_PROC_BROWSER_TEST_F(AddSupervisionBrowserTest, MAYBE_UMATest) { +IN_PROC_BROWSER_TEST_F(AddSupervisionBrowserTest, UMATest) { base::HistogramTester histogram_tester; base::UserActionTester user_action_tester; @@ -246,6 +220,4 @@ IN_PROC_BROWSER_TEST_F(AddSupervisionBrowserTest, MAYBE_UMATest) { 1); } -#endif // !defined(MEMORY_SANITIZER) - } // namespace chromeos diff --git a/chromium/chrome/browser/ui/webui/chromeos/arc_graphics_tracing/arc_graphics_tracing_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/arc_graphics_tracing/arc_graphics_tracing_ui.cc index d0a7fc4bb75..8beb112fa72 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/arc_graphics_tracing/arc_graphics_tracing_ui.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/arc_graphics_tracing/arc_graphics_tracing_ui.cc @@ -14,6 +14,7 @@ #include "chrome/grit/browser_resources.h" #include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui_data_source.h" +#include "services/network/public/mojom/content_security_policy.mojom.h" #include "ui/base/webui/web_ui_util.h" namespace { @@ -36,7 +37,8 @@ content::WebUIDataSource* CreateGraphicsDataSource() { IDR_ARC_GRAPHICS_TRACING_UI_JS); source->AddResourcePath(kArcTracingCssPath, IDR_ARC_TRACING_CSS); source->AddResourcePath(kArcTracingUiJsPath, IDR_ARC_TRACING_UI_JS); - source->OverrideContentSecurityPolicyScriptSrc( + source->OverrideContentSecurityPolicy( + network::mojom::CSPDirectiveName::ScriptSrc, "script-src chrome://resources 'self';"); base::DictionaryValue localized_strings; @@ -58,7 +60,8 @@ content::WebUIDataSource* CreateOverviewDataSource() { IDR_ARC_OVERVIEW_TRACING_UI_JS); source->AddResourcePath(kArcTracingCssPath, IDR_ARC_TRACING_CSS); source->AddResourcePath(kArcTracingUiJsPath, IDR_ARC_TRACING_UI_JS); - source->OverrideContentSecurityPolicyScriptSrc( + source->OverrideContentSecurityPolicy( + network::mojom::CSPDirectiveName::ScriptSrc, "script-src chrome://resources 'self';"); base::DictionaryValue localized_strings; diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.cc index d74e24d8ba0..8a66b8f69fe 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.cc @@ -31,6 +31,7 @@ #include "content/public/browser/web_ui_data_source.h" #include "content/public/common/content_features.h" #include "net/base/url_util.h" +#include "services/network/public/mojom/content_security_policy.mojom.h" #include "ui/chromeos/resources/grit/ui_chromeos_resources.h" #include "ui/display/display.h" #include "ui/display/screen.h" @@ -93,7 +94,8 @@ AssistantOptInUI::AssistantOptInUI(content::WebUI* web_ui) IDR_ASSISTANT_VOICE_MATCH_ANIMATION); source->AddResourcePath("voice_match_already_setup_animation.json", IDR_ASSISTANT_VOICE_MATCH_ALREADY_SETUP_ANIMATION); - source->OverrideContentSecurityPolicyWorkerSrc("worker-src blob: 'self';"); + source->OverrideContentSecurityPolicy( + network::mojom::CSPDirectiveName::WorkerSrc, "worker-src blob: 'self';"); content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source); // Do not zoom for Assistant opt-in web contents. diff --git a/chromium/chrome/browser/ui/webui/chromeos/bluetooth_pairing_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/bluetooth_pairing_dialog.cc index b65490702e4..4ff6decf773 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/bluetooth_pairing_dialog.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/bluetooth_pairing_dialog.cc @@ -7,8 +7,10 @@ #include "base/json/json_writer.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/webui/chromeos/bluetooth_dialog_localized_strings_provider.h" +#include "chrome/browser/ui/webui/webui_util.h" #include "chrome/common/url_constants.h" -#include "chrome/grit/browser_resources.h" +#include "chrome/grit/bluetooth_pairing_dialog_resources.h" +#include "chrome/grit/bluetooth_pairing_dialog_resources_map.h" #include "chrome/grit/generated_resources.h" #include "components/strings/grit/components_strings.h" #include "content/public/browser/web_ui.h" @@ -20,6 +22,14 @@ namespace chromeos { namespace { +#if !BUILDFLAG(OPTIMIZE_WEBUI) +namespace { +const char kGeneratedPath[] = + "@out_folder@/gen/chrome/browser/resources/chromeos/" + "bluetooth_pairing_dialog/"; +} +#endif + constexpr int kBluetoothPairingDialogHeight = 375; void AddBluetoothStrings(content::WebUIDataSource* html_source) { @@ -103,15 +113,17 @@ BluetoothPairingDialogUI::BluetoothPairingDialogUI(content::WebUI* web_ui) AddBluetoothStrings(source); source->AddLocalizedString("title", IDS_SETTINGS_BLUETOOTH_PAIR_DEVICE_TITLE); - source->UseStringsJs(); #if BUILDFLAG(OPTIMIZE_WEBUI) - source->SetDefaultResource(IDR_BLUETOOTH_PAIRING_DIALOG_VULCANIZED_HTML); - source->AddResourcePath("crisper.js", - IDR_BLUETOOTH_PAIRING_DIALOG_CRISPER_JS); + webui::SetupBundledWebUIDataSource( + source, "bluetooth_pairing_dialog.js", + IDR_BLUETOOTH_PAIRING_DIALOG_ROLLUP_JS, + IDR_BLUETOOTH_PAIRING_DIALOG_CONTAINER_HTML); #else - source->SetDefaultResource(IDR_BLUETOOTH_PAIRING_DIALOG_HTML); - source->AddResourcePath("bluetooth_pairing_dialog.js", - IDR_BLUETOOTH_PAIRING_DIALOG_JS); + webui::SetupWebUIDataSource( + source, + base::make_span(kBluetoothPairingDialogResources, + kBluetoothPairingDialogResourcesSize), + kGeneratedPath, IDR_BLUETOOTH_PAIRING_DIALOG_CONTAINER_HTML); #endif content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source); } diff --git a/chromium/chrome/browser/ui/webui/chromeos/camera/camera_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/camera/camera_ui.cc deleted file mode 100644 index 9906f67c75e..00000000000 --- a/chromium/chrome/browser/ui/webui/chromeos/camera/camera_ui.cc +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2019 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 "chrome/browser/ui/webui/chromeos/camera/camera_ui.h" - -#include <utility> - -#include "base/bind.h" -#include "base/feature_list.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/ui/webui/webui_util.h" -#include "chrome/browser/web_applications/system_web_app_manager.h" -#include "chrome/common/url_constants.h" -#include "chrome/grit/browser_resources.h" -#include "chrome/grit/camera_resources.h" -#include "chrome/grit/camera_resources_map.h" -#include "chromeos/constants/chromeos_features.h" -#include "content/public/browser/web_ui_data_source.h" -#include "mojo/public/js/grit/mojo_bindings_resources.h" - -namespace chromeos { - -namespace { - -content::WebUIDataSource* CreateCameraUIHTMLSource() { - content::WebUIDataSource* source = - content::WebUIDataSource::Create(chrome::kChromeUICameraHost); - - // Add all settings resources. - webui::AddResourcePathsBulk( - source, base::make_span(kCameraResources, kCameraResourcesSize)); - - static constexpr webui::ResourcePath kAdditionalResources[] = { - // Add WebUI version of the CCA browser proxy. - {"src/js/browser_proxy/browser_proxy.js", IDR_CAMERA_WEBUI_BROWSER_PROXY}, - - // Add mojom-lite files under expected paths. - {"src/js/mojo/camera_intent.mojom-lite.js", - IDR_CAMERA_CAMERA_INTENT_MOJOM_LITE_JS}, - {"src/js/mojo/image_capture.mojom-lite.js", - IDR_CAMERA_IMAGE_CAPTURE_MOJOM_LITE_JS}, - {"src/js/mojo/camera_common.mojom-lite.js", - IDR_CAMERA_CAMERA_COMMON_MOJOM_LITE_JS}, - {"src/js/mojo/camera_metadata.mojom-lite.js", - IDR_CAMERA_CAMERA_METADATA_MOJOM_LITE_JS}, - {"src/js/mojo/camera_metadata_tags.mojom-lite.js", - IDR_CAMERA_CAMERA_METADATA_TAGS_MOJOM_LITE_JS}, - {"src/js/mojo/camera_app.mojom-lite.js", IDR_CAMERA_APP_MOJOM_LITE_JS}, - {"src/js/mojo/mojo_bindings_lite.js", IDR_MOJO_MOJO_BINDINGS_LITE_JS}, - - // Add System Web App resources. - {"pwa.html", IDR_PWA_HTML}, - }; - webui::AddResourcePathsBulk(source, kAdditionalResources); - - source->UseStringsJs(); - - return source; -} - -} // namespace - -/////////////////////////////////////////////////////////////////////////////// -// -// CameraUI -// -/////////////////////////////////////////////////////////////////////////////// - -CameraUI::CameraUI(content::WebUI* web_ui) : ui::MojoWebUIController(web_ui) { - Profile* profile = Profile::FromWebUI(web_ui); - - // Set up the data source. - content::WebUIDataSource* source = CreateCameraUIHTMLSource(); - content::WebUIDataSource::Add(profile, source); -} - -CameraUI::~CameraUI() = default; - -// static -bool CameraUI::IsEnabled() { - return web_app::SystemWebAppManager::IsAppEnabled( - web_app::SystemAppType::CAMERA); -} - -} // namespace chromeos diff --git a/chromium/chrome/browser/ui/webui/chromeos/camera/camera_ui.h b/chromium/chrome/browser/ui/webui/chromeos/camera/camera_ui.h deleted file mode 100644 index 31dabca4e5e..00000000000 --- a/chromium/chrome/browser/ui/webui/chromeos/camera/camera_ui.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2019 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 CHROME_BROWSER_UI_WEBUI_CHROMEOS_CAMERA_CAMERA_UI_H_ -#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_CAMERA_CAMERA_UI_H_ - -#include "base/macros.h" -#include "ui/webui/mojo_web_ui_controller.h" - -namespace chromeos { - -class CameraUI : public ui::MojoWebUIController { - public: - explicit CameraUI(content::WebUI* web_ui); - ~CameraUI() override; - - // True when the Camera as a System Web App flag is true. - static bool IsEnabled(); - - private: - DISALLOW_COPY_AND_ASSIGN(CameraUI); -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_CAMERA_CAMERA_UI_H_ diff --git a/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer.mojom b/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer.mojom index e679865fb55..72e63a90a51 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer.mojom +++ b/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer.mojom @@ -25,10 +25,15 @@ interface PageHandler { // If a user cancels the installation without starting it at all, this should // be called so that metrics can be recorded. CancelBeforeStart(); - // The page normally is displayed in a dialog. Call this to close the dialog. - // chrome.send('dialogClose') should not be used, which could kill the page - // handler before previous mojom calls have been run. - Close(); + // This is called when the web page is "closed", and the dialog (or whatever) + // hosting it should also be closed. This can happen as a result of + // Page::RequestClose() being called, or it can happen spontaneously (e.g. + // user clicking cancel on the page or installation finished). + // + // Note that the web page should not use something like + // chrome.send('dialogClose'), which could kill the page handler before + // previous mojom calls have been run. + OnPageClosed(); // Fetches the amount of free disk space, the result is sent via // OnAmountOfFreeDiskSpace. RequestAmountOfFreeDiskSpace(); @@ -54,4 +59,7 @@ interface Page { OnAmountOfFreeDiskSpace(array<crostini.mojom.DiskSliderTick> ticks, int8 default_index, bool is_low_space_available); + // Informs the page that it should be closed. The page should respond with + // PageHandler::OnPageClosed() to indicate it is ready to be closed. + RequestClose(); }; diff --git a/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_dialog.cc index b3f75d222e5..28c41a9a9af 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_dialog.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_dialog.cc @@ -4,10 +4,13 @@ #include "chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_dialog.h" +#include "ash/public/cpp/shelf_types.h" +#include "ash/public/cpp/window_properties.h" #include "base/bind_helpers.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/chromeos/crostini/crostini_features.h" #include "chrome/browser/chromeos/crostini/crostini_manager.h" +#include "chrome/browser/chromeos/crostini/crostini_shelf_utils.h" #include "chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_ui.h" #include "chrome/common/webui_url_constants.h" #include "ui/base/ui_base_types.h" @@ -75,6 +78,10 @@ bool CrostiniInstallerDialog::ShouldCloseDialogOnEscape() const { void CrostiniInstallerDialog::AdjustWidgetInitParams( views::Widget::InitParams* params) { params->z_order = ui::ZOrderLevel::kNormal; + + const ash::ShelfID shelf_id(crostini::kCrostiniInstallerShelfId); + params->init_properties_container.SetProperty(ash::kShelfIDKey, + shelf_id.Serialize()); } bool CrostiniInstallerDialog::CanCloseDialog() const { @@ -82,7 +89,14 @@ bool CrostiniInstallerDialog::CanCloseDialog() const { // closing logic, we should find a more general solution. // Disallow closing without WebUI consent. - return installer_ui_ == nullptr || installer_ui_->can_close(); + // + // Note that while the function name |CanCloseDialog| does not indicate the + // intend to close the dialog, but it is indeed only called when we are + // closing it, so requesting closing the page here is appropriate. One might + // think we should actually do all of this in |OnDialogCloseRequested| + // instead, but unfortunately that function is called after the web content is + // closed. + return installer_ui_ == nullptr || installer_ui_->RequestClosePage(); } void CrostiniInstallerDialog::OnDialogShown(content::WebUI* webui) { diff --git a/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_page_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_page_handler.cc index 0bd746d7079..306b66c00bd 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_page_handler.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_page_handler.cc @@ -29,11 +29,11 @@ CrostiniInstallerPageHandler::CrostiniInstallerPageHandler( mojo::PendingReceiver<chromeos::crostini_installer::mojom::PageHandler> pending_page_handler, mojo::PendingRemote<chromeos::crostini_installer::mojom::Page> pending_page, - base::OnceClosure close_dialog_callback) + base::OnceClosure on_page_closed) : installer_ui_delegate_{installer_ui_delegate}, receiver_{this, std::move(pending_page_handler)}, page_{std::move(pending_page)}, - close_dialog_callback_{std::move(close_dialog_callback)} {} + on_page_closed_{std::move(on_page_closed)} {} CrostiniInstallerPageHandler::~CrostiniInstallerPageHandler() = default; @@ -43,9 +43,7 @@ void CrostiniInstallerPageHandler::Install(int64_t disk_size_bytes, if (base::FeatureList::IsEnabled(chromeos::features::kCrostiniDiskResizing)) { options.disk_size_bytes = disk_size_bytes; } - if (base::FeatureList::IsEnabled(chromeos::features::kCrostiniUsername)) { - options.container_username = username; - } + options.container_username = username; installer_ui_delegate_->Install( std::move(options), base::BindRepeating(&CrostiniInstallerPageHandler::OnProgressUpdate, @@ -64,9 +62,9 @@ void CrostiniInstallerPageHandler::CancelBeforeStart() { installer_ui_delegate_->CancelBeforeStart(); } -void CrostiniInstallerPageHandler::Close() { - if (close_dialog_callback_) { - std::move(close_dialog_callback_).Run(); +void CrostiniInstallerPageHandler::OnPageClosed() { + if (on_page_closed_) { + std::move(on_page_closed_).Run(); } } @@ -94,6 +92,10 @@ void CrostiniInstallerPageHandler::RequestAmountOfFreeDiskSpace() { weak_ptr_factory_.GetWeakPtr())); } +void CrostiniInstallerPageHandler::RequestClosePage() { + page_->RequestClose(); +} + void CrostiniInstallerPageHandler::OnAmountOfFreeDiskSpace(int64_t free_bytes) { int64_t max_bytes = free_bytes - crostini::disk::kDiskHeadroomBytes; diff --git a/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_page_handler.h b/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_page_handler.h index 94128cd43f6..8794f3de1ba 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_page_handler.h +++ b/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_page_handler.h @@ -30,16 +30,19 @@ class CrostiniInstallerPageHandler pending_page_handler, mojo::PendingRemote<chromeos::crostini_installer::mojom::Page> pending_page, - base::OnceClosure close_dialog_callback); + base::OnceClosure on_page_closed); ~CrostiniInstallerPageHandler() override; // chromeos::crostini_installer::mojom::PageHandler: void Install(int64_t disk_size_bytes, const std::string& username) override; void Cancel() override; void CancelBeforeStart() override; - void Close() override; + void OnPageClosed() override; void RequestAmountOfFreeDiskSpace() override; + // Send a close request to the web page. + void RequestClosePage(); + private: void OnProgressUpdate(crostini::mojom::InstallerState installer_state, double progress_fraction); @@ -50,7 +53,7 @@ class CrostiniInstallerPageHandler crostini::CrostiniInstallerUIDelegate* installer_ui_delegate_; mojo::Receiver<chromeos::crostini_installer::mojom::PageHandler> receiver_; mojo::Remote<chromeos::crostini_installer::mojom::Page> page_; - base::OnceClosure close_dialog_callback_; + base::OnceClosure on_page_closed_; base::WeakPtrFactory<CrostiniInstallerPageHandler> weak_ptr_factory_{this}; diff --git a/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_ui.cc index 47cab7a6f56..0e249a5e3cb 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_ui.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_ui.cc @@ -23,6 +23,7 @@ #include "chromeos/constants/chromeos_features.h" #include "components/strings/grit/components_strings.h" #include "content/public/browser/web_ui_data_source.h" +#include "services/network/public/mojom/content_security_policy.mojom.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/text/bytes_formatting.h" #include "ui/base/webui/web_ui_util.h" @@ -84,6 +85,7 @@ void AddStringResources(content::WebUIDataSource* source) { IDS_CROSTINI_INSTALLER_USERNAME_INVALID_CHARACTERS_ERROR}, {"usernameNotAvailableError", IDS_CROSTINI_INSTALLER_USERNAME_NOT_AVAILABLE_ERROR}, + {"customDiskSizeLabel", IDS_CROSTINI_INSTALLER_CUSTOM_DISK_SIZE_LABEL}, }; AddLocalizedStringsBulk(source, kStrings); @@ -117,6 +119,13 @@ void AddStringResources(content::WebUIDataSource* source) { ui::FormatBytesWithUnits(crostini::disk::kRecommendedDiskSizeBytes, ui::DATA_UNITS_GIBIBYTE, /*show_units=*/true))); + source->AddString( + "recommendedDiskSizeLabel", + l10n_util::GetStringFUTF8( + IDS_CROSTINI_INSTALLER_RECOMMENDED_DISK_SIZE_LABEL, + ui::FormatBytesWithUnits(crostini::disk::kRecommendedDiskSizeBytes, + ui::DATA_UNITS_GIBIBYTE, + /*show_units=*/true))); source->AddString("offlineError", l10n_util::GetStringFUTF8( IDS_CROSTINI_INSTALLER_OFFLINE_ERROR, device_name)); @@ -130,15 +139,13 @@ CrostiniInstallerUI::CrostiniInstallerUI(content::WebUI* web_ui) content::WebUIDataSource* source = content::WebUIDataSource::Create(chrome::kChromeUICrostiniInstallerHost); auto* profile = Profile::FromWebUI(web_ui); - source->OverrideContentSecurityPolicyScriptSrc( + source->OverrideContentSecurityPolicy( + network::mojom::CSPDirectiveName::ScriptSrc, "script-src chrome://resources chrome://test 'self';"); AddStringResources(source); source->AddBoolean( "diskResizingEnabled", base::FeatureList::IsEnabled(chromeos::features::kCrostiniDiskResizing)); - source->AddBoolean( - "crostiniCustomUsername", - base::FeatureList::IsEnabled(chromeos::features::kCrostiniUsername)); source->AddString("defaultContainerUsername", crostini::DefaultContainerUserNameForProfile(profile)); @@ -162,8 +169,13 @@ CrostiniInstallerUI::CrostiniInstallerUI(content::WebUI* web_ui) CrostiniInstallerUI::~CrostiniInstallerUI() = default; -bool CrostiniInstallerUI::can_close() { - return can_close_; +bool CrostiniInstallerUI::RequestClosePage() { + if (page_closed_ || !page_handler_) { + return true; + } + + page_handler_->RequestClosePage(); + return false; } void CrostiniInstallerUI::ClickInstallForTesting() { @@ -200,12 +212,12 @@ void CrostiniInstallerUI::CreatePageHandler( std::move(pending_page_handler), std::move(pending_page), // Using Unretained(this) because |page_handler_| will not out-live // |this|. - base::BindOnce(&CrostiniInstallerUI::OnWebUICloseDialog, + base::BindOnce(&CrostiniInstallerUI::OnPageClosed, base::Unretained(this))); } -void CrostiniInstallerUI::OnWebUICloseDialog() { - can_close_ = true; +void CrostiniInstallerUI::OnPageClosed() { + page_closed_ = true; // CloseDialog() is a no-op if we are not in a dialog (e.g. user // access the page using the URL directly, which is not supported). ui::MojoWebDialogUI::CloseDialog(nullptr); diff --git a/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_ui.h b/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_ui.h index 8f4fee5f139..de78f42ac95 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_ui.h +++ b/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_ui.h @@ -24,7 +24,10 @@ class CrostiniInstallerUI explicit CrostiniInstallerUI(content::WebUI* web_ui); ~CrostiniInstallerUI() override; - bool can_close(); + // Send a close request to the web page. Return true if the page is already + // closed. + bool RequestClosePage(); + void ClickInstallForTesting(); // Instantiates implementor of the mojom::PageHandlerFactory @@ -41,12 +44,12 @@ class CrostiniInstallerUI mojo::PendingReceiver<chromeos::crostini_installer::mojom::PageHandler> pending_page_handler) override; - void OnWebUICloseDialog(); + void OnPageClosed(); std::unique_ptr<CrostiniInstallerPageHandler> page_handler_; mojo::Receiver<chromeos::crostini_installer::mojom::PageHandlerFactory> page_factory_receiver_{this}; - bool can_close_ = false; + bool page_closed_ = false; WEB_UI_CONTROLLER_TYPE_DECL(); diff --git a/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader.mojom b/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader.mojom index 7f01682dc54..94cf4daa863 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader.mojom +++ b/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader.mojom @@ -42,10 +42,15 @@ interface PageHandler { CancelBeforeStart(); // If an upgrade fails, the user may choose to restore a container backup. Restore(); - // The page normally is displayed in a dialog. Call this to close the dialog. - // chrome.send('dialogClose') should not be used, which could kill the page - // handler before previous mojom calls have been run. - Close(); + // This is called when the web page is "closed", and the dialog (or whatever) + // hosting it should also be closed. This can happen as a result of + // Page::RequestClose() being called, or it can happen spontaneously (e.g. + // user clicking cancel on the page or installation finished). + // + // Note that the web page should not use something like + // chrome.send('dialogClose'), which could kill the page handler before + // previous mojom calls have been run. + OnPageClosed(); // Close the dialog and launch the Terminal or other app after a successful // upgrade. Launch(); @@ -81,4 +86,7 @@ interface Page { // After user cancels the upgrade, this is called when the cancellation // finishes. OnCanceled(); + // Informs the page that it should be closed. The page should respond with + // PageHandler::OnPageClosed() to indicate it is ready to be closed. + RequestClose(); }; diff --git a/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_dialog.cc index 11110bd02dc..9860f0058e0 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_dialog.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_dialog.cc @@ -4,8 +4,11 @@ #include "chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_dialog.h" +#include "ash/public/cpp/shelf_types.h" +#include "ash/public/cpp/window_properties.h" #include "base/metrics/histogram_functions.h" #include "chrome/browser/chromeos/crostini/crostini_manager.h" +#include "chrome/browser/chromeos/crostini/crostini_shelf_utils.h" #include "chrome/browser/chromeos/crostini/crostini_simple_types.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_ui.h" @@ -35,8 +38,7 @@ void CrostiniUpgraderDialog::Show(base::OnceClosure launch_closure, instance = new CrostiniUpgraderDialog(std::move(launch_closure), only_run_launch_closure_on_restart); instance->ShowSystemDialog(); - base::UmaHistogramEnumeration(crostini::kUpgradeDialogEventHistogram, - crostini::UpgradeDialogEvent::kDialogShown); + EmitUpgradeDialogEventHistogram(crostini::UpgradeDialogEvent::kDialogShown); } CrostiniUpgraderDialog::CrostiniUpgraderDialog( @@ -67,6 +69,10 @@ bool CrostiniUpgraderDialog::ShouldCloseDialogOnEscape() const { void CrostiniUpgraderDialog::AdjustWidgetInitParams( views::Widget::InitParams* params) { params->z_order = ui::ZOrderLevel::kNormal; + + const ash::ShelfID shelf_id(crostini::kCrostiniUpgraderShelfId); + params->init_properties_container.SetProperty(ash::kShelfIDKey, + shelf_id.Serialize()); } void CrostiniUpgraderDialog::SetDeletionClosureForTesting( @@ -83,7 +89,14 @@ bool CrostiniUpgraderDialog::CanCloseDialog() const { return true; } // Disallow closing without WebUI consent. - return upgrader_ui_ == nullptr || upgrader_ui_->can_close(); + // + // Note that while the function name |CanCloseDialog| does not indicate the + // intend to close the dialog, but it is indeed only called when we are + // closing it, so requesting closing the page here is appropriate. One might + // think we should actually do all of this in |OnDialogCloseRequested| + // instead, but unfortunately that function is called after the web content is + // closed. + return upgrader_ui_ == nullptr || upgrader_ui_->RequestClosePage(); } namespace { @@ -101,7 +114,7 @@ void RunLaunchClosure(base::WeakPtr<crostini::CrostiniManager> crostini_manager, return; } crostini_manager->RestartCrostini( - crostini::kCrostiniDefaultVmName, crostini::kCrostiniDefaultContainerName, + crostini::ContainerId::GetDefault(), base::BindOnce( [](base::OnceClosure launch_closure, crostini::CrostiniResult result) { @@ -122,9 +135,7 @@ void CrostiniUpgraderDialog::OnDialogShown(content::WebUI* webui) { crostini::CrostiniManager::GetForProfile(Profile::FromWebUI(webui)); crostini_manager->SetCrostiniDialogStatus(crostini::DialogType::UPGRADER, true); - crostini_manager->UpgradePromptShown( - crostini::ContainerId(crostini::kCrostiniDefaultVmName, - crostini::kCrostiniDefaultContainerName)); + crostini_manager->UpgradePromptShown(crostini::ContainerId::GetDefault()); upgrader_ui_ = static_cast<CrostiniUpgraderUI*>(webui->GetController()); upgrader_ui_->set_launch_callback(base::BindOnce( @@ -143,4 +154,9 @@ void CrostiniUpgraderDialog::OnCloseContents(content::WebContents* source, return SystemWebDialogDelegate::OnCloseContents(source, out_close_dialog); } +void CrostiniUpgraderDialog::EmitUpgradeDialogEventHistogram( + crostini::UpgradeDialogEvent event) { + base::UmaHistogramEnumeration("Crostini.UpgradeDialogEvent", event); +} + } // namespace chromeos diff --git a/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_dialog.h b/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_dialog.h index 7f1a2195063..356b0403b47 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_dialog.h +++ b/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_dialog.h @@ -5,6 +5,7 @@ #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_CROSTINI_UPGRADER_CROSTINI_UPGRADER_DIALOG_H_ #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_CROSTINI_UPGRADER_CROSTINI_UPGRADER_DIALOG_H_ +#include "chrome/browser/chromeos/crostini/crostini_simple_types.h" #include "chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.h" namespace chromeos { @@ -25,6 +26,9 @@ class CrostiniUpgraderDialog : public SystemWebDialogDelegate { void SetDeletionClosureForTesting( base::OnceClosure deletion_closure_for_testing); + static void EmitUpgradeDialogEventHistogram( + crostini::UpgradeDialogEvent event); + private: explicit CrostiniUpgraderDialog(base::OnceClosure launch_closure, bool only_run_launch_closure_on_restart); diff --git a/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_dialog_browsertest.cc b/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_dialog_browsertest.cc index 48239a18d87..d1c08e6622b 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_dialog_browsertest.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_dialog_browsertest.cc @@ -90,8 +90,7 @@ class CrostiniUpgraderDialogBrowserTest : public CrostiniDialogBrowserTest { os_release.set_id("debian"); os_release.set_version_id("9"); auto container_id = crostini::DefaultContainerId(); - crostini_manager()->SetContainerOsRelease( - container_id.vm_name, container_id.container_name, os_release); + crostini_manager()->SetContainerOsRelease(container_id, os_release); } const std::string& app_id() const { return app_id_; } @@ -132,7 +131,7 @@ IN_PROC_BROWSER_TEST_F(CrostiniUpgraderDialogBrowserTest, ShowsOnAppLaunch) { ExpectNoDialog(); histogram_tester.ExpectUniqueSample( - crostini::kUpgradeDialogEventHistogram, + "Crostini.UpgradeDialogEvent", static_cast<base::HistogramBase::Sample>( crostini::UpgradeDialogEvent::kDialogShown), 1); diff --git a/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_page_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_page_handler.cc index fd13e73652c..b16643e8411 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_page_handler.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_page_handler.cc @@ -22,13 +22,13 @@ CrostiniUpgraderPageHandler::CrostiniUpgraderPageHandler( mojo::PendingReceiver<chromeos::crostini_upgrader::mojom::PageHandler> pending_page_handler, mojo::PendingRemote<chromeos::crostini_upgrader::mojom::Page> pending_page, - base::OnceClosure close_dialog_callback, + base::OnceClosure on_page_closed, base::OnceCallback<void(bool)> launch_callback) : web_contents_{web_contents}, upgrader_ui_delegate_{upgrader_ui_delegate}, receiver_{this, std::move(pending_page_handler)}, page_{std::move(pending_page)}, - close_dialog_callback_{std::move(close_dialog_callback)}, + on_page_closed_{std::move(on_page_closed)}, launch_callback_{std::move(launch_callback)} { upgrader_ui_delegate_->AddObserver(this); } @@ -49,14 +49,17 @@ void CrostiniUpgraderPageHandler::OnBackupMaybeStarted(bool did_start) { Redisplay(); } +// Send a close request to the web page. +void CrostiniUpgraderPageHandler::RequestClosePage() { + page_->RequestClose(); +} + void CrostiniUpgraderPageHandler::Backup(bool show_file_chooser) { Redisplay(); - base::UmaHistogramEnumeration(crostini::kUpgradeDialogEventHistogram, - crostini::UpgradeDialogEvent::kDidBackup); - upgrader_ui_delegate_->Backup( - crostini::ContainerId(crostini::kCrostiniDefaultVmName, - crostini::kCrostiniDefaultContainerName), - show_file_chooser, web_contents_); + CrostiniUpgraderDialog::EmitUpgradeDialogEventHistogram( + crostini::UpgradeDialogEvent::kDidBackup); + upgrader_ui_delegate_->Backup(crostini::ContainerId::GetDefault(), + show_file_chooser, web_contents_); } void CrostiniUpgraderPageHandler::StartPrechecks() { @@ -65,24 +68,20 @@ void CrostiniUpgraderPageHandler::StartPrechecks() { void CrostiniUpgraderPageHandler::Upgrade() { Redisplay(); - upgrader_ui_delegate_->Upgrade( - crostini::ContainerId(crostini::kCrostiniDefaultVmName, - crostini::kCrostiniDefaultContainerName)); + upgrader_ui_delegate_->Upgrade(crostini::ContainerId::GetDefault()); } void CrostiniUpgraderPageHandler::Restore() { Redisplay(); - base::UmaHistogramEnumeration(crostini::kUpgradeDialogEventHistogram, - crostini::UpgradeDialogEvent::kDidRestore); - upgrader_ui_delegate_->Restore( - crostini::ContainerId(crostini::kCrostiniDefaultVmName, - crostini::kCrostiniDefaultContainerName), - web_contents_); + CrostiniUpgraderDialog::EmitUpgradeDialogEventHistogram( + crostini::UpgradeDialogEvent::kDidRestore); + upgrader_ui_delegate_->Restore(crostini::ContainerId::GetDefault(), + web_contents_); } void CrostiniUpgraderPageHandler::Cancel() { - base::UmaHistogramEnumeration(crostini::kUpgradeDialogEventHistogram, - crostini::UpgradeDialogEvent::kUpgradeCanceled); + CrostiniUpgraderDialog::EmitUpgradeDialogEventHistogram( + crostini::UpgradeDialogEvent::kUpgradeCanceled); upgrader_ui_delegate_->Cancel(); } @@ -91,8 +90,8 @@ void CrostiniUpgraderPageHandler::Launch() { } void CrostiniUpgraderPageHandler::CancelBeforeStart() { - base::UmaHistogramEnumeration(crostini::kUpgradeDialogEventHistogram, - crostini::UpgradeDialogEvent::kNotStarted); + CrostiniUpgraderDialog::EmitUpgradeDialogEventHistogram( + crostini::UpgradeDialogEvent::kNotStarted); restart_required_ = false; upgrader_ui_delegate_->CancelBeforeStart(); if (launch_callback_) { @@ -101,12 +100,12 @@ void CrostiniUpgraderPageHandler::CancelBeforeStart() { } } -void CrostiniUpgraderPageHandler::Close() { +void CrostiniUpgraderPageHandler::OnPageClosed() { if (launch_callback_) { Launch(); } - if (close_dialog_callback_) { - std::move(close_dialog_callback_).Run(); + if (on_page_closed_) { + std::move(on_page_closed_).Run(); } } @@ -117,15 +116,15 @@ void CrostiniUpgraderPageHandler::OnUpgradeProgress( void CrostiniUpgraderPageHandler::OnUpgradeSucceeded() { Redisplay(); - base::UmaHistogramEnumeration(crostini::kUpgradeDialogEventHistogram, - crostini::UpgradeDialogEvent::kUpgradeSuccess); + CrostiniUpgraderDialog::EmitUpgradeDialogEventHistogram( + crostini::UpgradeDialogEvent::kUpgradeSuccess); page_->OnUpgradeSucceeded(); } void CrostiniUpgraderPageHandler::OnUpgradeFailed() { Redisplay(); - base::UmaHistogramEnumeration(crostini::kUpgradeDialogEventHistogram, - crostini::UpgradeDialogEvent::kUpgradeFailed); + CrostiniUpgraderDialog::EmitUpgradeDialogEventHistogram( + crostini::UpgradeDialogEvent::kUpgradeFailed); page_->OnUpgradeFailed(); } @@ -135,15 +134,15 @@ void CrostiniUpgraderPageHandler::OnBackupProgress(int percent) { void CrostiniUpgraderPageHandler::OnBackupSucceeded(bool was_cancelled) { Redisplay(); - base::UmaHistogramEnumeration(crostini::kUpgradeDialogEventHistogram, - crostini::UpgradeDialogEvent::kBackupSucceeded); + CrostiniUpgraderDialog::EmitUpgradeDialogEventHistogram( + crostini::UpgradeDialogEvent::kBackupSucceeded); page_->OnBackupSucceeded(was_cancelled); } void CrostiniUpgraderPageHandler::OnBackupFailed() { Redisplay(); - base::UmaHistogramEnumeration(crostini::kUpgradeDialogEventHistogram, - crostini::UpgradeDialogEvent::kBackupFailed); + CrostiniUpgraderDialog::EmitUpgradeDialogEventHistogram( + crostini::UpgradeDialogEvent::kBackupFailed); page_->OnBackupFailed(); } @@ -158,16 +157,15 @@ void CrostiniUpgraderPageHandler::OnRestoreProgress(int percent) { void CrostiniUpgraderPageHandler::OnRestoreSucceeded() { Redisplay(); - base::UmaHistogramEnumeration( - crostini::kUpgradeDialogEventHistogram, + CrostiniUpgraderDialog::EmitUpgradeDialogEventHistogram( crostini::UpgradeDialogEvent::kRestoreSucceeded); page_->OnRestoreSucceeded(); } void CrostiniUpgraderPageHandler::OnRestoreFailed() { Redisplay(); - base::UmaHistogramEnumeration(crostini::kUpgradeDialogEventHistogram, - crostini::UpgradeDialogEvent::kRestoreFailed); + CrostiniUpgraderDialog::EmitUpgradeDialogEventHistogram( + crostini::UpgradeDialogEvent::kRestoreFailed); page_->OnRestoreFailed(); } diff --git a/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_page_handler.h b/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_page_handler.h index edf98821f6e..01c0ac74c9c 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_page_handler.h +++ b/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_page_handler.h @@ -32,10 +32,13 @@ class CrostiniUpgraderPageHandler pending_page_handler, mojo::PendingRemote<chromeos::crostini_upgrader::mojom::Page> pending_page, - base::OnceClosure close_dialog_callback, + base::OnceClosure on_page_closed, base::OnceCallback<void(bool)> launch_callback); ~CrostiniUpgraderPageHandler() override; + // Send a close request to the web page. + void RequestClosePage(); + // chromeos::crostini_upgrader::mojom::PageHandler: void Backup(bool show_file_chooser) override; void StartPrechecks() override; @@ -43,7 +46,7 @@ class CrostiniUpgraderPageHandler void Restore() override; void Cancel() override; void CancelBeforeStart() override; - void Close() override; + void OnPageClosed() override; void Launch() override; // CrostiniUpgraderUIObserver @@ -68,7 +71,7 @@ class CrostiniUpgraderPageHandler crostini::CrostiniUpgraderUIDelegate* upgrader_ui_delegate_; // Not owned. mojo::Receiver<chromeos::crostini_upgrader::mojom::PageHandler> receiver_; mojo::Remote<chromeos::crostini_upgrader::mojom::Page> page_; - base::OnceClosure close_dialog_callback_; + base::OnceClosure on_page_closed_; base::OnceCallback<void(bool)> launch_callback_; // Will we need to restart the container as part of launch_callback? // |restart_required_| is true unless the user cancels before starting the diff --git a/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_ui.cc index 8d195a25f0e..a9dbb7b64c1 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_ui.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_ui.cc @@ -21,6 +21,7 @@ #include "chromeos/constants/chromeos_features.h" #include "components/strings/grit/components_strings.h" #include "content/public/browser/web_ui_data_source.h" +#include "services/network/public/mojom/content_security_policy.mojom.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/text/bytes_formatting.h" #include "ui/base/webui/web_ui_util.h" @@ -97,7 +98,8 @@ CrostiniUpgraderUI::CrostiniUpgraderUI(content::WebUI* web_ui) : ui::MojoWebDialogUI{web_ui} { content::WebUIDataSource* source = content::WebUIDataSource::Create(chrome::kChromeUICrostiniUpgraderHost); - source->OverrideContentSecurityPolicyScriptSrc( + source->OverrideContentSecurityPolicy( + network::mojom::CSPDirectiveName::ScriptSrc, "script-src chrome://resources chrome://test 'self';"); AddStringResources(source); @@ -122,6 +124,15 @@ CrostiniUpgraderUI::CrostiniUpgraderUI(content::WebUI* web_ui) CrostiniUpgraderUI::~CrostiniUpgraderUI() = default; +bool CrostiniUpgraderUI::RequestClosePage() { + if (page_closed_ || !page_handler_) { + return true; + } + + page_handler_->RequestClosePage(); + return false; +} + void CrostiniUpgraderUI::BindInterface( mojo::PendingReceiver< chromeos::crostini_upgrader::mojom::PageHandlerFactory> @@ -145,13 +156,12 @@ void CrostiniUpgraderUI::CreatePageHandler( std::move(pending_page_handler), std::move(pending_page), // Using Unretained(this) because |page_handler_| will not out-live // |this|. - base::BindOnce(&CrostiniUpgraderUI::OnWebUICloseDialog, - base::Unretained(this)), + base::BindOnce(&CrostiniUpgraderUI::OnPageClosed, base::Unretained(this)), std::move(launch_callback_)); } -void CrostiniUpgraderUI::OnWebUICloseDialog() { - can_close_ = true; +void CrostiniUpgraderUI::OnPageClosed() { + page_closed_ = true; // CloseDialog() is a no-op if we are not in a dialog (e.g. user // access the page using the URL directly, which is not supported). ui::MojoWebDialogUI::CloseDialog(nullptr); diff --git a/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_ui.h b/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_ui.h index 6126283abd6..13c5605c215 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_ui.h +++ b/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_ui.h @@ -27,7 +27,10 @@ class CrostiniUpgraderUI explicit CrostiniUpgraderUI(content::WebUI* web_ui); ~CrostiniUpgraderUI() override; - bool can_close() { return can_close_; } + // Send a close request to the web page. Return true if the page is already + // closed. + bool RequestClosePage(); + void set_launch_callback(base::OnceCallback<void(bool)>(launch_callback)) { launch_callback_ = std::move(launch_callback); } @@ -47,7 +50,7 @@ class CrostiniUpgraderUI mojo::PendingReceiver<chromeos::crostini_upgrader::mojom::PageHandler> pending_page_handler) override; - void OnWebUICloseDialog(); + void OnPageClosed(); std::unique_ptr<CrostiniUpgraderPageHandler> page_handler_; mojo::Receiver<chromeos::crostini_upgrader::mojom::PageHandlerFactory> @@ -56,7 +59,7 @@ class CrostiniUpgraderUI // Not owned. Passed to |page_handler_| base::OnceCallback<void(bool)> launch_callback_; - bool can_close_ = false; + bool page_closed_ = false; WEB_UI_CONTROLLER_TYPE_DECL(); diff --git a/chromium/chrome/browser/ui/webui/chromeos/cryptohome_web_ui_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/cryptohome_web_ui_handler.cc index 0611cef1174..6a9d0c38941 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/cryptohome_web_ui_handler.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/cryptohome_web_ui_handler.cc @@ -5,7 +5,6 @@ #include "chrome/browser/ui/webui/chromeos/cryptohome_web_ui_handler.h" #include "base/bind.h" -#include "base/task/post_task.h" #include "base/values.h" #include "chromeos/dbus/cryptohome/cryptohome_client.h" #include "chromeos/dbus/dbus_thread_manager.h" @@ -40,9 +39,8 @@ void CryptohomeWebUIHandler::OnPageLoaded(const base::ListValue* args) { cryptohome_client->Pkcs11IsTpmTokenReady( GetCryptohomeBoolCallback("pkcs11-is-tpm-token-ready")); - base::PostTaskAndReplyWithResult( - FROM_HERE, {BrowserThread::IO}, - base::BindOnce(&crypto::IsTPMTokenReady, base::Closure()), + content::GetIOThreadTaskRunner({})->PostTaskAndReplyWithResult( + FROM_HERE, base::BindOnce(&crypto::IsTPMTokenReady, base::Closure()), base::BindOnce(&CryptohomeWebUIHandler::DidGetNSSUtilInfoOnUIThread, weak_ptr_factory_.GetWeakPtr())); } diff --git a/chromium/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc index 4333fb4d05c..3345379fa27 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc @@ -22,6 +22,7 @@ #include "base/macros.h" #include "base/memory/weak_ptr.h" #include "base/path_service.h" +#include "base/process/launch.h" #include "base/strings/pattern.h" #include "base/strings/strcat.h" #include "base/strings/stringprintf.h" @@ -217,6 +218,14 @@ std::pair<ino_t, base::ListValue> GetServiceLogContents( return {inode, std::move(result)}; } +bool GetDeveloperMode() { + std::string output; + if (!base::GetAppOutput({"/usr/bin/crossystem", "cros_debug"}, &output)) { + return false; + } + return output == "1"; +} + class DriveInternalsWebUIHandler; void ZipLogs(Profile* profile, @@ -263,6 +272,19 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler { base::BindRepeating(&DriveInternalsWebUIHandler::OnPeriodicUpdate, weak_ptr_factory_.GetWeakPtr())); web_ui()->RegisterMessageCallback( + "setVerboseLoggingEnabled", + base::BindRepeating( + &DriveInternalsWebUIHandler::SetVerboseLoggingEnabled, + weak_ptr_factory_.GetWeakPtr())); + web_ui()->RegisterMessageCallback( + "enableTracing", + base::BindRepeating(&DriveInternalsWebUIHandler::SetTracingEnabled, + weak_ptr_factory_.GetWeakPtr(), true)); + web_ui()->RegisterMessageCallback( + "disableTracing", + base::BindRepeating(&DriveInternalsWebUIHandler::SetTracingEnabled, + weak_ptr_factory_.GetWeakPtr(), false)); + web_ui()->RegisterMessageCallback( "restartDrive", base::BindRepeating(&DriveInternalsWebUIHandler::RestartDrive, weak_ptr_factory_.GetWeakPtr())); @@ -276,6 +298,38 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler { weak_ptr_factory_.GetWeakPtr())); } + void RegisterDeveloperMessages() { + CHECK(developer_mode_); + web_ui()->RegisterMessageCallback( + "setStartupArguments", + base::BindRepeating(&DriveInternalsWebUIHandler::SetStartupArguments, + weak_ptr_factory_.GetWeakPtr())); + web_ui()->RegisterMessageCallback( + "enableNetworking", + base::BindRepeating(&DriveInternalsWebUIHandler::SetNetworkingEnabled, + weak_ptr_factory_.GetWeakPtr(), true)); + web_ui()->RegisterMessageCallback( + "disableNetworking", + base::BindRepeating(&DriveInternalsWebUIHandler::SetNetworkingEnabled, + weak_ptr_factory_.GetWeakPtr(), false)); + web_ui()->RegisterMessageCallback( + "enableForcePauseSyncing", + base::BindRepeating(&DriveInternalsWebUIHandler::ForcePauseSyncing, + weak_ptr_factory_.GetWeakPtr(), true)); + web_ui()->RegisterMessageCallback( + "disableForcePauseSyncing", + base::BindRepeating(&DriveInternalsWebUIHandler::ForcePauseSyncing, + weak_ptr_factory_.GetWeakPtr(), false)); + web_ui()->RegisterMessageCallback( + "dumpAccountSettings", + base::BindRepeating(&DriveInternalsWebUIHandler::DumpAccountSettings, + weak_ptr_factory_.GetWeakPtr())); + web_ui()->RegisterMessageCallback( + "loadAccountSettings", + base::BindRepeating(&DriveInternalsWebUIHandler::LoadAccountSettings, + weak_ptr_factory_.GetWeakPtr())); + } + // Called when the page is first loaded. void OnPageLoaded(const base::ListValue* args) { AllowJavascript(); @@ -410,6 +464,17 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler { void UpdateDriveDebugSection() { SetSectionEnabled("drive-debug", true); + bool verbose_logging_enabled = profile()->GetPrefs()->GetBoolean( + drive::prefs::kDriveFsEnableVerboseLogging); + MaybeCallJavascript("updateVerboseLogging", + base::Value(verbose_logging_enabled)); + + base::ThreadPool::PostTaskAndReplyWithResult( + FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE}, + base::BindOnce(GetDeveloperMode), + base::BindOnce(&DriveInternalsWebUIHandler::OnGetDeveloperMode, + weak_ptr_factory_.GetWeakPtr())); + // Propagate the amount of local free space in bytes. base::FilePath home_path; if (base::PathService::Get(base::DIR_HOME, &home_path)) { @@ -423,6 +488,33 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler { } } + // Called when GetDeveloperMode() is complete. + void OnGetDeveloperMode(bool enabled) { + developer_mode_ = enabled; + if (!enabled) { + return; + } + + RegisterDeveloperMessages(); + + // Get the startup arguments. + drive::DriveIntegrationService* integration_service = + GetIntegrationService(); + if (integration_service) { + integration_service->GetStartupArguments( + base::BindOnce(&DriveInternalsWebUIHandler::OnGetStartupArguments, + weak_ptr_factory_.GetWeakPtr())); + } + } + + // Called when GetStartupArguments() is complete. + void OnGetStartupArguments(const std::string& arguments) { + DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(developer_mode_); + MaybeCallJavascript("updateStartupArguments", base::Value(arguments)); + SetSectionEnabled("developer-mode-controls", true); + } + // Called when AmountOfFreeDiskSpace() is complete. void OnGetFreeDiskSpace(int64_t free_space) { DCHECK_CURRENTLY_ON(BrowserThread::UI); @@ -440,6 +532,7 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler { drive::prefs::kDisableDriveOverCellular, drive::prefs::kDriveFsWasLaunchedAtLeastOnce, drive::prefs::kDriveFsPinnedMigrated, + drive::prefs::kDriveFsEnableVerboseLogging, }; PrefService* pref_service = profile()->GetPrefs(); @@ -552,6 +645,105 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler { std::move(response.second)); } + // Called when the "Verbose Logging" checkbox on the page is changed. + void SetVerboseLoggingEnabled(const base::ListValue* args) { + AllowJavascript(); + drive::DriveIntegrationService* integration_service = + GetIntegrationService(); + if (!integration_service) { + return; + } + + if (args->GetList().size() == 1 && args->GetList()[0].is_bool()) { + bool enabled = args->GetList()[0].GetBool(); + profile()->GetPrefs()->SetBoolean( + drive::prefs::kDriveFsEnableVerboseLogging, enabled); + RestartDrive(nullptr); + } + } + + // Called when the "Startup Arguments" field on the page is submitted. + void SetStartupArguments(const base::ListValue* args) { + AllowJavascript(); + + CHECK(developer_mode_); + + if (args->GetList().size() < 1 || !args->GetList()[0].is_string()) { + OnSetStartupArguments(false); + return; + } + + drive::DriveIntegrationService* integration_service = + GetIntegrationService(); + if (!integration_service) { + OnSetStartupArguments(false); + return; + } + + integration_service->SetStartupArguments( + args->GetList()[0].GetString(), + base::BindOnce(&DriveInternalsWebUIHandler::OnSetStartupArguments, + weak_ptr_factory_.GetWeakPtr())); + } + + void OnSetStartupArguments(bool success) { + DCHECK_CURRENTLY_ON(BrowserThread::UI); + DCHECK(developer_mode_); + if (success) { + RestartDrive(nullptr); + } + MaybeCallJavascript("updateStartupArgumentsStatus", base::Value(success)); + } + + void SetTracingEnabled(bool enabled, const base::ListValue* args) { + AllowJavascript(); + drive::DriveIntegrationService* integration_service = + GetIntegrationService(); + if (integration_service) { + integration_service->SetTracingEnabled(enabled); + } + } + + void SetNetworkingEnabled(bool enabled, const base::ListValue* args) { + AllowJavascript(); + CHECK(developer_mode_); + drive::DriveIntegrationService* integration_service = + GetIntegrationService(); + if (integration_service) { + integration_service->SetNetworkingEnabled(enabled); + } + } + + void ForcePauseSyncing(bool enabled, const base::ListValue* args) { + AllowJavascript(); + CHECK(developer_mode_); + drive::DriveIntegrationService* integration_service = + GetIntegrationService(); + if (integration_service) { + integration_service->ForcePauseSyncing(enabled); + } + } + + void DumpAccountSettings(const base::ListValue* args) { + AllowJavascript(); + CHECK(developer_mode_); + drive::DriveIntegrationService* integration_service = + GetIntegrationService(); + if (integration_service) { + integration_service->DumpAccountSettings(); + } + } + + void LoadAccountSettings(const base::ListValue* args) { + AllowJavascript(); + CHECK(developer_mode_); + drive::DriveIntegrationService* integration_service = + GetIntegrationService(); + if (integration_service) { + integration_service->LoadAccountSettings(); + } + } + // Called when the "Restart Drive" button on the page is pressed. void RestartDrive(const base::ListValue* args) { AllowJavascript(); @@ -619,6 +811,9 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler { // Service log file is being parsed. bool service_log_file_is_processing_ = false; + // Whether developer mode is enabled for debug commands. + bool developer_mode_ = false; + base::WeakPtrFactory<DriveInternalsWebUIHandler> weak_ptr_factory_{this}; DISALLOW_COPY_AND_ASSIGN(DriveInternalsWebUIHandler); }; @@ -695,8 +890,7 @@ class LogsZipper : public download::AllDownloadItemNotifier::Observer { void CleanUp() { base::ThreadPool::PostTask( FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT}, - base::BindOnce(base::IgnoreResult(&base::DeleteFile), zip_path_, - false)); + base::BindOnce(base::GetDeleteFileCallback(), zip_path_)); download_notifier_.reset(); if (drive_internals_) { drive_internals_->OnZipDone(); diff --git a/chromium/chrome/browser/ui/webui/chromeos/edu_account_login_handler_chromeos.cc b/chromium/chrome/browser/ui/webui/chromeos/edu_account_login_handler_chromeos.cc index 99f1d0742c2..a0611a51052 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/edu_account_login_handler_chromeos.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/edu_account_login_handler_chromeos.cc @@ -18,7 +18,7 @@ #include "chrome/browser/profiles/profile_key.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/signin/identity_manager_factory.h" -#include "chrome/browser/ui/webui/signin/inline_login_handler_dialog_chromeos.h" +#include "chrome/browser/ui/webui/signin/inline_login_dialog_chromeos.h" #include "chromeos/components/account_manager/account_manager.h" #include "chromeos/components/account_manager/account_manager_factory.h" #include "components/image_fetcher/core/image_fetcher_service.h" @@ -193,11 +193,11 @@ void EduAccountLoginHandler::HandleUpdateEduCoexistenceFlowResult( const base::Value::ConstListView& args_list = args->GetList(); CHECK_EQ(args_list.size(), 1u); int result = args_list[0].GetInt(); - DCHECK(result <= static_cast<int>(InlineLoginHandlerDialogChromeOS:: - EduCoexistenceFlowResult::kMaxValue)); - InlineLoginHandlerDialogChromeOS::UpdateEduCoexistenceFlowResult( - static_cast<InlineLoginHandlerDialogChromeOS::EduCoexistenceFlowResult>( - result)); + DCHECK(result <= + static_cast<int>( + InlineLoginDialogChromeOS::EduCoexistenceFlowResult::kMaxValue)); + InlineLoginDialogChromeOS::UpdateEduCoexistenceFlowResult( + static_cast<InlineLoginDialogChromeOS::EduCoexistenceFlowResult>(result)); } void EduAccountLoginHandler::FetchFamilyMembers() { diff --git a/chromium/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.cc index 93318f93336..40bff048c98 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.cc @@ -91,11 +91,10 @@ class DeviceEmulatorMessageHandler::BluetoothObserver void DeviceEmulatorMessageHandler::BluetoothObserver::DeviceAdded( const dbus::ObjectPath& object_path) { - std::unique_ptr<base::DictionaryValue> device = - owner_->GetDeviceInfo(object_path); + base::Value device = owner_->GetDeviceInfo(object_path); // Request to add the device to the view's list of devices. - owner_->FireWebUIListener("bluetooth-device-added", *device); + owner_->FireWebUIListener("bluetooth-device-added", device); } void DeviceEmulatorMessageHandler::BluetoothObserver::DevicePropertyChanged( @@ -223,42 +222,40 @@ void DeviceEmulatorMessageHandler::HandleRequestBluetoothInfo( fake_bluetooth_device_client_->GetDevicesForAdapter( dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath)); - auto devices = std::make_unique<base::ListValue>(); // Get each device's properties. - for (const dbus::ObjectPath& path : paths) { - std::unique_ptr<base::DictionaryValue> device = GetDeviceInfo(path); - devices->Append(std::move(device)); - } + base::Value devices(base::Value::Type::LIST); + for (const dbus::ObjectPath& path : paths) + devices.Append(GetDeviceInfo(path)); - std::unique_ptr<base::ListValue> predefined_devices = + base::Value predefined_devices = fake_bluetooth_device_client_->GetBluetoothDevicesAsDictionaries(); - auto pairing_method_options = std::make_unique<base::ListValue>(); - pairing_method_options->AppendString( + base::Value pairing_method_options(base::Value::Type::LIST); + pairing_method_options.Append( bluez::FakeBluetoothDeviceClient::kPairingMethodNone); - pairing_method_options->AppendString( + pairing_method_options.Append( bluez::FakeBluetoothDeviceClient::kPairingMethodPinCode); - pairing_method_options->AppendString( + pairing_method_options.Append( bluez::FakeBluetoothDeviceClient::kPairingMethodPassKey); - auto pairing_action_options = std::make_unique<base::ListValue>(); - pairing_action_options->AppendString( + base::Value pairing_action_options(base::Value::Type::LIST); + pairing_action_options.Append( bluez::FakeBluetoothDeviceClient::kPairingActionDisplay); - pairing_action_options->AppendString( + pairing_action_options.Append( bluez::FakeBluetoothDeviceClient::kPairingActionRequest); - pairing_action_options->AppendString( + pairing_action_options.Append( bluez::FakeBluetoothDeviceClient::kPairingActionConfirmation); - pairing_action_options->AppendString( + pairing_action_options.Append( bluez::FakeBluetoothDeviceClient::kPairingActionFail); - auto info = std::make_unique<base::DictionaryValue>(); - info->Set("predefined_devices", std::move(predefined_devices)); - info->Set("devices", std::move(devices)); - info->Set("pairing_method_options", std::move(pairing_method_options)); - info->Set("pairing_action_options", std::move(pairing_action_options)); + base::Value info(base::Value::Type::DICTIONARY); + info.SetKey("predefined_devices", std::move(predefined_devices)); + info.SetKey("devices", std::move(devices)); + info.SetKey("pairing_method_options", std::move(pairing_method_options)); + info.SetKey("pairing_action_options", std::move(pairing_action_options)); // Send the list of devices to the view. - FireWebUIListener("bluetooth-info-updated", *info); + FireWebUIListener("bluetooth-info-updated", info); } void DeviceEmulatorMessageHandler::HandleRequestBluetoothPair( @@ -579,39 +576,36 @@ std::string DeviceEmulatorMessageHandler::CreateBluetoothDeviceFromListValue( return props.device_path; } -std::unique_ptr<base::DictionaryValue> -DeviceEmulatorMessageHandler::GetDeviceInfo( +base::Value DeviceEmulatorMessageHandler::GetDeviceInfo( const dbus::ObjectPath& object_path) { // Get the device's properties. bluez::FakeBluetoothDeviceClient::Properties* props = fake_bluetooth_device_client_->GetProperties(object_path); - std::unique_ptr<base::DictionaryValue> device(new base::DictionaryValue()); - std::unique_ptr<base::ListValue> uuids(new base::ListValue); bluez::FakeBluetoothDeviceClient::SimulatedPairingOptions* options = fake_bluetooth_device_client_->GetPairingOptions(object_path); - device->SetString("path", object_path.value()); - device->SetString("name", props->name.value()); - device->SetString("alias", props->alias.value()); - device->SetString("address", props->address.value()); + base::Value device(base::Value::Type::DICTIONARY); + device.SetStringKey("path", object_path.value()); + device.SetStringKey("name", props->name.value()); + device.SetStringKey("alias", props->alias.value()); + device.SetStringKey("address", props->address.value()); if (options) { - device->SetString("pairingMethod", options->pairing_method); - device->SetString("pairingAuthToken", options->pairing_auth_token); - device->SetString("pairingAction", options->pairing_action); + device.SetStringKey("pairingMethod", options->pairing_method); + device.SetStringKey("pairingAuthToken", options->pairing_auth_token); + device.SetStringKey("pairingAction", options->pairing_action); } else { - device->SetString("pairingMethod", ""); - device->SetString("pairingAuthToken", ""); - device->SetString("pairingAction", ""); - } - device->SetInteger("classValue", props->bluetooth_class.value()); - device->SetBoolean("isTrusted", props->trusted.value()); - device->SetBoolean("incoming", false); - - for (const std::string& uuid : props->uuids.value()) { - uuids->AppendString(uuid); + device.SetStringKey("pairingMethod", ""); + device.SetStringKey("pairingAuthToken", ""); + device.SetStringKey("pairingAction", ""); } - - device->Set("uuids", std::move(uuids)); + device.SetIntKey("classValue", props->bluetooth_class.value()); + device.SetBoolKey("isTrusted", props->trusted.value()); + device.SetBoolKey("incoming", false); + + base::Value uuids(base::Value::Type::LIST); + for (const std::string& uuid : props->uuids.value()) + uuids.Append(uuid); + device.SetKey("uuids", std::move(uuids)); return device; } diff --git a/chromium/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.h b/chromium/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.h index 3afd435d960..9a59d740741 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.h +++ b/chromium/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.h @@ -16,7 +16,6 @@ #include "device/bluetooth/bluetooth_adapter.h" namespace base { -class DictionaryValue; class ListValue; } // namespace base @@ -118,8 +117,7 @@ class DeviceEmulatorMessageHandler : // Builds a dictionary with each key representing a property of the device // with path |object_path|. - std::unique_ptr<base::DictionaryValue> GetDeviceInfo( - const dbus::ObjectPath& object_path); + base::Value GetDeviceInfo(const dbus::ObjectPath& object_path); void ConnectToBluetoothDevice(const std::string& address); diff --git a/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/OWNERS b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/OWNERS index e7edf2e630f..a8183f48709 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/OWNERS +++ b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/OWNERS @@ -1,2 +1 @@ -olsen@chromium.org rsorokin@chromium.org diff --git a/chromium/chrome/browser/ui/webui/chromeos/internet_config_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/internet_config_dialog.cc index 43f44e8bbe9..af861bf1ef7 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/internet_config_dialog.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/internet_config_dialog.cc @@ -19,6 +19,7 @@ #include "components/strings/grit/components_strings.h" #include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui_data_source.h" +#include "ui/wm/core/shadow_types.h" namespace chromeos { @@ -114,6 +115,13 @@ const std::string& InternetConfigDialog::Id() { return dialog_id_; } +void InternetConfigDialog::AdjustWidgetInitParams( + views::Widget::InitParams* params) { + params->type = views::Widget::InitParams::Type::TYPE_WINDOW_FRAMELESS; + params->shadow_type = views::Widget::InitParams::ShadowType::kDrop; + params->shadow_elevation = wm::kShadowElevationActiveWindow; +} + void InternetConfigDialog::GetDialogSize(gfx::Size* size) const { const NetworkState* network = network_id_.empty() ? nullptr diff --git a/chromium/chrome/browser/ui/webui/chromeos/internet_config_dialog.h b/chromium/chrome/browser/ui/webui/chromeos/internet_config_dialog.h index f3d3dfcaf9f..4888ee69139 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/internet_config_dialog.h +++ b/chromium/chrome/browser/ui/webui/chromeos/internet_config_dialog.h @@ -25,6 +25,9 @@ class InternetConfigDialog : public SystemWebDialogDelegate { // Shows a network configuration dialog for a new network of |network_type|. static void ShowDialogForNetworkType(const std::string& network_type); + // SystemWebDialogDelegate + void AdjustWidgetInitParams(views::Widget::InitParams* params) override; + protected: // |dialog_id| provides a pre-calculated identifier for the dialog based on // the network type and the network id. diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/DEPS b/chromium/chrome/browser/ui/webui/chromeos/login/DEPS index 4994ed97905..6e2f237df12 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/DEPS +++ b/chromium/chrome/browser/ui/webui/chromeos/login/DEPS @@ -1,5 +1,4 @@ specific_include_rules = { - # TODO(mash): Fix. https://crbug.com/856375. "core_oobe_handler\.cc": [ "+ash/shell.h", ], @@ -8,8 +7,6 @@ specific_include_rules = { "+ash/shell.h", ], "oobe_display_chooser_unittest.cc": [ - # TODO(mash) Use a non-ash test ui::InputDeviceEventObserver - # environment for testing this. "+ash/display/display_configuration_controller.h", "+ash/shell.h", "+ash/test/ash_test_base.h", diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.cc index f2882ee9ec6..1b1f25b9582 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.cc @@ -4,19 +4,9 @@ #include "chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.h" -#include <memory> - -#include "base/bind.h" -#include "chrome/browser/chromeos/authpolicy/authpolicy_helper.h" -#include "chrome/browser/chromeos/login/oobe_screen.h" -#include "chrome/browser/chromeos/login/ui/login_display_host.h" #include "chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h" -#include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" #include "chrome/grit/generated_resources.h" -#include "chromeos/login/auth/key.h" #include "components/login/localized_values_builder.h" -#include "components/user_manager/known_user.h" -#include "ui/base/l10n/l10n_util.h" namespace chromeos { @@ -25,24 +15,19 @@ namespace { constexpr char kUsernameKey[] = "username"; constexpr char kErrorKey[] = "error"; -// Possible error states of the Active Directory password change screen. Must be -// in the same order as ACTIVE_DIRECTORY_PASSWORD_CHANGE_ERROR_STATE enum -// values. -enum class ActiveDirectoryPasswordChangeErrorState { - WRONG_OLD_PASSWORD = 0, - NEW_PASSWORD_REJECTED = 1, -}; - } // namespace +constexpr StaticOobeScreenId ActiveDirectoryPasswordChangeView::kScreenId; + ActiveDirectoryPasswordChangeScreenHandler:: ActiveDirectoryPasswordChangeScreenHandler( JSCallsContainer* js_calls_container, CoreOobeView* core_oobe_view) - : BaseScreenHandler(OobeScreen::SCREEN_ACTIVE_DIRECTORY_PASSWORD_CHANGE, - js_calls_container), - authpolicy_login_helper_(std::make_unique<AuthPolicyHelper>()), - core_oobe_view_(core_oobe_view) {} + : BaseScreenHandler(kScreenId, js_calls_container), + core_oobe_view_(core_oobe_view) { + set_user_acted_method_path( + "login.ActiveDirectoryPasswordChangeScreen.userActed"); +} ActiveDirectoryPasswordChangeScreenHandler:: ~ActiveDirectoryPasswordChangeScreenHandler() {} @@ -55,86 +40,41 @@ void ActiveDirectoryPasswordChangeScreenHandler::DeclareLocalizedValues( void ActiveDirectoryPasswordChangeScreenHandler::Initialize() {} void ActiveDirectoryPasswordChangeScreenHandler::RegisterMessages() { - AddCallback("completeActiveDirectoryPasswordChange", + BaseScreenHandler::RegisterMessages(); + AddCallback("login.ActiveDirectoryPasswordChangeScreen.changePassword", &ActiveDirectoryPasswordChangeScreenHandler::HandleComplete); - AddCallback("cancelActiveDirectoryPasswordChange", - &ActiveDirectoryPasswordChangeScreenHandler::HandleCancel); } -void ActiveDirectoryPasswordChangeScreenHandler::HandleComplete( +void ActiveDirectoryPasswordChangeScreenHandler::Show( const std::string& username, - const std::string& old_password, - const std::string& new_password) { - authpolicy_login_helper_->AuthenticateUser( - username, std::string() /* object_guid */, - old_password + "\n" + new_password + "\n" + new_password, - base::BindOnce( - &ActiveDirectoryPasswordChangeScreenHandler::OnAuthFinished, - weak_factory_.GetWeakPtr(), username, Key(new_password))); + int error) { + base::DictionaryValue data; + data.SetString(kUsernameKey, username); + data.SetInteger(kErrorKey, error); + ShowScreenWithData(kScreenId, &data); } -void ActiveDirectoryPasswordChangeScreenHandler::HandleCancel() { - authpolicy_login_helper_->CancelRequestsAndRestart(); +void ActiveDirectoryPasswordChangeScreenHandler::Bind( + ActiveDirectoryPasswordChangeScreen* screen) { + screen_ = screen; + BaseScreenHandler::SetBaseScreen(screen_); } -void ActiveDirectoryPasswordChangeScreenHandler::ShowScreen( - const std::string& username) { - base::DictionaryValue data; - data.SetString(kUsernameKey, username); - ShowScreenWithData(OobeScreen::SCREEN_ACTIVE_DIRECTORY_PASSWORD_CHANGE, - &data); +void ActiveDirectoryPasswordChangeScreenHandler::Unbind() { + screen_ = nullptr; + BaseScreenHandler::SetBaseScreen(nullptr); } -void ActiveDirectoryPasswordChangeScreenHandler::ShowScreenWithError( - int error) { - base::DictionaryValue data; - data.SetInteger(kErrorKey, error); - ShowScreenWithData(OobeScreen::SCREEN_ACTIVE_DIRECTORY_PASSWORD_CHANGE, - &data); +void ActiveDirectoryPasswordChangeScreenHandler::ShowSignInError( + const std::string& error_text) { + core_oobe_view_->ShowSignInError(0, error_text, std::string(), + HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); } -void ActiveDirectoryPasswordChangeScreenHandler::OnAuthFinished( - const std::string& username, - const Key& key, - authpolicy::ErrorType error, - const authpolicy::ActiveDirectoryAccountInfo& account_info) { - switch (error) { - case authpolicy::ERROR_NONE: { - DCHECK(account_info.has_account_id() && - !account_info.account_id().empty()); - const AccountId account_id = user_manager::known_user::GetAccountId( - username, account_info.account_id(), AccountType::ACTIVE_DIRECTORY); - DCHECK(LoginDisplayHost::default_host()); - LoginDisplayHost::default_host()->SetDisplayAndGivenName( - account_info.display_name(), account_info.given_name()); - UserContext user_context( - user_manager::UserType::USER_TYPE_ACTIVE_DIRECTORY, account_id); - user_context.SetKey(key); - user_context.SetAuthFlow(UserContext::AUTH_FLOW_ACTIVE_DIRECTORY); - user_context.SetIsUsingOAuth(false); - LoginDisplayHost::default_host()->CompleteLogin(user_context); - break; - } - case authpolicy::ERROR_BAD_PASSWORD: - ShowScreenWithError(static_cast<int>( - ActiveDirectoryPasswordChangeErrorState::WRONG_OLD_PASSWORD)); - break; - case authpolicy::ERROR_PASSWORD_REJECTED: - ShowScreenWithError(static_cast<int>( - ActiveDirectoryPasswordChangeErrorState::NEW_PASSWORD_REJECTED)); - core_oobe_view_->ShowSignInError( - 0, - l10n_util::GetStringUTF8( - IDS_AD_PASSWORD_CHANGE_NEW_PASSWORD_REJECTED_LONG_ERROR), - std::string(), HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); - break; - default: - NOTREACHED() << "Unhandled error: " << error; - ShowScreen(username); - core_oobe_view_->ShowSignInError( - 0, l10n_util::GetStringUTF8(IDS_AD_AUTH_UNKNOWN_ERROR), std::string(), - HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); - } +void ActiveDirectoryPasswordChangeScreenHandler::HandleComplete( + const std::string& old_password, + const std::string& new_password) { + screen_->ChangePassword(old_password, new_password); } } // namespace chromeos diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.h index 8768175e503..33e5eb4d230 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.h +++ b/chromium/chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.h @@ -8,21 +8,42 @@ #include <string> #include "base/macros.h" -#include "chrome/browser/chromeos/authpolicy/authpolicy_helper.h" +#include "chrome/browser/chromeos/login/screens/active_directory_password_change_screen.h" #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h" -namespace authpolicy { -class ActiveDirectoryAccountInfo; -} - namespace chromeos { +class ActiveDirectoryPasswordChangeScreen; class CoreOobeView; -class Key; -// A class that handles WebUI hooks in Active Directory password change screen. -class ActiveDirectoryPasswordChangeScreenHandler : public BaseScreenHandler { +// Interface for dependency injection between +// ActiveDirectoryPasswordChangeScreen and its WebUI representation. +class ActiveDirectoryPasswordChangeView { + public: + constexpr static StaticOobeScreenId kScreenId{"ad-password-change"}; + + virtual ~ActiveDirectoryPasswordChangeView() {} + + // Shows the contents of the screen. + virtual void Show(const std::string& username, int error) = 0; + + // Binds |screen| to the view. + virtual void Bind(ActiveDirectoryPasswordChangeScreen* screen) = 0; + + // Unbinds the screen from the view. + virtual void Unbind() = 0; + + // Shows sign-in error bubble. + virtual void ShowSignInError(const std::string& error_text) = 0; +}; + +// A class that handles WebUI hooks in Active Directory password change screen. +class ActiveDirectoryPasswordChangeScreenHandler + : public ActiveDirectoryPasswordChangeView, + public BaseScreenHandler { public: + using TView = ActiveDirectoryPasswordChangeView; + ActiveDirectoryPasswordChangeScreenHandler( JSCallsContainer* js_calls_container, CoreOobeView* core_oobe_view); @@ -36,37 +57,22 @@ class ActiveDirectoryPasswordChangeScreenHandler : public BaseScreenHandler { // WebUIMessageHandler implementation: void RegisterMessages() override; - // WebUI message handlers. - void HandleComplete(const std::string& username, - const std::string& old_password, - const std::string& new_password); - void HandleCancel(); - - // Shows the password change screen for |username|. - void ShowScreen(const std::string& username); + // ActiveDirectoryPasswordChangeView: + void Show(const std::string& username, int error) override; + void Bind(ActiveDirectoryPasswordChangeScreen* screen) override; + void Unbind() override; + void ShowSignInError(const std::string& error_text) override; private: - // Shows the screen with the error message corresponding to |error|. - void ShowScreenWithError(int error); - - // Callback called by AuthPolicyHelper::AuthenticateUser with results and - // error code. (see AuthPolicyHelper::AuthenticateUser) - void OnAuthFinished( - const std::string& username, - const Key& key, - authpolicy::ErrorType error, - const authpolicy::ActiveDirectoryAccountInfo& account_info); + // WebUI message handlers. + void HandleComplete(const std::string& old_password, + const std::string& new_password); - // Helper to call AuthPolicyClient and cancel calls if needed. Used to change - // password on the Active Directory server. - std::unique_ptr<AuthPolicyHelper> authpolicy_login_helper_; + ActiveDirectoryPasswordChangeScreen* screen_ = nullptr; // Non-owned. Used to display signin error. CoreOobeView* core_oobe_view_ = nullptr; - base::WeakPtrFactory<ActiveDirectoryPasswordChangeScreenHandler> - weak_factory_{this}; - DISALLOW_COPY_AND_ASSIGN(ActiveDirectoryPasswordChangeScreenHandler); }; diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.cc index 30bfa1f347e..fd90616362b 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.cc @@ -136,7 +136,7 @@ void AssistantOptInFlowScreenHandler::RegisterMessages() { &AssistantOptInFlowScreenHandler::HandleVoiceMatchScreenShown); AddCallback("login.AssistantOptInFlowScreen.GetMoreScreen.screenShown", &AssistantOptInFlowScreenHandler::HandleGetMoreScreenShown); - AddCallback("login.AssistantOptInFlowScreen.LoadingScreen.timeout", + AddCallback("login.AssistantOptInFlowScreen.timeout", &AssistantOptInFlowScreenHandler::HandleLoadingTimeout); AddCallback("login.AssistantOptInFlowScreen.flowFinished", &AssistantOptInFlowScreenHandler::HandleFlowFinished); @@ -519,7 +519,8 @@ void AssistantOptInFlowScreenHandler::HandleVoiceMatchScreenUserAction( // No need to disable hotword for retrain flow since user has a model. prefs->SetBoolean(assistant::prefs::kAssistantHotwordEnabled, false); } - StopSpeakerIdEnrollment(); + if (voice_match_enrollment_started_) + StopSpeakerIdEnrollment(); ShowNextScreen(); } else if (action == kRecordPressed) { if (!prefs->GetBoolean(assistant::prefs::kAssistantHotwordEnabled)) { diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.h index 2839eb2f64b..cff23bb6dcd 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.h +++ b/chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.h @@ -9,7 +9,6 @@ #include <string> #include <utility> -#include "ash/public/cpp/assistant/assistant_settings.h" #include "ash/public/cpp/assistant/assistant_setup.h" #include "ash/public/cpp/assistant/assistant_state.h" #include "base/macros.h" @@ -42,7 +41,6 @@ class AssistantOptInFlowScreenView { DISALLOW_COPY_AND_ASSIGN(AssistantOptInFlowScreenView); }; -// TODO(updowndota): Refactor to reuse AssistantOptInHandler methods. class AssistantOptInFlowScreenHandler : public BaseScreenHandler, public AssistantOptInFlowScreenView, diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/base_webui_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/base_webui_handler.cc index cff1e165eaa..7d650badd2d 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/base_webui_handler.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/login/base_webui_handler.cc @@ -41,8 +41,6 @@ void BaseWebUIHandler::ShowScreen(OobeScreenId screen) { void BaseWebUIHandler::ShowScreenWithData(OobeScreenId screen, const base::DictionaryValue* data) { - if (!web_ui()) - return; base::DictionaryValue screen_params; screen_params.SetString("id", screen.name); if (data) { diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc index b4a51961a0f..7071f8ae0f9 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc @@ -19,8 +19,6 @@ #include "build/branding_buildflags.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process_platform_part.h" -#include "chrome/browser/chromeos/accessibility/accessibility_manager.h" -#include "chrome/browser/chromeos/accessibility/magnification_manager.h" #include "chrome/browser/chromeos/login/configuration_keys.h" #include "chrome/browser/chromeos/login/demo_mode/demo_session.h" #include "chrome/browser/chromeos/login/demo_mode/demo_setup_controller.h" @@ -29,8 +27,7 @@ #include "chrome/browser/chromeos/login/screens/reset_screen.h" #include "chrome/browser/chromeos/login/ui/login_display_host.h" #include "chrome/browser/chromeos/login/wizard_controller.h" -#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" -#include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" +#include "chrome/browser/chromeos/policy/enrollment_requisition_manager.h" #include "chrome/browser/chromeos/system/input_device_settings.h" #include "chrome/browser/chromeos/system/timezone_resolver_manager.h" #include "chrome/browser/lifetime/application_lifetime.h" @@ -64,24 +61,9 @@ namespace chromeos { namespace { -bool IsRemoraRequisition() { - policy::DeviceCloudPolicyManagerChromeOS* policy_manager = - g_browser_process->platform_part() - ->browser_policy_connector_chromeos() - ->GetDeviceCloudPolicyManager(); - return policy_manager && policy_manager->IsRemoraRequisition(); -} - void LaunchResetScreen() { - // Don't recreate WizardController if it already exists. - WizardController* const wizard_controller = - WizardController::default_controller(); - if (wizard_controller && !wizard_controller->login_screen_started()) { - wizard_controller->AdvanceToScreen(ResetView::kScreenId); - } else { - DCHECK(LoginDisplayHost::default_host()); - LoginDisplayHost::default_host()->StartWizard(ResetView::kScreenId); - } + DCHECK(LoginDisplayHost::default_host()); + LoginDisplayHost::default_host()->StartWizard(ResetView::kScreenId); } } // namespace @@ -91,11 +73,6 @@ void LaunchResetScreen() { CoreOobeHandler::CoreOobeHandler(JSCallsContainer* js_calls_container) : BaseWebUIHandler(js_calls_container), version_info_updater_(this) { DCHECK(js_calls_container); - AccessibilityManager* accessibility_manager = AccessibilityManager::Get(); - CHECK(accessibility_manager); - accessibility_subscription_ = accessibility_manager->RegisterCallback( - base::Bind(&CoreOobeHandler::OnAccessibilityStatusChanged, - base::Unretained(this))); ash::TabletMode::Get()->AddObserver(this); @@ -118,17 +95,6 @@ void CoreOobeHandler::DeclareLocalizedValues( builder->Add("productName", IDS_SHORT_PRODUCT_NAME); builder->Add("learnMore", IDS_LEARN_MORE); - // OOBE accessibility options menu strings shown on each screen. - builder->Add("accessibilityLink", IDS_OOBE_ACCESSIBILITY_LINK); - builder->Add("spokenFeedbackOption", IDS_OOBE_SPOKEN_FEEDBACK_OPTION); - builder->Add("selectToSpeakOption", IDS_OOBE_SELECT_TO_SPEAK_OPTION); - builder->Add("largeCursorOption", IDS_OOBE_LARGE_CURSOR_OPTION); - builder->Add("highContrastOption", IDS_OOBE_HIGH_CONTRAST_MODE_OPTION); - builder->Add("screenMagnifierOption", IDS_OOBE_SCREEN_MAGNIFIER_OPTION); - builder->Add("dockedMagnifierOption", IDS_OOBE_DOCKED_MAGNIFIER_OPTION); - builder->Add("virtualKeyboardOption", IDS_OOBE_VIRTUAL_KEYBOARD_OPTION); - builder->Add("closeAccessibilityMenu", IDS_OOBE_CLOSE_ACCESSIBILITY_MENU); - // Strings for the device requisition prompt. builder->Add("deviceRequisitionPromptCancel", IDS_ENTERPRISE_DEVICE_REQUISITION_PROMPT_CANCEL); @@ -161,7 +127,6 @@ void CoreOobeHandler::DeclareLocalizedValues( } void CoreOobeHandler::Initialize() { - UpdateA11yState(); UpdateOobeUIVisibility(); #if BUILDFLAG(GOOGLE_CHROME_BRANDING) version_info_updater_.StartUpdate(true); @@ -188,18 +153,6 @@ void CoreOobeHandler::RegisterMessages() { &CoreOobeHandler::HandleSkipUpdateEnrollAfterEula); AddCallback("updateCurrentScreen", &CoreOobeHandler::HandleUpdateCurrentScreen); - AddCallback("enableHighContrast", &CoreOobeHandler::HandleEnableHighContrast); - AddCallback("enableLargeCursor", &CoreOobeHandler::HandleEnableLargeCursor); - AddCallback("enableVirtualKeyboard", - &CoreOobeHandler::HandleEnableVirtualKeyboard); - AddCallback("enableScreenMagnifier", - &CoreOobeHandler::HandleEnableScreenMagnifier); - AddCallback("enableSpokenFeedback", - &CoreOobeHandler::HandleEnableSpokenFeedback); - AddCallback("enableSelectToSpeak", - &CoreOobeHandler::HandleEnableSelectToSpeak); - AddCallback("enableDockedMagnifier", - &CoreOobeHandler::HandleEnableDockedMagnifier); AddCallback("setDeviceRequisition", &CoreOobeHandler::HandleSetDeviceRequisition); AddCallback("skipToLoginForTesting", @@ -234,38 +187,20 @@ void CoreOobeHandler::ShowSignInError( help_link_text, static_cast<int>(help_topic_id)); } -void CoreOobeHandler::ShowTpmError() { - CallJS("cr.ui.Oobe.showTpmError"); -} - void CoreOobeHandler::ShowDeviceResetScreen() { LaunchResetScreen(); } void CoreOobeHandler::ShowEnableDebuggingScreen() { - // Don't recreate WizardController if it already exists. - WizardController* wizard_controller = WizardController::default_controller(); - if (wizard_controller && !wizard_controller->login_screen_started()) { - wizard_controller->AdvanceToScreen(EnableDebuggingScreenView::kScreenId); - } + DCHECK(LoginDisplayHost::default_host()); + LoginDisplayHost::default_host()->StartWizard( + EnableDebuggingScreenView::kScreenId); } void CoreOobeHandler::ShowEnableAdbSideloadingScreen() { - // Don't recreate WizardController if it already exists. - WizardController* wizard_controller = WizardController::default_controller(); - if (wizard_controller && !wizard_controller->login_screen_started()) { - wizard_controller->AdvanceToScreen( - EnableAdbSideloadingScreenView::kScreenId); - } else { - DCHECK(LoginDisplayHost::default_host()); - LoginDisplayHost::default_host()->StartWizard( - EnableAdbSideloadingScreenView::kScreenId); - } -} - -void CoreOobeHandler::ShowActiveDirectoryPasswordChangeScreen( - const std::string& username) { - CallJS("cr.ui.Oobe.showActiveDirectoryPasswordChangeScreen", username); + DCHECK(LoginDisplayHost::default_host()); + LoginDisplayHost::default_host()->StartWizard( + EnableAdbSideloadingScreenView::kScreenId); } void CoreOobeHandler::ShowSignInUI(const std::string& email) { @@ -284,19 +219,6 @@ void CoreOobeHandler::RefocusCurrentPod() { CallJS("cr.ui.Oobe.refocusCurrentPod"); } -void CoreOobeHandler::ShowPasswordChangedScreen(bool show_password_error, - const std::string& email) { - CallJS("cr.ui.Oobe.showPasswordChangedScreen", show_password_error, email); -} - -void CoreOobeHandler::SetUsageStats(bool checked) { - CallJS("cr.ui.Oobe.setUsageStats", checked); -} - -void CoreOobeHandler::SetTpmPassword(const std::string& tpm_password) { - CallJS("cr.ui.Oobe.setTpmPassword", tpm_password); -} - void CoreOobeHandler::ClearErrors() { CallJS("cr.ui.Oobe.clearErrors"); } @@ -324,7 +246,8 @@ void CoreOobeHandler::SetShelfHeight(int height) { void CoreOobeHandler::HandleInitialized() { // TODO(crbug.com/1082670): Remove excessive logging after investigation. - LOG(ERROR) << "CoreOobeHandler::HandleInitialized"; + LOG(ERROR) << "1082670 : CoreOobeHandler::HandleInitialized"; + GetOobeUI()->InitializeHandlers(); AllowJavascript(); } @@ -344,44 +267,6 @@ void CoreOobeHandler::HandleUpdateCurrentScreen( screen == EulaView::kScreenId); } -void CoreOobeHandler::HandleEnableHighContrast(bool enabled) { - AccessibilityManager::Get()->EnableHighContrast(enabled); -} - -void CoreOobeHandler::HandleEnableLargeCursor(bool enabled) { - AccessibilityManager::Get()->EnableLargeCursor(enabled); -} - -void CoreOobeHandler::HandleEnableVirtualKeyboard(bool enabled) { - AccessibilityManager::Get()->EnableVirtualKeyboard(enabled); -} - -void CoreOobeHandler::HandleEnableScreenMagnifier(bool enabled) { - DCHECK(MagnificationManager::Get()); - MagnificationManager::Get()->SetMagnifierEnabled(enabled); -} - -void CoreOobeHandler::HandleEnableSpokenFeedback(bool /* enabled */) { - // Checkbox is initialized on page init and updates when spoken feedback - // setting is changed so just toggle spoken feedback here. - AccessibilityManager::Get()->EnableSpokenFeedback( - !AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); -} - -void CoreOobeHandler::HandleEnableSelectToSpeak(bool /* enabled */) { - // Checkbox is initialized on page init and updates when Select to Speak - // setting is changed so just toggle Select to Speak here. - AccessibilityManager::Get()->SetSelectToSpeakEnabled( - !AccessibilityManager::Get()->IsSelectToSpeakEnabled()); -} - -void CoreOobeHandler::HandleEnableDockedMagnifier(bool enabled) { - // Checkbox is initialized on page init and updates when the docked magnifier - // setting is changed so just toggle Select to Speak here. - DCHECK(MagnificationManager::Get()); - MagnificationManager::Get()->SetDockedMagnifierEnabled(enabled); -} - void CoreOobeHandler::HandleHideOobeDialog() { if (LoginDisplayHost::default_host()) LoginDisplayHost::default_host()->HideOobeDialog(); @@ -389,13 +274,11 @@ void CoreOobeHandler::HandleHideOobeDialog() { void CoreOobeHandler::HandleSetDeviceRequisition( const std::string& requisition) { - policy::BrowserPolicyConnectorChromeOS* connector = - g_browser_process->platform_part()->browser_policy_connector_chromeos(); std::string initial_requisition = - connector->GetDeviceCloudPolicyManager()->GetDeviceRequisition(); - connector->GetDeviceCloudPolicyManager()->SetDeviceRequisition(requisition); + policy::EnrollmentRequisitionManager::GetDeviceRequisition(); + policy::EnrollmentRequisitionManager::SetDeviceRequisition(requisition); - if (IsRemoraRequisition()) { + if (policy::EnrollmentRequisitionManager::IsRemoraRequisition()) { // CfM devices default to static timezone. g_browser_process->local_state()->SetInteger( prefs::kResolveDeviceTimezoneByGeolocationMethod, @@ -405,19 +288,21 @@ void CoreOobeHandler::HandleSetDeviceRequisition( // Exit Chrome to force the restart as soon as a new requisition is set. if (initial_requisition != - connector->GetDeviceCloudPolicyManager()->GetDeviceRequisition()) { + policy::EnrollmentRequisitionManager::GetDeviceRequisition()) { chrome::AttemptRestart(); } } void CoreOobeHandler::HandleSkipToLoginForTesting() { - if (WizardController::default_controller()) + WizardController* controller = WizardController::default_controller(); + if (controller && controller->is_initialized()) WizardController::default_controller()->SkipToLoginForTesting(); } void CoreOobeHandler::HandleSkipToUpdateForTesting() { - if (WizardController::default_controller()) - WizardController::default_controller()->SkipToUpdateForTesting(); + WizardController* controller = WizardController::default_controller(); + if (controller && controller->is_initialized()) + controller->SkipToUpdateForTesting(); } void CoreOobeHandler::HandleToggleResetScreen() { @@ -464,26 +349,6 @@ void CoreOobeHandler::ForwardAccelerator(std::string accelerator_name) { CallJS("cr.ui.Oobe.handleAccelerator", accelerator_name); } -void CoreOobeHandler::UpdateA11yState() { - base::DictionaryValue a11y_info; - a11y_info.SetBoolean("highContrastEnabled", - AccessibilityManager::Get()->IsHighContrastEnabled()); - a11y_info.SetBoolean("largeCursorEnabled", - AccessibilityManager::Get()->IsLargeCursorEnabled()); - a11y_info.SetBoolean("spokenFeedbackEnabled", - AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); - a11y_info.SetBoolean("selectToSpeakEnabled", - AccessibilityManager::Get()->IsSelectToSpeakEnabled()); - DCHECK(MagnificationManager::Get()); - a11y_info.SetBoolean("screenMagnifierEnabled", - MagnificationManager::Get()->IsMagnifierEnabled()); - a11y_info.SetBoolean("dockedMagnifierEnabled", - MagnificationManager::Get()->IsDockedMagnifierEnabled()); - a11y_info.SetBoolean("virtualKeyboardEnabled", - AccessibilityManager::Get()->IsVirtualKeyboardEnabled()); - CallJS("cr.ui.Oobe.refreshA11yInfo", a11y_info); -} - void CoreOobeHandler::UpdateOobeUIVisibility() { const std::string& display = GetOobeUI()->display_type(); bool has_api_keys_configured = google_apis::HasAPIKeyConfigured() && @@ -529,14 +394,8 @@ void CoreOobeHandler::UpdateLabel(const std::string& id, } void CoreOobeHandler::UpdateDeviceRequisition() { - policy::DeviceCloudPolicyManagerChromeOS* policy_manager = - g_browser_process->platform_part() - ->browser_policy_connector_chromeos() - ->GetDeviceCloudPolicyManager(); - if (policy_manager) { - CallJS("cr.ui.Oobe.updateDeviceRequisition", - policy_manager->GetDeviceRequisition()); - } + CallJS("cr.ui.Oobe.updateDeviceRequisition", + policy::EnrollmentRequisitionManager::GetDeviceRequisition()); } void CoreOobeHandler::UpdateKeyboardState() { @@ -588,14 +447,6 @@ void CoreOobeHandler::OnOobeConfigurationChanged() { CallJS("cr.ui.Oobe.updateOobeConfiguration", configuration); } -void CoreOobeHandler::OnAccessibilityStatusChanged( - const AccessibilityStatusEventDetails& details) { - if (details.notification_type == ACCESSIBILITY_MANAGER_SHUTDOWN) - accessibility_subscription_.reset(); - else - UpdateA11yState(); -} - void CoreOobeHandler::HandleLaunchHelpApp(double help_topic_id) { if (!help_app_.get()) help_app_ = new HelpAppLauncher( diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h index 44940f99887..fc684c7f0a5 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h +++ b/chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h @@ -16,7 +16,6 @@ #include "base/memory/weak_ptr.h" #include "base/optional.h" #include "base/values.h" -#include "chrome/browser/chromeos/accessibility/accessibility_manager.h" #include "chrome/browser/chromeos/login/demo_mode/demo_mode_detector.h" #include "chrome/browser/chromeos/login/help_app_launcher.h" #include "chrome/browser/chromeos/login/oobe_configuration.h" @@ -56,15 +55,10 @@ class CoreOobeView { const std::string& error_text, const std::string& help_link_text, HelpAppLauncher::HelpTopic help_topic_id) = 0; - virtual void ShowTpmError() = 0; virtual void ShowSignInUI(const std::string& email) = 0; virtual void ResetSignInUI(bool force_online) = 0; virtual void ClearUserPodPassword() = 0; virtual void RefocusCurrentPod() = 0; - virtual void ShowPasswordChangedScreen(bool show_password_error, - const std::string& email) = 0; - virtual void SetUsageStats(bool checked) = 0; - virtual void SetTpmPassword(const std::string& tmp_password) = 0; virtual void ClearErrors() = 0; virtual void ReloadContent(const base::DictionaryValue& dictionary) = 0; virtual void ReloadEulaContent(const base::DictionaryValue& dictionary) = 0; @@ -78,8 +72,6 @@ class CoreOobeView { virtual void InitDemoModeDetection() = 0; virtual void StopDemoModeDetection() = 0; virtual void UpdateKeyboardState() = 0; - virtual void ShowActiveDirectoryPasswordChangeScreen( - const std::string& username) = 0; }; // The core handler for Javascript messages related to the "oobe" view. @@ -139,15 +131,10 @@ class CoreOobeHandler : public BaseWebUIHandler, const std::string& error_text, const std::string& help_link_text, HelpAppLauncher::HelpTopic help_topic_id) override; - void ShowTpmError() override; void ShowSignInUI(const std::string& email) override; void ResetSignInUI(bool force_online) override; void ClearUserPodPassword() override; void RefocusCurrentPod() override; - void ShowPasswordChangedScreen(bool show_password_error, - const std::string& email) override; - void SetUsageStats(bool checked) override; - void SetTpmPassword(const std::string& tmp_password) override; void ClearErrors() override; void ReloadContent(const base::DictionaryValue& dictionary) override; void ReloadEulaContent(const base::DictionaryValue& dictionary) override; @@ -158,8 +145,6 @@ class CoreOobeHandler : public BaseWebUIHandler, void ShowDeviceResetScreen() override; void ShowEnableAdbSideloadingScreen() override; void ShowEnableDebuggingScreen() override; - void ShowActiveDirectoryPasswordChangeScreen( - const std::string& username) override; void InitDemoModeDetection() override; void StopDemoModeDetection() override; @@ -173,13 +158,6 @@ class CoreOobeHandler : public BaseWebUIHandler, void OnOobeConfigurationChanged() override; // Handlers for JS WebUI messages. - void HandleEnableLargeCursor(bool enabled); - void HandleEnableHighContrast(bool enabled); - void HandleEnableVirtualKeyboard(bool enabled); - void HandleEnableScreenMagnifier(bool enabled); - void HandleEnableSpokenFeedback(bool /* enabled */); - void HandleEnableSelectToSpeak(bool /* enabled */); - void HandleEnableDockedMagnifier(bool /* enabled */); void HandleHideOobeDialog(); void HandleInitialized(); void HandleSkipUpdateEnrollAfterEula(); @@ -211,9 +189,6 @@ class CoreOobeHandler : public BaseWebUIHandler, // to tab/shift-tab event. void HandleRaiseTabKeyEvent(bool reverse); - // Updates a11y menu state based on the current a11y features state(on/off). - void UpdateA11yState(); - // Calls javascript to sync OOBE UI visibility with show_oobe_ui_. void UpdateOobeUIVisibility(); @@ -226,10 +201,6 @@ class CoreOobeHandler : public BaseWebUIHandler, // Updates client area size based on the primary screen size. void UpdateClientAreaSize(); - // Notification of a change in the accessibility settings. - void OnAccessibilityStatusChanged( - const AccessibilityStatusEventDetails& details); - // True if we should show OOBE instead of login. bool show_oobe_ui_ = false; @@ -239,8 +210,6 @@ class CoreOobeHandler : public BaseWebUIHandler, // Help application used for help dialogs. scoped_refptr<HelpAppLauncher> help_app_; - std::unique_ptr<AccessibilityStatusSubscription> accessibility_subscription_; - DemoModeDetector demo_mode_detector_; mojo::Remote<ash::mojom::CrosDisplayConfigController> cros_display_config_; diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/debug/debug_overlay_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/debug/debug_overlay_handler.cc index 1520461230b..5548ccda6a3 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/debug/debug_overlay_handler.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/login/debug/debug_overlay_handler.cc @@ -12,6 +12,9 @@ #include "base/files/file_util.h" #include "base/path_service.h" #include "base/system/sys_info.h" +#include "base/task/post_task.h" +#include "base/task/task_traits.h" +#include "base/task/thread_pool.h" #include "base/time/time.h" #include "chrome/common/chrome_paths.h" #include "chromeos/constants/chromeos_switches.h" @@ -44,9 +47,10 @@ void RunStoreScreenshotOnTaskRunner( const base::FilePath& screenshot_dir, const std::string& screenshot_name, scoped_refptr<base::RefCountedMemory> png_data) { - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::BindOnce(&StoreScreenshot, screenshot_dir, - screenshot_name, png_data)); + base::ThreadPool::PostTask( + FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT}, + base::BindOnce(&StoreScreenshot, screenshot_dir, screenshot_name, + png_data)); } } // namespace diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/device_disabled_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/device_disabled_screen_handler.cc index a0b5afecfe5..b63e52d4391 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/device_disabled_screen_handler.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/login/device_disabled_screen_handler.cc @@ -20,37 +20,30 @@ DeviceDisabledScreenHandler::DeviceDisabledScreenHandler( } DeviceDisabledScreenHandler::~DeviceDisabledScreenHandler() { - if (delegate_) - delegate_->OnViewDestroyed(this); + if (screen_) + screen_->OnViewDestroyed(this); } -void DeviceDisabledScreenHandler::Show() { - if (!page_is_ready()) { - show_on_init_ = true; - return; - } - - if (delegate_) { - CallJS("login.DeviceDisabledScreen.setSerialNumberAndEnrollmentDomain", - delegate_->GetSerialNumber(), delegate_->GetEnrollmentDomain()); - CallJS("login.DeviceDisabledScreen.setMessage", delegate_->GetMessage()); - } - ShowScreen(kScreenId); +void DeviceDisabledScreenHandler::Show(const std::string& serial, + const std::string& domain, + const std::string& message) { + base::DictionaryValue screen_data; + screen_data.SetStringPath("serial", serial); + screen_data.SetStringPath("domain", domain); + screen_data.SetStringPath("message", message); + ShowScreenWithData(kScreenId, &screen_data); } void DeviceDisabledScreenHandler::Hide() { - show_on_init_ = false; + NOTREACHED() << "Device should reboot upon removing device disabled flag"; } -void DeviceDisabledScreenHandler::SetDelegate(DeviceDisabledScreen* delegate) { - delegate_ = delegate; - if (page_is_ready()) - Initialize(); +void DeviceDisabledScreenHandler::Bind(DeviceDisabledScreen* screen) { + screen_ = screen; } void DeviceDisabledScreenHandler::UpdateMessage(const std::string& message) { - if (page_is_ready()) - CallJS("login.DeviceDisabledScreen.setMessage", message); + CallJS("login.DeviceDisabledScreen.setMessage", message); } void DeviceDisabledScreenHandler::DeclareLocalizedValues( @@ -63,13 +56,6 @@ void DeviceDisabledScreenHandler::DeclareLocalizedValues( } void DeviceDisabledScreenHandler::Initialize() { - if (!page_is_ready() || !delegate_) - return; - - if (show_on_init_) { - Show(); - show_on_init_ = false; - } } void DeviceDisabledScreenHandler::RegisterMessages() { diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/device_disabled_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/device_disabled_screen_handler.h index 1cb75a48ab2..ed647dea28b 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/device_disabled_screen_handler.h +++ b/chromium/chrome/browser/ui/webui/chromeos/login/device_disabled_screen_handler.h @@ -19,9 +19,11 @@ class DeviceDisabledScreenView { virtual ~DeviceDisabledScreenView() {} - virtual void Show() = 0; + virtual void Show(const std::string& serial, + const std::string& domain, + const std::string& message) = 0; virtual void Hide() = 0; - virtual void SetDelegate(DeviceDisabledScreen* delegate) = 0; + virtual void Bind(DeviceDisabledScreen* screen) = 0; virtual void UpdateMessage(const std::string& message) = 0; }; @@ -35,9 +37,11 @@ class DeviceDisabledScreenHandler : public DeviceDisabledScreenView, ~DeviceDisabledScreenHandler() override; // DeviceDisabledScreenActor: - void Show() override; + void Show(const std::string& serial, + const std::string& domain, + const std::string& message) override; void Hide() override; - void SetDelegate(DeviceDisabledScreen* delegate) override; + void Bind(DeviceDisabledScreen* screen) override; void UpdateMessage(const std::string& message) override; // BaseScreenHandler: @@ -49,10 +53,7 @@ class DeviceDisabledScreenHandler : public DeviceDisabledScreenView, // WebUIMessageHandler: void RegisterMessages() override; - DeviceDisabledScreen* delegate_ = nullptr; - - // Indicates whether the screen should be shown right after initialization. - bool show_on_init_ = false; + DeviceDisabledScreen* screen_ = nullptr; DISALLOW_COPY_AND_ASSIGN(DeviceDisabledScreenHandler); }; diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc index e5f84a27dd2..81308cb95f2 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc @@ -27,7 +27,7 @@ #include "chrome/browser/chromeos/login/ui/login_display_host.h" #include "chrome/browser/chromeos/login/wizard_controller.h" #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" -#include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" +#include "chrome/browser/chromeos/policy/enrollment_requisition_manager.h" #include "chrome/browser/chromeos/policy/policy_oauth2_token_fetcher.h" #include "chrome/browser/policy/enrollment_status.h" #include "chrome/browser/profiles/profile.h" @@ -412,6 +412,12 @@ void EnrollmentScreenHandler::ShowEnrollmentStatus( IDS_ENTERPRISE_ENROLLMENT_CONSUMER_ACCOUNT_WITH_PACKAGED_LICENSE, true); break; + case policy:: + DM_STATUS_SERVICE_ENTERPRISE_ACCOUNT_IS_NOT_ELIGIBLE_TO_ENROLL: + ShowError( + IDS_ENTERPRISE_ENROLLMENT_ENTERPRISE_ACCOUNT_IS_NOT_ELIGIBLE_TO_ENROLL, + true); + break; case policy::DM_STATUS_SERVICE_ENTERPRISE_TOS_HAS_NOT_BEEN_ACCEPTED: ShowError( IDS_ENTERPRISE_ENROLLMENT_ENTERPRISE_TOS_HAS_NOT_BEEN_ACCEPTED, @@ -772,12 +778,12 @@ void EnrollmentScreenHandler::HandleCompleteLogin(const std::string& user) { void EnrollmentScreenHandler::OnGetCookiesForCompleteLogin( const std::string& user, - const net::CookieStatusList& cookies, - const net::CookieStatusList& excluded_cookies) { + const net::CookieAccessResultList& cookies, + const net::CookieAccessResultList& excluded_cookies) { std::string auth_code; - for (const auto& cookie_with_status : cookies) { - if (cookie_with_status.cookie.Name() == "oauth_code") { - auth_code = cookie_with_status.cookie.Value(); + for (const auto& cookie_with_access_result : cookies) { + if (cookie_with_access_result.cookie.Name() == "oauth_code") { + auth_code = cookie_with_access_result.cookie.Value(); break; } } @@ -882,11 +888,7 @@ void EnrollmentScreenHandler::DoShowWithPartition( if (!app_locale.empty()) screen_data.SetString("hl", app_locale); - policy::DeviceCloudPolicyManagerChromeOS* policy_manager = - g_browser_process->platform_part() - ->browser_policy_connector_chromeos() - ->GetDeviceCloudPolicyManager(); - const bool cfm = policy_manager && policy_manager->IsRemoraRequisition(); + const bool cfm = policy::EnrollmentRequisitionManager::IsRemoraRequisition(); screen_data.SetString("flow", cfm ? "cfm" : "enterprise"); ShowScreenWithData(EnrollmentScreenView::kScreenId, &screen_data); diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.h index b83224e3d25..4feaf4b6886 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.h +++ b/chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.h @@ -105,8 +105,8 @@ class EnrollmentScreenHandler void HandleCompleteLogin(const std::string& user); void OnGetCookiesForCompleteLogin( const std::string& user, - const net::CookieStatusList& cookies, - const net::CookieStatusList& excluded_cookies); + const net::CookieAccessResultList& cookies, + const net::CookieAccessResultList& excluded_cookies); void HandleAdCompleteLogin(const std::string& machine_name, const std::string& distinguished_name, const std::string& encryption_types, diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.cc index 03e3c845076..3040f27e447 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.cc @@ -8,6 +8,7 @@ #include <string> #include "base/bind.h" +#include "base/command_line.h" #include "base/macros.h" #include "base/strings/stringprintf.h" #include "chrome/browser/browser_process.h" @@ -143,7 +144,7 @@ void EulaScreenHandler::Initialize() { if (!page_is_ready() || !screen_) return; - core_oobe_view_->SetUsageStats(screen_->IsUsageStatsEnabled()); + CallJS("login.EulaScreen.setUsageStats", screen_->IsUsageStatsEnabled()); if (show_on_init_) { Show(); @@ -152,7 +153,7 @@ void EulaScreenHandler::Initialize() { } void EulaScreenHandler::OnPasswordFetched(const std::string& tpm_password) { - core_oobe_view_->SetTpmPassword(tpm_password); + CallJS("login.EulaScreen.setTpmPassword", tpm_password); } void EulaScreenHandler::HandleOnLearnMore() { diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/fake_update_required_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/fake_update_required_screen_handler.h index 4dc7fb49bde..956bf1de8c8 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/fake_update_required_screen_handler.h +++ b/chromium/chrome/browser/ui/webui/chromeos/login/fake_update_required_screen_handler.h @@ -39,6 +39,7 @@ class FakeUpdateRequiredScreenHandler : public UpdateRequiredView { void SetUIState(UpdateRequiredView::UIState ui_state) override; void SetEnterpriseAndDeviceName(const std::string& enterpriseDomain, const base::string16& deviceName) override {} + void SetEolMessage(const std::string& eolMessage) override {} UpdateRequiredView::UIState ui_state_; diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.cc index 14d58280bee..f22c63fb699 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.cc @@ -4,45 +4,11 @@ #include "chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.h" -#include "base/bind.h" #include "base/strings/string_number_conversions.h" #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.h" #include "chrome/browser/chromeos/login/screens/fingerprint_setup_screen.h" -#include "chrome/browser/chromeos/profiles/profile_helper.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/profiles/profile_manager.h" -#include "chrome/common/pref_names.h" #include "chrome/grit/generated_resources.h" #include "components/login/localized_values_builder.h" -#include "components/prefs/pref_service.h" -#include "content/public/browser/device_service.h" -#include "ui/base/l10n/l10n_util.h" - -namespace { - -// The max number of fingerprints that can be stored. -constexpr int kMaxAllowedFingerprints = 3; - -// Determines what the newly added fingerprint's name should be. -std::string GetDefaultFingerprintName(int enrolled_finger_count) { - DCHECK(enrolled_finger_count < kMaxAllowedFingerprints); - switch (enrolled_finger_count) { - case 0: - return l10n_util::GetStringUTF8( - IDS_OOBE_FINGERPINT_SETUP_SCREEN_NEW_FINGERPRINT_DEFAULT_NAME_1); - case 1: - return l10n_util::GetStringUTF8( - IDS_OOBE_FINGERPINT_SETUP_SCREEN_NEW_FINGERPRINT_DEFAULT_NAME_2); - case 2: - return l10n_util::GetStringUTF8( - IDS_OOBE_FINGERPINT_SETUP_SCREEN_NEW_FINGERPRINT_DEFAULT_NAME_3); - default: - NOTREACHED(); - } - return std::string(); -} - -} // namespace namespace chromeos { @@ -52,10 +18,6 @@ FingerprintSetupScreenHandler::FingerprintSetupScreenHandler( JSCallsContainer* js_calls_container) : BaseScreenHandler(kScreenId, js_calls_container) { set_user_acted_method_path("login.FingerprintSetupScreen.userActed"); - - content::GetDeviceService().BindFingerprint( - fp_service_.BindNewPipeAndPassReceiver()); - fp_service_->AddFingerprintObserver(receiver_.BindNewPipeAndPassRemote()); } FingerprintSetupScreenHandler::~FingerprintSetupScreenHandler() = default; @@ -104,10 +66,6 @@ void FingerprintSetupScreenHandler::DeclareLocalizedValues( void FingerprintSetupScreenHandler::RegisterMessages() { BaseScreenHandler::RegisterMessages(); - web_ui()->RegisterMessageCallback( - "startEnroll", - base::BindRepeating(&FingerprintSetupScreenHandler::HandleStartEnroll, - base::Unretained(this))); } void FingerprintSetupScreenHandler::Bind(FingerprintSetupScreen* screen) { @@ -119,70 +77,21 @@ void FingerprintSetupScreenHandler::Show() { ShowScreen(kScreenId); } -void FingerprintSetupScreenHandler::Hide() { - // Clean up existing fingerprint enroll session. - if (enroll_session_started_) { - fp_service_->CancelCurrentEnrollSession(base::BindOnce( - &FingerprintSetupScreenHandler::OnCancelCurrentEnrollSession, - weak_ptr_factory_.GetWeakPtr())); - } -} +void FingerprintSetupScreenHandler::Hide() {} void FingerprintSetupScreenHandler::Initialize() {} -void FingerprintSetupScreenHandler::OnRestarted() { - VLOG(1) << "Fingerprint session restarted."; -} - void FingerprintSetupScreenHandler::OnEnrollScanDone( device::mojom::ScanResult scan_result, bool enroll_session_complete, int percent_complete) { - VLOG(1) << "Receive fingerprint enroll scan result. scan_result=" - << scan_result - << ", enroll_session_complete=" << enroll_session_complete - << ", percent_complete=" << percent_complete; CallJS("login.FingerprintSetupScreen.onEnrollScanDone", static_cast<int>(scan_result), enroll_session_complete, percent_complete); - - if (enroll_session_complete) { - enroll_session_started_ = false; - - ++enrolled_finger_count_; - CallJS("login.FingerprintSetupScreen.enableAddAnotherFinger", - enrolled_finger_count_ < kMaxAllowedFingerprints); - - // Update the number of registered fingers, it's fine to override because - // this is the first time user log in and have no finger registered. - ProfileManager::GetActiveUserProfile()->GetPrefs()->SetInteger( - prefs::kQuickUnlockFingerprintRecord, enrolled_finger_count_); - } -} - -void FingerprintSetupScreenHandler::OnAuthScanDone( - device::mojom::ScanResult scan_result, - const base::flat_map<std::string, std::vector<std::string>>& matches) {} - -void FingerprintSetupScreenHandler::OnSessionFailed() { - // TODO(xiaoyinh): Add more user visible information when available. - LOG(ERROR) << "Fingerprint session failed."; -} - -void FingerprintSetupScreenHandler::HandleStartEnroll( - const base::ListValue* args) { - DCHECK(enrolled_finger_count_ < kMaxAllowedFingerprints); - - enroll_session_started_ = true; - fp_service_->StartEnrollSession( - ProfileHelper::Get()->GetUserIdHashFromProfile( - ProfileManager::GetActiveUserProfile()), - GetDefaultFingerprintName(enrolled_finger_count_)); } -void FingerprintSetupScreenHandler::OnCancelCurrentEnrollSession(bool success) { - if (!success) - LOG(ERROR) << "Failed to cancel current fingerprint enroll session."; +void FingerprintSetupScreenHandler::EnableAddAnotherFinger(bool enable) { + CallJS("login.FingerprintSetupScreen.enableAddAnotherFinger", enable); } } // namespace chromeos diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.h index 8e752278477..7eef2972b25 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.h +++ b/chromium/chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.h @@ -7,8 +7,6 @@ #include "base/macros.h" #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h" -#include "mojo/public/cpp/bindings/receiver.h" -#include "mojo/public/cpp/bindings/remote.h" #include "services/device/public/mojom/fingerprint.mojom.h" namespace chromeos { @@ -31,13 +29,19 @@ class FingerprintSetupScreenView { // Hides the contents of the screen. virtual void Hide() = 0; + + // Enables adding new finger. + virtual void EnableAddAnotherFinger(bool enable) = 0; + + // Trigger update UI state due to enroll status update. + virtual void OnEnrollScanDone(device::mojom::ScanResult scan_result, + bool enroll_session_complete, + int percent_complete) = 0; }; // The sole implementation of the FingerprintSetupScreenView, using WebUI. -class FingerprintSetupScreenHandler - : public BaseScreenHandler, - public FingerprintSetupScreenView, - public device::mojom::FingerprintObserver { +class FingerprintSetupScreenHandler : public BaseScreenHandler, + public FingerprintSetupScreenView { public: using TView = FingerprintSetupScreenView; @@ -53,36 +57,17 @@ class FingerprintSetupScreenHandler void Bind(FingerprintSetupScreen* screen) override; void Show() override; void Hide() override; - - // BaseScreenHandler: - void Initialize() override; - - // device::mojom::FingerprintObserver: - void OnRestarted() override; + void EnableAddAnotherFinger(bool enable) override; void OnEnrollScanDone(device::mojom::ScanResult scan_result, bool enroll_session_complete, int percent_complete) override; - void OnAuthScanDone( - device::mojom::ScanResult scan_result, - const base::flat_map<std::string, std::vector<std::string>>& matches) - override; - void OnSessionFailed() override; - private: - // JS callbacks. - void HandleStartEnroll(const base::ListValue* args); - - void OnCancelCurrentEnrollSession(bool success); + // BaseScreenHandler: + void Initialize() override; + private: FingerprintSetupScreen* screen_ = nullptr; - mojo::Remote<device::mojom::Fingerprint> fp_service_; - mojo::Receiver<device::mojom::FingerprintObserver> receiver_{this}; - int enrolled_finger_count_ = 0; - bool enroll_session_started_ = false; - - base::WeakPtrFactory<FingerprintSetupScreenHandler> weak_ptr_factory_{this}; - DISALLOW_COPY_AND_ASSIGN(FingerprintSetupScreenHandler); }; diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/gaia_password_changed_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/gaia_password_changed_screen_handler.cc new file mode 100644 index 00000000000..b901c35566a --- /dev/null +++ b/chromium/chrome/browser/ui/webui/chromeos/login/gaia_password_changed_screen_handler.cc @@ -0,0 +1,77 @@ +// Copyright 2020 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 "chrome/browser/ui/webui/chromeos/login/gaia_password_changed_screen_handler.h" + +#include "base/values.h" +#include "chrome/browser/chromeos/login/oobe_screen.h" +#include "chrome/browser/chromeos/login/screens/gaia_password_changed_screen.h" +#include "chrome/browser/chromeos/login/ui/login_display_host.h" +#include "chrome/grit/chromium_strings.h" +#include "chrome/grit/generated_resources.h" +#include "components/login/localized_values_builder.h" +#include "ui/chromeos/devicetype_utils.h" + +namespace chromeos { + +constexpr StaticOobeScreenId GaiaPasswordChangedView::kScreenId; + +GaiaPasswordChangedScreenHandler::GaiaPasswordChangedScreenHandler( + JSCallsContainer* js_calls_container) + : BaseScreenHandler(kScreenId, js_calls_container) { + set_user_acted_method_path("login.GaiaPasswordChangedScreen.userActed"); +} + +GaiaPasswordChangedScreenHandler::~GaiaPasswordChangedScreenHandler() { + if (screen_) + screen_->OnViewDestroyed(this); +} + +void GaiaPasswordChangedScreenHandler::DeclareLocalizedValues( + ::login::LocalizedValuesBuilder* builder) { + builder->Add("nextButtonText", IDS_OFFLINE_LOGIN_NEXT_BUTTON_TEXT); + builder->Add("oldPasswordHint", IDS_LOGIN_PASSWORD_CHANGED_OLD_PASSWORD_HINT); + builder->Add("oldPasswordIncorrect", + IDS_LOGIN_PASSWORD_CHANGED_INCORRECT_OLD_PASSWORD); + builder->Add("proceedAnywayButton", + IDS_LOGIN_PASSWORD_CHANGED_PROCEED_ANYWAY_BUTTON); + builder->Add("forgotOldPasswordButtonText", + IDS_LOGIN_PASSWORD_CHANGED_FORGOT_PASSWORD); + builder->AddF("passwordChangedTitle", IDS_LOGIN_PASSWORD_CHANGED_TITLE, + ui::GetChromeOSDeviceName()); + builder->Add("passwordChangedProceedAnywayTitle", + IDS_LOGIN_PASSWORD_CHANGED_PROCEED_ANYWAY); + builder->Add("passwordChangedTryAgain", IDS_LOGIN_PASSWORD_CHANGED_TRY_AGAIN); +} + +void GaiaPasswordChangedScreenHandler::Initialize() { + AddCallback("migrateUserData", + &GaiaPasswordChangedScreenHandler::HandleMigrateUserData); +} + +void GaiaPasswordChangedScreenHandler::Show(const std::string& email, + bool has_error) { + base::DictionaryValue data; + data.SetStringPath("email", email); + data.SetBoolPath("showError", has_error); + ShowScreenWithData(kScreenId, &data); +} + +void GaiaPasswordChangedScreenHandler::Bind(GaiaPasswordChangedScreen* screen) { + screen_ = screen; + BaseScreenHandler::SetBaseScreen(screen_); +} + +void GaiaPasswordChangedScreenHandler::Unbind() { + screen_ = nullptr; + BaseScreenHandler::SetBaseScreen(nullptr); +} + +void GaiaPasswordChangedScreenHandler::HandleMigrateUserData( + const std::string& old_password) { + if (screen_) + screen_->MigrateUserData(old_password); +} + +} // namespace chromeos diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/gaia_password_changed_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/gaia_password_changed_screen_handler.h new file mode 100644 index 00000000000..3c6d65fb1e7 --- /dev/null +++ b/chromium/chrome/browser/ui/webui/chromeos/login/gaia_password_changed_screen_handler.h @@ -0,0 +1,64 @@ +// Copyright 2020 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 CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_GAIA_PASSWORD_CHANGED_SCREEN_HANDLER_H_ +#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_GAIA_PASSWORD_CHANGED_SCREEN_HANDLER_H_ + +#include <string> + +#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h" + +namespace chromeos { + +class GaiaPasswordChangedScreen; + +// Interface for dependency injection between GaiaPasswordChangedScreen and its +// WebUI representation. +class GaiaPasswordChangedView { + public: + constexpr static StaticOobeScreenId kScreenId{"gaia-password-changed"}; + + virtual ~GaiaPasswordChangedView() {} + + // Shows the contents of the screen. + virtual void Show(const std::string& email, bool has_error) = 0; + + // Binds |screen| to the view. + virtual void Bind(GaiaPasswordChangedScreen* screen) = 0; + + // Unbinds the screen from the view. + virtual void Unbind() = 0; +}; + +class GaiaPasswordChangedScreenHandler : public GaiaPasswordChangedView, + public BaseScreenHandler { + public: + using TView = GaiaPasswordChangedView; + + explicit GaiaPasswordChangedScreenHandler( + JSCallsContainer* js_calls_container); + GaiaPasswordChangedScreenHandler(const GaiaPasswordChangedScreenHandler&) = + delete; + GaiaPasswordChangedScreenHandler& operator=( + const GaiaPasswordChangedScreenHandler&) = delete; + ~GaiaPasswordChangedScreenHandler() override; + + private: + void Show(const std::string& email, bool has_error) override; + void Bind(GaiaPasswordChangedScreen* screen) override; + void Unbind() override; + + void HandleMigrateUserData(const std::string& old_password); + + // BaseScreenHandler: + void DeclareLocalizedValues( + ::login::LocalizedValuesBuilder* builder) override; + void Initialize() override; + + GaiaPasswordChangedScreen* screen_ = nullptr; +}; + +} // namespace chromeos + +#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_GAIA_PASSWORD_CHANGED_SCREEN_HANDLER_H_ diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc index 64879360d33..1babe0f4d85 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc @@ -54,7 +54,6 @@ #include "chrome/browser/net/system_network_context_manager.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/ash/login_screen_client.h" -#include "chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" #include "chrome/browser/ui/webui/metrics_handler.h" @@ -340,14 +339,10 @@ GaiaScreenHandler::GaiaContext::GaiaContext() {} GaiaScreenHandler::GaiaScreenHandler( JSCallsContainer* js_calls_container, CoreOobeView* core_oobe_view, - const scoped_refptr<NetworkStateInformer>& network_state_informer, - ActiveDirectoryPasswordChangeScreenHandler* - active_directory_password_change_screen_handler) + const scoped_refptr<NetworkStateInformer>& network_state_informer) : BaseScreenHandler(kScreenId, js_calls_container), network_state_informer_(network_state_informer), - core_oobe_view_(core_oobe_view), - active_directory_password_change_screen_handler_( - active_directory_password_change_screen_handler) { + core_oobe_view_(core_oobe_view) { DCHECK(network_state_informer_.get()); } @@ -427,7 +422,7 @@ void GaiaScreenHandler::LoadGaiaWithPartition( base::BindOnce(&GaiaScreenHandler::OnSetCookieForLoadGaiaWithPartition, weak_factory_.GetWeakPtr(), context, partition_name); if (context.gaps_cookie.empty()) { - std::move(callback).Run(net::CanonicalCookie::CookieInclusionStatus()); + std::move(callback).Run(net::CookieInclusionStatus()); return; } @@ -465,7 +460,7 @@ void GaiaScreenHandler::LoadGaiaWithPartition( void GaiaScreenHandler::OnSetCookieForLoadGaiaWithPartition( const GaiaContext& context, const std::string& partition_name, - net::CanonicalCookie::CookieInclusionStatus status) { + net::CookieInclusionStatus status) { std::unique_ptr<std::string> version = std::make_unique<std::string>(); std::unique_ptr<bool> consent = std::make_unique<bool>(); base::OnceClosure get_version_and_consent = @@ -858,7 +853,9 @@ void GaiaScreenHandler::DoAdAuth( break; } case authpolicy::ERROR_PASSWORD_EXPIRED: - active_directory_password_change_screen_handler_->ShowScreen(username); + LoginDisplayHost::default_host() + ->GetWizardController() + ->ShowActiveDirectoryPasswordChangeScreen(username); break; case authpolicy::ERROR_PARSE_UPN_FAILED: case authpolicy::ERROR_BAD_USER_NAME: @@ -965,11 +962,11 @@ void GaiaScreenHandler::ContinueAuthenticationWhenCookiesAvailable() { } void GaiaScreenHandler::OnGetCookiesForCompleteAuthentication( - const net::CookieStatusList& cookies, - const net::CookieStatusList& excluded_cookies) { + const net::CookieAccessResultList& cookies, + const net::CookieAccessResultList& excluded_cookies) { std::string auth_code, gaps_cookie; - for (const auto& cookie_with_status : cookies) { - const auto& cookie = cookie_with_status.cookie; + for (const auto& cookie_with_access_result : cookies) { + const auto& cookie = cookie_with_access_result.cookie; if (cookie.Name() == kOAUTHCodeCookie) auth_code = cookie.Value(); else if (cookie.Name() == kGAPSCookie) @@ -1086,8 +1083,6 @@ void GaiaScreenHandler::HandleShowAddUser(const base::ListValue* args) { if (args) args->GetString(0, &email); set_populated_account(AccountId::FromUserEmail(email)); - if (!email.empty()) - SendReauthReason(AccountId::FromUserEmail(email)); OnShowAddUser(); } diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h index 02c0cce7974..3b00660c72b 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h +++ b/chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h @@ -23,6 +23,7 @@ #include "components/user_manager/user_type.h" #include "net/base/net_errors.h" #include "net/cookies/canonical_cookie.h" +#include "net/cookies/cookie_inclusion_status.h" #include "services/network/public/mojom/cookie_manager.mojom.h" class AccountId; @@ -38,7 +39,6 @@ class NSSTempCertsCacheChromeOS; namespace chromeos { -class ActiveDirectoryPasswordChangeScreenHandler; class Key; class SamlPasswordAttributes; class SigninScreenHandler; @@ -109,9 +109,7 @@ class GaiaScreenHandler : public BaseScreenHandler, GaiaScreenHandler( JSCallsContainer* js_calls_container, CoreOobeView* core_oobe_view, - const scoped_refptr<NetworkStateInformer>& network_state_informer, - ActiveDirectoryPasswordChangeScreenHandler* - active_directory_password_change_screen_handler); + const scoped_refptr<NetworkStateInformer>& network_state_informer); ~GaiaScreenHandler() override; // GaiaView: @@ -155,10 +153,9 @@ class GaiaScreenHandler : public BaseScreenHandler, const std::string& partition_name); // Called after the GAPS cookie, if present, is added to the cookie store. - void OnSetCookieForLoadGaiaWithPartition( - const GaiaContext& context, - const std::string& partition_name, - net::CanonicalCookie::CookieInclusionStatus status); + void OnSetCookieForLoadGaiaWithPartition(const GaiaContext& context, + const std::string& partition_name, + net::CookieInclusionStatus status); // Callback that loads GAIA after version and stat consent information has // been retrieved. @@ -332,8 +329,8 @@ class GaiaScreenHandler : public BaseScreenHandler, void ContinueAuthenticationWhenCookiesAvailable(); void OnGetCookiesForCompleteAuthentication( - const net::CookieStatusList& cookies, - const net::CookieStatusList& excluded_cookies); + const net::CookieAccessResultList& cookies, + const net::CookieAccessResultList& excluded_cookies); void OnCookieWaitTimeout(); @@ -356,9 +353,6 @@ class GaiaScreenHandler : public BaseScreenHandler, CoreOobeView* core_oobe_view_ = nullptr; - ActiveDirectoryPasswordChangeScreenHandler* - active_directory_password_change_screen_handler_ = nullptr; - // Account to pre-populate with. AccountId populated_account_id_; diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/native_window_delegate.h b/chromium/chrome/browser/ui/webui/chromeos/login/native_window_delegate.h deleted file mode 100644 index f7453e022bd..00000000000 --- a/chromium/chrome/browser/ui/webui/chromeos/login/native_window_delegate.h +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2012 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 CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_NATIVE_WINDOW_DELEGATE_H_ -#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_NATIVE_WINDOW_DELEGATE_H_ - -#include "ui/gfx/native_widget_types.h" - -namespace chromeos { - -// An interface to get gfx::NativeWindow. -class NativeWindowDelegate { - public: - NativeWindowDelegate() {} - virtual ~NativeWindowDelegate() {} - - // Returns corresponding native window. - virtual gfx::NativeWindow GetNativeWindow() const = 0; -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_NATIVE_WINDOW_DELEGATE_H_ diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.cc b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.cc index 9423ee9eb01..29c58fa4b2a 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.cc @@ -10,7 +10,6 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/strings/string_number_conversions.h" -#include "base/task/post_task.h" #include "chrome/browser/ui/ash/ash_util.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" @@ -58,8 +57,8 @@ void OobeDisplayChooser::TryToPlaceUiOnTouchDisplay() { display::Screen::GetScreen()->GetPrimaryDisplay(); if (primary_display.is_valid() && !TouchSupportAvailable(primary_display)) { - base::PostTask(FROM_HERE, {BrowserThread::UI}, - base::BindOnce(&OobeDisplayChooser::MaybeMoveToTouchDisplay, + content::GetUIThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&OobeDisplayChooser::MaybeMoveToTouchDisplay, weak_ptr_factory_.GetWeakPtr())); } } diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc index a8b92fcbf79..414a359c54e 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc @@ -31,6 +31,7 @@ #include "chrome/browser/chromeos/login/wizard_controller.h" #include "chrome/browser/chromeos/multidevice_setup/multidevice_setup_service_factory.h" #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" +#include "chrome/browser/chromeos/policy/enrollment_requisition_manager.h" #include "chrome/browser/chromeos/settings/shutdown_policy_handler.h" #include "chrome/browser/chromeos/system/input_device_settings.h" #include "chrome/browser/extensions/tab_helper.h" @@ -56,6 +57,7 @@ #include "chrome/browser/ui/webui/chromeos/login/error_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.h" +#include "chrome/browser/ui/webui/chromeos/login/gaia_password_changed_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/gesture_navigation_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.h" @@ -74,6 +76,7 @@ #include "chrome/browser/ui/webui/chromeos/login/supervision_transition_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler.h" +#include "chrome/browser/ui/webui/chromeos/login/tpm_error_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/update_required_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/update_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/user_board_screen_handler.h" @@ -101,6 +104,7 @@ #include "content/public/browser/web_ui_data_source.h" #include "content/public/common/content_features.h" #include "content/public/common/content_switches.h" +#include "services/network/public/mojom/content_security_policy.mojom.h" #include "ui/base/resource/resource_bundle.h" #include "ui/base/ui_base_features.h" #include "ui/base/webui/web_ui_util.h" @@ -192,7 +196,8 @@ void AddAssistantScreensResources(content::WebUIDataSource* source) { IDR_ASSISTANT_VOICE_MATCH_ANIMATION); source->AddResourcePath("voice_match_already_setup_animation.json", IDR_ASSISTANT_VOICE_MATCH_ALREADY_SETUP_ANIMATION); - source->OverrideContentSecurityPolicyWorkerSrc("worker-src blob: 'self';"); + source->OverrideContentSecurityPolicy( + network::mojom::CSPDirectiveName::WorkerSrc, "worker-src blob: 'self';"); } void AddGestureNavigationResources(content::WebUIDataSource* source) { @@ -202,13 +207,15 @@ void AddGestureNavigationResources(content::WebUIDataSource* source) { IDR_GESTURE_NAVIGATION_GO_BACK_ANIMATION); source->AddResourcePath("gesture_hotseat_overview.json", IDR_GESTURE_NAVIGATION_HOTSEAT_OVERVIEW_ANIMATION); - source->OverrideContentSecurityPolicyWorkerSrc("worker-src blob: 'self';"); + source->OverrideContentSecurityPolicy( + network::mojom::CSPDirectiveName::WorkerSrc, "worker-src blob: 'self';"); } void AddMarketingOptInResources(content::WebUIDataSource* source) { source->AddResourcePath("all_set.json", IDR_MARKETING_OPT_IN_ALL_SET_ANIMATION); - source->OverrideContentSecurityPolicyWorkerSrc("worker-src blob: 'self';"); + source->OverrideContentSecurityPolicy( + network::mojom::CSPDirectiveName::WorkerSrc, "worker-src blob: 'self';"); } void AddFingerprintResources(content::WebUIDataSource* source) { @@ -238,7 +245,9 @@ void AddFingerprintResources(content::WebUIDataSource* source) { // lottie animations, this update has to be performed manually. As the usage // increases, set this as the default so manual override is no longer // required. - source->OverrideContentSecurityPolicyWorkerSrc("worker-src blob: 'self';"); + source->OverrideContentSecurityPolicy( + network::mojom::CSPDirectiveName::WorkerSrc, + "worker-src blob: 'self';"); } else { source->AddResourcePath("fingerprint_scanner_animation.png", animation_id); } @@ -250,10 +259,12 @@ void AddDebuggerResources(content::WebUIDataSource* source) { base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); bool enable_debugger = command_line->HasSwitch(::chromeos::switches::kShowOobeDevOverlay); - // TODO(crbug.com/1073095): Also enable for ChromeOS test images. - // Enable for ChromeOS-on-linux for developers. - bool test_mode = !base::SysInfo::IsRunningOnChromeOS(); - if (enable_debugger && test_mode) { + // Enable for ChromeOS-on-linux for developers and test images. + if (enable_debugger && base::SysInfo::IsRunningOnChromeOS()) { + LOG(WARNING) << "OOBE Debug overlay can only be used on test images"; + base::SysInfo::CrashIfChromeOSNonTestImage(); + } + if (enable_debugger) { source->AddResourcePath(kDebuggerJSPath, IDR_OOBE_DEBUGGER_JS); } else { source->AddResourcePath(kDebuggerJSPath, IDR_OOBE_DEBUGGER_STUB_JS); @@ -325,8 +336,8 @@ content::WebUIDataSource* CreateOobeUIDataSource( AddDebuggerResources(source); source->AddResourcePath(kKeyboardUtilsJSPath, IDR_KEYBOARD_UTILS_JS); - source->OverrideContentSecurityPolicyObjectSrc( - "object-src chrome:;"); + source->OverrideContentSecurityPolicy( + network::mojom::CSPDirectiveName::ObjectSrc, "object-src chrome:;"); // Only add a filter when runing as test. const bool is_running_test = command_line->HasSwitch(::switches::kTestName) || @@ -348,14 +359,6 @@ std::string GetDisplayType(const GURL& url) { return path; } -bool IsRemoraRequisitioned() { - policy::DeviceCloudPolicyManagerChromeOS* policy_manager = - g_browser_process->platform_part() - ->browser_policy_connector_chromeos() - ->GetDeviceCloudPolicyManager(); - return policy_manager && policy_manager->IsRemoraRequisition(); -} - } // namespace // static @@ -454,13 +457,15 @@ void OobeUI::ConfigureOobeDisplay() { AddScreenHandler( std::make_unique<MarketingOptInScreenHandler>(js_calls_container_.get())); + AddScreenHandler(std::make_unique<GaiaPasswordChangedScreenHandler>( + js_calls_container_.get())); + auto password_change_handler = std::make_unique<ActiveDirectoryPasswordChangeScreenHandler>( js_calls_container_.get(), core_handler_); AddScreenHandler(std::make_unique<GaiaScreenHandler>( - js_calls_container_.get(), core_handler_, network_state_informer_, - password_change_handler.get())); + js_calls_container_.get(), core_handler_, network_state_informer_)); AddScreenHandler(std::move(password_change_handler)); @@ -494,6 +499,9 @@ void OobeUI::ConfigureOobeDisplay() { AddScreenHandler(std::make_unique<PackagedLicenseScreenHandler>( js_calls_container_.get())); + AddScreenHandler( + std::make_unique<TpmErrorScreenHandler>(js_calls_container_.get())); + Profile* profile = Profile::FromWebUI(web_ui()); // Set up the chrome://theme/ source, for Chrome logo. content::URLDataSource::Add(profile, std::make_unique<ThemeSource>(profile)); @@ -514,7 +522,7 @@ void OobeUI::ConfigureOobeDisplay() { content::URLDataSource::Add(profile, std::make_unique<chromeos::VideoSource>()); - if (IsRemoraRequisitioned()) + if (policy::EnrollmentRequisitionManager::IsRemoraRequisition()) oobe_display_chooser_ = std::make_unique<OobeDisplayChooser>(); } @@ -547,7 +555,7 @@ void OobeUI::BindInterface( OobeUI::OobeUI(content::WebUI* web_ui, const GURL& url) : ui::MojoWebUIController(web_ui, true /* enable_chrome_send */) { // TODO(crbug.com/1082670): Remove excessive logging after investigation. - LOG(ERROR) << "Creating new OobeUI"; + LOG(ERROR) << "1082670 : Creating new OobeUI"; display_type_ = GetDisplayType(url); @@ -648,12 +656,12 @@ void OobeUI::AddScreenHandler(std::unique_ptr<BaseScreenHandler> handler) { void OobeUI::InitializeHandlers() { // TODO(crbug.com/1082670): Remove excessive logging after investigation. - LOG(ERROR) << "OobeUI::InitializeHandlers"; + LOG(ERROR) << "1082670 : OobeUI::InitializeHandlers"; js_calls_container_->ExecuteDeferredJSCalls(web_ui()); // TODO(crbug.com/1082670): Remove excessive logging after investigation. - LOG(ERROR) << "OobeUI::Marking as ready and executing callbacks"; + LOG(ERROR) << "1082670 : OobeUI::Marking as ready and executing callbacks"; ready_ = true; for (size_t i = 0; i < ready_callbacks_.size(); ++i) @@ -686,7 +694,8 @@ bool OobeUI::IsScreenInitialized(OobeScreenId screen) { bool OobeUI::IsJSReady(const base::Closure& display_is_ready_callback) { // TODO(crbug.com/1082670): Remove excessive logging after investigation. - LOG(ERROR) << "OobeUI::IsJSReady? = " << ready_; + LOG(ERROR) << "1082670 : OobeUI::IsJSReady? = " << ready_; + if (!ready_) ready_callbacks_.push_back(display_is_ready_callback); return ready_; @@ -699,8 +708,7 @@ void OobeUI::ShowOobeUI(bool show) { oobe_display_chooser_->TryToPlaceUiOnTouchDisplay(); } -void OobeUI::ShowSigninScreen(SigninScreenHandlerDelegate* delegate, - NativeWindowDelegate* native_window_delegate) { +void OobeUI::ShowSigninScreen(SigninScreenHandlerDelegate* delegate) { // Check our device mode. policy::BrowserPolicyConnectorChromeOS* connector = g_browser_process->platform_part()->browser_policy_connector_chromeos(); @@ -712,7 +720,6 @@ void OobeUI::ShowSigninScreen(SigninScreenHandlerDelegate* delegate, } signin_screen_handler_->SetDelegate(delegate); - signin_screen_handler_->SetNativeWindowDelegate(native_window_delegate); signin_screen_handler_->Show(core_handler_->show_oobe_ui()); } @@ -723,7 +730,6 @@ void OobeUI::ForwardAccelerator(std::string accelerator_name) { void OobeUI::ResetSigninScreenHandlerDelegate() { signin_screen_handler_->SetDelegate(nullptr); - signin_screen_handler_->SetNativeWindowDelegate(nullptr); } diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.h b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.h index a87658eadf2..676a0c4ab5c 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.h +++ b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.h @@ -29,7 +29,6 @@ class DictionaryValue; namespace chromeos { class ErrorScreen; -class NativeWindowDelegate; class NetworkStateInformer; class OobeDisplayChooser; class SigninScreenHandler; @@ -87,8 +86,7 @@ class OobeUI : public ui::MojoWebUIController { void ShowOobeUI(bool show); // Shows the signin screen. - void ShowSigninScreen(SigninScreenHandlerDelegate* delegate, - NativeWindowDelegate* native_window_delegate); + void ShowSigninScreen(SigninScreenHandlerDelegate* delegate); // Forwards an accelerator to the webui to be handled. void ForwardAccelerator(std::string accelerator_name); diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/saml_challenge_key_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/saml_challenge_key_handler.cc index 499ad8e79e8..489d834c216 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/saml_challenge_key_handler.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/login/saml_challenge_key_handler.cc @@ -6,6 +6,7 @@ #include "base/base64.h" #include "base/bind.h" +#include "base/logging.h" #include "base/metrics/histogram_functions.h" #include "base/values.h" #include "chrome/browser/chromeos/attestation/tpm_challenge_key_result.h" diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc index 98622fce340..0ae35058be3 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc @@ -71,7 +71,6 @@ #include "chrome/browser/ui/webui/chromeos/login/error_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/l10n_util.h" -#include "chrome/browser/ui/webui/chromeos/login/native_window_delegate.h" #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h" #include "chrome/common/channel_info.h" #include "chrome/common/pref_names.h" @@ -159,12 +158,6 @@ class CallOnReturn { DISALLOW_COPY_AND_ASSIGN(CallOnReturn); }; -policy::MinimumVersionPolicyHandler* GetMinimumVersionPolicyHandler() { - return g_browser_process->platform_part() - ->browser_policy_connector_chromeos() - ->GetMinimumVersionPolicyHandler(); -} - } // namespace namespace chromeos { @@ -323,10 +316,6 @@ void SigninScreenHandler::DeclareLocalizedValues( builder->Add("offlineLogin", IDS_OFFLINE_LOGIN_HTML); builder->Add("ownerUserPattern", IDS_LOGIN_POD_OWNER_USER); builder->Add("removeUser", IDS_LOGIN_POD_REMOVE_USER); - builder->Add("errorTpmFailureTitle", IDS_LOGIN_ERROR_TPM_FAILURE_TITLE); - builder->Add("errorTpmFailureReboot", IDS_LOGIN_ERROR_TPM_FAILURE_REBOOT); - builder->Add("errorTpmFailureRebootButton", - IDS_LOGIN_ERROR_TPM_FAILURE_REBOOT_BUTTON); policy::BrowserPolicyConnectorChromeOS* connector = g_browser_process->platform_part()->browser_policy_connector_chromeos(); @@ -349,20 +338,9 @@ void SigninScreenHandler::DeclareLocalizedValues( builder->Add("multiProfilesOwnerPrimaryOnlyMsg", IDS_MULTI_PROFILES_OWNER_PRIMARY_ONLY_MSG); - // Strings used by password changed dialog. - builder->Add("oldPasswordHint", IDS_LOGIN_PASSWORD_CHANGED_OLD_PASSWORD_HINT); - builder->Add("oldPasswordIncorrect", - IDS_LOGIN_PASSWORD_CHANGED_INCORRECT_OLD_PASSWORD); - builder->Add("proceedAnywayButton", - IDS_LOGIN_PASSWORD_CHANGED_PROCEED_ANYWAY_BUTTON); + // Used by SAML password dialog. builder->Add("nextButtonText", IDS_OFFLINE_LOGIN_NEXT_BUTTON_TEXT); - builder->Add("forgotOldPasswordButtonText", - IDS_LOGIN_PASSWORD_CHANGED_FORGOT_PASSWORD); - builder->AddF("passwordChangedTitle", IDS_LOGIN_PASSWORD_CHANGED_TITLE, - ui::GetChromeOSDeviceName()); - builder->Add("passwordChangedProceedAnywayTitle", - IDS_LOGIN_PASSWORD_CHANGED_PROCEED_ANYWAY); - builder->Add("passwordChangedTryAgain", IDS_LOGIN_PASSWORD_CHANGED_TRY_AGAIN); + builder->Add("publicAccountInfoFormat", IDS_LOGIN_PUBLIC_ACCOUNT_INFO_FORMAT); builder->Add("publicAccountReminder", IDS_LOGIN_PUBLIC_ACCOUNT_SIGNOUT_REMINDER); @@ -439,7 +417,6 @@ void SigninScreenHandler::RegisterMessages() { &SigninScreenHandler::HandleLaunchSAMLPublicSession); AddRawCallback("offlineLogin", &SigninScreenHandler::HandleOfflineLogin); AddCallback("rebootSystem", &SigninScreenHandler::HandleRebootSystem); - AddCallback("removeUser", &SigninScreenHandler::HandleRemoveUser); AddCallback("toggleEnrollmentScreen", &SigninScreenHandler::HandleToggleEnrollmentScreen); AddCallback("toggleEnableDebuggingScreen", @@ -451,11 +428,7 @@ void SigninScreenHandler::RegisterMessages() { AddCallback("openInternetDetailDialog", &SigninScreenHandler::HandleOpenInternetDetailDialog); AddCallback("loginVisible", &SigninScreenHandler::HandleLoginVisible); - AddCallback("cancelPasswordChangedFlow", - &SigninScreenHandler::HandleCancelPasswordChangedFlow); AddCallback("cancelUserAdding", &SigninScreenHandler::HandleCancelUserAdding); - AddCallback("migrateUserData", &SigninScreenHandler::HandleMigrateUserData); - AddCallback("resyncUserData", &SigninScreenHandler::HandleResyncUserData); AddCallback("loginUIStateChanged", &SigninScreenHandler::HandleLoginUIStateChanged); AddCallback("showLoadingTimeoutError", @@ -492,11 +465,6 @@ void SigninScreenHandler::SetDelegate(SigninScreenHandlerDelegate* delegate) { delegate_->SetWebUIHandler(this); } -void SigninScreenHandler::SetNativeWindowDelegate( - NativeWindowDelegate* native_window_delegate) { - native_window_delegate_ = native_window_delegate; -} - void SigninScreenHandler::OnNetworkReady() { VLOG(1) << "OnNetworkReady() call."; gaia_screen_handler_->MaybePreloadAuthExtension(); @@ -931,26 +899,10 @@ void SigninScreenHandler::ShowError(int login_attempts, help_topic_id); } -void SigninScreenHandler::ShowErrorScreen(LoginDisplay::SigninError error_id) { - switch (error_id) { - case LoginDisplay::TPM_ERROR: - core_oobe_view_->ShowTpmError(); - break; - default: - NOTREACHED() << "Unknown sign in error"; - break; - } -} - void SigninScreenHandler::ShowSigninUI(const std::string& email) { core_oobe_view_->ShowSignInUI(email); } -void SigninScreenHandler::ShowPasswordChangedDialog(bool show_password_error, - const std::string& email) { - core_oobe_view_->ShowPasswordChangedScreen(show_password_error, email); -} - void SigninScreenHandler::ShowWhitelistCheckFailedError() { gaia_screen_handler_->ShowWhitelistCheckFailedError(); } @@ -1138,20 +1090,6 @@ void SigninScreenHandler::HandleRebootSystem() { power_manager::REQUEST_RESTART_FOR_USER, "WebUI signin screen"); } -void SigninScreenHandler::HandleRemoveUser(const AccountId& account_id) { - if (delegate_ && - (delegate_->IsUserSigninCompleted() || delegate_->IsSigninInProgress())) { - return; - } - - ProfileMetrics::LogProfileDeleteUser( - ProfileMetrics::DELETE_PROFILE_USER_MANAGER); - - if (!delegate_) - return; - delegate_->RemoveUser(account_id); -} - void SigninScreenHandler::HandleToggleEnrollmentScreen() { if (delegate_) delegate_->ShowEnterpriseEnrollmentScreen(); @@ -1201,12 +1139,6 @@ void SigninScreenHandler::HandleAccountPickerReady() { return; } - if (delegate_ && !oobe_ui_ && GetMinimumVersionPolicyHandler() && - !GetMinimumVersionPolicyHandler()->RequirementsAreSatisfied()) { - delegate_->ShowUpdateRequiredScreen(); - return; - } - is_account_picker_showing_first_time_ = true; // The wallpaper may have been set before the instance is initialized, so make @@ -1250,32 +1182,11 @@ void SigninScreenHandler::HandleLoginVisible(const std::string& source) { OnPreferencesChanged(); } -void SigninScreenHandler::HandleCancelPasswordChangedFlow( - const AccountId& account_id) { - if (account_id.is_valid()) { - RecordReauthReason(account_id, ReauthReason::PASSWORD_UPDATE_SKIPPED); - } - gaia_screen_handler_->StartClearingCookies( - base::Bind(&SigninScreenHandler::CancelPasswordChangedFlowInternal, - weak_factory_.GetWeakPtr())); -} - void SigninScreenHandler::HandleCancelUserAdding() { if (delegate_) delegate_->CancelUserAdding(); } -void SigninScreenHandler::HandleMigrateUserData( - const std::string& old_password) { - if (LoginDisplayHost::default_host()) - LoginDisplayHost::default_host()->MigrateUserData(old_password); -} - -void SigninScreenHandler::HandleResyncUserData() { - if (LoginDisplayHost::default_host()) - LoginDisplayHost::default_host()->ResyncUserData(); -} - void SigninScreenHandler::HandleLoginUIStateChanged(const std::string& source, bool active) { VLOG(0) << "Login WebUI >> active: " << active << ", " @@ -1432,14 +1343,6 @@ bool SigninScreenHandler::AllWhitelistedUsersPresent() { return true; } -void SigninScreenHandler::CancelPasswordChangedFlowInternal() { - if (delegate_) - ShowImpl(); - - if (LoginDisplayHost::default_host()) - LoginDisplayHost::default_host()->CancelPasswordChangedFlow(); -} - bool SigninScreenHandler::IsGaiaVisible() const { return IsSigninScreen(GetCurrentScreen()) && ui_state_ == UI_STATE_GAIA_SIGNIN; diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h index fd1bcb346e3..f250227407b 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h +++ b/chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h @@ -55,7 +55,6 @@ class CoreOobeView; class ErrorScreensHistogramHelper; class GaiaScreenHandler; class LoginFeedback; -class NativeWindowDelegate; class User; class UserContext; @@ -73,10 +72,7 @@ class LoginDisplayWebUIHandler { const std::string& error_text, const std::string& help_link_text, HelpAppLauncher::HelpTopic help_topic_id) = 0; - virtual void ShowErrorScreen(LoginDisplay::SigninError error_id) = 0; virtual void ShowSigninUI(const std::string& email) = 0; - virtual void ShowPasswordChangedDialog(bool show_password_error, - const std::string& email) = 0; virtual void ShowWhitelistCheckFailedError() = 0; virtual void LoadUsers(const user_manager::UserList& users, const base::ListValue& users_list) = 0; @@ -119,16 +115,10 @@ class SigninScreenHandlerDelegate { // Show wrong hwid screen. virtual void ShowWrongHWIDScreen() = 0; - // Show update required screen. - virtual void ShowUpdateRequiredScreen() = 0; - // --------------- Rest of the methods. // Cancels user adding. virtual void CancelUserAdding() = 0; - // Attempts to remove given user. - virtual void RemoveUser(const AccountId& account_id) = 0; - // Let the delegate know about the handler it is supposed to be using. virtual void SetWebUIHandler(LoginDisplayWebUIHandler* webui_handler) = 0; @@ -197,8 +187,6 @@ class SigninScreenHandler // delegate is set before Show() method will be called. void SetDelegate(SigninScreenHandlerDelegate* delegate); - void SetNativeWindowDelegate(NativeWindowDelegate* native_window_delegate); - // NetworkStateInformer::NetworkStateInformerObserver implementation: void OnNetworkReady() override; void UpdateState(NetworkError::ErrorReason reason) override; @@ -272,9 +260,6 @@ class SigninScreenHandler const std::string& help_link_text, HelpAppLauncher::HelpTopic help_topic_id) override; void ShowSigninUI(const std::string& email) override; - void ShowPasswordChangedDialog(bool show_password_error, - const std::string& email) override; - void ShowErrorScreen(LoginDisplay::SigninError error_id) override; void ShowWhitelistCheckFailedError() override; void LoadUsers(const user_manager::UserList& users, const base::ListValue& users_list) override; @@ -318,7 +303,6 @@ class SigninScreenHandler const std::string& input_method); void HandleOfflineLogin(const base::ListValue* args); void HandleRebootSystem(); - void HandleRemoveUser(const AccountId& account_id); void HandleToggleEnrollmentScreen(); void HandleToggleEnrollmentAd(); void HandleToggleEnableDebuggingScreen(); @@ -334,10 +318,7 @@ class SigninScreenHandler void HandleAccountPickerReady(); void HandleOpenInternetDetailDialog(); void HandleLoginVisible(const std::string& source); - void HandleCancelPasswordChangedFlow(const AccountId& account_id); void HandleCancelUserAdding(); - void HandleMigrateUserData(const std::string& password); - void HandleResyncUserData(); void HandleLoginUIStateChanged(const std::string& source, bool active); void HandleLoginScreenUpdate(); void HandleShowLoadingTimeoutError(); @@ -409,9 +390,6 @@ class SigninScreenHandler // A delegate that glues this handler with backend LoginDisplay. SigninScreenHandlerDelegate* delegate_ = nullptr; - // A delegate used to get gfx::NativeWindow. - NativeWindowDelegate* native_window_delegate_ = nullptr; - // Whether screen should be shown right after initialization. bool show_on_init_ = false; diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/supervision_transition_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/supervision_transition_screen_handler.cc index 311bd578880..7d212337687 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/supervision_transition_screen_handler.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/login/supervision_transition_screen_handler.cc @@ -13,6 +13,7 @@ #include "chrome/browser/chromeos/arc/session/arc_session_manager.h" #include "chrome/browser/chromeos/login/oobe_screen.h" #include "chrome/browser/chromeos/login/screens/supervision_transition_screen.h" +#include "chrome/browser/chromeos/profiles/profile_helper.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/ash/login_screen_client.h" #include "chrome/browser/ui/ash/system_tray_client.h" @@ -90,7 +91,10 @@ void SupervisionTransitionScreenHandler::Show() { &SupervisionTransitionScreenHandler::OnSupervisionTransitionFailed, weak_factory_.GetWeakPtr())); - registrar_.Init(profile_->GetPrefs()); + Profile* profile = ProfileManager::GetActiveUserProfile(); + DCHECK(!ProfileHelper::IsSigninProfile(profile)); + + registrar_.Init(profile->GetPrefs()); registrar_.Add( arc::prefs::kArcSupervisionTransition, base::BindRepeating( @@ -106,7 +110,7 @@ void SupervisionTransitionScreenHandler::Show() { base::DictionaryValue data; data.SetBoolean("isRemovingSupervision", - arc::GetSupervisionTransition(profile_) == + arc::GetSupervisionTransition(profile) == arc::ArcSupervisionTransition::CHILD_TO_REGULAR); ShowScreenWithData(kScreenId, &data); } @@ -118,8 +122,6 @@ base::OneShotTimer* SupervisionTransitionScreenHandler::GetTimerForTesting() { } void SupervisionTransitionScreenHandler::Initialize() { - profile_ = ProfileManager::GetPrimaryUserProfile(); - if (!screen_ || !show_on_init_) return; diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/supervision_transition_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/supervision_transition_screen_handler.h index 5785e0e65fc..76d085f82d7 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/supervision_transition_screen_handler.h +++ b/chromium/chrome/browser/ui/webui/chromeos/login/supervision_transition_screen_handler.h @@ -82,9 +82,6 @@ class SupervisionTransitionScreenHandler base::TimeTicks screen_shown_time_; - // The primary user profile. - Profile* profile_ = nullptr; - // Timer used to exit the page when timeout reaches. base::OneShotTimer timer_; diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.cc index 2e83bfb9b3d..a7bdc97a447 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.cc @@ -13,6 +13,7 @@ #include "components/login/localized_values_builder.h" #include "components/user_manager/user_manager.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/chromeos/devicetype_utils.h" namespace { @@ -111,6 +112,8 @@ void SyncConsentScreenHandler::DeclareLocalizedValues( builder); // SplitSettingsSync strings. + RememberLocalizedValue("syncConsentScreenSubtitle", + IDS_LOGIN_SYNC_CONSENT_SCREEN_SUBTITLE, builder); RememberLocalizedValue("syncConsentScreenOsSyncName", IDS_LOGIN_SYNC_CONSENT_SCREEN_OS_SYNC_NAME, builder); RememberLocalizedValue("syncConsentScreenOsSyncDescription", @@ -119,6 +122,10 @@ void SyncConsentScreenHandler::DeclareLocalizedValues( RememberLocalizedValue("syncConsentScreenChromeBrowserSyncName", IDS_LOGIN_SYNC_CONSENT_SCREEN_CHROME_BROWSER_SYNC_NAME, builder); + RememberLocalizedValue("syncConsentScreenAccept", + IDS_LOGIN_SYNC_CONSENT_SCREEN_ACCEPT2, builder); + RememberLocalizedValue("syncConsentScreenDecline", + IDS_LOGIN_SYNC_CONSENT_SCREEN_DECLINE2, builder); } void SyncConsentScreenHandler::Bind(SyncConsentScreen* screen) { @@ -127,10 +134,10 @@ void SyncConsentScreenHandler::Bind(SyncConsentScreen* screen) { } void SyncConsentScreenHandler::Show() { - bool is_child_account_ = - user_manager::UserManager::Get()->IsLoggedInAsChildUser(); + auto* user_manager = user_manager::UserManager::Get(); base::DictionaryValue data; - data.SetBoolean("isChildAccount", is_child_account_); + data.SetBoolean("isChildAccount", user_manager->IsLoggedInAsChildUser()); + data.SetString("deviceType", ui::GetChromeOSDeviceName()); ShowScreenWithData(kScreenId, &data); } @@ -149,6 +156,8 @@ void SyncConsentScreenHandler::RegisterMessages() { &SyncConsentScreenHandler::HandleContinueWithDefaults); AddCallback("login.SyncConsentScreen.acceptAndContinue", &SyncConsentScreenHandler::HandleAcceptAndContinue); + AddCallback("login.SyncConsentScreen.declineAndContinue", + &SyncConsentScreenHandler::HandleDeclineAndContinue); } void SyncConsentScreenHandler::GetAdditionalParameters( @@ -198,16 +207,26 @@ void SyncConsentScreenHandler::HandleContinueWithDefaults( void SyncConsentScreenHandler::HandleAcceptAndContinue( const login::StringList& consent_description, + const std::string& consent_confirmation) { + Continue(consent_description, consent_confirmation, UserChoice::kAccepted); +} + +void SyncConsentScreenHandler::HandleDeclineAndContinue( + const login::StringList& consent_description, + const std::string& consent_confirmation) { + Continue(consent_description, consent_confirmation, UserChoice::kDeclined); +} + +void SyncConsentScreenHandler::Continue( + const login::StringList& consent_description, const std::string& consent_confirmation, - bool enable_os_sync, - bool enable_browser_sync) { + UserChoice choice) { DCHECK(chromeos::features::IsSplitSettingsSyncEnabled()); std::vector<int> consent_description_ids; int consent_confirmation_id; GetConsentIDs(known_string_ids_, consent_description, consent_confirmation, &consent_description_ids, &consent_confirmation_id); - screen_->OnAcceptAndContinue(consent_description_ids, consent_confirmation_id, - enable_os_sync, enable_browser_sync); + screen_->OnContinue(consent_description_ids, consent_confirmation_id, choice); SyncConsentScreen::SyncConsentScreenTestDelegate* test_delegate = screen_->GetDelegateForTesting(); diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.h index af58bff845a..a11e554f091 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.h +++ b/chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.h @@ -42,6 +42,10 @@ class SyncConsentScreenHandler : public BaseScreenHandler, public: using TView = SyncConsentScreenView; + // These values are persisted to logs. Entries should not be renumbered and + // numeric values should never be reused. Public for testing. + enum class UserChoice { kDeclined = 0, kAccepted = 1, kMaxValue = kAccepted }; + explicit SyncConsentScreenHandler(JSCallsContainer* js_calls_container); ~SyncConsentScreenHandler() override; @@ -67,10 +71,17 @@ class SyncConsentScreenHandler : public BaseScreenHandler, void HandleContinueWithDefaults( const ::login::StringList& consent_description, const std::string& consent_confirmation); + + // WebUI message handlers for SplitSettingsSync. void HandleAcceptAndContinue(const ::login::StringList& consent_description, - const std::string& consent_confirmation, - bool enable_os_sync, - bool enable_browser_sync); + const std::string& consent_confirmation); + void HandleDeclineAndContinue(const ::login::StringList& consent_description, + const std::string& consent_confirmation); + + // Helper for the accept and decline cases. + void Continue(const ::login::StringList& consent_description, + const std::string& consent_confirmation, + UserChoice choice); // Adds resource |resource_id| both to |builder| and to |known_string_ids_|. void RememberLocalizedValue(const std::string& name, diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler.cc index 241a06360c0..873c6a473fc 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler.cc @@ -63,6 +63,8 @@ void TermsOfServiceScreenHandler::DeclareLocalizedValues( IDS_TERMS_OF_SERVICE_SCREEN_BACK_BUTTON); builder->Add("termsOfServiceAcceptButton", IDS_TERMS_OF_SERVICE_SCREEN_ACCEPT_BUTTON); + builder->Add("termsOfServiceRetryButton", + IDS_TERMS_OF_SERVICE_SCREEN_RETRY_BUTTON); } void TermsOfServiceScreenHandler::SetScreen(TermsOfServiceScreen* screen) { diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/tpm_error_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/tpm_error_screen_handler.cc new file mode 100644 index 00000000000..16f1e686924 --- /dev/null +++ b/chromium/chrome/browser/ui/webui/chromeos/login/tpm_error_screen_handler.cc @@ -0,0 +1,62 @@ +// Copyright 2020 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 "chrome/browser/ui/webui/chromeos/login/tpm_error_screen_handler.h" + +#include "base/values.h" +#include "chrome/browser/chromeos/login/oobe_screen.h" +#include "chrome/browser/chromeos/login/screens/tpm_error_screen.h" +#include "chrome/grit/chromium_strings.h" +#include "chrome/grit/generated_resources.h" +#include "components/login/localized_values_builder.h" + +namespace chromeos { + +constexpr StaticOobeScreenId TpmErrorView::kScreenId; + +TpmErrorScreenHandler::TpmErrorScreenHandler( + JSCallsContainer* js_calls_container) + : BaseScreenHandler(kScreenId, js_calls_container) { + set_user_acted_method_path("login.TPMErrorMessageScreen.userActed"); +} + +TpmErrorScreenHandler::~TpmErrorScreenHandler() { + if (screen_) + screen_->OnViewDestroyed(this); +} + +void TpmErrorScreenHandler::DeclareLocalizedValues( + ::login::LocalizedValuesBuilder* builder) { + builder->Add("errorTpmFailureTitle", IDS_LOGIN_ERROR_TPM_FAILURE_TITLE); + builder->Add("errorTpmFailureReboot", IDS_LOGIN_ERROR_TPM_FAILURE_REBOOT); + builder->Add("errorTpmFailureRebootButton", + IDS_LOGIN_ERROR_TPM_FAILURE_REBOOT_BUTTON); +} + +void TpmErrorScreenHandler::Initialize() { + if (show_on_init_) { + show_on_init_ = false; + Show(); + } +} + +void TpmErrorScreenHandler::Show() { + if (!page_is_ready()) { + show_on_init_ = true; + return; + } + ShowScreen(kScreenId); +} + +void TpmErrorScreenHandler::Bind(TpmErrorScreen* screen) { + screen_ = screen; + BaseScreenHandler::SetBaseScreen(screen_); +} + +void TpmErrorScreenHandler::Unbind() { + screen_ = nullptr; + BaseScreenHandler::SetBaseScreen(nullptr); +} + +} // namespace chromeos diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/tpm_error_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/tpm_error_screen_handler.h new file mode 100644 index 00000000000..a8258774ae7 --- /dev/null +++ b/chromium/chrome/browser/ui/webui/chromeos/login/tpm_error_screen_handler.h @@ -0,0 +1,60 @@ +// Copyright 2020 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 CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_TPM_ERROR_SCREEN_HANDLER_H_ +#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_TPM_ERROR_SCREEN_HANDLER_H_ + +#include <string> + +#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h" + +namespace chromeos { + +class TpmErrorScreen; + +// Interface for dependency injection between TpmErrorScreen and its +// WebUI representation. +class TpmErrorView { + public: + constexpr static StaticOobeScreenId kScreenId{"tpm-error-message"}; + + virtual ~TpmErrorView() {} + + // Shows the contents of the screen. + virtual void Show() = 0; + + // Binds |screen| to the view. + virtual void Bind(TpmErrorScreen* screen) = 0; + + // Unbinds the screen from the view. + virtual void Unbind() = 0; +}; + +class TpmErrorScreenHandler : public TpmErrorView, public BaseScreenHandler { + public: + using TView = TpmErrorView; + + explicit TpmErrorScreenHandler(JSCallsContainer* js_calls_container); + TpmErrorScreenHandler(const TpmErrorScreenHandler&) = delete; + TpmErrorScreenHandler& operator=(const TpmErrorScreenHandler&) = delete; + ~TpmErrorScreenHandler() override; + + private: + void Show() override; + void Bind(TpmErrorScreen* screen) override; + void Unbind() override; + + // BaseScreenHandler: + void DeclareLocalizedValues( + ::login::LocalizedValuesBuilder* builder) override; + void Initialize() override; + + bool show_on_init_ = false; + + TpmErrorScreen* screen_ = nullptr; +}; + +} // namespace chromeos + +#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_TPM_ERROR_SCREEN_HANDLER_H_ diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/update_required_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/update_required_screen_handler.cc index d938229bbd9..1ba28b56d11 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/update_required_screen_handler.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/login/update_required_screen_handler.cc @@ -65,6 +65,7 @@ void UpdateRequiredScreenHandler::DeclareLocalizedValues( IDS_OFFERS_CONSENT_INFOBAR_DISABLE_BUTTON); builder->Add("noNetworkMessage", IDS_UPDATE_REQUIRED_SCREEN_NO_NETWORK_MESSAGE); + builder->Add("eolAdminMessageTitle", IDS_UPDATE_REQUIRED_EOL_ADMIN_MESSAGE); } void UpdateRequiredScreenHandler::Initialize() { @@ -81,6 +82,10 @@ void UpdateRequiredScreenHandler::SetEnterpriseAndDeviceName( enterpriseDomain, deviceName); } +void UpdateRequiredScreenHandler::SetEolMessage(const std::string& eolMessage) { + CallJS("login.UpdateRequiredScreen.setEolMessage", eolMessage); +} + void UpdateRequiredScreenHandler::Show() { if (!page_is_ready()) { show_on_init_ = true; diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/update_required_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/update_required_screen_handler.h index 48bffc48e60..6c01540cd95 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/update_required_screen_handler.h +++ b/chromium/chrome/browser/ui/webui/chromeos/login/update_required_screen_handler.h @@ -65,6 +65,7 @@ class UpdateRequiredView { // Set enterprise and device name to be used in strings in the UI. virtual void SetEnterpriseAndDeviceName(const std::string& enterpriseDomain, const base::string16& deviceName) = 0; + virtual void SetEolMessage(const std::string& eolMessage) = 0; }; class UpdateRequiredScreenHandler : public UpdateRequiredView, @@ -90,6 +91,7 @@ class UpdateRequiredScreenHandler : public UpdateRequiredView, void SetUIState(UpdateRequiredView::UIState ui_state) override; void SetEnterpriseAndDeviceName(const std::string& enterpriseDomain, const base::string16& deviceName) override; + void SetEolMessage(const std::string& eolMessage) override; // BaseScreenHandler: void DeclareLocalizedValues( diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/update_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/update_screen_handler.h index be45877d228..7f2b3630ab0 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/update_screen_handler.h +++ b/chromium/chrome/browser/ui/webui/chromeos/login/update_screen_handler.h @@ -19,7 +19,7 @@ class UpdateScreen; // representation. Owned by UpdateScreen. class UpdateView { public: - constexpr static StaticOobeScreenId kScreenId{"update"}; + constexpr static StaticOobeScreenId kScreenId{"oobe-update"}; virtual ~UpdateView() {} diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.cc index cf6cf3e7cf3..38efaf95f19 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.cc @@ -15,6 +15,8 @@ #include "base/task_runner_util.h" #include "base/values.h" #include "chrome/browser/browser_process.h" +#include "chrome/browser/chromeos/accessibility/accessibility_manager.h" +#include "chrome/browser/chromeos/accessibility/magnification_manager.h" #include "chrome/browser/chromeos/login/demo_mode/demo_session.h" #include "chrome/browser/chromeos/login/screens/welcome_screen.h" #include "chrome/browser/chromeos/login/ui/input_events_blocker.h" @@ -47,6 +49,12 @@ WelcomeScreenHandler::WelcomeScreenHandler(JSCallsContainer* js_calls_container, core_oobe_view_(core_oobe_view) { set_user_acted_method_path("login.WelcomeScreen.userActed"); DCHECK(core_oobe_view_); + + AccessibilityManager* accessibility_manager = AccessibilityManager::Get(); + CHECK(accessibility_manager); + accessibility_subscription_ = accessibility_manager->RegisterCallback( + base::Bind(&WelcomeScreenHandler::OnAccessibilityStatusChanged, + base::Unretained(this))); } WelcomeScreenHandler::~WelcomeScreenHandler() { @@ -145,6 +153,17 @@ void WelcomeScreenHandler::DeclareLocalizedValues( builder->Add("keyboardDropdownTitle", IDS_KEYBOARD_DROPDOWN_TITLE); builder->Add("keyboardDropdownLabel", IDS_KEYBOARD_DROPDOWN_LABEL); + // OOBE accessibility options menu strings shown on each screen. + builder->Add("accessibilityLink", IDS_OOBE_ACCESSIBILITY_LINK); + builder->Add("spokenFeedbackOption", IDS_OOBE_SPOKEN_FEEDBACK_OPTION); + builder->Add("selectToSpeakOption", IDS_OOBE_SELECT_TO_SPEAK_OPTION); + builder->Add("largeCursorOption", IDS_OOBE_LARGE_CURSOR_OPTION); + builder->Add("highContrastOption", IDS_OOBE_HIGH_CONTRAST_MODE_OPTION); + builder->Add("screenMagnifierOption", IDS_OOBE_SCREEN_MAGNIFIER_OPTION); + builder->Add("dockedMagnifierOption", IDS_OOBE_DOCKED_MAGNIFIER_OPTION); + builder->Add("virtualKeyboardOption", IDS_OOBE_VIRTUAL_KEYBOARD_OPTION); + builder->Add("closeAccessibilityMenu", IDS_OOBE_CLOSE_ACCESSIBILITY_MENU); + builder->Add("a11ySettingToggleOptionOff", IDS_A11Y_SETTING_TOGGLE_OPTION_OFF); builder->Add("a11ySettingToggleOptionOn", IDS_A11Y_SETTING_TOGGLE_OPTION_ON); @@ -162,6 +181,21 @@ void WelcomeScreenHandler::DeclareJSCallbacks() { &WelcomeScreenHandler::HandleSetInputMethodId); AddCallback("WelcomeScreen.setTimezoneId", &WelcomeScreenHandler::HandleSetTimezoneId); + + AddCallback("WelcomeScreen.enableHighContrast", + &WelcomeScreenHandler::HandleEnableHighContrast); + AddCallback("WelcomeScreen.enableLargeCursor", + &WelcomeScreenHandler::HandleEnableLargeCursor); + AddCallback("WelcomeScreen.enableVirtualKeyboard", + &WelcomeScreenHandler::HandleEnableVirtualKeyboard); + AddCallback("WelcomeScreen.enableScreenMagnifier", + &WelcomeScreenHandler::HandleEnableScreenMagnifier); + AddCallback("WelcomeScreen.enableSpokenFeedback", + &WelcomeScreenHandler::HandleEnableSpokenFeedback); + AddCallback("WelcomeScreen.enableSelectToSpeak", + &WelcomeScreenHandler::HandleEnableSelectToSpeak); + AddCallback("WelcomeScreen.enableDockedMagnifier", + &WelcomeScreenHandler::HandleEnableDockedMagnifier); } void WelcomeScreenHandler::GetAdditionalParameters( @@ -227,8 +261,11 @@ void WelcomeScreenHandler::Initialize() { // Reload localized strings if they are already resolved. if (screen_ && screen_->language_list()) ReloadLocalizedContent(); + UpdateA11yState(); } +// WelcomeScreenHandler, private: ---------------------------------------------- + void WelcomeScreenHandler::HandleSetLocaleId(const std::string& locale_id) { if (screen_) screen_->SetApplicationLocale(locale_id); @@ -245,7 +282,71 @@ void WelcomeScreenHandler::HandleSetTimezoneId(const std::string& timezone_id) { screen_->SetTimezone(timezone_id); } -// WelcomeScreenHandler, private: ---------------------------------------------- +void WelcomeScreenHandler::HandleEnableHighContrast(bool enabled) { + AccessibilityManager::Get()->EnableHighContrast(enabled); +} + +void WelcomeScreenHandler::HandleEnableLargeCursor(bool enabled) { + AccessibilityManager::Get()->EnableLargeCursor(enabled); +} + +void WelcomeScreenHandler::HandleEnableVirtualKeyboard(bool enabled) { + AccessibilityManager::Get()->EnableVirtualKeyboard(enabled); +} + +void WelcomeScreenHandler::HandleEnableScreenMagnifier(bool enabled) { + DCHECK(MagnificationManager::Get()); + MagnificationManager::Get()->SetMagnifierEnabled(enabled); +} + +void WelcomeScreenHandler::HandleEnableSpokenFeedback(bool /* enabled */) { + // Checkbox is initialized on page init and updates when spoken feedback + // setting is changed so just toggle spoken feedback here. + AccessibilityManager::Get()->EnableSpokenFeedback( + !AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); +} + +void WelcomeScreenHandler::HandleEnableSelectToSpeak(bool /* enabled */) { + // Checkbox is initialized on page init and updates when Select to Speak + // setting is changed so just toggle Select to Speak here. + AccessibilityManager::Get()->SetSelectToSpeakEnabled( + !AccessibilityManager::Get()->IsSelectToSpeakEnabled()); +} + +void WelcomeScreenHandler::HandleEnableDockedMagnifier(bool enabled) { + // Checkbox is initialized on page init and updates when the docked magnifier + // setting is changed so just toggle Select to Speak here. + DCHECK(MagnificationManager::Get()); + MagnificationManager::Get()->SetDockedMagnifierEnabled(enabled); +} + +void WelcomeScreenHandler::OnAccessibilityStatusChanged( + const AccessibilityStatusEventDetails& details) { + if (details.notification_type == ACCESSIBILITY_MANAGER_SHUTDOWN) + accessibility_subscription_.reset(); + else + UpdateA11yState(); +} + +void WelcomeScreenHandler::UpdateA11yState() { + base::DictionaryValue a11y_info; + a11y_info.SetBoolean("highContrastEnabled", + AccessibilityManager::Get()->IsHighContrastEnabled()); + a11y_info.SetBoolean("largeCursorEnabled", + AccessibilityManager::Get()->IsLargeCursorEnabled()); + a11y_info.SetBoolean("spokenFeedbackEnabled", + AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); + a11y_info.SetBoolean("selectToSpeakEnabled", + AccessibilityManager::Get()->IsSelectToSpeakEnabled()); + DCHECK(MagnificationManager::Get()); + a11y_info.SetBoolean("screenMagnifierEnabled", + MagnificationManager::Get()->IsMagnifierEnabled()); + a11y_info.SetBoolean("dockedMagnifierEnabled", + MagnificationManager::Get()->IsDockedMagnifierEnabled()); + a11y_info.SetBoolean("virtualKeyboardEnabled", + AccessibilityManager::Get()->IsVirtualKeyboardEnabled()); + CallJS("login.WelcomeScreen.refreshA11yInfo", a11y_info); +} // static std::unique_ptr<base::ListValue> WelcomeScreenHandler::GetTimezoneList() { diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.h index 437027ab74a..6f7a19e6b12 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.h +++ b/chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.h @@ -9,6 +9,7 @@ #include <string> #include "base/macros.h" +#include "chrome/browser/chromeos/accessibility/accessibility_manager.h" #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h" namespace base { @@ -80,6 +81,20 @@ class WelcomeScreenHandler : public WelcomeView, public BaseScreenHandler { void HandleSetLocaleId(const std::string& locale_id); void HandleSetInputMethodId(const std::string& input_method_id); void HandleSetTimezoneId(const std::string& timezone_id); + void HandleEnableLargeCursor(bool enabled); + void HandleEnableHighContrast(bool enabled); + void HandleEnableVirtualKeyboard(bool enabled); + void HandleEnableScreenMagnifier(bool enabled); + void HandleEnableSpokenFeedback(bool /* enabled */); + void HandleEnableSelectToSpeak(bool /* enabled */); + void HandleEnableDockedMagnifier(bool /* enabled */); + + // Notification of a change in the accessibility settings. + void OnAccessibilityStatusChanged( + const AccessibilityStatusEventDetails& details); + + // Updates a11y menu state based on the current a11y features state(on/off). + void UpdateA11yState(); // Returns available timezones. Caller gets the ownership. static std::unique_ptr<base::ListValue> GetTimezoneList(); @@ -90,6 +105,8 @@ class WelcomeScreenHandler : public WelcomeView, public BaseScreenHandler { // Keeps whether screen should be shown right after initialization. bool show_on_init_ = false; + std::unique_ptr<AccessibilityStatusSubscription> accessibility_subscription_; + DISALLOW_COPY_AND_ASSIGN(WelcomeScreenHandler); }; diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.cc index e1b8a87d274..22167c3d0b2 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.cc @@ -16,11 +16,12 @@ constexpr StaticOobeScreenId WrongHWIDScreenView::kScreenId; WrongHWIDScreenHandler::WrongHWIDScreenHandler( JSCallsContainer* js_calls_container) : BaseScreenHandler(kScreenId, js_calls_container) { + set_user_acted_method_path("login.WrongHWIDMessageScreen.userActed"); } WrongHWIDScreenHandler::~WrongHWIDScreenHandler() { - if (delegate_) - delegate_->OnViewDestroyed(this); + if (screen_) + screen_->OnViewDestroyed(this); } void WrongHWIDScreenHandler::Show() { @@ -34,10 +35,14 @@ void WrongHWIDScreenHandler::Show() { void WrongHWIDScreenHandler::Hide() { } -void WrongHWIDScreenHandler::SetDelegate(WrongHWIDScreen* delegate) { - delegate_ = delegate; - if (page_is_ready()) - Initialize(); +void WrongHWIDScreenHandler::Bind(WrongHWIDScreen* screen) { + screen_ = screen; + BaseScreenHandler::SetBaseScreen(screen_); +} + +void WrongHWIDScreenHandler::Unbind() { + screen_ = nullptr; + BaseScreenHandler::SetBaseScreen(nullptr); } void WrongHWIDScreenHandler::DeclareLocalizedValues( @@ -52,22 +57,10 @@ void WrongHWIDScreenHandler::DeclareLocalizedValues( } void WrongHWIDScreenHandler::Initialize() { - if (!page_is_ready() || !delegate_) - return; - if (show_on_init_) { - Show(); show_on_init_ = false; + Show(); } } -void WrongHWIDScreenHandler::RegisterMessages() { - AddCallback("wrongHWIDOnSkip", &WrongHWIDScreenHandler::HandleOnSkip); -} - -void WrongHWIDScreenHandler::HandleOnSkip() { - if (delegate_) - delegate_->OnExit(); -} - } // namespace chromeos diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.h index c66ca8105d5..09a9b3456b5 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.h +++ b/chromium/chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.h @@ -23,7 +23,12 @@ class WrongHWIDScreenView { virtual void Show() = 0; virtual void Hide() = 0; - virtual void SetDelegate(WrongHWIDScreen* delegate) = 0; + + // Binds |screen| to the view. + virtual void Bind(WrongHWIDScreen* screen) = 0; + + // Unbinds the screen from the view. + virtual void Unbind() = 0; }; // WebUI implementation of WrongHWIDScreenActor. @@ -35,24 +40,19 @@ class WrongHWIDScreenHandler : public WrongHWIDScreenView, explicit WrongHWIDScreenHandler(JSCallsContainer* js_calls_container); ~WrongHWIDScreenHandler() override; + private: // WrongHWIDScreenActor implementation: void Show() override; void Hide() override; - void SetDelegate(WrongHWIDScreen* delegate) override; + void Bind(WrongHWIDScreen* screen) override; + void Unbind() override; // BaseScreenHandler implementation: void DeclareLocalizedValues( ::login::LocalizedValuesBuilder* builder) override; void Initialize() override; - // WebUIMessageHandler implementation: - void RegisterMessages() override; - - private: - // JS messages handlers. - void HandleOnSkip(); - - WrongHWIDScreen* delegate_ = nullptr; + WrongHWIDScreen* screen_ = nullptr; // Keeps whether screen should be shown right after initialization. bool show_on_init_ = false; @@ -63,4 +63,3 @@ class WrongHWIDScreenHandler : public WrongHWIDScreenView, } // namespace chromeos #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_WRONG_HWID_SCREEN_HANDLER_H_ - diff --git a/chromium/chrome/browser/ui/webui/chromeos/machine_learning/machine_learning_internals_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/machine_learning/machine_learning_internals_ui.cc index ace92dd56d2..b84b0101053 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/machine_learning/machine_learning_internals_ui.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/machine_learning/machine_learning_internals_ui.cc @@ -22,32 +22,45 @@ MachineLearningInternalsUI::MachineLearningInternalsUI( content::WebUIDataSource* const source = content::WebUIDataSource::Create( chrome::kChromeUIMachineLearningInternalsHost); - source->AddResourcePath( - "chromeos/services/machine_learning/public/mojom/tensor.mojom-lite.js", - IDR_MACHINE_LEARNING_INTERNALS_TENSOR_MOJO_JS); - source->AddResourcePath( - "chromeos/services/machine_learning/public/mojom/model.mojom-lite.js", - IDR_MACHINE_LEARNING_INTERNALS_MODEL_MOJO_JS); - source->AddResourcePath( - "chromeos/services/machine_learning/public/mojom/" - "graph_executor.mojom-lite.js", - IDR_MACHINE_LEARNING_INTERNALS_GRAPH_EXECUTOR_MOJO_JS); - source->AddResourcePath( - "chromeos/services/machine_learning/public/" - "mojom/machine_learning_service.mojom-lite.js", - IDR_MACHINE_LEARNING_INTERNALS_MACHINE_LEARNING_SERVICE_MOJO_JS); - source->AddResourcePath( - "chrome/browser/ui/webui/chromeos/machine_learning/" - "machine_learning_internals_page_handler.mojom-lite.js", - IDR_MACHINE_LEARNING_INTERNALS_PAGE_HANDLER_MOJO_JS); - source->AddResourcePath("machine_learning_internals.js", - IDR_MACHINE_LEARNING_INTERNALS_JS); - source->AddResourcePath("machine_learning_internals_utils.js", - IDR_MACHINE_LEARNING_INTERNALS_UTILS_JS); - source->AddResourcePath("test_model_tab.js", - IDR_MACHINE_LEARNING_INTERNALS_TEST_MODEL_TAB_JS); - source->SetDefaultResource(IDR_MACHINE_LEARNING_INTERNALS_HTML); + const std::map<int, std::string> resource_paths = { + {IDR_MACHINE_LEARNING_INTERNALS_GRAPH_EXECUTOR_MOJO_JS, + "chromeos/services/machine_learning/public/mojom/" + "graph_executor.mojom-lite.js"}, + + {IDR_MACHINE_LEARNING_INTERNALS_HANDWRITING_RECOGNIZER_MOJO_JS, + "chromeos/services/machine_learning/public/mojom/" + "handwriting_recognizer.mojom-lite.js"}, + + {IDR_MACHINE_LEARNING_INTERNALS_JS, "machine_learning_internals.js"}, + + {IDR_MACHINE_LEARNING_INTERNALS_MACHINE_LEARNING_SERVICE_MOJO_JS, + "chromeos/services/machine_learning/public/mojom/" + "machine_learning_service.mojom-lite.js"}, + + {IDR_MACHINE_LEARNING_INTERNALS_MODEL_MOJO_JS, + "chromeos/services/machine_learning/public/mojom/model.mojom-lite.js"}, + + {IDR_MACHINE_LEARNING_INTERNALS_PAGE_HANDLER_MOJO_JS, + "chrome/browser/ui/webui/chromeos/machine_learning/" + "machine_learning_internals_page_handler.mojom-lite.js"}, + {IDR_MACHINE_LEARNING_INTERNALS_TENSOR_MOJO_JS, + "chromeos/services/machine_learning/public/mojom/tensor.mojom-lite.js"}, + + {IDR_MACHINE_LEARNING_INTERNALS_TEST_MODEL_TAB_JS, "test_model_tab.js"}, + + {IDR_MACHINE_LEARNING_INTERNALS_TIME_MOJO_JS, + "mojo/public/mojom/base/time.mojom-lite.js"}, + + {IDR_MACHINE_LEARNING_INTERNALS_UTILS_JS, + "machine_learning_internals_utils.js"}, + }; + + for (const auto& path : resource_paths) { + source->AddResourcePath(path.second, path.first); + } + + source->SetDefaultResource(IDR_MACHINE_LEARNING_INTERNALS_HTML); content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source); } diff --git a/chromium/chrome/browser/ui/webui/chromeos/network_element_localized_strings_provider.cc b/chromium/chrome/browser/ui/webui/chromeos/network_element_localized_strings_provider.cc index 13fe503151a..603514f0d85 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/network_element_localized_strings_provider.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/network_element_localized_strings_provider.cc @@ -26,11 +26,13 @@ namespace network_element { namespace { constexpr webui::LocalizedString kElementLocalizedStrings[] = { + {"OncType", IDS_NETWORK_TYPE}, {"OncTypeCellular", IDS_NETWORK_TYPE_CELLULAR}, {"OncTypeEthernet", IDS_NETWORK_TYPE_ETHERNET}, {"OncTypeMobile", IDS_NETWORK_TYPE_MOBILE_DATA}, {"OncTypeTether", IDS_NETWORK_TYPE_TETHER}, {"OncTypeVPN", IDS_NETWORK_TYPE_VPN}, + {"OncTypeWireless", IDS_NETWORK_TYPE_WIRELESS}, {"OncTypeWiFi", IDS_NETWORK_TYPE_WIFI}, {"ipAddressNotAvailable", IDS_NETWORK_IP_ADDRESS_NA}, {"networkListItemConnected", IDS_STATUSBAR_NETWORK_DEVICE_CONNECTED}, diff --git a/chromium/chrome/browser/ui/webui/chromeos/network_logs_message_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/network_logs_message_handler.cc new file mode 100644 index 00000000000..423901dfc52 --- /dev/null +++ b/chromium/chrome/browser/ui/webui/chromeos/network_logs_message_handler.cc @@ -0,0 +1,203 @@ +// Copyright 2020 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 "chrome/browser/ui/webui/chromeos/network_logs_message_handler.h" + +#include <iostream> + +#include "base/files/file_util.h" +#include "base/strings/stringprintf.h" +#include "base/system/sys_info.h" +#include "base/task/task_traits.h" +#include "base/task/thread_pool.h" +#include "chrome/browser/chromeos/file_manager/filesystem_api_util.h" +#include "chrome/browser/chromeos/system_logs/debug_log_writer.h" +#include "chrome/browser/chromeos/system_logs/system_logs_writer.h" +#include "chrome/browser/download/download_prefs.h" +#include "chrome/browser/policy/chrome_policy_conversions_client.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/common/logging_chrome.h" +#include "chrome/grit/generated_resources.h" +#include "chromeos/dbus/dbus_thread_manager.h" +#include "chromeos/dbus/debug_daemon/debug_daemon_client.h" +#include "components/policy/core/browser/policy_conversions.h" +#include "content/public/browser/web_contents.h" +#include "content/public/browser/web_ui.h" +#include "ui/base/l10n/l10n_util.h" + +namespace chromeos { + +namespace { + +base::FilePath GetDownloadsDirectory(content::WebUI* web_ui) { + Profile* profile = Profile::FromWebUI(web_ui); + const DownloadPrefs* const prefs = DownloadPrefs::FromBrowserContext(profile); + base::FilePath path = prefs->DownloadPath(); + if (file_manager::util::IsUnderNonNativeLocalPath(profile, path)) + path = prefs->GetDefaultDownloadDirectoryForProfile(); + return path; +} + +std::string GetJsonPolicies(content::WebUI* web_ui) { + auto client = std::make_unique<policy::ChromePolicyConversionsClient>( + web_ui->GetWebContents()->GetBrowserContext()); + return policy::DictionaryPolicyConversions(std::move(client)).ToJSON(); +} + +bool WriteTimestampedFile(const base::FilePath& file_path, + const std::string& contents) { + base::FilePath timestamped_file_path = + logging::GenerateTimestampedName(file_path, base::Time::Now()); + int bytes_written = + base::WriteFile(timestamped_file_path, contents.data(), contents.size()); + return bytes_written > 0; +} + +bool GetBoolOrFalse(const base::Value* dict, const char* keyname) { + const base::Value* key = dict->FindKey(keyname); + return key && key->GetBool(); +} + +} // namespace + +NetworkLogsMessageHandler::NetworkLogsMessageHandler() = default; + +NetworkLogsMessageHandler::~NetworkLogsMessageHandler() = default; + +void NetworkLogsMessageHandler::RegisterMessages() { + out_dir_ = GetDownloadsDirectory(web_ui()); + web_ui()->RegisterMessageCallback( + "storeLogs", base::BindRepeating(&NetworkLogsMessageHandler::OnStoreLogs, + base::Unretained(this))); + web_ui()->RegisterMessageCallback( + "setShillDebugging", + base::BindRepeating(&NetworkLogsMessageHandler::OnSetShillDebugging, + base::Unretained(this))); +} + +void NetworkLogsMessageHandler::Respond(const std::string& callback_id, + const std::string& result, + bool is_error) { + base::Value response(base::Value::Type::LIST); + response.Append(result); + response.Append(is_error); + ResolveJavascriptCallback(base::Value(callback_id), response); +} + +void NetworkLogsMessageHandler::OnStoreLogs(const base::ListValue* list) { + CHECK_EQ(2u, list->GetSize()); + std::string callback_id; + CHECK(list->GetString(0, &callback_id)); + const base::Value* options; + CHECK(list->Get(1, &options)); + AllowJavascript(); + + if (GetBoolOrFalse(options, "systemLogs")) { + bool scrub_data = GetBoolOrFalse(options, "filterPII"); + chromeos::system_logs_writer::WriteSystemLogs( + out_dir_, scrub_data, + base::BindOnce(&NetworkLogsMessageHandler::OnWriteSystemLogs, + weak_factory_.GetWeakPtr(), callback_id, + options->Clone())); + } else { + MaybeWriteDebugLogs(callback_id, options->Clone()); + } +} + +void NetworkLogsMessageHandler::OnWriteSystemLogs( + const std::string& callback_id, + base::Value&& options, + base::Optional<base::FilePath> syslogs_path) { + if (!syslogs_path) { + Respond(callback_id, "Error writing system logs file.", /*is_error=*/true); + return; + } + MaybeWriteDebugLogs(callback_id, std::move(options)); +} + +void NetworkLogsMessageHandler::MaybeWriteDebugLogs( + const std::string& callback_id, + base::Value&& options) { + if (GetBoolOrFalse(&options, "debugLogs")) { + if (!base::SysInfo::IsRunningOnChromeOS()) { + Respond(callback_id, "Debug logs unavailable on Linux build.", + /*is_error=*/true); + return; + } + bool include_chrome = GetBoolOrFalse(&options, "chromeLogs"); + chromeos::debug_log_writer::StoreLogs( + out_dir_, include_chrome, + base::BindOnce(&NetworkLogsMessageHandler::OnWriteDebugLogs, + weak_factory_.GetWeakPtr(), callback_id, + std::move(options))); + } else { + MaybeWritePolicies(callback_id, std::move(options)); + } +} + +void NetworkLogsMessageHandler::OnWriteDebugLogs( + const std::string& callback_id, + base::Value&& options, + base::Optional<base::FilePath> logs_path) { + if (!logs_path) { + Respond(callback_id, "Error writing debug logs.", /*is_error=*/true); + return; + } + MaybeWritePolicies(callback_id, std::move(options)); +} + +void NetworkLogsMessageHandler::MaybeWritePolicies( + const std::string& callback_id, + base::Value&& options) { + if (GetBoolOrFalse(&options, "policies")) { + std::string json_policies = GetJsonPolicies(web_ui()); + base::ThreadPool::PostTaskAndReplyWithResult( + FROM_HERE, + {base::MayBlock(), base::TaskPriority::BEST_EFFORT, + base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN}, + base::BindOnce(WriteTimestampedFile, out_dir_.Append("policies.json"), + json_policies), + base::BindOnce(&NetworkLogsMessageHandler::OnWritePolicies, + weak_factory_.GetWeakPtr(), callback_id)); + } else { + OnWriteSystemLogsCompleted(callback_id); + } +} + +void NetworkLogsMessageHandler::OnWritePolicies(const std::string& callback_id, + bool result) { + if (!result) { + Respond(callback_id, "Error writing policies.", /*is_error=*/true); + return; + } + OnWriteSystemLogsCompleted(callback_id); +} + +void NetworkLogsMessageHandler::OnWriteSystemLogsCompleted( + const std::string& callback_id) { + Respond(callback_id, + l10n_util::GetStringUTF8(IDS_NETWORK_UI_NETWORK_LOGS_SUCCESS), + /*is_error=*/false); +} + +void NetworkLogsMessageHandler::OnSetShillDebugging( + const base::ListValue* list) { + CHECK_EQ(2u, list->GetSize()); + std::string callback_id, subsystem; + CHECK(list->GetString(0, &callback_id)); + CHECK(list->GetString(1, &subsystem)); + AllowJavascript(); + chromeos::DBusThreadManager::Get()->GetDebugDaemonClient()->SetDebugMode( + subsystem, + base::BindOnce(&NetworkLogsMessageHandler::OnSetShillDebuggingCompleted, + weak_factory_.GetWeakPtr(), callback_id)); +} + +void NetworkLogsMessageHandler::OnSetShillDebuggingCompleted( + const std::string& callback_id, + bool succeeded) { + Respond(callback_id, /*result=*/"", !succeeded); +} + +} // namespace chromeos diff --git a/chromium/chrome/browser/ui/webui/chromeos/network_logs_message_handler.h b/chromium/chrome/browser/ui/webui/chromeos/network_logs_message_handler.h new file mode 100644 index 00000000000..6ecb291a883 --- /dev/null +++ b/chromium/chrome/browser/ui/webui/chromeos/network_logs_message_handler.h @@ -0,0 +1,56 @@ +// Copyright 2020 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 CHROME_BROWSER_UI_WEBUI_CHROMEOS_NETWORK_LOGS_MESSAGE_HANDLER_H_ +#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_NETWORK_LOGS_MESSAGE_HANDLER_H_ + +#include <string> + +#include "base/files/file_path.h" +#include "base/memory/weak_ptr.h" +#include "base/optional.h" +#include "base/values.h" +#include "content/public/browser/web_ui_message_handler.h" + +namespace chromeos { + +class NetworkLogsMessageHandler : public content::WebUIMessageHandler { + public: + NetworkLogsMessageHandler(); + ~NetworkLogsMessageHandler() override; + NetworkLogsMessageHandler(const NetworkLogsMessageHandler&) = delete; + NetworkLogsMessageHandler& operator=(const NetworkLogsMessageHandler&) = + delete; + + private: + // WebUIMessageHandler + void RegisterMessages() override; + + void Respond(const std::string& callback_id, + const std::string& result, + bool is_error); + void OnStoreLogs(const base::ListValue* list); + void OnWriteSystemLogs(const std::string& callback_id, + base::Value&& options, + base::Optional<base::FilePath> syslogs_path); + void MaybeWriteDebugLogs(const std::string& callback_id, + base::Value&& options); + void OnWriteDebugLogs(const std::string& callback_id, + base::Value&& options, + base::Optional<base::FilePath> logs_path); + void MaybeWritePolicies(const std::string& callback_id, + base::Value&& options); + void OnWritePolicies(const std::string& callback_id, bool result); + void OnWriteSystemLogsCompleted(const std::string& callback_id); + void OnSetShillDebugging(const base::ListValue* list); + void OnSetShillDebuggingCompleted(const std::string& callback_id, + bool succeeded); + + base::FilePath out_dir_; + base::WeakPtrFactory<NetworkLogsMessageHandler> weak_factory_{this}; +}; + +} // namespace chromeos + +#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_NETWORK_LOGS_MESSAGE_HANDLER_H_ diff --git a/chromium/chrome/browser/ui/webui/chromeos/network_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/network_ui.cc index da91385d0c7..410696940e1 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/network_ui.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/network_ui.cc @@ -14,11 +14,15 @@ #include "base/memory/weak_ptr.h" #include "base/strings/stringprintf.h" #include "base/values.h" +#include "chrome/browser/chromeos/net/network_health/network_health_localized_strings.h" +#include "chrome/browser/chromeos/net/network_health/network_health_service.h" #include "chrome/browser/extensions/tab_helper.h" #include "chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog_launcher.h" #include "chrome/browser/ui/webui/chromeos/internet_config_dialog.h" #include "chrome/browser/ui/webui/chromeos/internet_detail_dialog.h" #include "chrome/browser/ui/webui/chromeos/network_element_localized_strings_provider.h" +#include "chrome/browser/ui/webui/chromeos/network_logs_message_handler.h" +#include "chrome/browser/ui/webui/chromeos/onc_import_message_handler.h" #include "chrome/common/url_constants.h" #include "chrome/grit/browser_resources.h" #include "chrome/grit/generated_resources.h" @@ -29,12 +33,14 @@ #include "chromeos/network/network_state_handler.h" #include "chromeos/network/onc/onc_utils.h" #include "chromeos/services/network_config/public/mojom/cros_network_config.mojom.h" +#include "chromeos/services/network_health/public/mojom/network_health.mojom.h" #include "components/device_event_log/device_event_log.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui_data_source.h" #include "content/public/browser/web_ui_message_handler.h" +#include "mojo/public/cpp/bindings/remote.h" #include "third_party/cros_system_api/dbus/service_constants.h" #include "ui/base/l10n/l10n_util.h" @@ -132,29 +138,35 @@ class NetworkConfigMessageHandler : public content::WebUIMessageHandler { } private: + void Respond(const std::string& callback_id, const base::Value& response) { + AllowJavascript(); + ResolveJavascriptCallback(base::Value(callback_id), response); + } + void GetShillNetworkProperties(const base::ListValue* arg_list) { - std::string guid; - if (!arg_list->GetString(0, &guid)) { - NOTREACHED(); - return; - } + CHECK_EQ(2u, arg_list->GetSize()); + std::string callback_id, guid; + CHECK(arg_list->GetString(0, &callback_id)); + CHECK(arg_list->GetString(1, &guid)); + std::string service_path; if (!GetServicePathFromGuid(guid, &service_path)) { - ErrorCallback(guid, kGetNetworkProperties, "Error.InvalidNetworkGuid", - nullptr); + ErrorCallback(callback_id, guid, kGetNetworkProperties, + "Error.InvalidNetworkGuid", nullptr); return; } NetworkHandler::Get()->network_configuration_handler()->GetShillProperties( service_path, base::BindOnce( &NetworkConfigMessageHandler::GetShillNetworkPropertiesSuccess, - weak_ptr_factory_.GetWeakPtr()), + weak_ptr_factory_.GetWeakPtr(), callback_id), base::Bind(&NetworkConfigMessageHandler::ErrorCallback, - weak_ptr_factory_.GetWeakPtr(), guid, + weak_ptr_factory_.GetWeakPtr(), callback_id, guid, kGetNetworkProperties)); } void GetShillNetworkPropertiesSuccess( + const std::string& callback_id, const std::string& service_path, const base::DictionaryValue& dictionary) { std::unique_ptr<base::DictionaryValue> dictionary_copy( @@ -167,47 +179,46 @@ class NetworkConfigMessageHandler : public content::WebUIMessageHandler { base::ListValue return_arg_list; return_arg_list.Append(std::move(dictionary_copy)); - - AllowJavascript(); - CallJavascriptFunction( - base::StringPrintf("NetworkUI.%sResult", kGetNetworkProperties), - return_arg_list); + Respond(callback_id, return_arg_list); } void GetShillDeviceProperties(const base::ListValue* arg_list) { - std::string type; - if (!arg_list->GetString(0, &type)) { - NOTREACHED(); - return; - } + CHECK_EQ(2u, arg_list->GetSize()); + std::string callback_id, type; + CHECK(arg_list->GetString(0, &callback_id)); + CHECK(arg_list->GetString(1, &type)); + const DeviceState* device = NetworkHandler::Get()->network_state_handler()->GetDeviceStateByType( onc::NetworkTypePatternFromOncType(type)); if (!device) { - ErrorCallback(type, kGetDeviceProperties, "Error.InvalidDeviceType", - nullptr); + ErrorCallback(callback_id, type, kGetDeviceProperties, + "Error.InvalidDeviceType", nullptr); return; } NetworkHandler::Get()->network_device_handler()->GetDeviceProperties( device->path(), base::BindOnce( &NetworkConfigMessageHandler::GetShillDevicePropertiesSuccess, - weak_ptr_factory_.GetWeakPtr()), + weak_ptr_factory_.GetWeakPtr(), callback_id), base::Bind(&NetworkConfigMessageHandler::ErrorCallback, - weak_ptr_factory_.GetWeakPtr(), type, kGetDeviceProperties)); + weak_ptr_factory_.GetWeakPtr(), callback_id, type, + kGetDeviceProperties)); } void GetShillEthernetEAP(const base::ListValue* arg_list) { + CHECK_EQ(1u, arg_list->GetSize()); + std::string callback_id; + CHECK(arg_list->GetString(0, &callback_id)); + NetworkStateHandler::NetworkStateList list; NetworkHandler::Get()->network_state_handler()->GetNetworkListByType( NetworkTypePattern::Primitive(shill::kTypeEthernetEap), true /* configured_only */, false /* visible_only */, 1 /* limit */, &list); - AllowJavascript(); if (list.empty()) { - CallJavascriptFunction( - base::StringPrintf("NetworkUI.%sResult", kGetEthernetEAP)); + Respond(callback_id, base::Value(base::Value::Type::LIST)); return; } const NetworkState* eap = list.front(); @@ -215,21 +226,25 @@ class NetworkConfigMessageHandler : public content::WebUIMessageHandler { properties.SetStringKey("guid", eap->guid()); properties.SetStringKey("name", eap->name()); properties.SetStringKey("type", eap->type()); - CallJavascriptFunction( - base::StringPrintf("NetworkUI.%sResult", kGetEthernetEAP), properties); + base::Value response(base::Value::Type::LIST); + response.Append(std::move(properties)); + Respond(callback_id, response); } void OpenCellularActivationUi(const base::ListValue* arg_list) { + CHECK_EQ(1u, arg_list->GetSize()); + std::string callback_id; + CHECK(arg_list->GetString(0, &callback_id)); + const NetworkState* cellular_network = NetworkHandler::Get()->network_state_handler()->FirstNetworkByType( NetworkTypePattern::Cellular()); if (cellular_network) cellular_setup::OpenCellularSetupDialog(cellular_network->guid()); - AllowJavascript(); - CallJavascriptFunction( - base::StringPrintf("NetworkUI.%sResult", kOpenCellularActivationUi), - base::Value(cellular_network != nullptr)); + base::Value response(base::Value::Type::LIST); + response.Append(base::Value(cellular_network != nullptr)); + Respond(callback_id, response); } void ShowNetworkDetails(const base::ListValue* arg_list) { @@ -257,6 +272,7 @@ class NetworkConfigMessageHandler : public content::WebUIMessageHandler { } void GetShillDevicePropertiesSuccess( + const std::string& callback_id, const std::string& device_path, const base::DictionaryValue& dictionary) { std::unique_ptr<base::DictionaryValue> dictionary_copy( @@ -267,14 +283,11 @@ class NetworkConfigMessageHandler : public content::WebUIMessageHandler { base::ListValue return_arg_list; return_arg_list.Append(std::move(dictionary_copy)); - - AllowJavascript(); - CallJavascriptFunction( - base::StringPrintf("NetworkUI.%sResult", kGetDeviceProperties), - return_arg_list); + Respond(callback_id, return_arg_list); } - void ErrorCallback(const std::string& guid_or_type, + void ErrorCallback(const std::string& callback_id, + const std::string& guid_or_type, const std::string& function_name, const std::string& error_name, std::unique_ptr<base::DictionaryValue> /* error_data */) { @@ -287,11 +300,7 @@ class NetworkConfigMessageHandler : public content::WebUIMessageHandler { dictionary.SetKey(key, base::Value(guid_or_type)); dictionary.SetKey("ShillError", base::Value(error_name)); return_arg_list.Append(std::move(dictionary)); - - AllowJavascript(); - CallJavascriptFunction( - base::StringPrintf("NetworkUI.%sResult", function_name.c_str()), - return_arg_list); + Respond(callback_id, return_arg_list); } void AddNetwork(const base::ListValue* args) { @@ -312,8 +321,21 @@ void NetworkUI::GetLocalizedStrings(base::DictionaryValue* localized_strings) { localized_strings->SetString("titleText", l10n_util::GetStringUTF16(IDS_NETWORK_UI_TITLE)); - localized_strings->SetString("titleText", - l10n_util::GetStringUTF16(IDS_NETWORK_UI_TITLE)); + localized_strings->SetString( + "generalTab", l10n_util::GetStringUTF16(IDS_NETWORK_UI_TAB_GENERAL)); + localized_strings->SetString( + "networkHealthTab", + l10n_util::GetStringUTF16(IDS_NETWORK_UI_TAB_NETWORK_HEALTH)); + localized_strings->SetString( + "networkLogsTab", + l10n_util::GetStringUTF16(IDS_NETWORK_UI_TAB_NETWORK_LOGS)); + localized_strings->SetString( + "networkStateTab", + l10n_util::GetStringUTF16(IDS_NETWORK_UI_TAB_NETWORK_STATE)); + localized_strings->SetString( + "networkSelectTab", + l10n_util::GetStringUTF16(IDS_NETWORK_UI_TAB_NETWORK_SELECT)); + localized_strings->SetString( "autoRefreshText", l10n_util::GetStringUTF16(IDS_NETWORK_UI_AUTO_REFRESH)); @@ -347,6 +369,9 @@ void NetworkUI::GetLocalizedStrings(base::DictionaryValue* localized_strings) { "networkListsLabel", l10n_util::GetStringUTF16(IDS_NETWORK_UI_NETWORK_LISTS)); localized_strings->SetString( + "networkHealthLabel", + l10n_util::GetStringUTF16(IDS_NETWORK_UI_NETWORK_HEALTH)); + localized_strings->SetString( "visibleNetworksLabel", l10n_util::GetStringUTF16(IDS_NETWORK_UI_VISIBLE_NETWORKS)); localized_strings->SetString( @@ -375,11 +400,60 @@ void NetworkUI::GetLocalizedStrings(base::DictionaryValue* localized_strings) { localized_strings->SetString( "addNewWifiButtonText", l10n_util::GetStringUTF16(IDS_NETWORK_UI_ADD_NEW_WIFI_BUTTON_TEXT)); + + localized_strings->SetString( + "importOncButtonText", + l10n_util::GetStringUTF16(IDS_NETWORK_UI_IMPORT_ONC_BUTTON_TEXT)); + + localized_strings->SetString( + "addWiFiListItemName", + l10n_util::GetStringUTF16(IDS_NETWORK_ADD_WI_FI_LIST_ITEM_NAME)); + + // Network logs + localized_strings->SetString( + "networkLogsDescription", + l10n_util::GetStringUTF16(IDS_NETWORK_UI_NETWORK_LOGS_DESCRIPTION)); + localized_strings->SetString( + "networkLogsSystemLogs", + l10n_util::GetStringUTF16(IDS_NETWORK_UI_NETWORK_LOGS_SYSTEM_LOGS)); + localized_strings->SetString( + "networkLogsFilterPii", + l10n_util::GetStringUTF16(IDS_NETWORK_UI_NETWORK_LOGS_FILTER_PII)); + localized_strings->SetString( + "networkLogsPolicies", + l10n_util::GetStringUTF16(IDS_NETWORK_UI_NETWORK_LOGS_POLICIES)); + localized_strings->SetString( + "networkLogsDebugLogs", + l10n_util::GetStringUTF16(IDS_NETWORK_UI_NETWORK_LOGS_DEBUG_LOGS)); + localized_strings->SetString( + "networkLogsChromeLogs", + l10n_util::GetStringUTF16(IDS_NETWORK_UI_NETWORK_LOGS_CHROME_LOGS)); + localized_strings->SetString( + "networkLogsStoreButton", + l10n_util::GetStringUTF16(IDS_NETWORK_UI_NETWORK_LOGS_STORE_BUTTON)); + localized_strings->SetString( + "networkLogsStatus", + l10n_util::GetStringUTF16(IDS_NETWORK_UI_NETWORK_LOGS_STATUS)); + localized_strings->SetString( + "networkLogsDebuggingTitle", + l10n_util::GetStringUTF16(IDS_NETWORK_UI_NETWORK_LOGS_DEBUGGING_TITLE)); + localized_strings->SetString( + "networkLogsDebuggingDescription", + l10n_util::GetStringUTF16( + IDS_NETWORK_UI_NETWORK_LOGS_DEBUGGING_DESCRIPTION)); + localized_strings->SetString( + "networkLogsDebuggingNone", + l10n_util::GetStringUTF16(IDS_NETWORK_UI_NETWORK_LOGS_DEBUGGING_NONE)); + localized_strings->SetString( + "networkLogsDebuggingUnknown", + l10n_util::GetStringUTF16(IDS_NETWORK_UI_NETWORK_LOGS_DEBUGGING_UNKNOWN)); } NetworkUI::NetworkUI(content::WebUI* web_ui) : ui::MojoWebUIController(web_ui, /*enable_chrome_send=*/true) { web_ui->AddMessageHandler(std::make_unique<NetworkConfigMessageHandler>()); + web_ui->AddMessageHandler(std::make_unique<OncImportMessageHandler>()); + web_ui->AddMessageHandler(std::make_unique<NetworkLogsMessageHandler>()); // Enable extension API calls in the WebUI. extensions::TabHelper::CreateForWebContents(web_ui->GetWebContents()); @@ -390,13 +464,23 @@ NetworkUI::NetworkUI(content::WebUI* web_ui) content::WebUIDataSource* html = content::WebUIDataSource::Create(chrome::kChromeUINetworkHost); html->AddLocalizedStrings(localized_strings); + network_health::AddLocalizedStrings(html); network_element::AddLocalizedStrings(html); - + network_element::AddOncLocalizedStrings(html); html->UseStringsJs(); - html->AddResourcePath("network_ui.css", IDR_NETWORK_UI_CSS); + + html->AddResourcePath("network_ui_browser_proxy.html", + IDR_NETWORK_UI_BROWSER_PROXY_HTML); + html->AddResourcePath("network_ui_browser_proxy.js", + IDR_NETWORK_UI_BROWSER_PROXY_JS); + html->AddResourcePath("network_ui.html", IDR_NETWORK_UI_HTML); html->AddResourcePath("network_ui.js", IDR_NETWORK_UI_JS); - html->SetDefaultResource(IDR_NETWORK_UI_HTML); + html->AddResourcePath("network_state_ui.html", IDR_NETWORK_STATE_UI_HTML); + html->AddResourcePath("network_state_ui.js", IDR_NETWORK_STATE_UI_JS); + html->AddResourcePath("network_logs_ui.html", IDR_NETWORK_LOGS_UI_HTML); + html->AddResourcePath("network_logs_ui.js", IDR_NETWORK_LOGS_UI_JS); + html->SetDefaultResource(IDR_NETWORK_UI_PAGE_HTML); content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(), html); @@ -409,6 +493,13 @@ void NetworkUI::BindInterface( ash::GetNetworkConfigService(std::move(receiver)); } +void NetworkUI::BindInterface( + mojo::PendingReceiver<network_health::mojom::NetworkHealthService> + receiver) { + network_health::NetworkHealthService::GetInstance()->BindRemote( + std::move(receiver)); +} + WEB_UI_CONTROLLER_TYPE_IMPL(NetworkUI) } // namespace chromeos diff --git a/chromium/chrome/browser/ui/webui/chromeos/network_ui.h b/chromium/chrome/browser/ui/webui/chromeos/network_ui.h index 8e4fc290ebd..b7bbd7dbae0 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/network_ui.h +++ b/chromium/chrome/browser/ui/webui/chromeos/network_ui.h @@ -7,6 +7,7 @@ #include "base/macros.h" #include "chromeos/services/network_config/public/mojom/cros_network_config.mojom-forward.h" +#include "chromeos/services/network_health/public/mojom/network_health.mojom-forward.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "ui/webui/mojo_web_ui_controller.h" @@ -24,11 +25,17 @@ class NetworkUI : public ui::MojoWebUIController { static void GetLocalizedStrings(base::DictionaryValue* localized_strings); - // Instantiates implementor of the mojom::CrosNetworkConfig mojo interface + // Instantiates implementation of the mojom::CrosNetworkConfig mojo interface // passing the pending receiver that will be internally bound. void BindInterface( mojo::PendingReceiver<network_config::mojom::CrosNetworkConfig> receiver); + // Instantiates implementation of the mojom::NetworkHealthService mojo + // interface passing the pending receiver that will be bound. + void BindInterface( + mojo::PendingReceiver<network_health::mojom::NetworkHealthService> + receiver); + private: WEB_UI_CONTROLLER_TYPE_DECL(); diff --git a/chromium/chrome/browser/ui/webui/chromeos/onc_import_message_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/onc_import_message_handler.cc new file mode 100644 index 00000000000..27cd4019b27 --- /dev/null +++ b/chromium/chrome/browser/ui/webui/chromeos/onc_import_message_handler.cc @@ -0,0 +1,124 @@ +// Copyright 2020 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 "chrome/browser/ui/webui/chromeos/onc_import_message_handler.h" + +#include "base/bind.h" +#include "base/bind_helpers.h" +#include "base/strings/stringprintf.h" +#include "base/values.h" +#include "chrome/browser/chromeos/profiles/profile_helper.h" +#include "chrome/browser/net/nss_context.h" +#include "chrome/browser/profiles/profile.h" +#include "chromeos/network/onc/onc_certificate_importer_impl.h" +#include "chromeos/network/onc/onc_parsed_certificates.h" +#include "chromeos/network/onc/onc_utils.h" +#include "components/onc/onc_constants.h" +#include "components/policy/core/browser/policy_conversions.h" +#include "content/public/browser/browser_task_traits.h" +#include "content/public/browser/browser_thread.h" + +namespace chromeos { + +OncImportMessageHandler::OncImportMessageHandler() = default; + +OncImportMessageHandler::~OncImportMessageHandler() = default; + +void OncImportMessageHandler::RegisterMessages() { + web_ui()->RegisterMessageCallback( + "importONC", base::BindRepeating(&OncImportMessageHandler::OnImportONC, + base::Unretained(this))); +} + +void OncImportMessageHandler::Respond(const std::string& callback_id, + const std::string& result, + bool is_error) { + base::Value response(base::Value::Type::LIST); + response.Append(result); + response.Append(is_error); + ResolveJavascriptCallback(base::Value(callback_id), response); +} + +void OncImportMessageHandler::OnImportONC(const base::ListValue* list) { + CHECK_EQ(2u, list->GetSize()); + std::string callback_id, onc_blob; + CHECK(list->GetString(0, &callback_id)); + CHECK(list->GetString(1, &onc_blob)); + AllowJavascript(); + GetNSSCertDatabaseForProfile( + Profile::FromWebUI(web_ui()), + base::Bind(&OncImportMessageHandler::ImportONCToNSSDB, + weak_factory_.GetWeakPtr(), callback_id, onc_blob)); +} + +void OncImportMessageHandler::ImportONCToNSSDB(const std::string& callback_id, + const std::string& onc_blob, + net::NSSCertDatabase* nssdb) { + const user_manager::User* user = + ProfileHelper::Get()->GetUserByProfile(Profile::FromWebUI(web_ui())); + if (!user) { + Respond(callback_id, "User not found.", /*is_error=*/true); + return; + } + + std::string result; + bool has_error = false; + + ::onc::ONCSource onc_source = ::onc::ONC_SOURCE_USER_IMPORT; + base::ListValue network_configs; + base::DictionaryValue global_network_config; + base::ListValue certificates; + if (!onc::ParseAndValidateOncForImport( + onc_blob, onc_source, /*passphrase=*/std::string(), &network_configs, + &global_network_config, &certificates)) { + has_error = true; + result += "Errors occurred during ONC parsing.\n"; + } + + std::string import_error; + int num_networks_imported = + onc::ImportNetworksForUser(user, network_configs, &import_error); + if (!import_error.empty()) { + has_error = true; + result += "Error importing networks: " + import_error + "\n"; + } + result += + base::StringPrintf("Networks imported: %d\n", num_networks_imported); + if (certificates.GetList().empty()) { + if (!num_networks_imported) + has_error = true; + Respond(callback_id, result, has_error); + return; + } + + auto cert_importer = std::make_unique<onc::CertificateImporterImpl>( + content::GetIOThreadTaskRunner({}), nssdb); + auto certs = std::make_unique<onc::OncParsedCertificates>(certificates); + if (certs->has_error()) { + has_error = true; + result += "Some certificates could not be parsed.\n"; + } + cert_importer->ImportAllCertificatesUserInitiated( + certs->server_or_authority_certificates(), certs->client_certificates(), + base::BindOnce(&OncImportMessageHandler::OnCertificatesImported, + weak_factory_.GetWeakPtr(), std::move(cert_importer), + callback_id, result, has_error)); +} + +void OncImportMessageHandler::OnCertificatesImported( + std::unique_ptr<onc::CertificateImporterImpl> cert_importer, + const std::string& callback_id, + const std::string& previous_result, + bool has_error, + bool cert_import_success) { + std::string result = previous_result; + if (!cert_import_success) { + has_error = true; + result += "Some certificates couldn't be imported.\n"; + } + Respond(callback_id, result, has_error); + // |cert_importer| will be destroyed when the callback exits. +} + +} // namespace chromeos diff --git a/chromium/chrome/browser/ui/webui/chromeos/onc_import_message_handler.h b/chromium/chrome/browser/ui/webui/chromeos/onc_import_message_handler.h new file mode 100644 index 00000000000..834850e6f58 --- /dev/null +++ b/chromium/chrome/browser/ui/webui/chromeos/onc_import_message_handler.h @@ -0,0 +1,57 @@ +// Copyright 2020 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 CHROME_BROWSER_UI_WEBUI_CHROMEOS_ONC_IMPORT_MESSAGE_HANDLER_H_ +#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_ONC_IMPORT_MESSAGE_HANDLER_H_ + +#include <string> + +#include "base/memory/weak_ptr.h" +#include "content/public/browser/web_ui_message_handler.h" + +namespace base { +class ListValue; +} + +namespace net { +class NSSCertDatabase; +} + +namespace chromeos { + +namespace onc { +class CertificateImporterImpl; +} + +class OncImportMessageHandler : public content::WebUIMessageHandler { + public: + OncImportMessageHandler(); + ~OncImportMessageHandler() override; + OncImportMessageHandler(const OncImportMessageHandler&) = delete; + OncImportMessageHandler& operator=(const OncImportMessageHandler&) = delete; + + private: + // WebUIMessageHandler + void RegisterMessages() override; + + void Respond(const std::string& callback_id, + const std::string& result, + bool is_error); + void OnImportONC(const base::ListValue* list); + void ImportONCToNSSDB(const std::string& callback_id, + const std::string& onc_blob, + net::NSSCertDatabase* nssdb); + void OnCertificatesImported( + std::unique_ptr<onc::CertificateImporterImpl> cert_importer, + const std::string& callback_id, + const std::string& previous_error, + bool has_error, + bool cert_import_success); + + base::WeakPtrFactory<OncImportMessageHandler> weak_factory_{this}; +}; + +} // namespace chromeos + +#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_ONC_IMPORT_MESSAGE_HANDLER_H_ diff --git a/chromium/chrome/browser/ui/webui/chromeos/set_time_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/set_time_ui.cc index cc12e4bb71f..c1a0275910c 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/set_time_ui.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/set_time_ui.cc @@ -33,6 +33,7 @@ #include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui_data_source.h" #include "content/public/browser/web_ui_message_handler.h" +#include "services/network/public/mojom/content_security_policy.mojom.h" #include "ui/base/webui/web_ui_util.h" #include "ui/resources/grit/webui_resources.h" @@ -173,7 +174,8 @@ SetTimeUI::SetTimeUI(content::WebUI* web_ui) : WebDialogUI(web_ui) { // Set up the chrome://set-time source. content::WebUIDataSource* source = content::WebUIDataSource::Create(chrome::kChromeUISetTimeHost); - source->OverrideContentSecurityPolicyScriptSrc( + source->OverrideContentSecurityPolicy( + network::mojom::CSPDirectiveName::ScriptSrc, "script-src chrome://resources chrome://test 'self';"); static constexpr webui::LocalizedString kStrings[] = { diff --git a/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_credentials_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_credentials_dialog.cc index 0e64776606e..1fc4d7be1c1 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_credentials_dialog.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_credentials_dialog.cc @@ -20,7 +20,7 @@ namespace chromeos { namespace smb_dialog { namespace { -constexpr int kSmbCredentialsDialogHeight = 250; +constexpr int kSmbCredentialsDialogHeight = 230; void AddSmbCredentialsDialogStrings(content::WebUIDataSource* html_source) { static const struct { @@ -135,5 +135,9 @@ void SmbCredentialsDialogUI::OnUpdateCredentials(const std::string& username, } } +bool SmbCredentialsDialog::ShouldShowCloseButton() const { + return false; +} + } // namespace smb_dialog } // namespace chromeos diff --git a/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_credentials_dialog.h b/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_credentials_dialog.h index b614f60c71c..1836c16f136 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_credentials_dialog.h +++ b/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_credentials_dialog.h @@ -41,6 +41,7 @@ class SmbCredentialsDialog : public SystemWebDialogDelegate { // ui::WebDialogDelegate void GetDialogSize(gfx::Size* size) const override; std::string GetDialogArgs() const override; + bool ShouldShowCloseButton() const override; private: const std::string mount_id_; diff --git a/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_share_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_share_dialog.cc index 2aa8bca9516..8ffea982338 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_share_dialog.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_share_dialog.cc @@ -21,7 +21,7 @@ namespace chromeos { namespace smb_dialog { namespace { -constexpr int kSmbShareDialogHeight = 564; +constexpr int kSmbShareDialogHeight = 515; void AddSmbSharesStrings(content::WebUIDataSource* html_source) { // Add strings specific to smb_dialog. @@ -96,5 +96,9 @@ SmbShareDialogUI::SmbShareDialogUI(content::WebUI* web_ui) SmbShareDialogUI::~SmbShareDialogUI() = default; +bool SmbShareDialog::ShouldShowCloseButton() const { + return false; +} + } // namespace smb_dialog } // namespace chromeos diff --git a/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_share_dialog.h b/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_share_dialog.h index 15ff3f6bee9..8902231aff8 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_share_dialog.h +++ b/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_share_dialog.h @@ -23,6 +23,7 @@ class SmbShareDialog : public SystemWebDialogDelegate { // ui::WebDialogDelegate void GetDialogSize(gfx::Size* size) const override; + bool ShouldShowCloseButton() const override; DISALLOW_COPY_AND_ASSIGN(SmbShareDialog); }; |