diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-02-13 15:05:36 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-02-14 10:33:47 +0000 |
commit | e684a3455bcc29a6e3e66a004e352dea4e1141e7 (patch) | |
tree | d55b4003bde34d7d05f558f02cfd82b2a66a7aac /chromium/chrome/browser/ui/webui/settings | |
parent | 2b94bfe47ccb6c08047959d1c26e392919550e86 (diff) | |
download | qtwebengine-chromium-e684a3455bcc29a6e3e66a004e352dea4e1141e7.tar.gz |
BASELINE: Update Chromium to 72.0.3626.110 and Ninja to 1.9.0
Change-Id: Ic57220b00ecc929a893c91f5cc552f5d3e99e922
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/chrome/browser/ui/webui/settings')
32 files changed, 426 insertions, 1234 deletions
diff --git a/chromium/chrome/browser/ui/webui/settings/about_handler.cc b/chromium/chrome/browser/ui/webui/settings/about_handler.cc index 2486208d075..c372368a1e0 100644 --- a/chromium/chrome/browser/ui/webui/settings/about_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/about_handler.cc @@ -53,7 +53,7 @@ #if defined(OS_CHROMEOS) #include "base/i18n/time_formatting.h" -#include "base/sys_info.h" +#include "base/system/sys_info.h" #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_factory.h" #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.cc index 63783ab71f7..439b6fea161 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.cc @@ -76,8 +76,16 @@ void CrostiniHandler::HandleRemoveCrostiniSharedPath( std::string path; CHECK(args->GetString(0, &path)); - crostini::UnsharePath(profile_, crostini::kCrostiniDefaultVmName, - base::FilePath(path), base::DoNothing()); + crostini::CrostiniSharePath::GetForProfile(profile_)->UnsharePath( + crostini::kCrostiniDefaultVmName, base::FilePath(path), + base::BindOnce( + [](const std::string& path, bool result, std::string failure_reason) { + if (!result) { + LOG(ERROR) << "Error unsharing " << path << ": " + << failure_reason; + } + }, + path)); } } // namespace settings diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.h index a43ff984077..37b71f5d4f2 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.h +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.h @@ -11,7 +11,7 @@ class Profile; namespace crostini { -enum class ConciergeClientResult; +enum class CrostiniResult; } namespace chromeos { diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc index 7556aa92135..15f648a7215 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc @@ -9,6 +9,7 @@ #include "base/bind.h" #include "base/command_line.h" #include "base/values.h" +#include "chrome/browser/ui/ash/ksv/keyboard_shortcut_viewer_util.h" #include "chrome/browser/ui/ash/tablet_mode_client.h" #include "chromeos/chromeos_switches.h" #include "content/public/browser/web_ui.h" @@ -68,8 +69,8 @@ void KeyboardHandler::RegisterMessages() { base::BindRepeating(&KeyboardHandler::HandleInitialize, base::Unretained(this))); web_ui()->RegisterMessageCallback( - "showKeyboardShortcutsOverlay", - base::BindRepeating(&KeyboardHandler::HandleShowKeyboardShortcutsOverlay, + "showKeyboardShortcutViewer", + base::BindRepeating(&KeyboardHandler::HandleShowKeyboardShortcutViewer, base::Unretained(this))); web_ui()->RegisterMessageCallback( "initializeKeyboardWatcher", @@ -97,13 +98,9 @@ void KeyboardHandler::HandleInitialize(const base::ListValue* args) { UpdateKeyboards(); } -void KeyboardHandler::HandleShowKeyboardShortcutsOverlay( +void KeyboardHandler::HandleShowKeyboardShortcutViewer( const base::ListValue* args) const { - ash::mojom::NewWindowControllerPtr new_window_controller; - content::ServiceManagerConnection::GetForProcess() - ->GetConnector() - ->BindInterface(ash::mojom::kServiceName, &new_window_controller); - new_window_controller->ShowKeyboardOverlay(); + keyboard_shortcut_viewer_util::ToggleKeyboardShortcutViewer(); } void KeyboardHandler::HandleKeyboardChange(const base::ListValue* args) { diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.h index be8f0ae6e0b..6b071f0e217 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.h +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.h @@ -58,8 +58,8 @@ class KeyboardHandler // Initializes the page with the current keyboard information. void HandleInitialize(const base::ListValue* args); - // Shows the Ash keyboard shortcuts overlay. - void HandleShowKeyboardShortcutsOverlay(const base::ListValue* args) const; + // Shows the Ash keyboard shortcut viewer. + void HandleShowKeyboardShortcutViewer(const base::ListValue* args) const; // Determines what types of keyboards are attached. void HandleKeyboardChange(const base::ListValue* args); diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler_unittest.cc index 6c907c084c2..04ddbb99df5 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler_unittest.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler_unittest.cc @@ -14,7 +14,9 @@ #include "content/public/test/test_web_ui.h" #include "services/ws/public/cpp/input_devices/input_device_client_test_api.h" #include "testing/gtest/include/gtest/gtest.h" +#include "ui/aura/test/aura_test_utils.h" #include "ui/events/devices/input_device.h" +#include "ui/events/devices/input_device_manager.h" namespace chromeos { namespace settings { @@ -32,6 +34,8 @@ class TestKeyboardHandler : public KeyboardHandler { class KeyboardHandlerTest : public testing::Test { public: KeyboardHandlerTest() : handler_test_api_(&handler_) { + input_device_manager_ = aura::test::CreateTestInputDeviceManager(); + handler_.set_web_ui(&web_ui_); handler_.RegisterMessages(); handler_.AllowJavascriptForTesting(); @@ -157,6 +161,7 @@ class KeyboardHandlerTest : public testing::Test { return has_internal_search_key; } + std::unique_ptr<ui::InputDeviceManager> input_device_manager_; ws::InputDeviceClientTestApi input_device_client_test_api_; content::TestWebUI web_ui_; TestKeyboardHandler handler_; diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.cc index e2b4af37067..a846c92fd02 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.cc @@ -10,7 +10,7 @@ #include <string> #include "base/files/file_util.h" -#include "base/sys_info.h" +#include "base/system/sys_info.h" #include "base/task/post_task.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" @@ -341,7 +341,7 @@ void StorageHandler::UpdateCrostiniSize() { weak_ptr_factory_.GetWeakPtr())); } -void StorageHandler::OnGetCrostiniSize(crostini::ConciergeClientResult result, +void StorageHandler::OnGetCrostiniSize(crostini::CrostiniResult result, int64_t size) { updating_crostini_size_ = false; FireWebUIListener("storage-crostini-size-changed", diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.h index 8d5f7b04ceb..7021667406a 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.h +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.h @@ -22,7 +22,7 @@ class Profile; namespace crostini { -enum class ConciergeClientResult; +enum class CrostiniResult; } // namespace crostini namespace chromeos { @@ -94,7 +94,7 @@ class StorageHandler : public ::settings::SettingsPageUIHandler { void UpdateCrostiniSize(); // Callback to update the UI about Crostini VMs and their apps and cache. - void OnGetCrostiniSize(crostini::ConciergeClientResult result, int64_t size); + void OnGetCrostiniSize(crostini::CrostiniResult result, int64_t size); // Requests updating the total size of other users' data. void UpdateOtherUsersSize(); diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/easy_unlock_settings_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/easy_unlock_settings_handler.cc deleted file mode 100644 index 371edb36ef3..00000000000 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/easy_unlock_settings_handler.cc +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright 2016 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/settings/chromeos/easy_unlock_settings_handler.h" - -#include <string> - -#include "base/bind.h" -#include "base/command_line.h" -#include "base/macros.h" -#include "base/values.h" -#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_service.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/common/pref_names.h" -#include "chromeos/components/proximity_auth/switches.h" -#include "content/public/browser/web_ui.h" -#include "content/public/browser/web_ui_data_source.h" - -namespace chromeos { -namespace settings { - -EasyUnlockSettingsHandler::EasyUnlockSettingsHandler(Profile* profile) - : profile_(profile) { - profile_pref_registrar_.Init(profile->GetPrefs()); -} - -EasyUnlockSettingsHandler::~EasyUnlockSettingsHandler() { - EasyUnlockService::Get(profile_)->RemoveObserver(this); -} - -EasyUnlockSettingsHandler* EasyUnlockSettingsHandler::Create( - content::WebUIDataSource* html_source, - Profile* profile) { - EasyUnlockService* easy_unlock_service = EasyUnlockService::Get(profile); - // The service is not created for LockScreenApp profiles or "off the record". - if (!easy_unlock_service) - return nullptr; - - bool allowed = easy_unlock_service->IsAllowed(); - html_source->AddBoolean("easyUnlockAllowed", allowed); - html_source->AddBoolean("easyUnlockEnabled", - allowed ? easy_unlock_service->IsEnabled() : false); - // TODO(crbug.com/894585): Remove this legacy special case after M71. - html_source->AddBoolean("easyUnlockInLegacyHostMode", - allowed && easy_unlock_service->IsInLegacyHostMode()); - - if (!allowed) - return nullptr; - - return new EasyUnlockSettingsHandler(profile); -} - -void EasyUnlockSettingsHandler::RegisterMessages() { - web_ui()->RegisterMessageCallback( - "easyUnlockGetEnabledStatus", - base::BindRepeating(&EasyUnlockSettingsHandler::HandleGetEnabledStatus, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "easyUnlockStartTurnOnFlow", - base::BindRepeating(&EasyUnlockSettingsHandler::HandleStartTurnOnFlow, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "easyUnlockGetTurnOffFlowStatus", - base::BindRepeating( - &EasyUnlockSettingsHandler::HandleGetTurnOffFlowStatus, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "easyUnlockStartTurnOffFlow", - base::BindRepeating(&EasyUnlockSettingsHandler::HandleStartTurnOffFlow, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "easyUnlockCancelTurnOffFlow", - base::BindRepeating(&EasyUnlockSettingsHandler::HandleCancelTurnOffFlow, - base::Unretained(this))); -} - -void EasyUnlockSettingsHandler::OnJavascriptAllowed() { - EasyUnlockService::Get(profile_)->AddObserver(this); - - profile_pref_registrar_.Add( - prefs::kEasyUnlockPairing, - base::Bind(&EasyUnlockSettingsHandler::SendEnabledStatus, - base::Unretained(this))); -} - -void EasyUnlockSettingsHandler::OnJavascriptDisallowed() { - EasyUnlockService::Get(profile_)->RemoveObserver(this); - profile_pref_registrar_.RemoveAll(); -} - -void EasyUnlockSettingsHandler::OnTurnOffOperationStatusChanged() { - FireWebUIListener("easy-unlock-turn-off-flow-status", - base::Value(GetTurnOffFlowStatus())); -} - -void EasyUnlockSettingsHandler::SendEnabledStatus() { - CallJavascriptFunction( - "cr.webUIListenerCallback", base::Value("easy-unlock-enabled-status"), - base::Value(EasyUnlockService::Get(profile_)->IsEnabled())); -} - -std::string EasyUnlockSettingsHandler::GetTurnOffFlowStatus() { - EasyUnlockService::TurnOffFlowStatus status = - EasyUnlockService::Get(profile_)->GetTurnOffFlowStatus(); - - // Translate status into JS UI state string. Note the translated string - // should match UIState defined in easy_unlock_turn_off_dialog.js. - std::string status_string; - switch (status) { - case EasyUnlockService::IDLE: - status_string = "idle"; - break; - case EasyUnlockService::PENDING: - status_string = "pending"; - break; - case EasyUnlockService::FAIL: - status_string = "server-error"; - break; - default: - LOG(ERROR) << "Unknown Easy unlock turn-off operation status: " << status; - status_string = "idle"; - break; - } - - return status_string; -} - -void EasyUnlockSettingsHandler::HandleGetEnabledStatus( - const base::ListValue* args) { - AllowJavascript(); - - CHECK_EQ(1U, args->GetSize()); - const base::Value* callback_id; - CHECK(args->Get(0, &callback_id)); - ResolveJavascriptCallback( - *callback_id, base::Value(EasyUnlockService::Get(profile_)->IsEnabled())); -} - -void EasyUnlockSettingsHandler::HandleStartTurnOnFlow( - const base::ListValue* args) { - EasyUnlockService::Get(profile_)->LaunchSetup(); -} - -void EasyUnlockSettingsHandler::HandleGetTurnOffFlowStatus( - const base::ListValue* args) { - CHECK_EQ(1U, args->GetSize()); - const base::Value* callback_id; - CHECK(args->Get(0, &callback_id)); - ResolveJavascriptCallback(*callback_id, base::Value(GetTurnOffFlowStatus())); -} - -void EasyUnlockSettingsHandler::HandleStartTurnOffFlow( - const base::ListValue* args) { - EasyUnlockService::Get(profile_)->RunTurnOffFlow(); -} - -void EasyUnlockSettingsHandler::HandleCancelTurnOffFlow( - const base::ListValue* args) { - EasyUnlockService::Get(profile_)->ResetTurnOffFlow(); -} - -} // namespace settings -} // namespace chromeos diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/easy_unlock_settings_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/easy_unlock_settings_handler.h deleted file mode 100644 index e4509d75036..00000000000 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/easy_unlock_settings_handler.h +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2016 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_SETTINGS_CHROMEOS_EASY_UNLOCK_SETTINGS_HANDLER_H_ -#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_EASY_UNLOCK_SETTINGS_HANDLER_H_ - -#include "base/macros.h" -#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_service_observer.h" -#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" -#include "components/prefs/pref_change_registrar.h" - -namespace content { -class WebUIDataSource; -} - -class Profile; - -namespace chromeos { -namespace settings { - -class EasyUnlockSettingsHandler : public ::settings::SettingsPageUIHandler, - public EasyUnlockServiceObserver { - public: - // Returns nullptr if EasyUnlock is not allowed for this device. - static EasyUnlockSettingsHandler* Create( - content::WebUIDataSource* html_source, - Profile* profile); - - ~EasyUnlockSettingsHandler() override; - - // SettingsPageUIHandler: - void RegisterMessages() override; - void OnJavascriptAllowed() override; - void OnJavascriptDisallowed() override; - - // EasyUnlockServiceObserver: - void OnTurnOffOperationStatusChanged() override; - - protected: - explicit EasyUnlockSettingsHandler(Profile* profile); - - private: - FRIEND_TEST_ALL_PREFIXES(EasyUnlockSettingsHandlerTest, EnabledStatus); - FRIEND_TEST_ALL_PREFIXES(EasyUnlockSettingsHandlerTest, TurnOffFlowStatus); - - void SendEnabledStatus(); - std::string GetTurnOffFlowStatus(); - - // JS callbacks. - void HandleGetEnabledStatus(const base::ListValue* args); - void HandleStartTurnOnFlow(const base::ListValue* args); - void HandleGetTurnOffFlowStatus(const base::ListValue* args); - void HandleStartTurnOffFlow(const base::ListValue* args); - void HandleCancelTurnOffFlow(const base::ListValue* args); - - Profile* const profile_; - - PrefChangeRegistrar profile_pref_registrar_; - - DISALLOW_COPY_AND_ASSIGN(EasyUnlockSettingsHandler); -}; - -} // namespace settings -} // namespace chromeos - -#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_EASY_UNLOCK_SETTINGS_HANDLER_H_ diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/easy_unlock_settings_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/easy_unlock_settings_handler_unittest.cc deleted file mode 100644 index f69e29ce1a1..00000000000 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/easy_unlock_settings_handler_unittest.cc +++ /dev/null @@ -1,281 +0,0 @@ -// Copyright 2016 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/settings/chromeos/easy_unlock_settings_handler.h" - -#include <memory> - -#include "base/bind.h" -#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_service.h" -#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_service_factory.h" -#include "chrome/test/base/testing_profile.h" -#include "content/public/browser/web_ui_data_source.h" -#include "content/public/test/test_browser_thread_bundle.h" -#include "content/public/test/test_web_ui.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace chromeos { -namespace settings { - -namespace { - -class FakeEasyUnlockService : public EasyUnlockService { - public: - explicit FakeEasyUnlockService(Profile* profile) - : EasyUnlockService(profile, nullptr /* secure_channel_client */), - turn_off_status_(IDLE), - is_allowed_(true), - is_enabled_(false) {} - - TurnOffFlowStatus GetTurnOffFlowStatus() const override { - return turn_off_status_; - } - - bool IsAllowed() const override { return is_allowed_; } - void set_is_allowed(bool is_allowed) { is_allowed_ = is_allowed; } - - bool IsEnabled() const override { return is_enabled_; } - void set_is_enabled(bool is_enabled) { is_enabled_ = is_enabled; } - - void RunTurnOffFlow() override { - turn_off_status_ = PENDING; - NotifyTurnOffOperationStatusChanged(); - } - - void ResetTurnOffFlow() override { - turn_off_status_ = IDLE; - NotifyTurnOffOperationStatusChanged(); - } - - void SetTurnOffFlowFailForTest() { - turn_off_status_ = FAIL; - NotifyTurnOffOperationStatusChanged(); - } - - private: - Type GetType() const override { return TYPE_REGULAR; } - AccountId GetAccountId() const override { return EmptyAccountId(); } - void LaunchSetup() override {} - void ClearPermitAccess() override {} - - const base::ListValue* GetRemoteDevices() const override { return nullptr; } - void SetRemoteDevices(const base::ListValue& devices) override {} - - std::string GetChallenge() const override { return std::string(); } - std::string GetWrappedSecret() const override { return std::string(); } - void RecordEasySignInOutcome(const AccountId& account_id, - bool success) const override {} - void RecordPasswordLoginEvent(const AccountId& account_id) const override {} - - void InitializeInternal() override {} - void ShutdownInternal() override {} - bool IsAllowedInternal() const override { return false; } - void OnWillFinalizeUnlock(bool success) override {} - void OnSuspendDoneInternal() override {} - - TurnOffFlowStatus turn_off_status_; - bool is_allowed_; - bool is_enabled_; -}; - -class TestEasyUnlockSettingsHandler : public EasyUnlockSettingsHandler { - public: - explicit TestEasyUnlockSettingsHandler(Profile* profile) - : EasyUnlockSettingsHandler(profile) {} - - using EasyUnlockSettingsHandler::set_web_ui; -}; - -std::unique_ptr<KeyedService> CreateEasyUnlockServiceForTest( - content::BrowserContext* context) { - return std::make_unique<FakeEasyUnlockService>( - Profile::FromBrowserContext(context)); -} - -std::unique_ptr<KeyedService> CreateNullEasyUnlockServiceForTest( - content::BrowserContext* context) { - return nullptr; -} - -} // namespace - -class EasyUnlockSettingsHandlerTest : public testing::Test { - public: - EasyUnlockSettingsHandlerTest() {} - - void SetUp() override { - TestingProfile::Builder builder; - builder.AddTestingFactory( - EasyUnlockServiceFactory::GetInstance(), - base::BindRepeating(&CreateEasyUnlockServiceForTest)); - profile_ = builder.Build(); - } - - Profile* profile() { return profile_.get(); } - content::TestWebUI* web_ui() { return &web_ui_; } - FakeEasyUnlockService* fake_easy_unlock_service() { - return static_cast<FakeEasyUnlockService*>( - EasyUnlockService::Get(profile_.get())); - } - - void MakeEasyUnlockServiceNull() { - TestingProfile::Builder builder; - builder.AddTestingFactory( - EasyUnlockServiceFactory::GetInstance(), - base::BindRepeating(&CreateNullEasyUnlockServiceForTest)); - profile_ = builder.Build(); - } - - void VerifyEnabledStatusCallback(size_t expected_total_calls, - bool expected_status) { - std::string event; - bool status; - - EXPECT_EQ(expected_total_calls, web_ui_.call_data().size()); - - const content::TestWebUI::CallData& data = *web_ui_.call_data().back(); - EXPECT_EQ("cr.webUIListenerCallback", data.function_name()); - ASSERT_TRUE(data.arg1()->GetAsString(&event)); - EXPECT_EQ("easy-unlock-enabled-status", event); - ASSERT_TRUE(data.arg2()->GetAsBoolean(&status)); - - EXPECT_EQ(expected_status, status); - } - - void VerifyTurnOffFlowStatusWebUIListenerCallback( - size_t expected_total_calls, - const std::string& expected_status) { - std::string event; - std::string status; - - EXPECT_EQ(expected_total_calls, web_ui_.call_data().size()); - - const content::TestWebUI::CallData& data = *web_ui_.call_data().back(); - EXPECT_EQ("cr.webUIListenerCallback", data.function_name()); - ASSERT_TRUE(data.arg1()->GetAsString(&event)); - EXPECT_EQ("easy-unlock-turn-off-flow-status", event); - ASSERT_TRUE(data.arg2()->GetAsString(&status)); - - EXPECT_EQ(expected_status, status); - } - - void VerifyTurnOffFlowStatusWebUIResponse( - size_t expected_total_calls, - const std::string& expected_callback_id, - const std::string& expected_status) { - EXPECT_EQ(expected_total_calls, web_ui()->call_data().size()); - - const content::TestWebUI::CallData& data = *web_ui()->call_data().back(); - EXPECT_EQ("cr.webUIResponse", data.function_name()); - - std::string callback_id; - ASSERT_TRUE(data.arg1()->GetAsString(&callback_id)); - EXPECT_EQ(expected_callback_id, callback_id); - - std::string actual_status; - ASSERT_TRUE(data.arg3()->GetAsString(&actual_status)); - EXPECT_EQ(expected_status, actual_status); - } - - private: - content::TestBrowserThreadBundle thread_bundle_; - std::unique_ptr<TestingProfile> profile_; - content::TestWebUI web_ui_; -}; - -TEST_F(EasyUnlockSettingsHandlerTest, OnlyCreatedWhenEasyUnlockAllowed) { - std::unique_ptr<EasyUnlockSettingsHandler> handler; - content::WebUIDataSource* data_source = - content::WebUIDataSource::Create("test-data-source"); - content::WebUIDataSource::Add(profile(), data_source); - handler.reset( - EasyUnlockSettingsHandler::Create(data_source, profile())); - EXPECT_TRUE(handler.get()); - - fake_easy_unlock_service()->set_is_allowed(false); - handler.reset(EasyUnlockSettingsHandler::Create(data_source, profile())); - EXPECT_FALSE(handler.get()); -} - -TEST_F(EasyUnlockSettingsHandlerTest, NotCreatedWhenEasyUnlockServiceNull) { - MakeEasyUnlockServiceNull(); - std::unique_ptr<EasyUnlockSettingsHandler> handler; - content::WebUIDataSource* data_source = - content::WebUIDataSource::Create("test-data-source"); - content::WebUIDataSource::Add(profile(), data_source); - handler.reset(EasyUnlockSettingsHandler::Create(data_source, profile())); - EXPECT_FALSE(handler.get()); -} - -TEST_F(EasyUnlockSettingsHandlerTest, EnabledStatus) { - std::unique_ptr<EasyUnlockSettingsHandler> handler; - handler.reset(new TestEasyUnlockSettingsHandler(profile())); - handler->set_web_ui(web_ui()); - - // Test the JS -> C++ -> JS callback path. - base::ListValue list_args; - list_args.AppendString("test-callback-id"); - handler->HandleGetEnabledStatus(&list_args); - - EXPECT_EQ(1U, web_ui()->call_data().size()); - - const content::TestWebUI::CallData& data = *web_ui()->call_data().back(); - EXPECT_EQ("cr.webUIResponse", data.function_name()); - - std::string callback_id; - ASSERT_TRUE(data.arg1()->GetAsString(&callback_id)); - EXPECT_EQ("test-callback-id", callback_id); - - bool enabled_status = false; - ASSERT_TRUE(data.arg3()->GetAsBoolean(&enabled_status)); - EXPECT_FALSE(enabled_status); - - // Test the C++ -> JS push path. - handler->SendEnabledStatus(); - VerifyEnabledStatusCallback(2U, false); - - fake_easy_unlock_service()->set_is_enabled(true); - handler->SendEnabledStatus(); - VerifyEnabledStatusCallback(3U, true); -} - -TEST_F(EasyUnlockSettingsHandlerTest, TurnOffFlowStatus) { - std::unique_ptr<EasyUnlockSettingsHandler> handler; - handler.reset(new TestEasyUnlockSettingsHandler(profile())); - handler->set_web_ui(web_ui()); - - // Send an initial status query to turn on service observer. - base::ListValue list_args1; - list_args1.AppendString("test-callback-id-1"); - handler->HandleGetEnabledStatus(&list_args1); - EXPECT_EQ(1U, web_ui()->call_data().size()); - - base::ListValue list_args2; - list_args2.AppendString("test-callback-id-2"); - handler->HandleGetTurnOffFlowStatus(&list_args2); - VerifyTurnOffFlowStatusWebUIResponse(2U, "test-callback-id-2", "idle"); - - handler->HandleStartTurnOffFlow(nullptr); - VerifyTurnOffFlowStatusWebUIListenerCallback(3U, "pending"); - - base::ListValue list_args3; - list_args3.AppendString("test-callback-id-3"); - handler->HandleGetTurnOffFlowStatus(&list_args3); - VerifyTurnOffFlowStatusWebUIResponse(4U, "test-callback-id-3", "pending"); - - handler->HandleCancelTurnOffFlow(nullptr); - VerifyTurnOffFlowStatusWebUIListenerCallback(5U, "idle"); - - fake_easy_unlock_service()->SetTurnOffFlowFailForTest(); - VerifyTurnOffFlowStatusWebUIListenerCallback(6U, "server-error"); - - base::ListValue list_args4; - list_args4.AppendString("test-callback-id-4"); - handler->HandleGetTurnOffFlowStatus(&list_args4); - VerifyTurnOffFlowStatusWebUIResponse(7U, "test-callback-id-4", - "server-error"); -} - -} // namespace settings -} // namespace chromeos diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/internet_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/internet_handler_unittest.cc index 679b5cfdd3d..75a86bfae5d 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/internet_handler_unittest.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/internet_handler_unittest.cc @@ -53,8 +53,6 @@ class InternetHandlerTest : public BrowserWithTestWindowTest { fake_tracker_.get()); } - void TearDown() override { BrowserWithTestWindowTest::TearDown(); } - void RequestGmsCoreNotificationsDisabledDeviceNames() { handler_->RequestGmsCoreNotificationsDisabledDeviceNames(nullptr); } diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.cc index c9f32d271f2..aaf9de111c8 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.cc @@ -137,8 +137,8 @@ void MultideviceHandler::UpdatePageContent() { std::unique_ptr<base::DictionaryValue> page_content_dictionary = GeneratePageContentDataDictionary(); DCHECK(page_content_dictionary); - PA_LOG(INFO) << "Updating MultiDevice settings page content with: " - << *page_content_dictionary << "."; + PA_LOG(VERBOSE) << "Updating MultiDevice settings page content with: " + << *page_content_dictionary << "."; FireWebUIListener("settings.updateMultidevicePageContentData", *page_content_dictionary); } @@ -166,8 +166,8 @@ void MultideviceHandler::HandleGetPageContent(const base::ListValue* args) { std::unique_ptr<base::DictionaryValue> page_content_dictionary = GeneratePageContentDataDictionary(); DCHECK(page_content_dictionary); - PA_LOG(INFO) << "Responding to getPageContentData() request with: " - << *page_content_dictionary << "."; + PA_LOG(VERBOSE) << "Responding to getPageContentData() request with: " + << *page_content_dictionary << "."; ResolveJavascriptCallback(base::Value(callback_id), *page_content_dictionary); } @@ -213,9 +213,8 @@ void MultideviceHandler::HandleRetryPendingHostSetup( } void MultideviceHandler::HandleSetUpAndroidSms(const base::ListValue* args) { - PA_LOG(INFO) << "SetUpSMS triggered."; DCHECK(args->empty()); - android_sms_app_helper_->InstallAndLaunchAndroidSmsApp(); + android_sms_app_helper_->SetUpAndLaunchAndroidSmsApp(); } void MultideviceHandler::HandleGetSmartLockSignInEnabled( diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/smb_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/smb_handler.cc deleted file mode 100644 index fe499876eb0..00000000000 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/smb_handler.cc +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright 2018 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/ui/webui/settings/chromeos/smb_handler.h" - -#include <string> -#include <utility> - -#include "base/bind.h" -#include "base/values.h" -#include "chrome/browser/chromeos/file_system_provider/provided_file_system_info.h" -#include "chrome/browser/profiles/profile.h" -#include "content/public/browser/web_ui_message_handler.h" - -namespace chromeos { -namespace settings { - -namespace { - -smb_client::SmbService* GetSmbService(Profile* profile) { - smb_client::SmbService* const service = smb_client::SmbService::Get(profile); - return service; -} - -base::Value BuildShareList(const std::vector<smb_client::SmbUrl>& shares) { - base::Value shares_list(base::Value::Type::LIST); - for (const auto& share : shares) { - shares_list.GetList().push_back(base::Value(share.GetWindowsUNCString())); - } - return shares_list; -} - -} // namespace - -SmbHandler::SmbHandler(Profile* profile) - : profile_(profile), weak_ptr_factory_(this) {} - -SmbHandler::~SmbHandler() = default; - -void SmbHandler::RegisterMessages() { - web_ui()->RegisterMessageCallback( - "smbMount", - base::BindRepeating(&SmbHandler::HandleSmbMount, base::Unretained(this))); - - web_ui()->RegisterMessageCallback( - "startDiscovery", base::BindRepeating(&SmbHandler::HandleStartDiscovery, - base::Unretained(this))); -} - -void SmbHandler::HandleSmbMount(const base::ListValue* args) { - CHECK_EQ(5U, args->GetSize()); - std::string mount_url; - std::string mount_name; - std::string username; - std::string password; - bool use_kerberos; - CHECK(args->GetString(0, &mount_url)); - CHECK(args->GetString(1, &mount_name)); - CHECK(args->GetString(2, &username)); - CHECK(args->GetString(3, &password)); - CHECK(args->GetBoolean(4, &use_kerberos)); - - smb_client::SmbService* const service = GetSmbService(profile_); - if (!service) { - return; - } - - chromeos::file_system_provider::MountOptions mo; - mo.display_name = mount_name.empty() ? mount_url : mount_name; - mo.writable = true; - - auto mount_response = base::BindOnce(&SmbHandler::HandleSmbMountResponse, - weak_ptr_factory_.GetWeakPtr()); - auto mount_call = - base::BindOnce(&smb_client::SmbService::Mount, base::Unretained(service), - mo, base::FilePath(mount_url), username, password, - use_kerberos, std::move(mount_response)); - - if (host_discovery_done_) { - std::move(mount_call).Run(); - } else { - stored_mount_call_ = std::move(mount_call); - } -} - -void SmbHandler::HandleSmbMountResponse(SmbMountResult result) { - AllowJavascript(); - FireWebUIListener("on-add-smb-share", base::Value(static_cast<int>(result))); -} - -void SmbHandler::HandleStartDiscovery(const base::ListValue* args) { - smb_client::SmbService* const service = GetSmbService(profile_); - if (!service) { - return; - } - - service->GatherSharesInNetwork( - base::BindOnce(&SmbHandler::HandleDiscoveryDone, - weak_ptr_factory_.GetWeakPtr()), - base::BindRepeating(&SmbHandler::HandleGatherSharesResponse, - weak_ptr_factory_.GetWeakPtr())); -} - -void SmbHandler::HandleDiscoveryDone() { - host_discovery_done_ = true; - if (!stored_mount_call_.is_null()) { - std::move(stored_mount_call_).Run(); - } -} - -void SmbHandler::HandleGatherSharesResponse( - const std::vector<smb_client::SmbUrl>& shares_gathered) { - AllowJavascript(); - FireWebUIListener("on-shares-found", BuildShareList(shares_gathered)); -} - - -} // namespace settings -} // namespace chromeos diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/smb_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/smb_handler.h deleted file mode 100644 index 42a5602d593..00000000000 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/smb_handler.h +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2018 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_SMB_HANDLER_H_ -#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_SMB_HANDLER_H_ - -#include "base/callback_forward.h" -#include "base/files/file.h" -#include "base/macros.h" -#include "base/memory/weak_ptr.h" -#include "chrome/browser/chromeos/smb_client/smb_service.h" -#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" - -class Profile; - -namespace chromeos { -namespace settings { - -using smb_client::SmbMountResult; - -class SmbHandler : public ::settings::SettingsPageUIHandler { - public: - explicit SmbHandler(Profile* profile); - ~SmbHandler() override; - - void RegisterMessages() override; - void OnJavascriptAllowed() override {} - void OnJavascriptDisallowed() override {} - - private: - // WebUI call to mount an Smb Filesystem. - void HandleSmbMount(const base::ListValue* args); - - // WebUI call to start file share discovery on the network. - void HandleStartDiscovery(const base::ListValue* args); - - // Callback handler for SmbMount. - void HandleSmbMountResponse(SmbMountResult result); - - // Callback handler for StartDiscovery. - void HandleGatherSharesResponse( - const std::vector<smb_client::SmbUrl>& shares_gathered); - - // Callback handler that indicates discovery is complete. - void HandleDiscoveryDone(); - - bool host_discovery_done_ = false; - base::OnceClosure stored_mount_call_; - Profile* const profile_; - base::WeakPtrFactory<SmbHandler> weak_ptr_factory_; - - DISALLOW_COPY_AND_ASSIGN(SmbHandler); -}; - -} // namespace settings -} // namespace chromeos - -#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_SMB_HANDLER_H_ diff --git a/chromium/chrome/browser/ui/webui/settings/custom_home_pages_table_model.cc b/chromium/chrome/browser/ui/webui/settings/custom_home_pages_table_model.cc index 69675d49bc5..3632a26b706 100644 --- a/chromium/chrome/browser/ui/webui/settings/custom_home_pages_table_model.cc +++ b/chromium/chrome/browser/ui/webui/settings/custom_home_pages_table_model.cc @@ -152,7 +152,7 @@ void CustomHomePagesTableModel::Remove(int index) { } void CustomHomePagesTableModel::SetToCurrentlyOpenPages( - const content::WebContents* ignore_contents) { + content::WebContents* ignore_contents) { // Remove the current entries. while (RowCount()) RemoveWithoutNotification(0); @@ -166,7 +166,7 @@ void CustomHomePagesTableModel::SetToCurrentlyOpenPages( for (int tab_index = 0; tab_index < browser->tab_strip_model()->count(); ++tab_index) { - const content::WebContents* contents = + content::WebContents* contents = browser->tab_strip_model()->GetWebContentsAt(tab_index); if (contents == ignore_contents) continue; diff --git a/chromium/chrome/browser/ui/webui/settings/custom_home_pages_table_model.h b/chromium/chrome/browser/ui/webui/settings/custom_home_pages_table_model.h index 04760e43e7b..80937b2d8fe 100644 --- a/chromium/chrome/browser/ui/webui/settings/custom_home_pages_table_model.h +++ b/chromium/chrome/browser/ui/webui/settings/custom_home_pages_table_model.h @@ -54,7 +54,7 @@ class CustomHomePagesTableModel : public ui::TableModel { // Clears any entries and fills the list with pages currently opened in the // browser. |ignore_contents| is omitted from the open pages. - void SetToCurrentlyOpenPages(const content::WebContents* ignore_contents); + void SetToCurrentlyOpenPages(content::WebContents* ignore_contents); // Returns the set of urls this model contains. std::vector<GURL> GetURLs(); diff --git a/chromium/chrome/browser/ui/webui/settings/languages_handler.cc b/chromium/chrome/browser/ui/webui/settings/languages_handler.cc index 0346fa16e01..68aa52886fa 100644 --- a/chromium/chrome/browser/ui/webui/settings/languages_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/languages_handler.cc @@ -70,14 +70,6 @@ void LanguagesHandler::HandleSetProspectiveUILanguage( std::string language_code; CHECK(args->GetString(0, &language_code)); -#if defined(OS_CHROMEOS) - // check if prospectiveUILanguage is allowed by policy (AllowedUILocales) - if (!chromeos::locale_util::IsAllowedUILocale(language_code, - profile_->GetPrefs())) { - return; - } -#endif - #if defined(OS_WIN) PrefService* prefs = g_browser_process->local_state(); prefs->SetString(language::prefs::kApplicationLocale, language_code); diff --git a/chromium/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc b/chromium/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc index c235469b5f0..ab6b01e39cf 100644 --- a/chromium/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc +++ b/chromium/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc @@ -21,6 +21,7 @@ #include "chrome/browser/profiles/profile_shortcut_manager.h" #include "chrome/browser/signin/account_consistency_mode_manager.h" #include "chrome/browser/sync/profile_sync_service_factory.h" +#include "chrome/browser/ui/passwords/manage_passwords_view_utils.h" #include "chrome/browser/ui/webui/policy_indicator_localized_strings_provider.h" #include "chrome/common/chrome_features.h" #include "chrome/common/chrome_switches.h" @@ -36,6 +37,7 @@ #include "components/browser_sync/profile_sync_service.h" #include "components/google/core/common/google_util.h" #include "components/omnibox/browser/omnibox_field_trial.h" +#include "components/password_manager/core/browser/manage_passwords_referrer.h" #include "components/password_manager/core/common/password_manager_features.h" #include "components/safe_browsing/common/safe_browsing_prefs.h" #include "components/signin/core/browser/signin_buildflags.h" @@ -47,13 +49,14 @@ #include "content/public/common/content_features.h" #include "media/base/media_switches.h" #include "services/device/public/cpp/device_features.h" +#include "ui/accessibility/accessibility_switches.h" #include "ui/base/l10n/l10n_util.h" #if defined(OS_CHROMEOS) #include "ash/public/cpp/ash_features.h" #include "ash/public/cpp/ash_switches.h" #include "ash/public/interfaces/voice_interaction_controller.mojom.h" -#include "base/sys_info.h" +#include "base/system/sys_info.h" #include "chrome/browser/chromeos/arc/arc_util.h" #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_factory.h" @@ -61,6 +64,7 @@ #include "chrome/browser/chromeos/profiles/profile_helper.h" #include "chrome/browser/ui/webui/chromeos/bluetooth_dialog_localized_strings_provider.h" #include "chrome/browser/ui/webui/chromeos/network_element_localized_strings_provider.h" +#include "chrome/browser/ui/webui/chromeos/smb_shares/smb_shares_localized_strings_provider.h" #include "chromeos/chromeos_features.h" #include "chromeos/chromeos_switches.h" #include "chromeos/services/multidevice_setup/public/cpp/url_provider.h" @@ -79,6 +83,10 @@ #if defined(GOOGLE_CHROME_BUILD) #include "base/metrics/field_trial_params.h" +#include "base/strings/strcat.h" +#include "base/strings/utf_string_conversions.h" +#include "chrome/grit/chrome_unscaled_resources.h" +#include "ui/base/resource/resource_bundle.h" #endif #endif // defined(OS_WIN) @@ -147,10 +155,13 @@ void AddCommonStrings(content::WebUIDataSource* html_source, Profile* profile) { {"retry", IDS_SETTINGS_RETRY}, {"save", IDS_SAVE}, {"settings", IDS_SETTINGS_SETTINGS}, + {"settingsAltPageTitle", IDS_SETTINGS_ALT_PAGE_TITLE}, {"toggleOn", IDS_SETTINGS_TOGGLE_ON}, {"toggleOff", IDS_SETTINGS_TOGGLE_OFF}, {"notValid", IDS_SETTINGS_NOT_VALID}, {"notValidWebAddress", IDS_SETTINGS_NOT_VALID_WEB_ADDRESS}, + {"notValidWebAddressForContentType", + IDS_SETTINGS_NOT_VALID_WEB_ADDRESS_FOR_CONTENT_TYPE}, }; AddLocalizedStringsBulk(html_source, localized_strings, arraysize(localized_strings)); @@ -209,6 +220,29 @@ void AddA11yStrings(content::WebUIDataSource* html_source) { {"delayBeforeClickShort", IDS_SETTINGS_DELAY_BEFORE_CLICK_SHORT}, {"delayBeforeClickLong", IDS_SETTINGS_DELAY_BEFORE_CLICK_LONG}, {"delayBeforeClickVeryLong", IDS_SETTINGS_DELAY_BEFORE_CLICK_VERY_LONG}, + {"autoclickEventTypeLabel", IDS_SETTINGS_AUTOCLICK_EVENT_TYPE_LABEL}, + {"autoclickEventTypeLeftClick", + IDS_SETTINGS_AUTOCLICK_EVENT_TYPE_LEFT_CLICK}, + {"autoclickEventTypeRightClick", + IDS_SETTINGS_AUTOCLICK_EVENT_TYPE_RIGHT_CLICK}, + {"autoclickEventTypeDragAndDrop", + IDS_SETTINGS_AUTOCLICK_EVENT_TYPE_DRAG_AND_DROP}, + {"autoclickEventTypeDoubleClick", + IDS_SETTINGS_AUTOCLICK_EVENT_TYPE_DOUBLE_CLICK}, + {"autoclickEventTypeNoAction", IDS_SETTINGS_AUTOCLICK_EVENT_TYPE_NO_ACTION}, + {"autoclickRevertToLeftClick", IDS_SETTINGS_AUTOCLICK_REVERT_TO_LEFT_CLICK}, + {"autoclickMovementThresholdLabel", + IDS_SETTINGS_AUTOCLICK_MOVEMENT_THRESHOLD_LABEL}, + {"autoclickMovementThresholdExtraSmall", + IDS_SETTINGS_AUTOCLICK_MOVEMENT_THRESHOLD_EXTRA_SMALL}, + {"autoclickMovementThresholdSmall", + IDS_SETTINGS_AUTOCLICK_MOVEMENT_THRESHOLD_SMALL}, + {"autoclickMovementThresholdDefault", + IDS_SETTINGS_AUTOCLICK_MOVEMENT_THRESHOLD_DEFAULT}, + {"autoclickMovementThresholdLarge", + IDS_SETTINGS_AUTOCLICK_MOVEMENT_THRESHOLD_LARGE}, + {"autoclickMovementThresholdExtraLarge", + IDS_SETTINGS_AUTOCLICK_MOVEMENT_THRESHOLD_EXTRA_LARGE}, {"dictationDescription", IDS_SETTINGS_ACCESSIBILITY_DICTATION_DESCRIPTION}, {"dictationLabel", IDS_SETTINGS_ACCESSIBILITY_DICTATION_LABEL}, {"onScreenKeyboardLabel", IDS_SETTINGS_ON_SCREEN_KEYBOARD_LABEL}, @@ -301,7 +335,17 @@ void AddA11yStrings(content::WebUIDataSource* html_source) { html_source->AddBoolean( "showExperimentalA11yFeatures", base::CommandLine::ForCurrentProcess()->HasSwitch( - chromeos::switches::kEnableExperimentalAccessibilityFeatures)); + ::switches::kEnableExperimentalAccessibilityFeatures)); + + html_source->AddBoolean( + "showExperimentalAccessibilityAutoclick", + base::CommandLine::ForCurrentProcess()->HasSwitch( + ::switches::kEnableExperimentalAccessibilityAutoclick)); + + html_source->AddBoolean( + "showExperimentalAccessibilitySwitchAccess", + base::CommandLine::ForCurrentProcess()->HasSwitch( + ::switches::kEnableExperimentalAccessibilitySwitchAccess)); html_source->AddBoolean("dockedMagnifierFeatureEnabled", ash::features::IsDockedMagnifierEnabled()); @@ -477,6 +521,7 @@ void AddAppearanceStrings(content::WebUIDataSource* html_source, #endif #if defined(OS_MACOSX) {"tabsToLinks", IDS_SETTINGS_TABS_TO_LINKS_PREF}, + {"warnBeforeQuitting", IDS_SETTINGS_WARN_BEFORE_QUITTING_PREF}, #endif }; AddLocalizedStringsBulk(html_source, localized_strings, @@ -516,7 +561,7 @@ void AddBluetoothStrings(content::WebUIDataSource* html_source) { void AddChangePasswordStrings(content::WebUIDataSource* html_source) { LocalizedString localized_strings[] = { {"changePasswordPageTitle", IDS_SETTINGS_CHANGE_PASSWORD_TITLE}, - {"changePasswordPageDetails", IDS_SETTINGS_CHANGE_PASSWORD_DETAIL}, + {"changePasswordPageDetails", IDS_PAGE_INFO_CHANGE_PASSWORD_DETAILS}, {"changePasswordPageButton", IDS_SETTINGS_CHANGE_PASSWORD_BUTTON}, }; AddLocalizedStringsBulk(html_source, localized_strings, @@ -655,8 +700,8 @@ void AddDeviceStrings(content::WebUIDataSource* html_source) { {"keyRepeatRate", IDS_SETTINGS_KEYBOARD_AUTO_REPEAT_RATE}, {"keyRepeatRateSlow", IDS_SETTINGS_KEYBOARD_AUTO_REPEAT_RATE_SLOW}, {"keyRepeatRateFast", IDS_SETTINGS_KEYBOARD_AUTO_REPEAT_FAST}, - {"showKeyboardShortcutsOverlay", - IDS_SETTINGS_KEYBOARD_SHOW_KEYBOARD_SHORTCUTS_OVERLAY}, + {"showKeyboardShortcutViewer", + IDS_SETTINGS_KEYBOARD_SHOW_SHORTCUT_VIEWER}, {"keyboardShowLanguageAndInput", IDS_SETTINGS_KEYBOARD_SHOW_LANGUAGE_AND_INPUT}, }; @@ -839,10 +884,6 @@ void AddDownloadsStrings(content::WebUIDataSource* html_source) { {"smbSharesLearnMoreLabel", IDS_SETTINGS_DOWNLOADS_SMB_SHARES_LEARN_MORE_LABEL}, {"addSmbShare", IDS_SETTINGS_DOWNLOADS_SMB_SHARES_ADD_SHARE}, - {"smbShareUrl", IDS_SETTINGS_DOWNLOADS_ADD_SHARE_URL}, - {"smbShareName", IDS_SETTINGS_DOWNLOADS_ADD_SHARE_NAME}, - {"smbShareUsername", IDS_SETTINGS_DOWNLOADS_ADD_SHARE_USERNAME}, - {"smbSharePassword", IDS_SETTINGS_DOWNLOADS_ADD_SHARE_PASSWORD}, {"smbShareAddedSuccessfulMessage", IDS_SETTINGS_DOWNLOADS_SHARE_ADDED_SUCCESS_MESSAGE}, {"smbShareAddedErrorMessage", @@ -857,20 +898,14 @@ void AddDownloadsStrings(content::WebUIDataSource* html_source) { IDS_SETTINGS_DOWNLOADS_SHARE_ADDED_MOUNT_EXISTS_MESSAGE}, {"smbShareAddedInvalidURLMessage", IDS_SETTINGS_DOWNLOADS_SHARE_ADDED_MOUNT_INVALID_URL_MESSAGE}, - {"smbShareAuthenticationMethod", - IDS_SETTINGS_DOWNLOADS_ADD_SHARE_AUTHENTICATION_METHOD}, - {"smbShareStandardAuthentication", - IDS_SETTINGS_DOWNLOADS_ADD_SHARE_STANDARD_AUTHENTICATION}, - {"smbShareKerberosAuthentication", - IDS_SETTINGS_DOWNLOADS_ADD_SHARE_KERBEROS_AUTHENTICATION}, #endif }; AddLocalizedStringsBulk(html_source, localized_strings, arraysize(localized_strings)); #if defined(OS_CHROMEOS) - html_source->AddBoolean("enableNativeSmbSetting", - base::FeatureList::IsEnabled(features::kNativeSmb)); + chromeos::smb_dialog::AddLocalizedStrings(html_source); + html_source->AddString("smbSharesLearnMoreURL", GetHelpUrlWithBoard(chrome::kSmbSharesLearnMoreURL)); #endif @@ -952,9 +987,18 @@ void AddChromeCleanupStrings(content::WebUIDataSource* html_source) { .spec(); html_source->AddString("chromeCleanupLearnMoreUrl", cleanup_learn_more_url); + // The "powered by" footer contains an HTML fragment with the SVG logo of the + // partner. The logo is added directly to the DOM, rather than as an <img> + // src, to make sure that screen readers can find accessibility tags inside + // the SVG. + const std::string powered_by_element = + base::StrCat({"<span id='powered-by-logo'>", + ui::ResourceBundle::GetSharedInstance().GetRawDataResource( + IDR_CHROME_CLEANUP_PARTNER), + "</span>"}); const base::string16 powered_by_html = l10n_util::GetStringFUTF16(IDS_SETTINGS_RESET_CLEANUP_FOOTER_POWERED_BY, - L"<span id='powered-by-logo'></span>"); + base::UTF8ToUTF16(powered_by_element)); html_source->AddString("chromeCleanupPoweredByHtml", powered_by_html); const base::string16 cleanup_details_explanation = @@ -1103,29 +1147,6 @@ void AddDateTimeStrings(content::WebUIDataSource* html_source) { void AddEasyUnlockStrings(content::WebUIDataSource* html_source) { LocalizedString localized_strings[] = { {"easyUnlockSectionTitle", IDS_SETTINGS_EASY_UNLOCK_SECTION_TITLE}, - {"easyUnlockSetupButton", IDS_SETTINGS_EASY_UNLOCK_SETUP}, - // Easy Unlock turn-off dialog. - {"easyUnlockTurnOffButton", IDS_SETTINGS_EASY_UNLOCK_TURN_OFF}, - {"easyUnlockTurnOffOfflineTitle", - IDS_SETTINGS_EASY_UNLOCK_TURN_OFF_OFFLINE_TITLE}, - {"easyUnlockTurnOffOfflineMessage", - IDS_SETTINGS_EASY_UNLOCK_TURN_OFF_OFFLINE_MESSAGE}, - {"easyUnlockTurnOffErrorTitle", - IDS_SETTINGS_EASY_UNLOCK_TURN_OFF_ERROR_TITLE}, - {"easyUnlockTurnOffErrorMessage", - IDS_SETTINGS_EASY_UNLOCK_TURN_OFF_ERROR_MESSAGE}, - {"easyUnlockAllowSignInLabel", - IDS_SETTINGS_EASY_UNLOCK_ALLOW_SIGN_IN_LABEL}, - {"easyUnlockProximityThresholdLabel", - IDS_SETTINGS_EASY_UNLOCK_PROXIMITY_THRESHOLD_LABEL}, - {"easyUnlockProximityThresholdVeryClose", - IDS_SETTINGS_EASY_UNLOCK_PROXIMITY_THRESHOLD_VERY_CLOSE}, - {"easyUnlockProximityThresholdClose", - IDS_SETTINGS_EASY_UNLOCK_PROXIMITY_THRESHOLD_CLOSE}, - {"easyUnlockProximityThresholdFar", - IDS_SETTINGS_EASY_UNLOCK_PROXIMITY_THRESHOLD_FAR}, - {"easyUnlockProximityThresholdVeryFar", - IDS_SETTINGS_EASY_UNLOCK_PROXIMITY_THRESHOLD_VERY_FAR}, {"easyUnlockUnlockDeviceOnly", IDS_SETTINGS_EASY_UNLOCK_UNLOCK_DEVICE_ONLY}, {"easyUnlockUnlockDeviceAndAllowSignin", @@ -1133,32 +1154,6 @@ void AddEasyUnlockStrings(content::WebUIDataSource* html_source) { }; AddLocalizedStringsBulk(html_source, localized_strings, arraysize(localized_strings)); - - base::string16 device_name = - l10n_util::GetStringUTF16(ui::GetChromeOSDeviceTypeResourceId()); - html_source->AddString( - "easyUnlockSetupIntro", - l10n_util::GetStringFUTF16(IDS_SETTINGS_EASY_UNLOCK_SETUP_INTRO, - device_name)); - html_source->AddString( - "easyUnlockDescription", - l10n_util::GetStringFUTF16(IDS_SETTINGS_EASY_UNLOCK_DESCRIPTION, - device_name)); - html_source->AddString( - "easyUnlockTurnOffTitle", - l10n_util::GetStringFUTF16(IDS_SETTINGS_EASY_UNLOCK_TURN_OFF_TITLE, - device_name)); - html_source->AddString( - "easyUnlockTurnOffDescription", - l10n_util::GetStringFUTF16(IDS_SETTINGS_EASY_UNLOCK_TURN_OFF_DESCRIPTION, - device_name)); - html_source->AddString( - "easyUnlockProximityThresholdLabel", - l10n_util::GetStringFUTF16( - IDS_SETTINGS_EASY_UNLOCK_PROXIMITY_THRESHOLD_LABEL, device_name)); - - html_source->AddString("easyUnlockLearnMoreURL", - GetHelpUrlWithBoard(chrome::kEasyUnlockLearnMoreUrl)); } void AddInternetStrings(content::WebUIDataSource* html_source) { @@ -1204,6 +1199,7 @@ void AddInternetStrings(content::WebUIDataSource* html_source) { IDS_SETTINGS_INTERNET_KNOWN_NETWORKS_MENU_FORGET}, {"networkAllowDataRoaming", IDS_SETTINGS_SETTINGS_NETWORK_ALLOW_DATA_ROAMING}, + {"networkAlwaysOnVpn", IDS_SETTINGS_INTERNET_NETWORK_ALWAYS_ON_VPN}, {"networkAutoConnect", IDS_SETTINGS_INTERNET_NETWORK_AUTO_CONNECT}, {"networkButtonActivate", IDS_SETTINGS_INTERNET_BUTTON_ACTIVATE}, {"networkButtonConfigure", IDS_SETTINGS_INTERNET_BUTTON_CONFIGURE}, @@ -1413,11 +1409,13 @@ void AddOnStartupStrings(content::WebUIDataSource* html_source) { arraysize(localized_strings)); } -void AddPasswordsAndFormsStrings(content::WebUIDataSource* html_source, - Profile* profile) { +void AddAutofillStrings(content::WebUIDataSource* html_source, + Profile* profile) { LocalizedString localized_strings[] = { - {"passwordsAndAutofillPageTitle", - IDS_SETTINGS_PASSWORDS_AND_AUTOFILL_PAGE_TITLE}, + {"autofillPageTitle", IDS_SETTINGS_AUTOFILL}, + {"passwords", IDS_SETTINGS_PASSWORDS}, + {"creditCards", IDS_AUTOFILL_PAYMENT_METHODS}, + {"noCreditCardsFound", IDS_SETTINGS_PAYMENT_METHODS_NONE}, {"googlePayments", IDS_SETTINGS_GOOGLE_PAYMENTS}, {"googlePaymentsCached", IDS_SETTINGS_GOOGLE_PAYMENTS_CACHED}, {"enableProfilesLabel", IDS_AUTOFILL_ENABLE_PROFILES_TOGGLE_LABEL}, @@ -1435,7 +1433,6 @@ void AddPasswordsAndFormsStrings(content::WebUIDataSource* html_source, {"removeAddress", IDS_SETTINGS_ADDRESS_REMOVE}, {"removeCreditCard", IDS_SETTINGS_CREDIT_CARD_REMOVE}, {"clearCreditCard", IDS_SETTINGS_CREDIT_CARD_CLEAR}, - {"creditCardsDetail", IDS_SETTINGS_AUTOFILL_CREDIT_CARD_DETAIL}, {"creditCardType", IDS_SETTINGS_AUTOFILL_CREDIT_CARD_TYPE_COLUMN_LABEL}, {"creditCardExpiration", IDS_SETTINGS_CREDIT_CARD_EXPIRATION_DATE}, {"creditCardName", IDS_SETTINGS_NAME_ON_CREDIT_CARD}, @@ -1445,10 +1442,7 @@ void AddPasswordsAndFormsStrings(content::WebUIDataSource* html_source, {"creditCardExpired", IDS_SETTINGS_CREDIT_CARD_EXPIRED}, {"editCreditCardTitle", IDS_SETTINGS_EDIT_CREDIT_CARD_TITLE}, {"addCreditCardTitle", IDS_SETTINGS_ADD_CREDIT_CARD_TITLE}, - {"migrateCreditCardsLabelSingle", - IDS_SETTINGS_SINGLE_MIGRATABLE_CARD_LABEL}, - {"migrateCreditCardsLabelMultiple", - IDS_SETTINGS_MULTIPLE_MIGRATABLE_CARDS_LABEL}, + {"migrateCreditCardsLabel", IDS_SETTINGS_MIGRATABLE_CARDS_LABEL}, {"migratableCardsInfoSingle", IDS_SETTINGS_SINGLE_MIGRATABLE_CARD_INFO}, {"migratableCardsInfoMultiple", IDS_SETTINGS_MULTIPLE_MIGRATABLE_CARDS_INFO}, @@ -1460,7 +1454,6 @@ void AddPasswordsAndFormsStrings(content::WebUIDataSource* html_source, IDS_SETTINGS_PASSWORDS_AUTOSIGNIN_CHECKBOX_LABEL}, {"passwordsAutosigninDescription", IDS_SETTINGS_PASSWORDS_AUTOSIGNIN_CHECKBOX_DESC}, - {"passwordsDetail", IDS_SETTINGS_PASSWORDS_DETAIL}, {"savedPasswordsHeading", IDS_SETTINGS_PASSWORDS_SAVED_HEADING}, {"passwordExceptionsHeading", IDS_SETTINGS_PASSWORDS_EXCEPTIONS_HEADING}, {"deletePasswordException", IDS_SETTINGS_PASSWORDS_DELETE_EXCEPTION}, @@ -1497,31 +1490,16 @@ void AddPasswordsAndFormsStrings(content::WebUIDataSource* html_source, {"exportPasswordsFailTipsAnotherFolder", IDS_SETTINGS_PASSWORDS_EXPORTING_FAILURE_TIP_ANOTHER_FOLDER}}; - // TODO(https://crbug.com/854562): Integrate these strings into the - // |localized_strings| array once Autofill Home is fully launched. - if (base::FeatureList::IsEnabled(password_manager::features::kAutofillHome)) { - html_source->AddLocalizedString("autofill", - IDS_AUTOFILL_ADDRESSES_SETTINGS_TITLE); - html_source->AddLocalizedString("passwords", - IDS_SETTINGS_PASSWORDS_AUTOFILL_HOME); - html_source->AddLocalizedString("creditCards", - IDS_AUTOFILL_PAYMENT_METHODS); - html_source->AddLocalizedString("noCreditCardsFound", - IDS_SETTINGS_PAYMENT_METHODS_NONE); - } else { - html_source->AddLocalizedString("autofill", IDS_SETTINGS_AUTOFILL); - html_source->AddLocalizedString("passwords", IDS_SETTINGS_PASSWORDS); - html_source->AddLocalizedString("creditCards", - IDS_SETTINGS_AUTOFILL_CREDIT_CARD_HEADING); - html_source->AddLocalizedString("noCreditCardsFound", - IDS_SETTINGS_CREDIT_CARD_NONE); - } + GURL google_password_manager_url = GetGooglePasswordManagerURL( + password_manager::ManagePasswordsReferrer::kChromeSettings); html_source->AddString( "managePasswordsLabel", l10n_util::GetStringFUTF16( IDS_SETTINGS_PASSWORDS_MANAGE_PASSWORDS, - l10n_util::GetStringUTF16(IDS_PASSWORDS_WEB_LINK))); + base::UTF8ToUTF16(google_password_manager_url.spec()))); + html_source->AddString("googlePasswordManagerUrl", + google_password_manager_url.spec()); html_source->AddString("passwordManagerLearnMoreURL", chrome::kPasswordManagerLearnMoreURL); html_source->AddString("manageAddressesUrl", @@ -1554,9 +1532,6 @@ void AddPasswordsAndFormsStrings(content::WebUIDataSource* html_source, sync_service->IsUsingSecondaryPassphrase()); html_source->AddBoolean( "uploadToGoogleActive", - base::FeatureList::IsEnabled( - autofill::features:: - kAutofillEnablePaymentsInteractionsOnAuthError) || syncer::GetUploadToGoogleState( sync_service, syncer::ModelType::AUTOFILL_WALLET_DATA) == syncer::UploadState::ACTIVE); @@ -1593,10 +1568,6 @@ void AddPasswordsAndFormsStrings(content::WebUIDataSource* html_source, AddLocalizedStringsBulk(html_source, localized_strings, arraysize(localized_strings)); - - html_source->AddBoolean("EnableCompanyName", - base::FeatureList::IsEnabled( - autofill::features::kAutofillEnableCompanyName)); } void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) { @@ -1713,7 +1684,9 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) { {"editPerson", IDS_SETTINGS_EDIT_PERSON}, {"profileNameAndPicture", IDS_SETTINGS_PROFILE_NAME_AND_PICTURE}, {"showShortcutLabel", IDS_SETTINGS_PROFILE_SHORTCUT_TOGGLE_LABEL}, - {"syncWillStart", IDS_SETTINGS_SYNC_WILL_START}, + {"syncWillStart", unified_consent::IsUnifiedConsentFeatureEnabled() + ? IDS_SETTINGS_SYNC_WILL_START_UNITY + : IDS_SETTINGS_SYNC_WILL_START}, {"syncSettingsSavedToast", IDS_SETTINGS_SYNC_SETTINGS_SAVED_TOAST_LABEL}, {"cancelSync", IDS_SETTINGS_SYNC_SETTINGS_CANCEL_SYNC}, #endif // defined(OS_CHROMEOS) @@ -1736,12 +1709,9 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) { {"syncSignInPromptWithNoAccount", IDS_SETTINGS_SYNC_SIGN_IN_PROMPT_WITH_NO_ACCOUNT}, #endif - {"syncUnifiedConsentToggleTitle", - IDS_SETTINGS_PEOPLE_SYNC_UNIFIED_CONSENT_TOGGLE_TITLE}, {"syncOverview", IDS_SETTINGS_SYNC_OVERVIEW}, {"syncDisabled", IDS_PROFILES_DICE_SYNC_DISABLED_TITLE}, - {"syncDisabledByAdministrator", - IDS_SETTINGS_SYNC_DISABLED_BY_ADMINISTRATOR}, + {"syncDisabledByAdministrator", IDS_SIGNED_IN_WITH_SYNC_DISABLED}, {"syncSignin", IDS_SETTINGS_SYNC_SIGNIN}, {"syncDisconnect", IDS_SETTINGS_PEOPLE_SIGN_OUT}, {"syncDisconnectTitle", IDS_SETTINGS_SYNC_DISCONNECT_TITLE}, @@ -1756,28 +1726,20 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) { {"deleteProfileWarningWithoutCounts", IDS_SETTINGS_SYNC_DISCONNECT_DELETE_PROFILE_WARNING_WITHOUT_COUNTS}, {"syncDisconnectConfirm", IDS_SETTINGS_SYNC_DISCONNECT_CONFIRM}, - {"sync", unified_consent::IsUnifiedConsentFeatureEnabled() - ? IDS_SETTINGS_SYNC_UNIFIED_CONSENT - : IDS_SETTINGS_SYNC}, - {"syncDescription", unified_consent::IsUnifiedConsentFeatureEnabled() - ? IDS_SETTINGS_SYNC_DESCRIPTION_UNIFIED_CONSENT - : IDS_SETTINGS_SYNC_DESCRIPTION}, + {"sync", IDS_SETTINGS_SYNC}, {"nonPersonalizedServicesSectionLabel", IDS_SETTINGS_NON_PERSONALIZED_SERVICES_SECTION_LABEL}, - {"nonPersonalizedServicesSectionDesc", - IDS_SETTINGS_NON_PERSONALIZED_SERVICES_SECTION_DESC}, - {"nonPersonalizedServicesExpandA11yLabel", - IDS_SETTINGS_NON_PERSONALIZED_SERVICES_SECTION_ACCESSIBILITY_LABEL}, - {"syncExpandA11yLabel", IDS_SETTINGS_SYNC_SECTION_ACCESSIBILITY_LABEL}, {"syncAndNonPersonalizedServices", IDS_SETTINGS_SYNC_SYNC_AND_NON_PERSONALIZED_SERVICES}, {"syncPageTitle", unified_consent::IsUnifiedConsentFeatureEnabled() ? IDS_SETTINGS_SYNC_SYNC_AND_NON_PERSONALIZED_SERVICES : IDS_SETTINGS_SYNC_PAGE_TITLE}, + {"syncAdvancedPageTitle", IDS_SETTINGS_SYNC_ADVANCED_PAGE_TITLE}, {"syncLoading", IDS_SETTINGS_SYNC_LOADING}, {"syncTimeout", IDS_SETTINGS_SYNC_TIMEOUT}, {"syncEverythingCheckboxLabel", IDS_SETTINGS_SYNC_EVERYTHING_CHECKBOX_LABEL}, + {"manageGoogleAccount", IDS_SETTINGS_MANAGE_GOOGLE_ACCOUNT}, {"appCheckboxLabel", IDS_SETTINGS_APPS_CHECKBOX_LABEL}, {"extensionsCheckboxLabel", IDS_SETTINGS_EXTENSIONS_CHECKBOX_LABEL}, {"settingsCheckboxLabel", IDS_SETTINGS_SETTINGS_CHECKBOX_LABEL}, @@ -1788,11 +1750,12 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) { {"bookmarksCheckboxLabel", IDS_SETTINGS_BOOKMARKS_CHECKBOX_LABEL}, {"passwordsCheckboxLabel", IDS_SETTINGS_PASSWORDS_CHECKBOX_LABEL}, {"openTabsCheckboxLabel", IDS_SETTINGS_OPEN_TABS_CHECKBOX_LABEL}, - {"userEventsCheckboxLabel", IDS_SETTINGS_USER_EVENTS_CHECKBOX_LABEL}, - {"userEventsCheckboxText", IDS_SETTINGS_USER_EVENTS_CHECKBOX_TEXT}, {"driveSuggestPref", IDS_DRIVE_SUGGEST_PREF}, {"driveSuggestPrefDesc", IDS_DRIVE_SUGGEST_PREF_DESC}, - {"manageSyncedDataTitle", IDS_SETTINGS_MANAGE_SYNCED_DATA_TITLE}, + {"manageSyncedDataTitle", + unified_consent::IsUnifiedConsentFeatureEnabled() + ? IDS_SETTINGS_MANAGE_SYNCED_DATA_TITLE_UNIFIED_CONSENT + : IDS_SETTINGS_MANAGE_SYNCED_DATA_TITLE}, {"encryptionOptionsTitle", IDS_SETTINGS_ENCRYPTION_OPTIONS}, {"syncDataEncryptedText", IDS_SETTINGS_SYNC_DATA_ENCRYPTED_TEXT}, {"encryptWithGoogleCredentialsLabel", @@ -1808,22 +1771,12 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) { {"personalizeGoogleServicesTitle", IDS_SETTINGS_PERSONALIZE_GOOGLE_SERVICES_TITLE}, {"existingPassphraseTitle", IDS_SETTINGS_EXISTING_PASSPHRASE_TITLE}, + {"enablePaymentsIntegrationCheckboxLabel", + IDS_AUTOFILL_ENABLE_PAYMENTS_INTEGRATION_CHECKBOX_LABEL}, }; AddLocalizedStringsBulk(html_source, localized_strings, arraysize(localized_strings)); - if (base::FeatureList::IsEnabled(password_manager::features::kAutofillHome)) { - // TODO(https://crbug.com/854562): Integrate this string into the - // |localized_strings| array once Autofill Home is fully launched. - html_source->AddLocalizedString( - "enablePaymentsIntegrationCheckboxLabel", - IDS_AUTOFILL_ENABLE_PAYMENTS_INTEGRATION_CHECKBOX_LABEL); - } else { - html_source->AddLocalizedString( - "enablePaymentsIntegrationCheckboxLabel", - IDS_SETTINGS_ENABLE_PAYMENTS_INTEGRATION_CHECKBOX_LABEL); - } - // Format numbers to be used on the pin keyboard. for (int j = 0; j <= 9; j++) { html_source->AddString("pinKeyboard" + base::IntToString(j), @@ -1920,6 +1873,8 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) { html_source->AddString("activityControlsUrl", chrome::kGoogleAccountActivityControlsURL); + html_source->AddString("googleAccountUrl", chrome::kGoogleAccountURL); + html_source->AddBoolean("profileShortcutsEnabled", ProfileShortcutManager::IsFeatureEnabled()); @@ -2328,7 +2283,6 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source, IDS_SETTINGS_COOKIES_LOCAL_STORAGE_LAST_MODIFIED_LABEL}, {"noUsbDevicesFound", IDS_SETTINGS_NO_USB_DEVICES_FOUND}, {"serviceWorkerOrigin", IDS_SETTINGS_COOKIES_LOCAL_STORAGE_ORIGIN_LABEL}, - {"serviceWorkerScopes", IDS_SETTINGS_COOKIES_SERVICE_WORKER_SCOPES_LABEL}, {"serviceWorkerSize", IDS_SETTINGS_COOKIES_LOCAL_STORAGE_SIZE_ON_DISK_LABEL}, {"sharedWorkerWorker", IDS_SETTINGS_COOKIES_SHARED_WORKER_WORKER_LABEL}, @@ -2734,10 +2688,6 @@ void AddMultideviceStrings(content::WebUIDataSource* html_source) { AddLocalizedStringsBulk(html_source, localized_strings, arraysize(localized_strings)); - html_source->AddBoolean( - "enableMultideviceSettings", - base::FeatureList::IsEnabled( - chromeos::features::kEnableUnifiedMultiDeviceSettings)); html_source->AddString( "multideviceVerificationText", l10n_util::GetStringFUTF16( @@ -2788,6 +2738,7 @@ void AddLocalizedStrings(content::WebUIDataSource* html_source, Profile* profile) { AddA11yStrings(html_source); AddAboutStrings(html_source); + AddAutofillStrings(html_source, profile); AddAppearanceStrings(html_source, profile); #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) @@ -2801,7 +2752,6 @@ void AddLocalizedStrings(content::WebUIDataSource* html_source, AddDownloadsStrings(html_source); AddLanguagesStrings(html_source); AddOnStartupStrings(html_source); - AddPasswordsAndFormsStrings(html_source, profile); AddPeopleStrings(html_source, profile); AddPrintingStrings(html_source); AddPrivacyStrings(html_source, profile); diff --git a/chromium/chrome/browser/ui/webui/settings/md_settings_ui.cc b/chromium/chrome/browser/ui/webui/settings/md_settings_ui.cc index 051c36122b7..257e8c6dd6c 100644 --- a/chromium/chrome/browser/ui/webui/settings/md_settings_ui.cc +++ b/chromium/chrome/browser/ui/webui/settings/md_settings_ui.cc @@ -16,6 +16,7 @@ #include "base/metrics/histogram_macros.h" #include "build/build_config.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/passwords/manage_passwords_view_utils.h" #include "chrome/browser/ui/webui/metrics_handler.h" #include "chrome/browser/ui/webui/settings/about_handler.h" #include "chrome/browser/ui/webui/settings/appearance_handler.h" @@ -30,7 +31,6 @@ #include "chrome/browser/ui/webui/settings/profile_info_handler.h" #include "chrome/browser/ui/webui/settings/protocol_handlers_handler.h" #include "chrome/browser/ui/webui/settings/reset_settings_handler.h" -#include "chrome/browser/ui/webui/settings/safe_browsing_handler.h" #include "chrome/browser/ui/webui/settings/search_engines_handler.h" #include "chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.h" #include "chrome/browser/ui/webui/settings/settings_cookies_view_handler.h" @@ -61,7 +61,6 @@ #include "chrome/browser/conflicts/incompatible_applications_updater_win.h" #include "chrome/browser/conflicts/token_util_win.h" #include "chrome/browser/ui/webui/settings/incompatible_applications_handler_win.h" -#include "chrome/grit/chrome_unscaled_resources.h" #endif #endif // defined(OS_WIN) @@ -71,6 +70,7 @@ #endif // defined(OS_WIN) || defined(OS_CHROMEOS) #if defined(OS_CHROMEOS) +#include "ash/public/cpp/resources/grit/ash_public_unscaled_resources.h" #include "ash/public/cpp/stylus_utils.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chromeos/arc/arc_util.h" @@ -80,6 +80,7 @@ #include "chrome/browser/chromeos/multidevice_setup/android_sms_app_helper_delegate_impl.h" #include "chrome/browser/chromeos/multidevice_setup/multidevice_setup_client_factory.h" #include "chrome/browser/signin/account_tracker_service_factory.h" +#include "chrome/browser/ui/webui/chromeos/smb_shares/smb_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/accessibility_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/account_manager_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/android_apps_handler.h" @@ -92,17 +93,18 @@ #include "chrome/browser/ui/webui/settings/chromeos/device_power_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/device_storage_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.h" -#include "chrome/browser/ui/webui/settings/chromeos/easy_unlock_settings_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/internet_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h" -#include "chrome/browser/ui/webui/settings/chromeos/smb_handler.h" +#include "chrome/browser/web_applications/system_web_app_manager.h" #include "chrome/common/chrome_switches.h" +#include "chrome/grit/browser_resources.h" #include "chromeos/account_manager/account_manager.h" #include "chromeos/account_manager/account_manager_factory.h" #include "chromeos/chromeos_features.h" #include "chromeos/chromeos_switches.h" +#include "chromeos/services/multidevice_setup/public/cpp/prefs.h" #include "components/arc/arc_util.h" #include "ui/base/ui_base_features.h" #else // !defined(OS_CHROMEOS) @@ -177,8 +179,6 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui) AddSettingsPageUIHandler(std::make_unique<PeopleHandler>(profile)); AddSettingsPageUIHandler(std::make_unique<ProfileInfoHandler>(profile)); AddSettingsPageUIHandler(std::make_unique<ProtocolHandlersHandler>()); - AddSettingsPageUIHandler( - std::make_unique<SafeBrowsingHandler>(profile->GetPrefs())); AddSettingsPageUIHandler(std::make_unique<SearchEnginesHandler>(profile)); AddSettingsPageUIHandler(std::make_unique<SiteSettingsHandler>(profile)); AddSettingsPageUIHandler(std::make_unique<StartupPagesHandler>(web_ui)); @@ -219,32 +219,17 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui) } AddSettingsPageUIHandler( std::make_unique<chromeos::settings::KeyboardHandler>()); - if (!profile->IsGuestSession() && - base::FeatureList::IsEnabled( - chromeos::features::kEnableUnifiedMultiDeviceSetup) && - base::FeatureList::IsEnabled( - chromeos::features::kEnableUnifiedMultiDeviceSettings) && - base::FeatureList::IsEnabled(chromeos::features::kMultiDeviceApi)) { - AddSettingsPageUIHandler( - std::make_unique<chromeos::settings::MultideviceHandler>( - profile->GetPrefs(), - chromeos::multidevice_setup::MultiDeviceSetupClientFactory:: - GetForProfile(profile), - std::make_unique< - chromeos::multidevice_setup::AndroidSmsAppHelperDelegateImpl>( - profile))); - } AddSettingsPageUIHandler( std::make_unique<chromeos::settings::PointerHandler>()); AddSettingsPageUIHandler( - std::make_unique<chromeos::settings::SmbHandler>(profile)); - AddSettingsPageUIHandler( std::make_unique<chromeos::settings::StorageHandler>(profile)); AddSettingsPageUIHandler( std::make_unique<chromeos::settings::StylusHandler>()); AddSettingsPageUIHandler( std::make_unique<chromeos::settings::InternetHandler>(profile)); AddSettingsPageUIHandler(std::make_unique<TtsHandler>()); + AddSettingsPageUIHandler( + std::make_unique<chromeos::smb_dialog::SmbHandler>(profile)); #else AddSettingsPageUIHandler(std::make_unique<DefaultBrowserHandler>()); AddSettingsPageUIHandler(std::make_unique<ManageProfileHandler>(profile)); @@ -260,13 +245,6 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui) #if defined(OS_WIN) AddSettingsPageUIHandler(std::make_unique<ChromeCleanupHandler>(profile)); - -#if defined(GOOGLE_CHROME_BUILD) - html_source->AddResourcePath("partner-logo.svg", IDR_CHROME_CLEANUP_PARTNER); -#if BUILDFLAG(OPTIMIZE_WEBUI) - exclude_from_gzip.push_back("partner-logo.svg"); -#endif -#endif // defined(GOOGLE_CHROME_BUILD) #endif // defined(OS_WIN) #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) @@ -297,11 +275,29 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui) password_protection_available); #if defined(OS_CHROMEOS) - chromeos::settings::EasyUnlockSettingsHandler* easy_unlock_handler = - chromeos::settings::EasyUnlockSettingsHandler::Create(html_source, - profile); - if (easy_unlock_handler) - AddSettingsPageUIHandler(base::WrapUnique(easy_unlock_handler)); + if (!profile->IsGuestSession() && + base::FeatureList::IsEnabled( + chromeos::features::kEnableUnifiedMultiDeviceSetup) && + base::FeatureList::IsEnabled( + chromeos::features::kEnableUnifiedMultiDeviceSettings) && + base::FeatureList::IsEnabled(chromeos::features::kMultiDeviceApi)) { + AddSettingsPageUIHandler( + std::make_unique<chromeos::settings::MultideviceHandler>( + profile->GetPrefs(), + chromeos::multidevice_setup::MultiDeviceSetupClientFactory:: + GetForProfile(profile), + std::make_unique< + chromeos::multidevice_setup::AndroidSmsAppHelperDelegateImpl>( + profile))); + } + html_source->AddBoolean( + "enableMultideviceSettings", + base::FeatureList::IsEnabled( + chromeos::features::kEnableUnifiedMultiDeviceSettings)); + html_source->AddBoolean( + "multideviceAllowedByPolicy", + chromeos::multidevice_setup::AreAnyMultiDeviceFeaturesAllowed( + profile->GetPrefs())); AddSettingsPageUIHandler(base::WrapUnique( chromeos::settings::DateTimeHandler::Create(html_source))); @@ -314,8 +310,9 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui) html_source->AddBoolean( "quickUnlockDisabledByPolicy", chromeos::quick_unlock::IsPinDisabledByPolicy(profile->GetPrefs())); - html_source->AddBoolean("fingerprintUnlockEnabled", - chromeos::quick_unlock::IsFingerprintEnabled()); + html_source->AddBoolean( + "fingerprintUnlockEnabled", + chromeos::quick_unlock::IsFingerprintEnabled(profile)); html_source->AddBoolean("lockScreenNotificationsEnabled", ash::features::IsLockScreenNotificationsEnabled()); html_source->AddBoolean( @@ -327,9 +324,7 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui) html_source->AddBoolean("showCrostini", crostini::IsCrostiniUIAllowedForProfile(profile)); - // TODO(crbug.com/868747): Show an explanatory message instead of hiding the - // storage management info. - html_source->AddBoolean("hideStorageInfo", + html_source->AddBoolean("isDemoSession", chromeos::DemoSession::IsDeviceInDemoMode()); // We have 2 variants of Android apps settings. Default case, when the Play @@ -360,11 +355,9 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui) html_source->AddBoolean("unifiedConsentEnabled", unified_consent::IsUnifiedConsentFeatureEnabled()); - // TODO(jdoerrie): https://crbug.com/854562. - // Remove once Autofill Home is launched. html_source->AddBoolean( - "autofillHomeEnabled", - base::FeatureList::IsEnabled(password_manager::features::kAutofillHome)); + "navigateToGooglePasswordManager", + ShouldManagePasswordsinGooglePasswordManager(profile)); html_source->AddBoolean("showImportPasswords", base::FeatureList::IsEnabled( @@ -378,6 +371,18 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui) // Add the metrics handler to write uma stats. web_ui->AddMessageHandler(std::make_unique<MetricsHandler>()); +#if defined(OS_CHROMEOS) + // Add the System Web App resources for Settings. + if (web_app::SystemWebAppManager::ShouldEnableForProfile(profile)) { + html_source->AddResourcePath("icon-192.png", IDR_SETTINGS_LOGO_192); + html_source->AddResourcePath("pwa.html", IDR_PWA_HTML); +#if BUILDFLAG(OPTIMIZE_WEBUI) + exclude_from_gzip.push_back("icon-192.png"); + exclude_from_gzip.push_back("pwa.html"); +#endif // BUILDFLAG(OPTIMIZE_WEBUI) + } +#endif // defined (OS_CHROMEOS) + #if BUILDFLAG(OPTIMIZE_WEBUI) const bool use_polymer_2 = base::FeatureList::IsEnabled(features::kWebUIPolymer2); @@ -392,6 +397,9 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui) ? IDR_MD_SETTINGS_VULCANIZED_P2_HTML : IDR_MD_SETTINGS_VULCANIZED_HTML); html_source->UseGzip(exclude_from_gzip); +#if defined(OS_CHROMEOS) + html_source->AddResourcePath("manifest.json", IDR_MD_SETTINGS_MANIFEST); +#endif // defined (OS_CHROMEOS) #else // Add all settings resources. for (size_t i = 0; i < kSettingsResourcesSize; ++i) { diff --git a/chromium/chrome/browser/ui/webui/settings/people_handler.cc b/chromium/chrome/browser/ui/webui/settings/people_handler.cc index 7d6abb49ada..a1e56381edc 100644 --- a/chromium/chrome/browser/ui/webui/settings/people_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/people_handler.cc @@ -21,6 +21,7 @@ #include "chrome/browser/profiles/profile_metrics.h" #include "chrome/browser/profiles/profile_window.h" #include "chrome/browser/signin/chrome_signin_helper.h" +#include "chrome/browser/signin/identity_manager_factory.h" #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" #include "chrome/browser/signin/signin_error_controller_factory.h" #include "chrome/browser/signin/signin_manager_factory.h" @@ -41,7 +42,7 @@ #include "components/autofill/core/common/autofill_prefs.h" #include "components/browser_sync/profile_sync_service.h" #include "components/prefs/pref_service.h" -#include "components/signin/core/browser/profile_management_switches.h" +#include "components/signin/core/browser/account_consistency_method.h" #include "components/signin/core/browser/profile_oauth2_token_service.h" #include "components/signin/core/browser/signin_error_controller.h" #include "components/signin/core/browser/signin_header_helper.h" @@ -49,7 +50,6 @@ #include "components/signin/core/browser/signin_pref_names.h" #include "components/strings/grit/components_strings.h" #include "components/sync/base/passphrase_enums.h" -#include "components/sync/base/sync_prefs.h" #include "components/unified_consent/feature.h" #include "components/unified_consent/unified_consent_metrics.h" #include "content/public/browser/render_view_host.h" @@ -66,7 +66,6 @@ #include "components/signin/core/browser/signin_manager_base.h" #else #include "chrome/browser/signin/signin_util.h" -#include "chrome/browser/ui/user_manager.h" #include "chrome/browser/ui/webui/profile_helper.h" #include "components/signin/core/browser/signin_manager.h" #endif @@ -220,7 +219,7 @@ const char PeopleHandler::kPassphraseFailedPageStatus[] = "passphraseFailed"; PeopleHandler::PeopleHandler(Profile* profile) : profile_(profile), configuring_sync_(false), - signin_observer_(this), + identity_manager_observer_(this), #if BUILDFLAG(ENABLE_DICE_SUPPORT) sync_service_observer_(this), account_tracker_observer_(this) { @@ -262,14 +261,6 @@ void PeopleHandler::RegisterMessages() { "SyncSetupGetSyncStatus", base::BindRepeating(&PeopleHandler::HandleGetSyncStatus, base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "SyncSetupManageOtherPeople", - base::BindRepeating(&PeopleHandler::HandleManageOtherPeople, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "UnifiedConsentToggleChanged", - base::BindRepeating(&PeopleHandler::OnUnifiedConsentToggleChanged, - base::Unretained(this))); #if defined(OS_CHROMEOS) web_ui()->RegisterMessageCallback( "AttemptUserExit", @@ -310,10 +301,10 @@ void PeopleHandler::OnJavascriptAllowed() { prefs::kSigninAllowed, base::Bind(&PeopleHandler::UpdateSyncStatus, base::Unretained(this))); - SigninManagerBase* signin_manager( - SigninManagerFactory::GetInstance()->GetForProfile(profile_)); - if (signin_manager) - signin_observer_.Add(signin_manager); + identity::IdentityManager* identity_manager( + IdentityManagerFactory::GetInstance()->GetForProfile(profile_)); + if (identity_manager) + identity_manager_observer_.Add(identity_manager); // This is intentionally not using GetSyncService(), to go around the // Profile::IsSyncAllowed() check. @@ -332,7 +323,7 @@ void PeopleHandler::OnJavascriptAllowed() { void PeopleHandler::OnJavascriptDisallowed() { profile_pref_registrar_.RemoveAll(); - signin_observer_.RemoveAll(); + identity_manager_observer_.RemoveAll(); sync_service_observer_.RemoveAll(); #if BUILDFLAG(ENABLE_DICE_SUPPORT) account_tracker_observer_.RemoveAll(); @@ -497,8 +488,8 @@ void PeopleHandler::HandleSetDatatypes(const base::ListValue* args) { return; } - service->OnUserChoseDatatypes(configuration.sync_everything, - configuration.data_types); + service->GetUserSettings()->SetChosenDataTypes(configuration.sync_everything, + configuration.data_types); // Choosing data types to sync never fails. ResolveJavascriptCallback(*callback_id, base::Value(kConfigurePageStatus)); @@ -608,7 +599,7 @@ void PeopleHandler::HandleSetEncryption(const base::ListValue* args) { // Don't allow "encrypt all" if the ProfileSyncService doesn't allow it. // The UI is hidden, but the user may have enabled it e.g. by fiddling with // the web inspector. - if (!service->IsEncryptEverythingAllowed()) + if (!service->GetUserSettings()->IsEncryptEverythingAllowed()) configuration.encrypt_all = false; // Note: Data encryption will not occur until configuration is complete @@ -616,34 +607,35 @@ void PeopleHandler::HandleSetEncryption(const base::ListValue* args) { // engine), so the user still has a chance to cancel out of the operation // if (for example) some kind of passphrase error is encountered. if (configuration.encrypt_all) - service->EnableEncryptEverything(); + service->GetUserSettings()->EnableEncryptEverything(); bool passphrase_failed = false; if (!configuration.passphrase.empty()) { // We call IsPassphraseRequired() here (instead of // IsPassphraseRequiredForDecryption()) because the user may try to enter // a passphrase even though no encrypted data types are enabled. - if (service->IsPassphraseRequired()) { + if (service->GetUserSettings()->IsPassphraseRequired()) { // If we have pending keys, try to decrypt them with the provided // passphrase. We track if this succeeds or fails because a failed // decryption should result in an error even if there aren't any encrypted // data types. - passphrase_failed = - !service->SetDecryptionPassphrase(configuration.passphrase); + passphrase_failed = !service->GetUserSettings()->SetDecryptionPassphrase( + configuration.passphrase); } else { // OK, the user sent us a passphrase, but we don't have pending keys. So // it either means that the pending keys were resolved somehow since the // time the UI was displayed (re-encryption, pending passphrase change, // etc) or the user wants to re-encrypt. if (configuration.set_new_passphrase && - !service->IsUsingSecondaryPassphrase()) { - service->SetEncryptionPassphrase(configuration.passphrase, - ProfileSyncService::EXPLICIT); + !service->GetUserSettings()->IsUsingSecondaryPassphrase()) { + service->GetUserSettings()->SetEncryptionPassphrase( + configuration.passphrase); } } } - if (passphrase_failed || service->IsPassphraseRequiredForDecryption()) { + if (passphrase_failed || + service->GetUserSettings()->IsPassphraseRequiredForDecryption()) { // If the user doesn't enter any passphrase, we won't call // SetDecryptionPassphrase() (passphrase_failed == false), but we still // want to display an error message to let the user know that their blank @@ -672,6 +664,9 @@ void PeopleHandler::HandleShowSetupUI(const base::ListValue* args) { if (service && !sync_blocker_) sync_blocker_ = service->GetSetupInProgressHandle(); + // TODO(treib): Should we also call SetSyncRequested(true) here? That's what + // happens in the non-Unity code path. + GetLoginUIService()->SetLoginUI(this); PushSyncPrefs(); @@ -709,14 +704,13 @@ void PeopleHandler::HandleShowSetupUI(const base::ListValue* args) { return; if (!service->IsEngineInitialized() || - service->HasDisableReason( - syncer::SyncService::DISABLE_REASON_USER_CHOICE)) { + !service->GetUserSettings()->IsSyncRequested()) { // Requesting the sync service to start may trigger call to PushSyncPrefs. // Setting up the startup tracker beforehand correctly signals the // re-entrant call to early exit. sync_startup_tracker_ = std::make_unique<SyncStartupTracker>(profile_, this); - // RequestStart() does two things: + // SetSyncRequested(true) does two things: // 1) If DISABLE_REASON_USER_CHOICE is set (meaning that Sync was reset via // the dashboard), clears it. // 2) Pokes the sync service to start *immediately*, i.e. bypass deferred @@ -727,7 +721,7 @@ void PeopleHandler::HandleShowSetupUI(const base::ListValue* args) { // already running in standalone transport mode and so the engine is already // initialized. In that case, this will trigger the service to switch to // full Sync-the-feature mode. - service->RequestStart(); + service->GetUserSettings()->SetSyncRequested(true); // See if it's even possible to bring up the sync engine - if not // (unrecoverable error?), don't bother displaying a spinner that will be @@ -798,7 +792,9 @@ void PeopleHandler::HandleSignout(const base::ListValue* args) { DCHECK(!delete_profile) << "Deleting the profile should only be offered the user is syncing."; ProfileOAuth2TokenServiceFactory::GetForProfile(profile_) - ->RevokeAllCredentials(); + ->RevokeAllCredentials( + signin_metrics::SourceForRefreshTokenOperation:: + kSettings_Signout); } } @@ -814,7 +810,8 @@ void PeopleHandler::HandlePauseSync(const base::ListValue* args) { DCHECK(signin_manager->IsAuthenticated()); ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)->UpdateCredentials( signin_manager->GetAuthenticatedAccountId(), - OAuth2TokenServiceDelegate::kInvalidRefreshToken); + OAuth2TokenServiceDelegate::kInvalidRefreshToken, + signin_metrics::SourceForRefreshTokenOperation::kSettings_PauseSync); } #endif @@ -828,22 +825,6 @@ void PeopleHandler::HandleGetSyncStatus(const base::ListValue* args) { ResolveJavascriptCallback(*callback_id, *GetSyncStatusDictionary()); } -void PeopleHandler::HandleManageOtherPeople(const base::ListValue* /* args */) { -#if !defined(OS_CHROMEOS) - UserManager::Show(base::FilePath(), - profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); -#endif // !defined(OS_CHROMEOS) -} - -void PeopleHandler::OnUnifiedConsentToggleChanged(const base::ListValue* args) { - bool is_toggle_checked = args->GetList()[0].GetBool(); - if (!is_toggle_checked) { - unified_consent::metrics::RecordUnifiedConsentRevoked( - unified_consent::metrics::UnifiedConsentRevokeReason:: - kUserDisabledSettingsToggle); - } -} - void PeopleHandler::CloseSyncSetup() { // Stop a timer to handle timeout in waiting for checking network connection. engine_start_timer_.reset(); @@ -860,9 +841,10 @@ void PeopleHandler::CloseSyncSetup() { // Don't log a cancel event if the sync setup dialog is being // automatically closed due to an auth error. if ((service->current_login_ui() == this) && - (!sync_service || (!sync_service->IsFirstSetupComplete() && - sync_service->GetAuthError().state() == - GoogleServiceAuthError::NONE))) { + (!sync_service || + (!sync_service->GetUserSettings()->IsFirstSetupComplete() && + sync_service->GetAuthError().state() == + GoogleServiceAuthError::NONE))) { if (configuring_sync_) { ProfileSyncService::SyncEvent( ProfileSyncService::CANCEL_DURING_CONFIGURE); @@ -924,13 +906,13 @@ void PeopleHandler::CloseUI() { FireWebUIListener("page-status-changed", base::Value(kDonePageStatus)); } -void PeopleHandler::GoogleSigninSucceeded(const std::string& /* account_id */, - const std::string& /* username */) { +void PeopleHandler::OnPrimaryAccountSet( + const AccountInfo& primary_account_info) { UpdateSyncStatus(); } -void PeopleHandler::GoogleSignedOut(const std::string& /* account_id */, - const std::string& /* username */) { +void PeopleHandler::OnPrimaryAccountCleared( + const AccountInfo& previous_primary_account_info) { UpdateSyncStatus(); } @@ -957,6 +939,10 @@ PeopleHandler::GetSyncStatusDictionary() { SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile_); DCHECK(signin); + + auto* identity_manager = IdentityManagerFactory::GetForProfile(profile_); + DCHECK(identity_manager); + #if !defined(OS_CHROMEOS) // Signout is not allowed if the user has policy (crbug.com/172204). if (!signin_util::IsUserSignoutAllowedForProfile(profile_)) { @@ -992,18 +978,18 @@ PeopleHandler::GetSyncStatusDictionary() { &link_label, &action_type) == sync_ui_util::SYNC_ERROR; sync_status->SetString("statusText", status_label); + sync_status->SetString("statusActionText", link_label); sync_status->SetBoolean("hasError", status_has_error); sync_status->SetString("statusAction", GetSyncErrorAction(action_type)); sync_status->SetBoolean("managed", disallowed_by_policy); sync_status->SetBoolean( - "disabled", - !service || disallowed_by_policy || - service->HasDisableReason( - syncer::SyncService::DISABLE_REASON_PLATFORM_OVERRIDE)); + "disabled", !service || disallowed_by_policy || + !service->GetUserSettings()->IsSyncAllowedByPlatform()); sync_status->SetBoolean("signedIn", signin->IsAuthenticated()); - sync_status->SetString("signedInUsername", - signin_ui_util::GetAuthenticatedUsername(signin)); + sync_status->SetString( + "signedInUsername", + signin_ui_util::GetAuthenticatedUsername(identity_manager)); sync_status->SetBoolean("hasUnrecoverableError", service && service->HasUnrecoverableError()); return sync_status; @@ -1055,28 +1041,32 @@ void PeopleHandler::PushSyncPrefs() { // TODO(treib): How do we want to handle pref groups, i.e. when only some of // the sync types behind a checkbox are force-enabled? crbug.com/403326 } - PrefService* pref_service = profile_->GetPrefs(); - syncer::SyncPrefs sync_prefs(pref_service); - args.SetBoolean("syncAllDataTypes", sync_prefs.HasKeepEverythingSynced()); - args.SetBoolean("paymentsIntegrationEnabled", - autofill::prefs::IsPaymentsIntegrationEnabled(pref_service)); - args.SetBoolean("encryptAllData", service->IsEncryptEverythingEnabled()); + args.SetBoolean("syncAllDataTypes", + service->GetUserSettings()->IsSyncEverythingEnabled()); + args.SetBoolean( + "paymentsIntegrationEnabled", + autofill::prefs::IsPaymentsIntegrationEnabled(profile_->GetPrefs())); + args.SetBoolean("encryptAllData", + service->GetUserSettings()->IsEncryptEverythingEnabled()); args.SetBoolean("encryptAllDataAllowed", - service->IsEncryptEverythingAllowed()); + service->GetUserSettings()->IsEncryptEverythingAllowed()); // We call IsPassphraseRequired() here, instead of calling // IsPassphraseRequiredForDecryption(), because we want to show the passphrase // UI even if no encrypted data types are enabled. - args.SetBoolean("passphraseRequired", service->IsPassphraseRequired()); + args.SetBoolean("passphraseRequired", + service->GetUserSettings()->IsPassphraseRequired()); // To distinguish between PassphraseType::FROZEN_IMPLICIT_PASSPHRASE and // PassphraseType::CUSTOM_PASSPHRASE // we only set passphraseTypeIsCustom for PassphraseType::CUSTOM_PASSPHRASE. args.SetBoolean("passphraseTypeIsCustom", - service->GetPassphraseType() == + service->GetUserSettings()->GetPassphraseType() == syncer::PassphraseType::CUSTOM_PASSPHRASE); - base::Time passphrase_time = service->GetExplicitPassphraseTime(); - syncer::PassphraseType passphrase_type = service->GetPassphraseType(); + base::Time passphrase_time = + service->GetUserSettings()->GetExplicitPassphraseTime(); + syncer::PassphraseType passphrase_type = + service->GetUserSettings()->GetPassphraseType(); if (!passphrase_time.is_null()) { base::string16 passphrase_time_str = base::TimeFormatShortDate(passphrase_time); @@ -1128,7 +1118,7 @@ void PeopleHandler::MarkFirstSetupComplete() { ProfileSyncService* service = GetSyncService(); // The sync service may be nullptr if it has been just disabled by policy. - if (!service || service->IsFirstSetupComplete()) + if (!service || service->GetUserSettings()->IsFirstSetupComplete()) return; // This is the first time configuring sync, so log it. @@ -1138,7 +1128,7 @@ void PeopleHandler::MarkFirstSetupComplete() { // We're done configuring, so notify ProfileSyncService that it is OK to // start syncing. sync_blocker_.reset(); - service->SetFirstSetupComplete(); + service->GetUserSettings()->SetFirstSetupComplete(); FireWebUIListener("sync-settings-saved"); } diff --git a/chromium/chrome/browser/ui/webui/settings/people_handler.h b/chromium/chrome/browser/ui/webui/settings/people_handler.h index 6652b50d0a1..6af3d98b7ec 100644 --- a/chromium/chrome/browser/ui/webui/settings/people_handler.h +++ b/chromium/chrome/browser/ui/webui/settings/people_handler.h @@ -21,15 +21,14 @@ #include "chrome/browser/ui/webui/signin/login_ui_service.h" #include "components/prefs/pref_change_registrar.h" #include "components/signin/core/browser/signin_buildflags.h" -#include "components/signin/core/browser/signin_manager_base.h" #include "components/sync/driver/sync_service_observer.h" +#include "services/identity/public/cpp/identity_manager.h" #if BUILDFLAG(ENABLE_DICE_SUPPORT) #include "components/signin/core/browser/account_tracker_service.h" #endif class LoginUIService; -class SigninManagerBase; namespace browser_sync { class ProfileSyncService; @@ -50,7 +49,7 @@ class SyncSetupInProgressHandle; namespace settings { class PeopleHandler : public SettingsPageUIHandler, - public SigninManagerBase::Observer, + public identity::IdentityManager::Observer, public SyncStartupTracker::Observer, #if BUILDFLAG(ENABLE_DICE_SUPPORT) public AccountTrackerService::Observer, @@ -136,11 +135,10 @@ class PeopleHandler : public SettingsPageUIHandler, // LoginUIService::LoginUI implementation. void FocusUI() override; - // SigninManagerBase::Observer implementation. - void GoogleSigninSucceeded(const std::string& account_id, - const std::string& username) override; - void GoogleSignedOut(const std::string& account_id, - const std::string& username) override; + // IdentityManager::Observer implementation. + void OnPrimaryAccountSet(const AccountInfo& primary_account_info) override; + void OnPrimaryAccountCleared( + const AccountInfo& previous_primary_account_info) override; // syncer::SyncServiceObserver implementation. void OnStateChanged(syncer::SyncService* sync) override; @@ -180,8 +178,6 @@ class PeopleHandler : public SettingsPageUIHandler, void HandlePauseSync(const base::ListValue* args); #endif void HandleGetSyncStatus(const base::ListValue* args); - void HandleManageOtherPeople(const base::ListValue* args); - void OnUnifiedConsentToggleChanged(const base::ListValue* args); #if !defined(OS_CHROMEOS) // Displays the GAIA login form. @@ -258,7 +254,8 @@ class PeopleHandler : public SettingsPageUIHandler, PrefChangeRegistrar profile_pref_registrar_; // Manages observer lifetimes. - ScopedObserver<SigninManagerBase, PeopleHandler> signin_observer_; + ScopedObserver<identity::IdentityManager, PeopleHandler> + identity_manager_observer_; ScopedObserver<browser_sync::ProfileSyncService, PeopleHandler> sync_service_observer_; diff --git a/chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc index 02cc8300a10..f8566400196 100644 --- a/chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc +++ b/chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc @@ -15,12 +15,10 @@ #include "base/stl_util.h" #include "base/values.h" #include "build/build_config.h" -#include "chrome/browser/signin/account_tracker_service_factory.h" -#include "chrome/browser/signin/fake_signin_manager_builder.h" +#include "chrome/browser/signin/identity_test_environment_profile_adaptor.h" #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" #include "chrome/browser/signin/scoped_account_consistency.h" #include "chrome/browser/signin/signin_error_controller_factory.h" -#include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/browser/sync/profile_sync_test_util.h" #include "chrome/browser/ui/chrome_pages.h" @@ -35,8 +33,6 @@ #include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_profile.h" #include "components/prefs/pref_service.h" -#include "components/signin/core/browser/account_tracker_service.h" -#include "components/signin/core/browser/fake_auth_status_provider.h" #include "components/signin/core/browser/profile_oauth2_token_service.h" #include "components/signin/core/browser/signin_manager.h" #include "components/sync/base/sync_prefs.h" @@ -50,6 +46,8 @@ #include "content/public/test/test_browser_thread_bundle.h" #include "content/public/test/test_web_ui.h" #include "content/public/test/web_contents_tester.h" +#include "google_apis/gaia/oauth2_token_service_delegate.h" +#include "services/identity/public/cpp/identity_manager.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/base/layout.h" @@ -113,7 +111,6 @@ std::string GetConfiguration(const base::DictionaryValue* extra_values, result.SetBoolean("tabsSynced", types.Has(syncer::PROXY_TABS)); result.SetBoolean("themesSynced", types.Has(syncer::THEMES)); result.SetBoolean("typedUrlsSynced", types.Has(syncer::TYPED_URLS)); - result.SetBoolean("userEventsSynced", types.Has(syncer::USER_EVENTS)); result.SetBoolean("paymentsIntegrationEnabled", false); std::string args; base::JSONWriter::Write(result, &args); @@ -161,7 +158,6 @@ void CheckConfigDataTypeArguments(const base::DictionaryValue* dictionary, CheckBool(dictionary, "tabsSynced", types.Has(syncer::PROXY_TABS)); CheckBool(dictionary, "themesSynced", types.Has(syncer::THEMES)); CheckBool(dictionary, "typedUrlsSynced", types.Has(syncer::TYPED_URLS)); - CheckBool(dictionary, "userEventsSynced", types.Has(syncer::USER_EVENTS)); } } // namespace @@ -206,10 +202,12 @@ class PeopleHandlerTest : public ChromeRenderViewHostTestHarness { error_ = GoogleServiceAuthError::AuthErrorNone(); // Sign in the user. - mock_signin_ = SigninManagerFactory::GetForProfile(profile()); + identity_test_env_adaptor_ = + std::make_unique<IdentityTestEnvironmentProfileAdaptor>(profile()); + std::string username = GetTestUser(); if (!username.empty()) - mock_signin_->SetAuthenticatedAccountInfo(username, username); + identity_test_env()->SetPrimaryAccount(username); mock_pss_ = static_cast<ProfileSyncServiceMock*>( ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( @@ -236,9 +234,18 @@ class PeopleHandlerTest : public ChromeRenderViewHostTestHarness { handler_->set_web_ui(nullptr); handler_->DisallowJavascript(); handler_->sync_startup_tracker_.reset(); + identity_test_env_adaptor_.reset(); ChromeRenderViewHostTestHarness::TearDown(); } + content::BrowserContext* CreateBrowserContext() override { + // Setup the profile. + std::unique_ptr<TestingProfile> profile = + IdentityTestEnvironmentProfileAdaptor:: + CreateProfileForIdentityTestEnvironment(); + return profile.release(); + } + // Setup the expectations for calls made when displaying the config page. void SetDefaultExpectationsForConfigPage() { ON_CALL(*mock_pss_, GetDisableReasons()) @@ -258,7 +265,6 @@ class PeopleHandlerTest : public ChromeRenderViewHostTestHarness { void SetupInitializedProfileSyncService() { // An initialized ProfileSyncService will have already completed sync setup // and will have an initialized sync engine. - ASSERT_TRUE(mock_signin_->IsInitialized()); ON_CALL(*mock_pss_, GetTransportState()) .WillByDefault(Return(syncer::SyncService::TransportState::ACTIVE)); } @@ -325,9 +331,14 @@ class PeopleHandlerTest : public ChromeRenderViewHostTestHarness { return std::string(kTestUser); } + identity::IdentityTestEnvironment* identity_test_env() { + return identity_test_env_adaptor_->identity_test_env(); + } + ProfileSyncServiceMock* mock_pss_; GoogleServiceAuthError error_; - SigninManagerBase* mock_signin_; + std::unique_ptr<IdentityTestEnvironmentProfileAdaptor> + identity_test_env_adaptor_; content::TestWebUI web_ui_; TestWebUIProvider test_provider_; std::unique_ptr<TestChromeWebUIControllerFactory> test_factory_; @@ -347,9 +358,7 @@ TEST_F(PeopleHandlerFirstSigninTest, DisplayBasicLogin) { .WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NOT_SIGNED_IN)); ON_CALL(*mock_pss_, IsFirstSetupComplete()).WillByDefault(Return(false)); // Ensure that the user is not signed in before calling |HandleStartSignin()|. - SigninManager* manager = SigninManager::FromSigninManagerBase(mock_signin_); - manager->SignOut(signin_metrics::SIGNOUT_TEST, - signin_metrics::SignoutDelete::IGNORE_METRIC); + identity_test_env()->ClearPrimaryAccount(); base::ListValue list_args; handler_->HandleStartSignin(&list_args); @@ -696,9 +705,7 @@ TEST_F(PeopleHandlerTest, SetNewCustomPassphrase) { ON_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) .WillByDefault(Return(false)); SetupInitializedProfileSyncService(); - EXPECT_CALL(*mock_pss_, - SetEncryptionPassphrase("custom_passphrase", - ProfileSyncService::EXPLICIT)); + EXPECT_CALL(*mock_pss_, SetEncryptionPassphrase("custom_passphrase")); handler_->HandleSetEncryption(&list_args); ExpectPageStatusResponse(PeopleHandler::kConfigurePageStatus); @@ -820,10 +827,20 @@ TEST_F(PeopleHandlerTest, ShowSigninOnAuthError) { GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); SetupInitializedProfileSyncService(); - mock_signin_->SetAuthenticatedAccountInfo(kTestUser, kTestUser); - FakeAuthStatusProvider provider( - SigninErrorControllerFactory::GetForProfile(profile())); - provider.SetAuthError(kTestUser, error_); + DCHECK_EQ( + identity_test_env()->identity_manager()->GetPrimaryAccountInfo().email, + kTestUser); + const std::string& account_id = identity_test_env() + ->identity_manager() + ->GetPrimaryAccountInfo() + .account_id; + ProfileOAuth2TokenService* token_service = + ProfileOAuth2TokenServiceFactory::GetForProfile(profile()); + token_service->UpdateCredentials(account_id, "refresh_token"); + // TODO(https://crbug.com/836212): Do not use the delegate directly, because + // it is internal API. + token_service->GetDelegate()->UpdateAuthError(account_id, error_); + ON_CALL(*mock_pss_, GetDisableReasons()) .WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NONE)); ON_CALL(*mock_pss_, IsPassphraseRequired()).WillByDefault(Return(false)); @@ -876,7 +893,6 @@ TEST_F(PeopleHandlerTest, ShowSetupSyncEverything) { CheckBool(dictionary, "tabsRegistered", true); CheckBool(dictionary, "themesRegistered", true); CheckBool(dictionary, "typedUrlsRegistered", true); - CheckBool(dictionary, "userEventsRegistered", true); CheckBool(dictionary, "paymentsIntegrationEnabled", true); CheckBool(dictionary, "passphraseRequired", false); CheckBool(dictionary, "passphraseTypeIsCustom", false); @@ -1022,28 +1038,26 @@ TEST_P(PeopleHandlerDiceUnifiedConsentTest, StoredAccountsList) { std::tie(dice_enabled, unified_consent_enabled) = GetParam(); unified_consent::ScopedUnifiedConsent unified_consent( unified_consent_enabled - ? unified_consent::UnifiedConsentFeatureState::kEnabledWithBump + ? unified_consent::UnifiedConsentFeatureState::kEnabled : unified_consent::UnifiedConsentFeatureState::kDisabled); ScopedAccountConsistency dice( dice_enabled ? signin::AccountConsistencyMethod::kDice : signin::AccountConsistencyMethod::kDiceFixAuthErrors); // Setup the profile. - TestingProfile profile; - AccountTrackerService* account_tracker = - AccountTrackerServiceFactory::GetForProfile(&profile); - SigninManager* signin_manager = SigninManagerFactory::GetForProfile(&profile); - ProfileOAuth2TokenService* token_service = - ProfileOAuth2TokenServiceFactory::GetForProfile(&profile); - std::string account_1 = - account_tracker->SeedAccountInfo("1234", "a@gmail.com"); - std::string account_2 = - account_tracker->SeedAccountInfo("5678", "b@gmail.com"); - token_service->UpdateCredentials(account_1, "token"); - token_service->UpdateCredentials(account_2, "token"); - signin_manager->SetAuthenticatedAccountInfo("1234", "a@gmail.com"); - - PeopleHandler handler(&profile); + std::unique_ptr<TestingProfile> profile = + IdentityTestEnvironmentProfileAdaptor:: + CreateProfileForIdentityTestEnvironment(); + + auto identity_test_env_adaptor = + std::make_unique<IdentityTestEnvironmentProfileAdaptor>(profile.get()); + auto* identity_test_env = identity_test_env_adaptor->identity_test_env(); + + auto account_1 = identity_test_env->MakeAccountAvailable("a@gmail.com"); + auto account_2 = identity_test_env->MakeAccountAvailable("b@gmail.com"); + identity_test_env->SetPrimaryAccount(account_1.email); + + PeopleHandler handler(profile.get()); std::unique_ptr<base::ListValue> accounts_list = handler.GetStoredAccountsList(); diff --git a/chromium/chrome/browser/ui/webui/settings/safe_browsing_handler.cc b/chromium/chrome/browser/ui/webui/settings/safe_browsing_handler.cc deleted file mode 100644 index 56b43446319..00000000000 --- a/chromium/chrome/browser/ui/webui/settings/safe_browsing_handler.cc +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2016 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/settings/safe_browsing_handler.h" - -#include "base/bind.h" -#include "base/bind_helpers.h" -#include "base/values.h" -#include "components/prefs/pref_service.h" -#include "components/safe_browsing/common/safe_browsing_prefs.h" -#include "content/public/browser/web_ui.h" - -namespace settings { - -namespace { - -base::DictionaryValue GetSberStateDictionaryValue(const PrefService& prefs) { - base::DictionaryValue dict; - dict.SetBoolean("enabled", safe_browsing::IsExtendedReportingEnabled(prefs)); - // TODO(crbug.com/813107): SBEROIA policy is being deprecated, revisit this - // after it is removed. - dict.SetBoolean("managed", - !safe_browsing::IsExtendedReportingOptInAllowed(prefs) || - safe_browsing::IsExtendedReportingPolicyManaged(prefs)); - return dict; -} - -} // namespace - -SafeBrowsingHandler::SafeBrowsingHandler(PrefService* prefs) : prefs_(prefs) {} -SafeBrowsingHandler::~SafeBrowsingHandler() {} - -void SafeBrowsingHandler::RegisterMessages() { - web_ui()->RegisterMessageCallback( - "getSafeBrowsingExtendedReporting", - base::BindRepeating( - &SafeBrowsingHandler::HandleGetSafeBrowsingExtendedReporting, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "setSafeBrowsingExtendedReportingEnabled", - base::BindRepeating( - &SafeBrowsingHandler::HandleSetSafeBrowsingExtendedReportingEnabled, - base::Unretained(this))); -} - -void SafeBrowsingHandler::OnJavascriptAllowed() { - profile_pref_registrar_.Init(prefs_); - profile_pref_registrar_.Add( - prefs::kSafeBrowsingScoutReportingEnabled, - base::Bind(&SafeBrowsingHandler::OnPrefChanged, base::Unretained(this))); -} - -void SafeBrowsingHandler::OnJavascriptDisallowed() { - profile_pref_registrar_.RemoveAll(); -} - -void SafeBrowsingHandler::HandleGetSafeBrowsingExtendedReporting( - const base::ListValue* args) { - AllowJavascript(); - const base::Value* callback_id; - CHECK(args->Get(0, &callback_id)); - - ResolveJavascriptCallback(*callback_id, GetSberStateDictionaryValue(*prefs_)); -} - -void SafeBrowsingHandler::HandleSetSafeBrowsingExtendedReportingEnabled( - const base::ListValue* args) { - bool enabled; - CHECK(args->GetBoolean(0, &enabled)); - safe_browsing::SetExtendedReportingPrefAndMetric( - prefs_, enabled, safe_browsing::SBER_OPTIN_SITE_CHROME_SETTINGS); -} - -void SafeBrowsingHandler::OnPrefChanged(const std::string& pref_name) { - DCHECK(pref_name == prefs::kSafeBrowsingScoutReportingEnabled); - - FireWebUIListener("safe-browsing-extended-reporting-change", - GetSberStateDictionaryValue(*prefs_)); -} - -} // namespace settings diff --git a/chromium/chrome/browser/ui/webui/settings/safe_browsing_handler.h b/chromium/chrome/browser/ui/webui/settings/safe_browsing_handler.h deleted file mode 100644 index 45d3bd21df2..00000000000 --- a/chromium/chrome/browser/ui/webui/settings/safe_browsing_handler.h +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2016 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_SETTINGS_SAFE_BROWSING_HANDLER_H_ -#define CHROME_BROWSER_UI_WEBUI_SETTINGS_SAFE_BROWSING_HANDLER_H_ - -#include <string> - -#include "base/macros.h" -#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" -#include "components/prefs/pref_change_registrar.h" - -namespace settings { - -class SafeBrowsingHandler : public SettingsPageUIHandler { - public: - explicit SafeBrowsingHandler(PrefService* prefs); - ~SafeBrowsingHandler() override; - - // SettingsPageUIHandler: - void RegisterMessages() override; - void OnJavascriptAllowed() override; - void OnJavascriptDisallowed() override; - - private: - // Handler for "getSafeBrowsingExtendedReporting" message. Passed a single - // callback ID argument. - void HandleGetSafeBrowsingExtendedReporting(const base::ListValue* args); - - // Handler for "setSafeBrowsingExtendedReportingEnabled" message. Passed a - // single |enabled| boolean argument. - void HandleSetSafeBrowsingExtendedReportingEnabled( - const base::ListValue* args); - - // Called when the local state pref controlling Safe Browsing extended - // reporting changes. - void OnPrefChanged(const std::string& pref_name); - - // Used to track pref changes that affect whether Safe Browsing extended - // reporting is enabled. - PrefChangeRegistrar profile_pref_registrar_; - - // Weak pointer. - PrefService* prefs_; - - DISALLOW_COPY_AND_ASSIGN(SafeBrowsingHandler); -}; - -} // namespace settings - -#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_SAFE_BROWSING_HANDLER_H_ diff --git a/chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc b/chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc index 88ecd47d81d..39487b81589 100644 --- a/chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc @@ -351,7 +351,8 @@ void ClearBrowsingDataHandler::UpdateSyncState() { base::Value(sync_service_ && sync_service_->IsSyncFeatureActive() && sync_service_->GetActiveDataTypes().Has( syncer::HISTORY_DELETE_DIRECTIVES)), - base::Value(ShouldShowCookieException(profile_))); + base::Value( + browsing_data_counter_utils::ShouldShowCookieException(profile_))); } void ClearBrowsingDataHandler::RefreshHistoryNotice() { @@ -391,7 +392,8 @@ void ClearBrowsingDataHandler::UpdateCounterText( CallJavascriptFunction( "cr.webUIListenerCallback", base::Value("update-counter-text"), base::Value(result->source()->GetPrefName()), - base::Value(GetChromeCounterTextFromResult(result.get(), profile_))); + base::Value(browsing_data_counter_utils::GetChromeCounterTextFromResult( + result.get(), profile_))); } void ClearBrowsingDataHandler::HandleTimePeriodChanged( diff --git a/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc b/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc index 721518a1f17..71096cd9445 100644 --- a/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc @@ -30,7 +30,7 @@ #include "chrome/grit/generated_resources.h" #include "components/prefs/pref_service.h" #include "components/prefs/scoped_user_pref_update.h" -#include "components/signin/core/browser/profile_management_switches.h" +#include "components/signin/core/browser/account_consistency_method.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/web_ui.h" diff --git a/chromium/chrome/browser/ui/webui/settings/site_settings_handler.cc b/chromium/chrome/browser/ui/webui/settings/site_settings_handler.cc index 76a7f5baab6..bf646ef3d11 100644 --- a/chromium/chrome/browser/ui/webui/settings/site_settings_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/site_settings_handler.cc @@ -38,6 +38,7 @@ #include "chrome/common/pref_names.h" #include "chrome/grit/generated_resources.h" #include "components/content_settings/core/browser/host_content_settings_map.h" +#include "components/content_settings/core/browser/website_settings_registry.h" #include "components/content_settings/core/common/content_settings_types.h" #include "components/content_settings/core/common/content_settings_utils.h" #include "components/crx_file/id_util.h" @@ -47,6 +48,7 @@ #include "content/public/browser/notification_service.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_ui.h" +#include "content/public/common/origin_util.h" #include "content/public/common/page_zoom.h" #include "content/public/common/url_constants.h" #include "extensions/browser/extension_registry.h" @@ -65,6 +67,10 @@ namespace settings { namespace { +// Keys of the dictionary returned by HandleIsPatternValidForType. +constexpr char kIsValidKey[] = "isValid"; +constexpr char kReasonKey[] = "reason"; + constexpr char kEffectiveTopLevelDomainPlus1Name[] = "etldPlus1"; constexpr char kOriginList[] = "origins"; constexpr char kNumCookies[] = "numCookies"; @@ -182,6 +188,40 @@ void ConvertSiteGroupMapToListValue( } } +bool IsPatternValidForType(const std::string& pattern_string, + const std::string& type, + Profile* profile, + std::string* out_error) { + ContentSettingsType content_type = + site_settings::ContentSettingsTypeFromGroupName(type); + + ContentSettingsPattern pattern = + ContentSettingsPattern::FromString(pattern_string); + + HostContentSettingsMap* map = + HostContentSettingsMapFactory::GetForProfile(profile); + + // Don't allow an input of '*', even though it's a valid pattern. This + // changes the default setting. + if (!pattern.IsValid() || pattern == ContentSettingsPattern::Wildcard()) { + *out_error = l10n_util::GetStringUTF8(IDS_SETTINGS_NOT_VALID_WEB_ADDRESS); + return false; + } + + // Check if a setting can be set for this url and setting type, and if not, + // return false with a string saying why. + GURL url(pattern_string); + if (url.is_valid() && map->IsRestrictedToSecureOrigins(content_type) && + !content::IsOriginSecure(url)) { + *out_error = l10n_util::GetStringUTF8( + IDS_SETTINGS_NOT_VALID_WEB_ADDRESS_FOR_CONTENT_TYPE); + return false; + } + + // The pattern is valid. + return true; +} + } // namespace SiteSettingsHandler::SiteSettingsHandler(Profile* profile) @@ -258,8 +298,8 @@ void SiteSettingsHandler::RegisterMessages() { base::BindRepeating(&SiteSettingsHandler::HandleIsOriginValid, base::Unretained(this))); web_ui()->RegisterMessageCallback( - "isPatternValid", - base::BindRepeating(&SiteSettingsHandler::HandleIsPatternValid, + "isPatternValidForType", + base::BindRepeating(&SiteSettingsHandler::HandleIsPatternValidForType, base::Unretained(this))); web_ui()->RegisterMessageCallback( "updateIncognitoStatus", @@ -1001,25 +1041,25 @@ void SiteSettingsHandler::HandleIsOriginValid(const base::ListValue* args) { base::Value(GURL(origin_string).is_valid())); } -void SiteSettingsHandler::HandleIsPatternValid( +void SiteSettingsHandler::HandleIsPatternValidForType( const base::ListValue* args) { AllowJavascript(); - CHECK_EQ(2U, args->GetSize()); + CHECK_EQ(3U, args->GetSize()); const base::Value* callback_id; CHECK(args->Get(0, &callback_id)); std::string pattern_string; CHECK(args->GetString(1, &pattern_string)); + std::string type; + CHECK(args->GetString(2, &type)); - ContentSettingsPattern pattern = - ContentSettingsPattern::FromString(pattern_string); - bool valid = pattern.IsValid(); - - // If the input is just '*' don't allow it, even though it's a valid pattern. - // This changes the default setting. - if (pattern == ContentSettingsPattern::Wildcard()) - valid = false; + std::string reason = ""; + bool is_valid = + IsPatternValidForType(pattern_string, type, profile_, &reason); - ResolveJavascriptCallback(*callback_id, base::Value(valid)); + base::Value return_value(base::Value::Type::DICTIONARY); + return_value.SetKey(kIsValidKey, base::Value(is_valid)); + return_value.SetKey(kReasonKey, base::Value(std::move(reason))); + ResolveJavascriptCallback(*callback_id, return_value); } void SiteSettingsHandler::HandleUpdateIncognitoStatus( diff --git a/chromium/chrome/browser/ui/webui/settings/site_settings_handler.h b/chromium/chrome/browser/ui/webui/settings/site_settings_handler.h index 7a5f9c9b787..902f8fc7b11 100644 --- a/chromium/chrome/browser/ui/webui/settings/site_settings_handler.h +++ b/chromium/chrome/browser/ui/webui/settings/site_settings_handler.h @@ -87,6 +87,7 @@ class SiteSettingsHandler : public SettingsPageUIHandler, FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerTest, GetAllSitesLocalStorage); FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerTest, Origins); FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerTest, Patterns); + FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerTest, PatternsAndContentType); FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerTest, ZoomLevels); FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerInfobarTest, SettingPermissionsTriggersInfobar); @@ -146,8 +147,8 @@ class SiteSettingsHandler : public SettingsPageUIHandler, // Returns whether a given string is a valid origin. void HandleIsOriginValid(const base::ListValue* args); - // Returns whether a given pattern is valid. - void HandleIsPatternValid(const base::ListValue* args); + // Returns whether the pattern is valid given the type. + void HandleIsPatternValidForType(const base::ListValue* args); // Looks up whether an incognito session is active. void HandleUpdateIncognitoStatus(const base::ListValue* args); diff --git a/chromium/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc index 301b05f54d6..577253bd64f 100644 --- a/chromium/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc +++ b/chromium/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc @@ -54,6 +54,23 @@ constexpr char kSetting[] = "setting"; constexpr char kSource[] = "source"; constexpr char kExtensionName[] = "Test Extension"; +const struct PatternContentTypeTestCase { + struct { + const char* const pattern; + const char* const content_type; + } arguments; + struct { + const bool validity; + const char* const reason; + } expected; +} kPatternsAndContentTypeTestCases[]{ + {{"https://google.com", "cookies"}, {true, ""}}, + {{";", "cookies"}, {false, "Not a valid web address"}}, + {{"*", "cookies"}, {false, "Not a valid web address"}}, + {{"http://google.com", "location"}, {false, "Origin must be secure"}}, + {{"http://127.0.0.1", "location"}, {true, ""}}, // Localhost is secure. + {{"http://[::1]", "location"}, {true, ""}}}; + #if BUILDFLAG(ENABLE_PLUGINS) // Waits until a change is observed in content settings. class FlashContentSettingsChangeWaiter : public content_settings::Observer { @@ -270,7 +287,9 @@ class SiteSettingsHandlerTest : public testing::Test { EXPECT_EQ(0U, exceptions->GetSize()); } - void ValidatePattern(bool expected_validity, size_t expected_total_calls) { + void ValidatePattern(bool expected_validity, + size_t expected_total_calls, + std::string expected_reason) { EXPECT_EQ(expected_total_calls, web_ui()->call_data().size()); const content::TestWebUI::CallData& data = *web_ui()->call_data().back(); @@ -284,9 +303,16 @@ class SiteSettingsHandlerTest : public testing::Test { ASSERT_TRUE(data.arg2()->GetAsBoolean(&success)); ASSERT_TRUE(success); - bool valid; - ASSERT_TRUE(data.arg3()->GetAsBoolean(&valid)); + const base::DictionaryValue* result = nullptr; + ASSERT_TRUE(data.arg3()->GetAsDictionary(&result)); + + bool valid = false; + ASSERT_TRUE(result->GetBoolean("isValid", &valid)); EXPECT_EQ(expected_validity, valid); + + std::string reason; + ASSERT_TRUE(result->GetString("reason", &reason)); + EXPECT_EQ(expected_reason, reason); } void ValidateIncognitoExists( @@ -973,30 +999,18 @@ TEST_F(SiteSettingsHandlerTest, ExtensionDisplayName) { site_settings::SiteSettingSource::kDefault, 1U); } -TEST_F(SiteSettingsHandlerTest, Patterns) { - base::ListValue args; - std::string pattern("[*.]google.com"); - args.AppendString(kCallbackId); - args.AppendString(pattern); - handler()->HandleIsPatternValid(&args); - ValidatePattern(true, 1U); - - base::ListValue invalid; - std::string bad_pattern(";"); - invalid.AppendString(kCallbackId); - invalid.AppendString(bad_pattern); - handler()->HandleIsPatternValid(&invalid); - ValidatePattern(false, 2U); - - // The wildcard pattern ('*') is a valid pattern, but not allowed to be - // entered in site settings as it changes the default setting. - // (crbug.com/709539). - base::ListValue invalid_wildcard; - std::string bad_pattern_wildcard("*"); - invalid_wildcard.AppendString(kCallbackId); - invalid_wildcard.AppendString(bad_pattern_wildcard); - handler()->HandleIsPatternValid(&invalid_wildcard); - ValidatePattern(false, 3U); +TEST_F(SiteSettingsHandlerTest, PatternsAndContentType) { + unsigned counter = 1; + for (const auto& test_case : kPatternsAndContentTypeTestCases) { + base::ListValue args; + args.AppendString(kCallbackId); + args.AppendString(test_case.arguments.pattern); + args.AppendString(test_case.arguments.content_type); + handler()->HandleIsPatternValidForType(&args); + ValidatePattern(test_case.expected.validity, counter, + test_case.expected.reason); + ++counter; + } } TEST_F(SiteSettingsHandlerTest, Incognito) { diff --git a/chromium/chrome/browser/ui/webui/settings/tts_handler.cc b/chromium/chrome/browser/ui/webui/settings/tts_handler.cc index 4a02d3dc710..9ac54fa35a3 100644 --- a/chromium/chrome/browser/ui/webui/settings/tts_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/tts_handler.cc @@ -11,10 +11,9 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/speech/extension_api/tts_engine_extension_api.h" #include "chrome/browser/speech/extension_api/tts_engine_extension_observer.h" -#include "chrome/browser/speech/tts_controller.h" -#include "chrome/browser/speech/tts_controller_impl.h" #include "chrome/common/extensions/extension_constants.h" #include "chrome/grit/generated_resources.h" +#include "content/public/browser/tts_controller.h" #include "content/public/browser/web_ui.h" #include "extensions/browser/event_router.h" #include "extensions/browser/extension_registry.h" @@ -28,7 +27,7 @@ namespace settings { TtsHandler::TtsHandler() : weak_factory_(this) {} TtsHandler::~TtsHandler() { - TtsController::GetInstance()->RemoveVoicesChangedDelegate(this); + content::TtsController::GetInstance()->RemoveVoicesChangedDelegate(this); } void TtsHandler::HandleGetAllTtsVoiceData(const base::ListValue* args) { @@ -53,7 +52,7 @@ void TtsHandler::HandleGetTtsExtensions(const base::ListValue* args) { registry->GetInstalledExtension(extension_id); if (!extension) { // The extension is still loading from OnVoicesChange call to - // TtsControllerImpl::GetVoices(). Don't do any work, voices will + // TtsController::GetVoices(). Don't do any work, voices will // be updated again after extension load. continue; } @@ -73,9 +72,10 @@ void TtsHandler::HandleGetTtsExtensions(const base::ListValue* args) { } void TtsHandler::OnVoicesChanged() { - TtsControllerImpl* impl = TtsControllerImpl::GetInstance(); - std::vector<VoiceData> voices; - impl->GetVoices(Profile::FromWebUI(web_ui()), &voices); + content::TtsController* tts_controller = + content::TtsController::GetInstance(); + std::vector<content::VoiceData> voices; + tts_controller->GetVoices(Profile::FromWebUI(web_ui()), &voices); const std::string& app_locale = g_browser_process->GetApplicationLocale(); base::ListValue responses; for (const auto& voice : voices) { @@ -125,14 +125,15 @@ void TtsHandler::HandlePreviewTtsVoice(const base::ListValue* args) { json->GetString("name", &name); json->GetString("extension", &extension_id); - Utterance* utterance = new Utterance(Profile::FromWebUI(web_ui())); + content::Utterance* utterance = + new content::Utterance(Profile::FromWebUI(web_ui())); utterance->set_text(text); utterance->set_voice_name(name); utterance->set_extension_id(extension_id); utterance->set_src_url(GURL("chrome://settings/manageAccessibility/tts")); utterance->set_event_delegate(nullptr); - TtsController::GetInstance()->Stop(); - TtsController::GetInstance()->SpeakOrEnqueue(utterance); + content::TtsController::GetInstance()->Stop(); + content::TtsController::GetInstance()->SpeakOrEnqueue(utterance); } void TtsHandler::RegisterMessages() { @@ -153,14 +154,14 @@ void TtsHandler::RegisterMessages() { } void TtsHandler::OnJavascriptAllowed() { - TtsController::GetInstance()->AddVoicesChangedDelegate(this); + content::TtsController::GetInstance()->AddVoicesChangedDelegate(this); } void TtsHandler::OnJavascriptDisallowed() { - TtsController::GetInstance()->RemoveVoicesChangedDelegate(this); + content::TtsController::GetInstance()->RemoveVoicesChangedDelegate(this); } -int TtsHandler::GetVoiceLangMatchScore(const VoiceData* voice, +int TtsHandler::GetVoiceLangMatchScore(const content::VoiceData* voice, const std::string& app_locale) { if (voice->lang.empty() || app_locale.empty()) return 0; @@ -176,7 +177,7 @@ void TtsHandler::WakeTtsEngine(const base::ListValue* args) { Profile* profile = Profile::FromWebUI(web_ui()); TtsExtensionEngine::GetInstance()->LoadBuiltInTtsExtension(profile); extensions::ProcessManager::Get(profile)->WakeEventPage( - extension_misc::kSpeechSynthesisExtensionId, + extension_misc::kGoogleSpeechSynthesisExtensionId, base::BindOnce(&TtsHandler::OnTtsEngineAwake, weak_factory_.GetWeakPtr())); } diff --git a/chromium/chrome/browser/ui/webui/settings/tts_handler.h b/chromium/chrome/browser/ui/webui/settings/tts_handler.h index 0f9d26426d8..3263578a4b8 100644 --- a/chromium/chrome/browser/ui/webui/settings/tts_handler.h +++ b/chromium/chrome/browser/ui/webui/settings/tts_handler.h @@ -6,15 +6,16 @@ #define CHROME_BROWSER_UI_WEBUI_SETTINGS_TTS_HANDLER_H_ #include "base/memory/weak_ptr.h" -#include "chrome/browser/speech/tts_controller.h" #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" +#include "content/public/browser/tts_controller.h" class Profile; namespace settings { // Chrome "/manageAccessibility/tts/*" settings page UI handler. -class TtsHandler : public SettingsPageUIHandler, public VoicesChangedDelegate { +class TtsHandler : public SettingsPageUIHandler, + public content::VoicesChangedDelegate { public: TtsHandler(); ~TtsHandler() override; @@ -34,7 +35,7 @@ class TtsHandler : public SettingsPageUIHandler, public VoicesChangedDelegate { private: void WakeTtsEngine(const base::ListValue* args); void OnTtsEngineAwake(bool success); - int GetVoiceLangMatchScore(const VoiceData* voice, + int GetVoiceLangMatchScore(const content::VoiceData* voice, const std::string& app_locale); base::WeakPtrFactory<TtsHandler> weak_factory_; |