summaryrefslogtreecommitdiffstats
path: root/chromium/chrome/browser/ui/webui/settings
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-05-16 09:59:13 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-05-20 10:28:53 +0000
commit6c11fb357ec39bf087b8b632e2b1e375aef1b38b (patch)
treec8315530db18a8ee566521c39ab8a6af4f72bc03 /chromium/chrome/browser/ui/webui/settings
parent3ffaed019d0772e59d6cdb2d0d32fe4834c31f72 (diff)
BASELINE: Update Chromium to 74.0.3729.159
Change-Id: I8d2497da544c275415aedd94dd25328d555de811 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/chrome/browser/ui/webui/settings')
-rw-r--r--chromium/chrome/browser/ui/webui/settings/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/about_handler.cc53
-rw-r--r--chromium/chrome/browser/ui/webui/settings/accessibility_main_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/change_password_handler.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chrome_cleanup_handler.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.cc105
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.h34
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/android_apps_handler.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.cc59
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.h12
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc25
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h15
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/date_time_handler.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/date_time_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc12
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler_unittest.cc46
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.cc23
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler_browsertest.cc16
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.cc18
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.h5
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/internet_handler.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/settings/downloads_handler.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/settings/font_handler.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc116
-rw-r--r--chromium/chrome/browser/ui/webui/settings/md_settings_ui.cc14
-rw-r--r--chromium/chrome/browser/ui/webui/settings/people_handler.cc47
-rw-r--r--chromium/chrome/browser/ui/webui/settings/people_handler.h9
-rw-r--r--chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc42
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc13
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.h8
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc16
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler_unittest.cc31
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_startup_pages_handler.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/settings/site_settings_handler.cc299
-rw-r--r--chromium/chrome/browser/ui/webui/settings/site_settings_handler.h17
-rw-r--r--chromium/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc90
-rw-r--r--chromium/chrome/browser/ui/webui/settings/tts_handler.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/settings/tts_handler.h1
42 files changed, 663 insertions, 498 deletions
diff --git a/chromium/chrome/browser/ui/webui/settings/OWNERS b/chromium/chrome/browser/ui/webui/settings/OWNERS
index 03050fea1b8..93f7d799e7d 100644
--- a/chromium/chrome/browser/ui/webui/settings/OWNERS
+++ b/chromium/chrome/browser/ui/webui/settings/OWNERS
@@ -1,3 +1,5 @@
file://chrome/browser/resources/settings/OWNERS
+per-file people_handler*=tangltom@chromium.org
+
# COMPONENT: UI>Settings
diff --git a/chromium/chrome/browser/ui/webui/settings/about_handler.cc b/chromium/chrome/browser/ui/webui/settings/about_handler.cc
index 5a4b72f32cd..3bb9116bb70 100644
--- a/chromium/chrome/browser/ui/webui/settings/about_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/about_handler.cc
@@ -80,7 +80,8 @@ namespace {
#if defined(OS_CHROMEOS)
-// Directory containing the regulatory labels for supported regions.
+// The directory containing the regulatory labels for supported
+// models/regions, relative to chromeos-assets directory
const char kRegulatoryLabelsDirectory[] = "regulatory_labels";
// File names of the image file and the file containing alt text for the label.
@@ -164,27 +165,31 @@ bool CanChangeChannel(Profile* profile) {
return service && service->IsOwner();
}
-// Returns the path of the regulatory labels directory for a given region, if
-// found. Must be called from the blocking pool.
+// Returns the relative path under the chromeos-assets dir
+// to the directory of regulatory labels for a given region, if found
+// (e.g. "regulatory_labels/us"). Must be called from the blocking pool.
base::FilePath GetRegulatoryLabelDirForRegion(const std::string& region) {
- // Generate the path under the asset dir or URL host to the regulatory files
- // for the region, e.g., "regulatory_labels/us/".
- const base::FilePath region_path =
- base::FilePath(kRegulatoryLabelsDirectory).AppendASCII(region);
-
- // Check for file existence starting in /usr/share/chromeos-assets/, e.g.,
- // "/usr/share/chromeos-assets/regulatory_labels/us/label.png".
- const base::FilePath asset_dir(chrome::kChromeOSAssetPath);
- if (base::PathExists(asset_dir.Append(region_path)
- .AppendASCII(kRegulatoryLabelImageFilename))) {
- return region_path;
+ base::FilePath region_path(kRegulatoryLabelsDirectory);
+ const std::string model_subdir =
+ base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ chromeos::switches::kRegulatoryLabelDir);
+ if (!model_subdir.empty()) {
+ region_path = region_path.AppendASCII(model_subdir);
}
+ region_path = region_path.AppendASCII(region);
- return base::FilePath();
+ // Check if the label image file exists in the full path, e.g.,
+ // "/usr/share/chromeos-assets/regulatory_labels/us/label.png".
+ const base::FilePath image_path =
+ base::FilePath(chrome::kChromeOSAssetPath)
+ .Append(region_path)
+ .AppendASCII(kRegulatoryLabelImageFilename);
+ return base::PathExists(image_path) ? region_path : base::FilePath();
}
-// Finds the directory for the regulatory label, using the VPD region code.
-// Also tries "us" as a fallback region. Must be called from the blocking pool.
+// Finds the relative path under the chromeos-assets dir to the region
+// subdirectory of regulatory labels, using the VPD region code. Also
+// tries "us" as a fallback region. Must be called from the blocking pool.
base::FilePath FindRegulatoryLabelDir() {
std::string region;
base::FilePath region_path;
@@ -202,12 +207,14 @@ base::FilePath FindRegulatoryLabelDir() {
return region_path;
}
-// Reads the file containing the regulatory label text, if found, relative to
-// the asset directory. Must be called from the blocking pool.
+// Reads the file containing the regulatory label text, if found
+// in the given relative path under the chromeos-assets dir.
+// Must be called from the blocking pool.
std::string ReadRegulatoryLabelText(const base::FilePath& label_dir_path) {
- base::FilePath text_path(chrome::kChromeOSAssetPath);
- text_path = text_path.Append(label_dir_path);
- text_path = text_path.AppendASCII(kRegulatoryLabelTextFilename);
+ const base::FilePath text_path =
+ base::FilePath(chrome::kChromeOSAssetPath)
+ .Append(label_dir_path)
+ .AppendASCII(kRegulatoryLabelTextFilename);
std::string contents;
if (base::ReadFileToString(text_path, &contents))
@@ -679,7 +686,7 @@ void AboutHandler::SetUpdateStatus(VersionUpdater::Status status,
event->SetBoolean("rollback", rollback);
event->SetString("version", version);
// DictionaryValue does not support int64_t, so convert to string.
- event->SetString("size", base::Int64ToString(size));
+ event->SetString("size", base::NumberToString(size));
#if defined(OS_CHROMEOS)
if (status == VersionUpdater::FAILED_OFFLINE ||
status == VersionUpdater::FAILED_CONNECTION_TYPE_DISALLOWED) {
diff --git a/chromium/chrome/browser/ui/webui/settings/accessibility_main_handler.cc b/chromium/chrome/browser/ui/webui/settings/accessibility_main_handler.cc
index 9c8dbc4e0fd..b93fe9f7688 100644
--- a/chromium/chrome/browser/ui/webui/settings/accessibility_main_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/accessibility_main_handler.cc
@@ -65,7 +65,7 @@ void AccessibilityMainHandler::HandleCheckAccessibilityImageLabels(
web_contents->GetRenderViewHost()->GetWidget()->GetView();
gfx::Rect rect = view->GetViewBounds();
auto model = std::make_unique<AccessibilityLabelsBubbleModel>(
- Profile::FromWebUI(web_ui()), web_contents);
+ Profile::FromWebUI(web_ui()), web_contents, true /* enable always */);
chrome::ShowConfirmBubble(
web_contents->GetTopLevelNativeWindow(), view->GetNativeView(),
gfx::Point(rect.CenterPoint().x(), rect.y()), std::move(model));
diff --git a/chromium/chrome/browser/ui/webui/settings/change_password_handler.cc b/chromium/chrome/browser/ui/webui/settings/change_password_handler.cc
index 01225cba2aa..a768aa185c9 100644
--- a/chromium/chrome/browser/ui/webui/settings/change_password_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/change_password_handler.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/ui/webui/settings/change_password_handler.h"
+#include "base/bind.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/safe_browsing/chrome_password_protection_service.h"
#include "components/prefs/pref_service.h"
diff --git a/chromium/chrome/browser/ui/webui/settings/chrome_cleanup_handler.cc b/chromium/chrome/browser/ui/webui/settings/chrome_cleanup_handler.cc
index e28dfbf7dd9..8f06cb1276f 100644
--- a/chromium/chrome/browser/ui/webui/settings/chrome_cleanup_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chrome_cleanup_handler.cc
@@ -8,6 +8,7 @@
#include <string>
#include <utility>
+#include "base/bind.h"
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/metrics/histogram_macros.h"
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.cc
index 7efa92b655c..caccda79fb5 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.cc
@@ -18,7 +18,6 @@
#include "chrome/browser/ui/webui/signin/inline_login_handler_dialog_chromeos.h"
#include "chromeos/account_manager/account_manager.h"
#include "chromeos/account_manager/account_manager_factory.h"
-#include "components/signin/core/browser/account_tracker_service.h"
#include "components/user_manager/user.h"
#include "google_apis/gaia/google_service_auth_error.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -52,21 +51,32 @@ AccountManager::AccountKey GetAccountKeyFromJsCallback(
return AccountManager::AccountKey{id, account_type};
}
+bool IsSameAccount(const AccountManager::AccountKey& account_key,
+ const AccountId& account_id) {
+ switch (account_key.account_type) {
+ case chromeos::account_manager::AccountType::ACCOUNT_TYPE_GAIA:
+ return (account_id.GetAccountType() == AccountType::GOOGLE) &&
+ (account_id.GetGaiaId() == account_key.id);
+ case chromeos::account_manager::AccountType::ACCOUNT_TYPE_ACTIVE_DIRECTORY:
+ return (account_id.GetAccountType() == AccountType::ACTIVE_DIRECTORY) &&
+ (account_id.GetObjGuid() == account_key.id);
+ case chromeos::account_manager::AccountType::ACCOUNT_TYPE_UNSPECIFIED:
+ return false;
+ }
+}
+
} // namespace
AccountManagerUIHandler::AccountManagerUIHandler(
AccountManager* account_manager,
- AccountTrackerService* account_tracker_service,
identity::IdentityManager* identity_manager)
: account_manager_(account_manager),
- account_tracker_service_(account_tracker_service),
identity_manager_(identity_manager),
- account_mapper_util_(account_tracker_service_),
account_manager_observer_(this),
- account_tracker_service_observer_(this),
+ identity_manager_observer_(this),
weak_factory_(this) {
DCHECK(account_manager_);
- DCHECK(account_tracker_service_);
+ DCHECK(identity_manager_);
}
AccountManagerUIHandler::~AccountManagerUIHandler() = default;
@@ -102,13 +112,13 @@ void AccountManagerUIHandler::HandleGetAccounts(const base::ListValue* args) {
base::Value callback_id = args->GetList()[0].Clone();
account_manager_->GetAccounts(
- base::BindOnce(&AccountManagerUIHandler::GetAccountsCallbackHandler,
+ base::BindOnce(&AccountManagerUIHandler::OnGetAccounts,
weak_factory_.GetWeakPtr(), std::move(callback_id)));
}
-void AccountManagerUIHandler::GetAccountsCallbackHandler(
+void AccountManagerUIHandler::OnGetAccounts(
base::Value callback_id,
- std::vector<AccountManager::AccountKey> account_keys) {
+ const std::vector<AccountManager::Account>& stored_accounts) {
base::ListValue accounts;
const AccountId device_account_id =
@@ -117,34 +127,34 @@ void AccountManagerUIHandler::GetAccountsCallbackHandler(
->GetAccountId();
base::DictionaryValue device_account;
- for (const auto& account_key : account_keys) {
+ for (const auto& stored_account : stored_accounts) {
+ const AccountManager::AccountKey& account_key = stored_account.key;
// We are only interested in listing GAIA accounts.
if (account_key.account_type !=
account_manager::AccountType::ACCOUNT_TYPE_GAIA) {
continue;
}
- AccountInfo account_info =
- account_tracker_service_->FindAccountInfoByGaiaId(account_key.id);
- DCHECK(!account_info.IsEmpty());
base::DictionaryValue account;
account.SetString("id", account_key.id);
account.SetInteger("accountType", account_key.account_type);
account.SetBoolean("isDeviceAccount", false);
- const std::string oauth_account_id =
- account_mapper_util_.AccountKeyToOAuthAccountId(account_key);
+ base::Optional<AccountInfo> maybe_account_info =
+ identity_manager_->FindAccountInfoForAccountWithRefreshTokenByGaiaId(
+ account_key.id);
+ DCHECK(maybe_account_info.has_value());
+
account.SetBoolean(
"isSignedIn",
- identity_manager_->HasAccountWithRefreshToken(oauth_account_id) &&
- !identity_manager_
- ->HasAccountWithRefreshTokenInPersistentErrorState(
- oauth_account_id));
- account.SetString("fullName", account_info.full_name);
- account.SetString("email", account_info.email);
- if (!account_info.account_image.IsEmpty()) {
- account.SetString("pic", webui::GetBitmapDataUrl(
- account_info.account_image.AsBitmap()));
+ !identity_manager_->HasAccountWithRefreshTokenInPersistentErrorState(
+ maybe_account_info->account_id));
+ account.SetString("fullName", maybe_account_info->full_name);
+ account.SetString("email", maybe_account_info->email);
+ if (!maybe_account_info->account_image.IsEmpty()) {
+ account.SetString("pic",
+ webui::GetBitmapDataUrl(
+ maybe_account_info->account_image.AsBitmap()));
} else {
gfx::ImageSkia default_icon =
*ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
@@ -154,7 +164,7 @@ void AccountManagerUIHandler::GetAccountsCallbackHandler(
default_icon.GetRepresentation(1.0f).GetBitmap()));
}
- if (account_mapper_util_.IsEqual(account_key, device_account_id)) {
+ if (IsSameAccount(account_key, device_account_id)) {
device_account = std::move(account);
} else {
accounts.GetList().push_back(std::move(account));
@@ -199,7 +209,7 @@ void AccountManagerUIHandler::HandleRemoveAccount(const base::ListValue* args) {
->GetAccountId();
const AccountManager::AccountKey account_key =
GetAccountKeyFromJsCallback(dictionary);
- if (account_mapper_util_.IsEqual(account_key, device_account_id)) {
+ if (IsSameAccount(account_key, device_account_id)) {
// It should not be possible to remove a device account.
return;
}
@@ -214,50 +224,39 @@ void AccountManagerUIHandler::HandleShowWelcomeDialogIfRequired(
void AccountManagerUIHandler::OnJavascriptAllowed() {
account_manager_observer_.Add(account_manager_);
- account_tracker_service_observer_.Add(account_tracker_service_);
+ identity_manager_observer_.Add(identity_manager_);
}
void AccountManagerUIHandler::OnJavascriptDisallowed() {
account_manager_observer_.RemoveAll();
- account_tracker_service_observer_.RemoveAll();
+ identity_manager_observer_.RemoveAll();
}
-// |AccountManager::Observer| overrides.
-// Note: We need to listen on |AccountManager| in addition to
-// |AccountTrackerService| because there is no guarantee that |AccountManager|
-// (our source of truth) will have a newly added account by the time
-// |AccountTrackerService| has it.
+// |AccountManager::Observer| overrides. Note: We need to listen on
+// |AccountManager| in addition to |IdentityManager| because there is no
+// guarantee that |AccountManager| (our source of truth) will have a newly added
+// account by the time |IdentityManager| has it.
void AccountManagerUIHandler::OnTokenUpserted(
- const AccountManager::AccountKey& account_key) {
+ const AccountManager::Account& account) {
RefreshUI();
}
void AccountManagerUIHandler::OnAccountRemoved(
- const AccountManager::AccountKey& account_key) {
+ const AccountManager::Account& account) {
RefreshUI();
}
-// |AccountTrackerService::Observer| overrides.
-// For newly added accounts, |AccountTrackerService| may take some time to
-// fetch user's full name and account image. Whenever that is completed, we
-// may need to update the UI with this new set of information.
-// Note that we may be listening to |AccountTrackerService| but we still
-// consider |AccountManager| to be the source of truth for account list.
-void AccountManagerUIHandler::OnAccountUpdated(const AccountInfo& info) {
+// |identity::IdentityManager::Observer| overrides. For newly added accounts,
+// |identity::IdentityManager| may take some time to fetch user's full name and
+// account image. Whenever that is completed, we may need to update the UI with
+// this new set of information. Note that we may be listening to
+// |identity::IdentityManager| but we still consider |AccountManager| to be the
+// source of truth for account list.
+void AccountManagerUIHandler::OnExtendedAccountInfoUpdated(
+ const AccountInfo& info) {
RefreshUI();
}
-void AccountManagerUIHandler::OnAccountUpdateFailed(
- const std::string& account_id) {
- // An account fetch failed for |account_id|, but we must display the account
- // anyways (if it was not being displayed already) so that users do not think
- // that their account has suddenly disappeared.
- RefreshUI();
-}
-
-void AccountManagerUIHandler::OnAccountRemoved(const AccountInfo& account_key) {
-}
-
void AccountManagerUIHandler::RefreshUI() {
FireWebUIListener("accounts-changed");
}
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.h
index 2b2a1918f4e..029da8d3344 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.h
@@ -11,10 +11,8 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/scoped_observer.h"
-#include "chrome/browser/chromeos/account_mapper_util.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "chromeos/account_manager/account_manager.h"
-#include "components/signin/core/browser/account_tracker_service.h"
#include "services/identity/public/cpp/identity_manager.h"
namespace chromeos {
@@ -22,12 +20,11 @@ namespace settings {
class AccountManagerUIHandler : public ::settings::SettingsPageUIHandler,
public AccountManager::Observer,
- public AccountTrackerService::Observer {
+ public identity::IdentityManager::Observer {
public:
- // Accepts non-owning pointers to |AccountManager| and
- // |AccountTrackerService|. Both of these must outlive |this| instance.
+ // Accepts non-owning pointers to |AccountManager|, |AccountTrackerService|
+ // and |IdentityManager|. Both of these must outlive |this| instance.
AccountManagerUIHandler(AccountManager* account_manager,
- AccountTrackerService* account_tracker_service,
identity::IdentityManager* identity_manager);
~AccountManagerUIHandler() override;
@@ -39,13 +36,11 @@ class AccountManagerUIHandler : public ::settings::SettingsPageUIHandler,
// |AccountManager::Observer| overrides.
// |AccountManager| is considered to be the source of truth for account
// information.
- void OnTokenUpserted(const AccountManager::AccountKey& account_key) override;
- void OnAccountRemoved(const AccountManager::AccountKey& account_key) override;
+ void OnTokenUpserted(const AccountManager::Account& account) override;
+ void OnAccountRemoved(const AccountManager::Account& account) override;
- // |AccountTrackerService::Observer| overrides.
- void OnAccountUpdated(const AccountInfo& info) override;
- void OnAccountUpdateFailed(const std::string& account_id) override;
- void OnAccountRemoved(const AccountInfo& account_key) override;
+ // |identity::IdentityManager::Observer| overrides.
+ void OnExtendedAccountInfoUpdated(const AccountInfo& info) override;
private:
// WebUI "getAccounts" message callback.
@@ -64,9 +59,9 @@ class AccountManagerUIHandler : public ::settings::SettingsPageUIHandler,
void HandleShowWelcomeDialogIfRequired(const base::ListValue* args);
// |AccountManager::GetAccounts| callback.
- void GetAccountsCallbackHandler(
+ void OnGetAccounts(
base::Value callback_id,
- std::vector<AccountManager::AccountKey> account_keys);
+ const std::vector<AccountManager::Account>& stored_accounts);
// Refreshes the UI.
void RefreshUI();
@@ -74,23 +69,18 @@ class AccountManagerUIHandler : public ::settings::SettingsPageUIHandler,
// A non-owning pointer to |AccountManager|.
AccountManager* const account_manager_;
- // A non-owning pointer to |AccountTrackerService|.
- AccountTrackerService* const account_tracker_service_;
-
// A non-owning pointer to |IdentityManager|.
identity::IdentityManager* const identity_manager_;
- chromeos::AccountMapperUtil account_mapper_util_;
-
// An observer for |AccountManager|. Automatically deregisters when |this| is
// destructed.
ScopedObserver<AccountManager, AccountManager::Observer>
account_manager_observer_;
- // An observer for |AccountTrackerService|. Automatically deregisters when
+ // An observer for |identity::IdentityManager|. Automatically deregisters when
// |this| is destructed.
- ScopedObserver<AccountTrackerService, AccountTrackerService::Observer>
- account_tracker_service_observer_;
+ ScopedObserver<identity::IdentityManager, identity::IdentityManager::Observer>
+ identity_manager_observer_;
base::WeakPtrFactory<AccountManagerUIHandler> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(AccountManagerUIHandler);
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/android_apps_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/android_apps_handler.cc
index 20b842fa019..4cf92f5fcda 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/android_apps_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/android_apps_handler.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/ui/webui/settings/chromeos/android_apps_handler.h"
+#include "base/bind.h"
#include "base/values.h"
#include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/profiles/profile.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 439b6fea161..d8f69e3f354 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.cc
@@ -4,7 +4,11 @@
#include "chrome/browser/ui/webui/settings/chromeos/crostini_handler.h"
+#include <string>
+
+#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "chrome/browser/chromeos/crostini/crostini_export_import.h"
#include "chrome/browser/chromeos/crostini/crostini_manager.h"
#include "chrome/browser/chromeos/crostini/crostini_share_path.h"
#include "chrome/browser/chromeos/crostini/crostini_util.h"
@@ -18,7 +22,13 @@ namespace settings {
CrostiniHandler::CrostiniHandler(Profile* profile)
: profile_(profile), weak_ptr_factory_(this) {}
-CrostiniHandler::~CrostiniHandler() = default;
+CrostiniHandler::~CrostiniHandler() {
+ if (crostini::CrostiniManager::GetForProfile(profile_)
+ ->HasInstallerViewStatusObserver(this)) {
+ crostini::CrostiniManager::GetForProfile(profile_)
+ ->RemoveInstallerViewStatusObserver(this);
+ }
+}
void CrostiniHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
@@ -38,6 +48,21 @@ void CrostiniHandler::RegisterMessages() {
"removeCrostiniSharedPath",
base::BindRepeating(&CrostiniHandler::HandleRemoveCrostiniSharedPath,
weak_ptr_factory_.GetWeakPtr()));
+ web_ui()->RegisterMessageCallback(
+ "exportCrostiniContainer",
+ base::BindRepeating(&CrostiniHandler::HandleExportCrostiniContainer,
+ weak_ptr_factory_.GetWeakPtr()));
+ web_ui()->RegisterMessageCallback(
+ "importCrostiniContainer",
+ base::BindRepeating(&CrostiniHandler::HandleImportCrostiniContainer,
+ weak_ptr_factory_.GetWeakPtr()));
+ web_ui()->RegisterMessageCallback(
+ "requestCrostiniInstallerStatus",
+ base::BindRepeating(
+ &CrostiniHandler::HandleCrostiniInstallerStatusRequest,
+ weak_ptr_factory_.GetWeakPtr()));
+ crostini::CrostiniManager::GetForProfile(profile_)
+ ->AddInstallerViewStatusObserver(this);
}
void CrostiniHandler::HandleRequestCrostiniInstallerView(
@@ -88,5 +113,37 @@ void CrostiniHandler::HandleRemoveCrostiniSharedPath(
path));
}
+void CrostiniHandler::HandleExportCrostiniContainer(
+ const base::ListValue* args) {
+ CHECK_EQ(0U, args->GetSize());
+ crostini::CrostiniExportImport::GetForProfile(profile_)->ExportContainer(
+ web_ui()->GetWebContents());
+}
+
+void CrostiniHandler::HandleImportCrostiniContainer(
+ const base::ListValue* args) {
+ CHECK_EQ(0U, args->GetSize());
+ crostini::CrostiniExportImport::GetForProfile(profile_)->ImportContainer(
+ web_ui()->GetWebContents());
+}
+
+void CrostiniHandler::HandleCrostiniInstallerStatusRequest(
+ const base::ListValue* args) {
+ AllowJavascript();
+ CHECK_EQ(0U, args->GetSize());
+ bool status = crostini::CrostiniManager::GetForProfile(profile_)
+ ->GetInstallerViewStatus();
+ OnCrostiniInstallerViewStatusChanged(status);
+}
+
+void CrostiniHandler::OnCrostiniInstallerViewStatusChanged(bool status) {
+ // It's technically possible for this to be called before Javascript is
+ // enabled, in which case we must not call FireWebUIListener
+ if (IsJavascriptAllowed()) {
+ // Other side listens with cr.addWebUIListener
+ FireWebUIListener("crostini-installer-status-changed", base::Value(status));
+ }
+}
+
} // namespace settings
} // namespace chromeos
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 37b71f5d4f2..6358b30e17b 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_CROSTINI_HANDLER_H_
#include "base/memory/weak_ptr.h"
+#include "chrome/browser/chromeos/crostini/crostini_manager.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
class Profile;
@@ -17,7 +18,8 @@ enum class CrostiniResult;
namespace chromeos {
namespace settings {
-class CrostiniHandler : public ::settings::SettingsPageUIHandler {
+class CrostiniHandler : public ::settings::SettingsPageUIHandler,
+ public crostini::InstallerViewStatusObserver {
public:
explicit CrostiniHandler(Profile* profile);
~CrostiniHandler() override;
@@ -36,6 +38,14 @@ class CrostiniHandler : public ::settings::SettingsPageUIHandler {
void HandleGetCrostiniSharedPathsDisplayText(const base::ListValue* args);
// Remove a specified path from being shared.
void HandleRemoveCrostiniSharedPath(const base::ListValue* args);
+ // Export the crostini container.
+ void HandleExportCrostiniContainer(const base::ListValue* args);
+ // Import the crostini container.
+ void HandleImportCrostiniContainer(const base::ListValue* args);
+ // Handle a request for the CrostiniInstallerView status.
+ void HandleCrostiniInstallerStatusRequest(const base::ListValue* args);
+ // Handle the CrostiniInstallerView opening/closing.
+ void OnCrostiniInstallerViewStatusChanged(bool open) override;
Profile* profile_;
// weak_ptr_factory_ should always be last member.
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc
index 440b61401c3..28b9e86154d 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc
@@ -15,6 +15,7 @@
#include "base/metrics/histogram_macros.h"
#include "base/path_service.h"
#include "base/strings/string_util.h"
+#include "base/strings/stringprintf.h"
#include "base/task/post_task.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "base/values.h"
@@ -103,7 +104,7 @@ void QueryAutoconf(const std::string& printer_uri,
// Behavior for querying a non-IPP uri is undefined and disallowed.
if (!IsIppUri(printer_uri) || !optional.has_value()) {
PRINTER_LOG(ERROR) << "Printer uri is invalid: " << printer_uri;
- callback.Run(false, "", "", "", false);
+ callback.Run(false, "", "", "", {}, false);
return;
}
@@ -423,7 +424,7 @@ void CupsPrintersHandler::HandleGetPrinterInfo(const base::ListValue* args) {
if (printer_address.empty()) {
// Run the failure callback.
- OnAutoconfQueried(callback_id, false, "", "", "", false);
+ OnAutoconfQueried(callback_id, false, "", "", "", {}, false);
return;
}
@@ -452,6 +453,7 @@ void CupsPrintersHandler::OnAutoconfQueriedDiscovered(
const std::string& make,
const std::string& model,
const std::string& make_and_model,
+ const std::vector<std::string>& document_formats,
bool ipp_everywhere) {
RecordIppQuerySuccess(success);
@@ -488,12 +490,14 @@ void CupsPrintersHandler::OnAutoconfQueriedDiscovered(
FireManuallyAddDiscoveredPrinter(*printer);
}
-void CupsPrintersHandler::OnAutoconfQueried(const std::string& callback_id,
- bool success,
- const std::string& make,
- const std::string& model,
- const std::string& make_and_model,
- bool ipp_everywhere) {
+void CupsPrintersHandler::OnAutoconfQueried(
+ const std::string& callback_id,
+ bool success,
+ const std::string& make,
+ const std::string& model,
+ const std::string& make_and_model,
+ const std::vector<std::string>& document_formats,
+ bool ipp_everywhere) {
RecordIppQuerySuccess(success);
if (!success) {
@@ -521,8 +525,11 @@ void CupsPrintersHandler::OnAutoconfQueried(const std::string& callback_id,
return;
}
- PpdProvider::PrinterSearchData ppd_search_data;
+ PrinterSearchData ppd_search_data;
+ ppd_search_data.discovery_type =
+ PrinterSearchData::PrinterDiscoveryType::kManual;
ppd_search_data.make_and_model.push_back(make_and_model);
+ ppd_search_data.supported_document_formats = document_formats;
// Try to resolve the PPD matching.
ppd_provider_->ResolvePpdReference(
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h
index f6b4aa1b81a..0362548c17a 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h
@@ -68,15 +68,18 @@ class CupsPrintersHandler : public ::settings::SettingsPageUIHandler,
const std::string& make,
const std::string& model,
const std::string& make_and_model,
+ const std::vector<std::string>& document_formats,
bool ipp_everywhere);
// Handles the callback for HandleGetPrinterInfo for a discovered printer.
- void OnAutoconfQueriedDiscovered(std::unique_ptr<Printer> printer,
- bool success,
- const std::string& make,
- const std::string& model,
- const std::string& make_and_model,
- bool ipp_everywhere);
+ void OnAutoconfQueriedDiscovered(
+ std::unique_ptr<Printer> printer,
+ bool success,
+ const std::string& make,
+ const std::string& model,
+ const std::string& make_and_model,
+ const std::vector<std::string>& document_formats,
+ bool ipp_everywhere);
// Callback for PPD matching attempts;
void OnPpdResolved(const std::string& callback_id,
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/date_time_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/date_time_handler.cc
index 779d2504b25..2423ebcd3dc 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/date_time_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/date_time_handler.cc
@@ -13,8 +13,7 @@
#include "chrome/browser/chromeos/system/timezone_util.h"
#include "chrome/common/pref_names.h"
#include "chromeos/constants/chromeos_switches.h"
-#include "chromeos/dbus/dbus_thread_manager.h"
-#include "chromeos/dbus/system_clock_client.h"
+#include "chromeos/dbus/system_clock/system_clock_client.h"
#include "chromeos/settings/timezone_settings.h"
#include "components/policy/proto/chrome_device_policy.pb.h"
#include "components/prefs/pref_service.h"
@@ -101,8 +100,7 @@ void DateTimeHandler::RegisterMessages() {
}
void DateTimeHandler::OnJavascriptAllowed() {
- SystemClockClient* system_clock_client =
- DBusThreadManager::Get()->GetSystemClockClient();
+ SystemClockClient* system_clock_client = SystemClockClient::Get();
scoped_observer_.Add(system_clock_client);
SystemClockCanSetTimeChanged(system_clock_client->CanSetTime());
@@ -152,7 +150,7 @@ void DateTimeHandler::HandleGetTimeZones(const base::ListValue* args) {
void DateTimeHandler::HandleShowSetDateTimeUI(const base::ListValue* args) {
// Make sure the clock status hasn't changed since the button was clicked.
- if (!DBusThreadManager::Get()->GetSystemClockClient()->CanSetTime())
+ if (!SystemClockClient::Get()->CanSetTime())
return;
SetTimeDialog::ShowDialog(
web_ui()->GetWebContents()->GetTopLevelNativeWindow());
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/date_time_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/date_time_handler.h
index b04142f82f7..c4f2a32f874 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/date_time_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/date_time_handler.h
@@ -12,7 +12,7 @@
#include "base/scoped_observer.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
-#include "chromeos/dbus/system_clock_client.h"
+#include "chromeos/dbus/system_clock/system_clock_client.h"
#include "components/prefs/pref_change_registrar.h"
namespace base {
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 8daed6d7f45..20bc0890273 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
@@ -12,10 +12,12 @@
#include "chrome/browser/ui/ash/ksv/keyboard_shortcut_viewer_util.h"
#include "chrome/browser/ui/ash/tablet_mode_client.h"
#include "chromeos/constants/chromeos_switches.h"
+#include "chromeos/services/assistant/public/features.h"
#include "content/public/browser/web_ui.h"
#include "content/public/common/service_manager_connection.h"
#include "services/service_manager/public/cpp/connector.h"
#include "ui/chromeos/events/event_rewriter_chromeos.h"
+#include "ui/chromeos/events/keyboard_layout_util.h"
#include "ui/events/devices/input_device_manager.h"
namespace {
@@ -138,13 +140,9 @@ void KeyboardHandler::UpdateShowKeys() {
keyboards_state.has_external_non_apple_keyboard ||
!base::CommandLine::ForCurrentProcess()->HasSwitch(
chromeos::switches::kHasChromeOSKeyboard);
- const bool has_diamond_key =
- base::CommandLine::ForCurrentProcess()->HasSwitch(
- chromeos::switches::kHasChromeOSDiamondKey);
base::Value keyboard_params(base::Value::Type::DICTIONARY);
keyboard_params.SetKey("showCapsLock", base::Value(has_caps_lock));
- keyboard_params.SetKey("showDiamondKey", base::Value(has_diamond_key));
keyboard_params.SetKey(
"showExternalMetaKey",
base::Value(keyboards_state.has_external_non_apple_keyboard));
@@ -153,6 +151,12 @@ void KeyboardHandler::UpdateShowKeys() {
keyboard_params.SetKey("hasInternalKeyboard",
base::Value(keyboards_state.has_internal_keyboard));
+ const bool show_assistant_key_settings =
+ chromeos::assistant::features::IsKeyRemappingEnabled() &&
+ ui::DeviceKeyboardHasAssistantKey();
+ keyboard_params.SetKey("hasAssistantKey",
+ base::Value(show_assistant_key_settings));
+
FireWebUIListener(kShowKeysChangedName, keyboard_params);
}
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 2b828787676..c43acae183c 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
@@ -49,7 +49,6 @@ class KeyboardHandlerTest : public testing::Test {
// which keys should be shown. False is returned if the message was invalid or
// not found.
bool GetLastShowKeysChangedMessage(bool* has_caps_lock_out,
- bool* has_diamond_key_out,
bool* has_external_meta_key_out,
bool* has_apple_command_key_out,
bool* has_internal_search_out)
@@ -72,7 +71,6 @@ class KeyboardHandlerTest : public testing::Test {
const base::Value* keyboard_params = data->arg2();
const std::vector<std::pair<std::string, bool*>> path_to_out_param = {
{"showCapsLock", has_caps_lock_out},
- {"showDiamondKey", has_diamond_key_out},
{"showExternalMetaKey", has_external_meta_key_out},
{"showAppleCommandKey", has_apple_command_key_out},
{"hasInternalKeyboard", has_internal_search_out},
@@ -98,35 +96,21 @@ class KeyboardHandlerTest : public testing::Test {
bool has_caps_lock = false;
bool ignored = false;
if (!GetLastShowKeysChangedMessage(&has_caps_lock, &ignored, &ignored,
- &ignored, &ignored)) {
+ &ignored)) {
ADD_FAILURE() << "Didn't get " << KeyboardHandler::kShowKeysChangedName;
return false;
}
return has_caps_lock;
}
- // Returns true if the last keys-changed message reported that a "diamond" key
- // is present and false otherwise. A failure is added if a message wasn't
- // found.
- bool HasDiamondKey() {
- bool has_diamond_key = false;
- bool ignored = false;
- if (!GetLastShowKeysChangedMessage(&ignored, &has_diamond_key, &ignored,
- &ignored, &ignored)) {
- ADD_FAILURE() << "Didn't get " << KeyboardHandler::kShowKeysChangedName;
- return false;
- }
- return has_diamond_key;
- }
-
// Returns true if the last keys-changed message reported that a Meta key on
// an external keyboard is present and false otherwise. A failure is added if
// a message wasn't found.
bool HasExternalMetaKey() {
bool has_external_meta = false;
bool ignored = false;
- if (!GetLastShowKeysChangedMessage(&ignored, &ignored, &has_external_meta,
- &ignored, &ignored)) {
+ if (!GetLastShowKeysChangedMessage(&ignored, &has_external_meta, &ignored,
+ &ignored)) {
ADD_FAILURE() << "Didn't get " << KeyboardHandler::kShowKeysChangedName;
return false;
}
@@ -139,7 +123,7 @@ class KeyboardHandlerTest : public testing::Test {
bool HasAppleCommandKey() {
bool has_apple_command_key = false;
bool ignored = false;
- if (!GetLastShowKeysChangedMessage(&ignored, &ignored, &ignored,
+ if (!GetLastShowKeysChangedMessage(&ignored, &ignored,
&has_apple_command_key, &ignored)) {
ADD_FAILURE() << "Didn't get " << KeyboardHandler::kShowKeysChangedName;
return false;
@@ -153,7 +137,7 @@ class KeyboardHandlerTest : public testing::Test {
bool HasInternalSearchKey() {
bool has_internal_search_key = false;
bool ignored = false;
- if (!GetLastShowKeysChangedMessage(&ignored, &ignored, &ignored, &ignored,
+ if (!GetLastShowKeysChangedMessage(&ignored, &ignored, &ignored,
&has_internal_search_key)) {
ADD_FAILURE() << "Didn't get " << KeyboardHandler::kShowKeysChangedName;
return false;
@@ -177,7 +161,6 @@ TEST_F(KeyboardHandlerTest, DefaultKeys) {
handler_test_api_.Initialize();
EXPECT_FALSE(HasInternalSearchKey());
EXPECT_FALSE(HasCapsLock());
- EXPECT_FALSE(HasDiamondKey());
EXPECT_FALSE(HasExternalMetaKey());
EXPECT_FALSE(HasAppleCommandKey());
}
@@ -188,7 +171,6 @@ TEST_F(KeyboardHandlerTest, NonChromeOSKeyboard) {
handler_test_api_.Initialize();
EXPECT_FALSE(HasInternalSearchKey());
EXPECT_TRUE(HasCapsLock());
- EXPECT_FALSE(HasDiamondKey());
EXPECT_FALSE(HasExternalMetaKey());
EXPECT_FALSE(HasAppleCommandKey());
}
@@ -202,7 +184,6 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) {
handler_test_api_.Initialize();
EXPECT_TRUE(HasInternalSearchKey());
EXPECT_FALSE(HasCapsLock());
- EXPECT_FALSE(HasDiamondKey());
EXPECT_FALSE(HasExternalMetaKey());
EXPECT_FALSE(HasAppleCommandKey());
@@ -213,7 +194,6 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) {
{2, ui::INPUT_DEVICE_USB, "external keyboard"}});
EXPECT_TRUE(HasInternalSearchKey());
EXPECT_TRUE(HasCapsLock());
- EXPECT_FALSE(HasDiamondKey());
EXPECT_TRUE(HasExternalMetaKey());
EXPECT_FALSE(HasAppleCommandKey());
@@ -224,7 +204,6 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) {
{3, ui::INPUT_DEVICE_USB, "Apple Inc. Apple Keyboard"}});
EXPECT_TRUE(HasInternalSearchKey());
EXPECT_TRUE(HasCapsLock());
- EXPECT_FALSE(HasDiamondKey());
EXPECT_FALSE(HasExternalMetaKey());
EXPECT_TRUE(HasAppleCommandKey());
@@ -235,7 +214,6 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) {
{3, ui::INPUT_DEVICE_USB, "Apple Inc. Apple Keyboard"}});
EXPECT_FALSE(HasInternalSearchKey());
EXPECT_TRUE(HasCapsLock());
- EXPECT_FALSE(HasDiamondKey());
EXPECT_TRUE(HasExternalMetaKey());
EXPECT_TRUE(HasAppleCommandKey());
@@ -247,7 +225,6 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) {
{4, ui::INPUT_DEVICE_USB, "Topre Corporation Realforce 87"}});
EXPECT_FALSE(HasInternalSearchKey());
EXPECT_TRUE(HasCapsLock());
- EXPECT_FALSE(HasDiamondKey());
EXPECT_TRUE(HasExternalMetaKey());
EXPECT_FALSE(HasAppleCommandKey());
@@ -255,19 +232,6 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) {
input_device_client_test_api_.SetKeyboardDevices({});
EXPECT_FALSE(HasInternalSearchKey());
EXPECT_FALSE(HasCapsLock());
- EXPECT_FALSE(HasDiamondKey());
- EXPECT_FALSE(HasExternalMetaKey());
- EXPECT_FALSE(HasAppleCommandKey());
-}
-
-TEST_F(KeyboardHandlerTest, DiamondKey) {
- base::CommandLine::ForCurrentProcess()->AppendSwitch(
- chromeos::switches::kHasChromeOSKeyboard);
- base::CommandLine::ForCurrentProcess()->AppendSwitch(
- chromeos::switches::kHasChromeOSDiamondKey);
- handler_test_api_.Initialize();
- EXPECT_FALSE(HasCapsLock());
- EXPECT_TRUE(HasDiamondKey());
EXPECT_FALSE(HasExternalMetaKey());
EXPECT_FALSE(HasAppleCommandKey());
}
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.cc
index 4f0138fc90a..ca32d32706f 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.cc
@@ -139,8 +139,7 @@ void PowerHandler::RegisterMessages() {
}
void PowerHandler::OnJavascriptAllowed() {
- PowerManagerClient* power_manager_client =
- DBusThreadManager::Get()->GetPowerManagerClient();
+ PowerManagerClient* power_manager_client = PowerManagerClient::Get();
power_manager_client_observer_.Add(power_manager_client);
power_manager_client->GetSwitchStates(base::Bind(
&PowerHandler::OnGotSwitchStates, weak_ptr_factory_.GetWeakPtr()));
@@ -176,9 +175,8 @@ void PowerHandler::PowerChanged(
}
void PowerHandler::PowerManagerRestarted() {
- DBusThreadManager::Get()->GetPowerManagerClient()->GetSwitchStates(
- base::BindOnce(&PowerHandler::OnGotSwitchStates,
- weak_ptr_factory_.GetWeakPtr()));
+ PowerManagerClient::Get()->GetSwitchStates(base::BindOnce(
+ &PowerHandler::OnGotSwitchStates, weak_ptr_factory_.GetWeakPtr()));
}
void PowerHandler::LidEventReceived(PowerManagerClient::LidState state,
@@ -189,9 +187,7 @@ void PowerHandler::LidEventReceived(PowerManagerClient::LidState state,
void PowerHandler::HandleUpdatePowerStatus(const base::ListValue* args) {
AllowJavascript();
- chromeos::DBusThreadManager::Get()
- ->GetPowerManagerClient()
- ->RequestStatusUpdate();
+ chromeos::PowerManagerClient::Get()->RequestStatusUpdate();
}
void PowerHandler::HandleSetPowerSource(const base::ListValue* args) {
@@ -199,8 +195,7 @@ void PowerHandler::HandleSetPowerSource(const base::ListValue* args) {
std::string id;
CHECK(args->GetString(0, &id));
- chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->SetPowerSource(
- id);
+ chromeos::PowerManagerClient::Get()->SetPowerSource(id);
}
void PowerHandler::HandleRequestPowerManagementSettings(
@@ -280,7 +275,7 @@ void PowerHandler::HandleSetLidClosedBehavior(const base::ListValue* args) {
void PowerHandler::SendBatteryStatus() {
const base::Optional<power_manager::PowerSupplyProperties>& proto =
- DBusThreadManager::Get()->GetPowerManagerClient()->GetLastStatus();
+ PowerManagerClient::Get()->GetLastStatus();
DCHECK(proto);
bool charging = proto->battery_state() ==
power_manager::PowerSupplyProperties_BatteryState_CHARGING;
@@ -302,10 +297,10 @@ void PowerHandler::SendBatteryStatus() {
status_text = l10n_util::GetStringFUTF16(
charging ? IDS_SETTINGS_BATTERY_STATUS_CHARGING
: IDS_SETTINGS_BATTERY_STATUS,
- base::IntToString16(percent), GetBatteryTimeText(time_left));
+ base::NumberToString16(percent), GetBatteryTimeText(time_left));
} else {
status_text = l10n_util::GetStringFUTF16(IDS_SETTINGS_BATTERY_STATUS_SHORT,
- base::IntToString16(percent));
+ base::NumberToString16(percent));
}
base::DictionaryValue battery_dict;
@@ -323,7 +318,7 @@ void PowerHandler::SendBatteryStatus() {
void PowerHandler::SendPowerSources() {
const base::Optional<power_manager::PowerSupplyProperties>& proto =
- DBusThreadManager::Get()->GetPowerManagerClient()->GetLastStatus();
+ PowerManagerClient::Get()->GetLastStatus();
DCHECK(proto);
base::ListValue sources_list;
for (int i = 0; i < proto->available_external_power_source_size(); i++) {
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler_browsertest.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler_browsertest.cc
index edfc117d906..9206cad0173 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler_browsertest.cc
@@ -14,7 +14,6 @@
#include "base/values.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/test/base/in_process_browser_test.h"
-#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/fake_power_manager_client.h"
#include "chromeos/dbus/power_policy_controller.h"
#include "components/policy/core/browser/browser_policy_connector.h"
@@ -54,10 +53,6 @@ class PowerHandlerTest : public InProcessBrowserTest {
// InProcessBrowserTest:
void SetUpInProcessBrowserTestFixture() override {
- power_manager_client_ = new chromeos::FakePowerManagerClient;
- chromeos::DBusThreadManager::GetSetterForTesting()->SetPowerManagerClient(
- base::WrapUnique(power_manager_client_));
-
// Initialize user policy.
ON_CALL(provider_, IsInitializationComplete(_)).WillByDefault(Return(true));
policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_);
@@ -145,9 +140,6 @@ class PowerHandlerTest : public InProcessBrowserTest {
base::RunLoop().RunUntilIdle();
}
- // Owned by chromeos::DBusThreadManager.
- chromeos::FakePowerManagerClient* power_manager_client_;
-
std::unique_ptr<TestPowerHandler> handler_;
std::unique_ptr<TestPowerHandler::TestAPI> test_api_;
@@ -172,8 +164,8 @@ IN_PROC_BROWSER_TEST_F(PowerHandlerTest, SendInitialSettings) {
// Verifies that WebUI receives updated settings when the lid state changes.
IN_PROC_BROWSER_TEST_F(PowerHandlerTest, SendSettingsForLidStateChanges) {
- power_manager_client_->SetLidState(PowerManagerClient::LidState::NOT_PRESENT,
- base::TimeTicks());
+ chromeos::FakePowerManagerClient::Get()->SetLidState(
+ PowerManagerClient::LidState::NOT_PRESENT, base::TimeTicks());
EXPECT_EQ(
CreateSettingsChangedString(
PowerHandler::IdleBehavior::DISPLAY_OFF_SLEEP,
@@ -181,8 +173,8 @@ IN_PROC_BROWSER_TEST_F(PowerHandlerTest, SendSettingsForLidStateChanges) {
false /* lid_closed_controlled */, false /* has_lid */),
GetLastSettingsChangedMessage());
- power_manager_client_->SetLidState(PowerManagerClient::LidState::OPEN,
- base::TimeTicks());
+ chromeos::FakePowerManagerClient::Get()->SetLidState(
+ PowerManagerClient::LidState::OPEN, base::TimeTicks());
EXPECT_EQ(
CreateSettingsChangedString(
PowerHandler::IdleBehavior::DISPLAY_OFF_SLEEP,
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 8553ff4c95e..5ef78d58cdf 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
@@ -9,6 +9,7 @@
#include <numeric>
#include <string>
+#include "base/bind.h"
#include "base/files/file_util.h"
#include "base/system/sys_info.h"
#include "base/task/post_task.h"
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.cc
index 7ddc716d6c6..9b7cf3f1d55 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.cc
@@ -232,7 +232,7 @@ void FingerprintHandler::HandleStartEnroll(const base::ListValue* args) {
for (int i = 1; i <= kMaxAllowedFingerprints; ++i) {
std::string fingerprint_name = l10n_util::GetStringFUTF8(
IDS_SETTINGS_PEOPLE_LOCK_SCREEN_NEW_FINGERPRINT_DEFAULT_NAME,
- base::IntToString16(i));
+ base::NumberToString16(i));
if (!base::ContainsValue(fingerprints_labels_, fingerprint_name)) {
fp_service_->StartEnrollSession(user_id_, fingerprint_name);
break;
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.cc
index dc187325511..4ea6720e436 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.cc
@@ -9,6 +9,7 @@
#include "ash/public/interfaces/assistant_controller.mojom.h"
#include "ash/public/interfaces/constants.mojom.h"
#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/values.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.h"
@@ -40,6 +41,10 @@ void GoogleAssistantHandler::RegisterMessages() {
"retrainAssistantVoiceModel",
base::BindRepeating(&GoogleAssistantHandler::HandleRetrainVoiceModel,
base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "syncVoiceModelStatus",
+ base::BindRepeating(&GoogleAssistantHandler::HandleSyncVoiceModelStatus,
+ base::Unretained(this)));
}
void GoogleAssistantHandler::HandleShowGoogleAssistantSettings(
@@ -58,8 +63,17 @@ void GoogleAssistantHandler::HandleShowGoogleAssistantSettings(
void GoogleAssistantHandler::HandleRetrainVoiceModel(
const base::ListValue* args) {
CHECK_EQ(0U, args->GetSize());
- chromeos::AssistantOptInDialog::Show(
- ash::mojom::FlowType::SPEAKER_ID_ENROLLMENT, base::DoNothing());
+ chromeos::AssistantOptInDialog::Show(ash::mojom::FlowType::SPEAKER_ID_RETRAIN,
+ base::DoNothing());
+}
+
+void GoogleAssistantHandler::HandleSyncVoiceModelStatus(
+ const base::ListValue* args) {
+ CHECK_EQ(0U, args->GetSize());
+ if (!settings_manager_.is_bound())
+ BindAssistantSettingsManager();
+
+ settings_manager_->SyncSpeakerIdEnrollmentStatus();
}
void GoogleAssistantHandler::BindAssistantSettingsManager() {
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.h
index d99ede18195..87d09bc8304 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.h
@@ -29,13 +29,12 @@ class GoogleAssistantHandler : public ::settings::SettingsPageUIHandler {
void HandleShowGoogleAssistantSettings(const base::ListValue* args);
// WebUI call to retrain Assistant voice model.
void HandleRetrainVoiceModel(const base::ListValue* args);
+ // WebUI call to sync Assistant voice model status.
+ void HandleSyncVoiceModelStatus(const base::ListValue* args);
// Bind to assistant settings manager.
void BindAssistantSettingsManager();
- // Callback for deleting voice model.
- void DeleteVoiceModelCallback();
-
Profile* const profile_;
assistant::mojom::AssistantSettingsManagerPtr settings_manager_;
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/internet_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/internet_handler.cc
index 7a4c8bed26e..7b5b6b021fa 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/internet_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/internet_handler.cc
@@ -145,8 +145,9 @@ void InternetHandler::AddThirdPartyVpn(const base::ListValue* args) {
NET_LOG(ERROR) << "Empty app id for " << kAddThirdPartyVpnMessage;
return;
}
- if (profile_ != GetProfileForPrimaryUser()) {
- NET_LOG(ERROR) << "Only the primary user can add VPNs";
+ if (profile_ != GetProfileForPrimaryUser() || profile_->IsChild()) {
+ NET_LOG(ERROR)
+ << "Only the primary user and non-child accounts can add VPNs";
return;
}
diff --git a/chromium/chrome/browser/ui/webui/settings/downloads_handler.cc b/chromium/chrome/browser/ui/webui/settings/downloads_handler.cc
index de780d05a34..be86d1418f2 100644
--- a/chromium/chrome/browser/ui/webui/settings/downloads_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/downloads_handler.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/ui/webui/settings/downloads_handler.h"
+#include "base/bind.h"
#include "base/metrics/user_metrics.h"
#include "base/values.h"
#include "chrome/browser/download/download_prefs.h"
diff --git a/chromium/chrome/browser/ui/webui/settings/font_handler.cc b/chromium/chrome/browser/ui/webui/settings/font_handler.cc
index 1406eb7ae8a..7053f743452 100644
--- a/chromium/chrome/browser/ui/webui/settings/font_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/font_handler.cc
@@ -9,6 +9,7 @@
#include <utility>
#include <vector>
+#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/i18n/rtl.h"
#include "chrome/browser/browser_process.h"
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 b06ae469370..7b0b41f9780 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
@@ -10,6 +10,7 @@
#include "base/feature_list.h"
#include "base/i18n/number_formatting.h"
#include "base/strings/string_number_conversions.h"
+#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "build/buildflag.h"
@@ -35,16 +36,17 @@
#include "components/autofill/core/browser/personal_data_manager.h"
#include "components/autofill/core/common/autofill_constants.h"
#include "components/autofill/core/common/autofill_features.h"
-#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/omnibox/common/omnibox_features.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"
#include "components/strings/grit/components_strings.h"
#include "components/subresource_filter/core/browser/subresource_filter_features.h"
+#include "components/sync/driver/sync_service.h"
#include "components/sync/driver/sync_service_utils.h"
+#include "components/sync/driver/sync_user_settings.h"
#include "components/unified_consent/feature.h"
#include "content/public/browser/web_ui_data_source.h"
#include "content/public/common/content_features.h"
@@ -54,11 +56,12 @@
#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/system/sys_info.h"
+#include "chrome/browser/chromeos/account_manager/account_manager_util.h"
#include "chrome/browser/chromeos/arc/arc_util.h"
+#include "chrome/browser/chromeos/assistant/assistant_util.h"
#include "chrome/browser/chromeos/crostini/crostini_util.h"
#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h"
#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_factory.h"
@@ -76,6 +79,7 @@
#include "components/user_manager/user_manager.h"
#include "ui/chromeos/devicetype_utils.h"
#include "ui/chromeos/events/keyboard_layout_util.h"
+#include "ui/display/display_features.h"
#include "ui/display/display_switches.h"
#include "ui/display/manager/touch_device_manager.h"
#else
@@ -159,7 +163,7 @@ void AddCommonStrings(content::WebUIDataSource* html_source, Profile* profile) {
"isGuest",
#if defined(OS_CHROMEOS)
user_manager::UserManager::Get()->IsLoggedInAsGuest() ||
- user_manager::UserManager::Get()->IsLoggedInAsPublicAccount());
+ user_manager::UserManager::Get()->IsLoggedInAsPublicAccount());
#else
profile->IsOffTheRecord());
#endif
@@ -320,15 +324,15 @@ void AddA11yStrings(content::WebUIDataSource* html_source) {
AddLocalizedStringsBulk(html_source, kLocalizedStrings,
base::size(kLocalizedStrings));
- base::CommandLine& cmd = *base::CommandLine::ForCurrentProcess();
html_source->AddBoolean(
"showExperimentalA11yLabels",
- cmd.HasSwitch(::switches::kEnableExperimentalAccessibilityLabels));
+ base::FeatureList::IsEnabled(features::kExperimentalAccessibilityLabels));
#if defined(OS_CHROMEOS)
html_source->AddString("a11yLearnMoreUrl",
chrome::kChromeAccessibilityHelpURL);
+ base::CommandLine& cmd = *base::CommandLine::ForCurrentProcess();
html_source->AddBoolean(
"showExperimentalA11yFeatures",
cmd.HasSwitch(::switches::kEnableExperimentalAccessibilityFeatures));
@@ -340,9 +344,6 @@ void AddA11yStrings(content::WebUIDataSource* html_source) {
html_source->AddBoolean(
"showExperimentalAccessibilitySwitchAccess",
cmd.HasSwitch(::switches::kEnableExperimentalAccessibilitySwitchAccess));
-
- html_source->AddBoolean("dockedMagnifierFeatureEnabled",
- ash::features::IsDockedMagnifierEnabled());
#endif
}
@@ -440,12 +441,12 @@ void AddAboutStrings(content::WebUIDataSource* html_source) {
}
#if defined(OS_CHROMEOS)
-void AddCrostiniStrings(content::WebUIDataSource* html_source) {
+void AddCrostiniStrings(content::WebUIDataSource* html_source,
+ Profile* profile) {
static constexpr LocalizedString kLocalizedStrings[] = {
{"crostiniPageTitle", IDS_SETTINGS_CROSTINI_TITLE},
{"crostiniPageLabel", IDS_SETTINGS_CROSTINI_LABEL},
{"crostiniEnable", IDS_SETTINGS_TURN_ON},
- {"crostiniRemove", IDS_SETTINGS_CROSTINI_REMOVE},
{"crostiniSharedPaths", IDS_SETTINGS_CROSTINI_SHARED_PATHS},
{"crostiniSharedPathsListHeading",
IDS_SETTINGS_CROSTINI_SHARED_PATHS_LIST_HEADING},
@@ -455,18 +456,28 @@ void AddCrostiniStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_CROSTINI_SHARED_PATHS_INSTRUCTIONS_REMOVE},
{"crostiniSharedPathsRemoveSharing",
IDS_SETTINGS_CROSTINI_SHARED_PATHS_REMOVE_SHARING},
+ {"crostiniExportImportTitle", IDS_SETTINGS_CROSTINI_EXPORT_IMPORT_TITLE},
+ {"crostiniExport", IDS_SETTINGS_CROSTINI_EXPORT},
+ {"crostiniExportLabel", IDS_SETTINGS_CROSTINI_EXPORT_LABEL},
+ {"crostiniImport", IDS_SETTINGS_CROSTINI_IMPORT},
+ {"crostiniImportLabel", IDS_SETTINGS_CROSTINI_IMPORT_LABEL},
{"crostiniSharedUsbDevicesLabel",
IDS_SETTINGS_CROSTINI_SHARED_USB_DEVICES_LABEL},
{"crostiniSharedUsbDevicesDescription",
IDS_SETTINGS_CROSTINI_SHARED_USB_DEVICES_DESCRIPTION},
+ {"crostiniSharedUsbDevicesListHeading",
+ IDS_SETTINGS_CROSTINI_SHARED_USB_DEVICES_LIST_HEADING},
};
AddLocalizedStringsBulk(html_source, kLocalizedStrings,
base::size(kLocalizedStrings));
html_source->AddString(
"crostiniSubtext",
l10n_util::GetStringFUTF16(
- IDS_SETTINGS_CROSTINI_SUBTEXT,
+ IDS_SETTINGS_CROSTINI_SUBTEXT, ui::GetChromeOSDeviceName(),
GetHelpUrlWithBoard(chrome::kLinuxAppsLearnMoreURL)));
+ html_source->AddString("crostiniRemove", l10n_util::GetStringFUTF16(
+ IDS_SETTINGS_CROSTINI_REMOVE,
+ ui::GetChromeOSDeviceName()));
html_source->AddString(
"crostiniSharedPathsInstructionsLocate",
l10n_util::GetStringFUTF16(
@@ -474,10 +485,36 @@ void AddCrostiniStrings(content::WebUIDataSource* html_source) {
base::ASCIIToUTF16(
crostini::ContainerChromeOSBaseDirectory().value())));
html_source->AddBoolean(
+ "showCrostiniExportImport",
+ crostini::IsCrostiniExportImportUIAllowedForProfile(profile));
+ html_source->AddBoolean(
"enableCrostiniUsbDeviceSupport",
base::FeatureList::IsEnabled(chromeos::features::kCrostiniUsbSupport));
}
+void AddKioskNextShellStrings(content::WebUIDataSource* html_source) {
+ static constexpr LocalizedString kLocalizedStrings[] = {
+ {"kioskNextShellPageTitle", IDS_SETTINGS_KIOSK_NEXT_SHELL_TITLE},
+ {"kioskNextShellPageLabel", IDS_SETTINGS_KIOSK_NEXT_SHELL_LABEL},
+ {"kioskNextShellPageSubtextEnable",
+ IDS_SETTINGS_KIOSK_NEXT_SHELL_SUBTEXT_ENABLE},
+ {"kioskNextShellPageSubtextDisable",
+ IDS_SETTINGS_KIOSK_NEXT_SHELL_SUBTEXT_DISABLE},
+ {"kioskNextShellTurnOn", IDS_SETTINGS_TURN_ON},
+ {"kioskNextShellTurnOff", IDS_SETTINGS_KIOSK_NEXT_SHELL_TURN_OFF},
+ {"kioskNextShellEnabledDialogTitle",
+ IDS_SETTINGS_KIOSK_NEXT_SHELL_ENABLED_DIALOG_TITLE},
+ {"kioskNextShellDisabledDialogTitle",
+ IDS_SETTINGS_KIOSK_NEXT_SHELL_DISABLED_DIALOG_TITLE},
+ {"kioskNextShellEnabledDialogBody",
+ IDS_SETTINGS_KIOSK_NEXT_SHELL_ENABLED_DIALOG_BODY},
+ {"kioskNextShellDisabledDialogBody",
+ IDS_SETTINGS_KIOSK_NEXT_SHELL_DISABLED_DIALOG_BODY},
+ };
+ AddLocalizedStringsBulk(html_source, kLocalizedStrings,
+ base::size(kLocalizedStrings));
+}
+
void AddAndroidAppStrings(content::WebUIDataSource* html_source) {
LocalizedString localized_strings[] = {
{"androidAppsPageTitle", arc::IsPlayStoreAvailable()
@@ -697,6 +734,7 @@ void AddDeviceStrings(content::WebUIDataSource* html_source) {
{"keyboardKeyDiamond", IDS_SETTINGS_KEYBOARD_KEY_DIAMOND},
{"keyboardKeyEscape", IDS_SETTINGS_KEYBOARD_KEY_ESCAPE},
{"keyboardKeyBackspace", IDS_SETTINGS_KEYBOARD_KEY_BACKSPACE},
+ {"keyboardKeyAssistant", IDS_SETTINGS_KEYBOARD_KEY_ASSISTANT},
{"keyboardKeyDisabled", IDS_SETTINGS_KEYBOARD_KEY_DISABLED},
{"keyboardKeyExternalCommand",
IDS_SETTINGS_KEYBOARD_KEY_EXTERNAL_COMMAND},
@@ -780,6 +818,8 @@ void AddDeviceStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_DISPLAY_RESOLUTION_TEXT_NATIVE},
{"displayResolutionSublabel", IDS_SETTINGS_DISPLAY_RESOLUTION_SUBLABEL},
{"displayResolutionMenuItem", IDS_SETTINGS_DISPLAY_RESOLUTION_MENU_ITEM},
+ {"displayResolutionInterlacedMenuItem",
+ IDS_SETTINGS_DISPLAY_RESOLUTION_INTERLACED_MENU_ITEM},
{"displayZoomTitle", IDS_SETTINGS_DISPLAY_ZOOM_TITLE},
{"displayZoomSublabel", IDS_SETTINGS_DISPLAY_ZOOM_SUBLABEL},
{"displayZoomValue", IDS_SETTINGS_DISPLAY_ZOOM_VALUE},
@@ -813,8 +853,9 @@ void AddDeviceStrings(content::WebUIDataSource* html_source) {
base::CommandLine& cmd = *base::CommandLine::ForCurrentProcess();
html_source->AddBoolean("unifiedDesktopAvailable",
cmd.HasSwitch(::switches::kEnableUnifiedDesktop));
- html_source->AddBoolean("multiMirroringAvailable",
- !cmd.HasSwitch(::switches::kDisableMultiMirroring));
+
+ html_source->AddBoolean("listAllDisplayModes",
+ display::features::IsListAllDisplayModesEnabled());
html_source->AddBoolean(
"enableTouchCalibrationSetting",
@@ -823,9 +864,6 @@ void AddDeviceStrings(content::WebUIDataSource* html_source) {
html_source->AddBoolean("hasExternalTouchDevice",
display::HasExternalTouchscreenDevice());
- html_source->AddBoolean("nightLightFeatureEnabled",
- ash::features::IsNightLightEnabled());
-
static constexpr LocalizedString kStorageStrings[] = {
{"storageTitle", IDS_SETTINGS_STORAGE_TITLE},
{"storageItemInUse", IDS_SETTINGS_STORAGE_ITEM_IN_USE},
@@ -1331,6 +1369,7 @@ void AddLanguagesStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_LANGUAGES_OFFER_TO_TRANSLATE_IN_THIS_LANGUAGE},
{"offerToEnableTranslate",
IDS_SETTINGS_LANGUAGES_OFFER_TO_ENABLE_TRANSLATE},
+ {"translateTargetLabel", IDS_SETTINGS_LANGUAGES_TRANSLATE_TARGET},
#if !defined(OS_MACOSX)
{"spellCheckListTitle", IDS_SETTINGS_LANGUAGES_SPELL_CHECK_LIST_TITLE},
{"spellCheckExpandA11yLabel",
@@ -1501,7 +1540,9 @@ void AddAutofillStrings(content::WebUIDataSource* html_source,
{"exportPasswordsFailTipsEnoughSpace",
IDS_SETTINGS_PASSWORDS_EXPORTING_FAILURE_TIP_ENOUGH_SPACE},
{"exportPasswordsFailTipsAnotherFolder",
- IDS_SETTINGS_PASSWORDS_EXPORTING_FAILURE_TIP_ANOTHER_FOLDER}};
+ IDS_SETTINGS_PASSWORDS_EXPORTING_FAILURE_TIP_ANOTHER_FOLDER},
+ {"savedToThisDeviceOnly",
+ IDS_SETTINGS_PAYMENTS_SAVED_TO_THIS_DEVICE_ONLY}};
GURL google_password_manager_url = GetGooglePasswordManagerURL(
password_manager::ManagePasswordsReferrer::kChromeSettings);
@@ -1517,6 +1558,10 @@ void AddAutofillStrings(content::WebUIDataSource* html_source,
chrome::kPasswordManagerLearnMoreURL);
html_source->AddString("manageAddressesUrl",
autofill::payments::GetManageAddressesUrl(0).spec());
+ html_source->AddString("manageCreditCardsLabel",
+ l10n_util::GetStringFUTF16(
+ IDS_SETTINGS_PAYMENTS_MANAGE_CREDIT_CARDS,
+ base::UTF8ToUTF16(chrome::kPaymentMethodsURL)));
html_source->AddString("manageCreditCardsUrl",
autofill::payments::GetManageInstrumentsUrl(0).spec());
html_source->AddString("paymentMethodsLearnMoreURL",
@@ -1538,16 +1583,17 @@ void AddAutofillStrings(content::WebUIDataSource* html_source,
profile->GetPrefs()) != 0);
syncer::SyncService* sync_service =
- ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile);
+ ProfileSyncServiceFactory::GetForProfile(profile);
if (sync_service && sync_service->CanSyncFeatureStart() &&
sync_service->GetPreferredDataTypes().Has(syncer::AUTOFILL_PROFILE)) {
- html_source->AddBoolean("isUsingSecondaryPassphrase",
- sync_service->IsUsingSecondaryPassphrase());
+ html_source->AddBoolean(
+ "isUsingSecondaryPassphrase",
+ sync_service->GetUserSettings()->IsUsingSecondaryPassphrase());
html_source->AddBoolean(
"uploadToGoogleActive",
- syncer::GetUploadToGoogleState(
- sync_service, syncer::ModelType::AUTOFILL_WALLET_DATA) ==
- syncer::UploadState::ACTIVE);
+ syncer::GetUploadToGoogleState(
+ sync_service, syncer::ModelType::AUTOFILL_WALLET_DATA) ==
+ syncer::UploadState::ACTIVE);
} else {
html_source->AddBoolean("isUsingSecondaryPassphrase", false);
html_source->AddBoolean("uploadToGoogleActive", false);
@@ -1800,7 +1846,7 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) {
// Format numbers to be used on the pin keyboard.
for (int j = 0; j <= 9; j++) {
- html_source->AddString("pinKeyboard" + base::IntToString(j),
+ html_source->AddString("pinKeyboard" + base::NumberToString(j),
base::FormatNumber(int64_t{j}));
}
@@ -1850,8 +1896,7 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) {
"syncDisconnectManagedProfileExplanation",
l10n_util::GetStringFUTF8(
IDS_SETTINGS_SYNC_DISCONNECT_MANAGED_PROFILE_EXPLANATION,
- base::ASCIIToUTF16("$1"),
- base::ASCIIToUTF16(sync_dashboard_url)));
+ base::ASCIIToUTF16("$1"), base::ASCIIToUTF16(sync_dashboard_url)));
// The syncDisconnect text differs depending on Dice-enabledness.
if (AccountConsistencyModeManager::IsDiceEnabledForProfile(profile)) {
@@ -1883,8 +1928,6 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) {
}
#endif
- html_source->AddString("syncErrorHelpUrl", chrome::kSyncErrorsHelpURL);
-
html_source->AddString("activityControlsUrl",
chrome::kGoogleAccountActivityControlsURL);
@@ -1905,7 +1948,7 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) {
// Used to control the display of Chrome OS Account Manager submenu in the
// People section.
html_source->AddBoolean("isAccountManagerEnabled",
- chromeos::switches::IsAccountManagerEnabled());
+ chromeos::IsAccountManagerAvailable(profile));
#endif
}
@@ -2130,7 +2173,7 @@ void AddSearchInSettingsStrings(content::WebUIDataSource* html_source) {
{"searchPrompt", IDS_SETTINGS_SEARCH_PROMPT},
{"searchNoResults", IDS_SEARCH_NO_RESULTS},
{"searchResults", IDS_SEARCH_RESULTS},
- // TODO(dpapad): IDS_DOWNLOAD_CLEAR_SEARCH and IDS_MD_HISTORY_CLEAR_SEARCH
+ // TODO(dpapad): IDS_DOWNLOAD_CLEAR_SEARCH and IDS_HISTORY_CLEAR_SEARCH
// are identical, merge them to one and re-use here.
{"clearSearch", IDS_DOWNLOAD_CLEAR_SEARCH},
};
@@ -2146,7 +2189,7 @@ void AddSearchInSettingsStrings(content::WebUIDataSource* html_source) {
void AddSearchStrings(content::WebUIDataSource* html_source, Profile* profile) {
#if defined(OS_CHROMEOS)
const bool is_assistant_allowed =
- arc::IsAssistantAllowedForProfile(profile) ==
+ assistant::IsAssistantAllowedForProfile(profile) ==
ash::mojom::AssistantAllowedState::ALLOWED;
#endif
@@ -2300,6 +2343,7 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
{"cookieName", IDS_SETTINGS_COOKIES_COOKIE_NAME_LABEL},
{"cookiePath", IDS_SETTINGS_COOKIES_COOKIE_PATH_LABEL},
{"cookieSendFor", IDS_SETTINGS_COOKIES_COOKIE_SENDFOR_LABEL},
+ {"databaseOrigin", IDS_SETTINGS_COOKIES_LOCAL_STORAGE_ORIGIN_LABEL},
{"fileSystemOrigin", IDS_SETTINGS_COOKIES_LOCAL_STORAGE_ORIGIN_LABEL},
{"fileSystemPersistentUsage",
IDS_SETTINGS_COOKIES_FILE_SYSTEM_PERSISTENT_USAGE_LABEL},
@@ -2323,7 +2367,6 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
IDS_SETTINGS_COOKIES_LOCAL_STORAGE_SIZE_ON_DISK_LABEL},
{"sharedWorkerWorker", IDS_SETTINGS_COOKIES_SHARED_WORKER_WORKER_LABEL},
{"sharedWorkerName", IDS_SETTINGS_COOKIES_COOKIE_NAME_LABEL},
- {"webdbDesc", IDS_SETTINGS_COOKIES_WEB_DATABASE_DESCRIPTION_LABEL},
{"siteSettingsCategoryPageTitle", IDS_SETTINGS_SITE_SETTINGS_CATEGORY},
{"siteSettingsCategoryCamera", IDS_SETTINGS_SITE_SETTINGS_CAMERA},
{"siteSettingsCameraLabel", IDS_SETTINGS_SITE_SETTINGS_CAMERA_LABEL},
@@ -2587,10 +2630,6 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
subresource_filter::kSafeBrowsingSubresourceFilter));
html_source->AddBoolean(
- "enableSoundContentSetting",
- base::FeatureList::IsEnabled(features::kSoundContentSetting));
-
- html_source->AddBoolean(
"enableBlockAutoplayContentSetting",
base::FeatureList::IsEnabled(media::kAutoplayDisableSettings));
@@ -2809,7 +2848,8 @@ void AddLocalizedStrings(content::WebUIDataSource* html_source,
AddWebContentStrings(html_source);
#if defined(OS_CHROMEOS)
- AddCrostiniStrings(html_source);
+ AddCrostiniStrings(html_source, profile);
+ AddKioskNextShellStrings(html_source);
AddAndroidAppStrings(html_source);
AddBluetoothStrings(html_source);
AddChromeOSUserStrings(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 34587daaef9..291fbdf27b6 100644
--- a/chromium/chrome/browser/ui/webui/settings/md_settings_ui.cc
+++ b/chromium/chrome/browser/ui/webui/settings/md_settings_ui.cc
@@ -12,6 +12,7 @@
#include <vector>
#include "ash/public/cpp/ash_features.h"
+#include "base/bind.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/stl_util.h"
@@ -85,7 +86,6 @@
#include "chrome/browser/chromeos/login/demo_mode/demo_session.h"
#include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.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"
@@ -207,7 +207,6 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui)
AddSettingsPageUIHandler(
std::make_unique<chromeos::settings::AccountManagerUIHandler>(
account_manager,
- AccountTrackerServiceFactory::GetInstance()->GetForProfile(profile),
IdentityManagerFactory::GetForProfile(profile)));
}
AddSettingsPageUIHandler(
@@ -328,9 +327,15 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui)
html_source->AddBoolean(
"lockScreenHideSensitiveNotificationsSupported",
ash::features::IsLockScreenHideSensitiveNotificationsSupported());
+ html_source->AddBoolean("showTechnologyBadge",
+ !ash::features::IsSeparateNetworkIconsEnabled());
html_source->AddBoolean("hasInternalStylus",
ash::stylus_utils::HasInternalStylus());
+ html_source->AddBoolean(
+ "showKioskNextShell",
+ base::FeatureList::IsEnabled(ash::features::kKioskNextShell));
+
html_source->AddBoolean("showCrostini",
crostini::IsCrostiniUIAllowedForProfile(
profile, false /* check_policy */));
@@ -341,6 +346,9 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui)
html_source->AddBoolean("isDemoSession",
chromeos::DemoSession::IsDeviceInDemoMode());
+ html_source->AddBoolean("assistantEnabled",
+ chromeos::switches::IsAssistantEnabled());
+
// We have 2 variants of Android apps settings. Default case, when the Play
// Store app exists we show expandable section that allows as to
// enable/disable the Play Store and link to Android settings which is
@@ -386,7 +394,7 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui)
#if defined(OS_CHROMEOS)
// Add the System Web App resources for Settings.
- if (web_app::SystemWebAppManager::ShouldEnableForProfile(profile)) {
+ if (web_app::SystemWebAppManager::IsEnabled()) {
html_source->AddResourcePath("icon-192.png", IDR_SETTINGS_LOGO_192);
html_source->AddResourcePath("pwa.html", IDR_PWA_HTML);
#if BUILDFLAG(OPTIMIZE_WEBUI)
diff --git a/chromium/chrome/browser/ui/webui/settings/people_handler.cc b/chromium/chrome/browser/ui/webui/settings/people_handler.cc
index 7c368a6df80..eeeb1fa6ae0 100644
--- a/chromium/chrome/browser/ui/webui/settings/people_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/people_handler.cc
@@ -99,7 +99,8 @@ SyncConfigInfo::SyncConfigInfo()
SyncConfigInfo::~SyncConfigInfo() {}
bool GetConfiguration(const std::string& json, SyncConfigInfo* config) {
- std::unique_ptr<base::Value> parsed_value = base::JSONReader::Read(json);
+ std::unique_ptr<base::Value> parsed_value =
+ base::JSONReader::ReadDeprecated(json);
base::DictionaryValue* result;
if (!parsed_value || !parsed_value->GetAsDictionary(&result)) {
DLOG(ERROR) << "GetConfiguration() not passed a Dictionary";
@@ -295,7 +296,7 @@ void PeopleHandler::OnJavascriptAllowed() {
// This is intentionally not using GetSyncService(), to go around the
// Profile::IsSyncAllowed() check.
syncer::SyncService* sync_service =
- ProfileSyncServiceFactory::GetSyncServiceForProfile(profile_);
+ ProfileSyncServiceFactory::GetForProfile(profile_);
if (sync_service)
sync_service_observer_.Add(sync_service);
}
@@ -421,7 +422,7 @@ void PeopleHandler::SyncStartupCompleted() {
syncer::SyncService* PeopleHandler::GetSyncService() const {
return profile_->IsSyncAllowed()
- ? ProfileSyncServiceFactory::GetSyncServiceForProfile(profile_)
+ ? ProfileSyncServiceFactory::GetForProfile(profile_)
: nullptr;
}
@@ -467,11 +468,11 @@ void PeopleHandler::HandleGetStoredAccounts(const base::ListValue* args) {
ResolveJavascriptCallback(*callback_id, GetStoredAccountsList());
}
-void PeopleHandler::OnAccountUpdated(const AccountInfo& info) {
+void PeopleHandler::OnExtendedAccountInfoUpdated(const AccountInfo& info) {
FireWebUIListener("stored-accounts-updated", GetStoredAccountsList());
}
-void PeopleHandler::OnAccountRemovedWithInfo(const AccountInfo& info) {
+void PeopleHandler::OnExtendedAccountInfoRemoved(const AccountInfo& info) {
FireWebUIListener("stored-accounts-updated", GetStoredAccountsList());
}
@@ -497,10 +498,11 @@ base::Value PeopleHandler::GetStoredAccountsList() {
// If dice is disabled (and unified consent enabled), show only the primary
// account.
auto* identity_manager = IdentityManagerFactory::GetForProfile(profile_);
- if (identity_manager->HasPrimaryAccount()) {
- accounts_list.push_back(
- GetAccountValue(identity_manager->GetPrimaryAccountInfo()));
- }
+ base::Optional<AccountInfo> primary_account_info =
+ identity_manager->FindExtendedAccountInfoForAccount(
+ identity_manager->GetPrimaryAccountInfo());
+ if (primary_account_info.has_value())
+ accounts_list.push_back(GetAccountValue(primary_account_info.value()));
}
return accounts;
@@ -765,7 +767,9 @@ void PeopleHandler::HandlePauseSync(const base::ListValue* args) {
auto* identity_manager = IdentityManagerFactory::GetForProfile(profile_);
DCHECK(identity_manager->HasPrimaryAccount());
- AccountInfo primary_account_info = identity_manager->GetPrimaryAccountInfo();
+ CoreAccountInfo primary_account_info =
+ identity_manager->GetPrimaryAccountInfo();
+
identity_manager->GetAccountsMutator()->AddOrUpdateAccount(
primary_account_info.gaia, primary_account_info.email,
OAuth2TokenServiceDelegate::kInvalidRefreshToken,
@@ -872,12 +876,12 @@ void PeopleHandler::CloseUI() {
}
void PeopleHandler::OnPrimaryAccountSet(
- const AccountInfo& primary_account_info) {
+ const CoreAccountInfo& primary_account_info) {
UpdateSyncStatus();
}
void PeopleHandler::OnPrimaryAccountCleared(
- const AccountInfo& previous_primary_account_info) {
+ const CoreAccountInfo& previous_primary_account_info) {
UpdateSyncStatus();
}
@@ -931,7 +935,7 @@ PeopleHandler::GetSyncStatusDictionary() {
// nuanced information, since GetSyncService() returns nullptr if anything
// makes Profile::IsSyncAllowed() false.
syncer::SyncService* service =
- ProfileSyncServiceFactory::GetSyncServiceForProfile(profile_);
+ ProfileSyncServiceFactory::GetForProfile(profile_);
bool disallowed_by_policy =
service && service->HasDisableReason(
syncer::SyncService::DISABLE_REASON_ENTERPRISE_POLICY);
@@ -948,8 +952,7 @@ PeopleHandler::GetSyncStatusDictionary() {
sync_ui_util::ActionType action_type = sync_ui_util::NO_ACTION;
bool status_has_error =
- sync_ui_util::GetStatusLabels(profile_, service, identity_manager,
- &status_label, &link_label,
+ sync_ui_util::GetStatusLabels(profile_, &status_label, &link_label,
&action_type) == sync_ui_util::SYNC_ERROR;
sync_status->SetString("statusText", status_label);
sync_status->SetString("statusActionText", link_label);
@@ -1044,12 +1047,15 @@ void PeopleHandler::PushSyncPrefs() {
if (!passphrase_time.is_null()) {
base::string16 passphrase_time_str =
base::TimeFormatShortDate(passphrase_time);
- args.SetString("enterPassphraseBody",
- GetStringFUTF16(IDS_SYNC_ENTER_PASSPHRASE_BODY_WITH_DATE,
- passphrase_time_str));
+ args.SetString(
+ "enterPassphraseBody",
+ GetStringFUTF16(IDS_SYNC_ENTER_PASSPHRASE_BODY_WITH_DATE,
+ base::ASCIIToUTF16(chrome::kSyncErrorsHelpURL),
+ passphrase_time_str));
args.SetString(
"enterGooglePassphraseBody",
GetStringFUTF16(IDS_SYNC_ENTER_GOOGLE_PASSPHRASE_BODY_WITH_DATE,
+ base::ASCIIToUTF16(chrome::kSyncErrorsHelpURL),
passphrase_time_str));
switch (passphrase_type) {
case syncer::PassphraseType::FROZEN_IMPLICIT_PASSPHRASE:
@@ -1086,10 +1092,6 @@ void PeopleHandler::UpdateSyncStatus() {
}
void PeopleHandler::MarkFirstSetupComplete() {
- // Suppress the sign in promo once the user starts sync. This way the user
- // doesn't see the sign in promo even if they sign out later on.
- signin::SetUserSkippedPromo(profile_);
-
syncer::SyncService* service = GetSyncService();
// The sync service may be nullptr if it has been just disabled by policy.
if (!service || service->GetUserSettings()->IsFirstSetupComplete())
@@ -1100,7 +1102,6 @@ void PeopleHandler::MarkFirstSetupComplete() {
// We're done configuring, so notify SyncService that it is OK to start
// syncing.
- sync_blocker_.reset();
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 e4748f7864f..8c8774d54c3 100644
--- a/chromium/chrome/browser/ui/webui/settings/people_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/people_handler.h
@@ -128,12 +128,13 @@ class PeopleHandler : public SettingsPageUIHandler,
void FocusUI() override;
// IdentityManager::Observer implementation.
- void OnPrimaryAccountSet(const AccountInfo& primary_account_info) override;
+ void OnPrimaryAccountSet(
+ const CoreAccountInfo& primary_account_info) override;
void OnPrimaryAccountCleared(
- const AccountInfo& previous_primary_account_info) override;
+ const CoreAccountInfo& previous_primary_account_info) override;
#if BUILDFLAG(ENABLE_DICE_SUPPORT)
- void OnAccountUpdated(const AccountInfo& info) override;
- void OnAccountRemovedWithInfo(const AccountInfo& info) override;
+ void OnExtendedAccountInfoUpdated(const AccountInfo& info) override;
+ void OnExtendedAccountInfoRemoved(const AccountInfo& info) override;
#endif
// syncer::SyncServiceObserver implementation.
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 a4fe434142c..e4b50c4ef5f 100644
--- a/chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc
@@ -51,7 +51,6 @@ using ::testing::_;
using ::testing::Invoke;
using ::testing::Mock;
using ::testing::Return;
-using ::testing::ReturnRef;
using ::testing::Values;
using browser_sync::ProfileSyncService;
using browser_sync::ProfileSyncServiceMock;
@@ -192,10 +191,10 @@ class TestWebUIProvider
// /ClientLogin enabled or not.
class PeopleHandlerTest : public ChromeRenderViewHostTestHarness {
public:
- PeopleHandlerTest() : error_(GoogleServiceAuthError::NONE) {}
+ PeopleHandlerTest() = default;
+
void SetUp() override {
ChromeRenderViewHostTestHarness::SetUp();
- error_ = GoogleServiceAuthError::AuthErrorNone();
// Sign in the user.
identity_test_env_adaptor_ =
@@ -208,7 +207,6 @@ class PeopleHandlerTest : public ChromeRenderViewHostTestHarness {
mock_pss_ = static_cast<ProfileSyncServiceMock*>(
ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse(
profile(), base::BindRepeating(&BuildMockProfileSyncService)));
- ON_CALL(*mock_pss_, GetAuthError()).WillByDefault(ReturnRef(error_));
ON_CALL(*mock_pss_->GetUserSettingsMock(), GetPassphraseType())
.WillByDefault(Return(syncer::PassphraseType::IMPLICIT_PASSPHRASE));
ON_CALL(*mock_pss_->GetUserSettingsMock(), GetExplicitPassphraseTime())
@@ -336,7 +334,6 @@ class PeopleHandlerTest : public ChromeRenderViewHostTestHarness {
}
ProfileSyncServiceMock* mock_pss_;
- GoogleServiceAuthError error_;
std::unique_ptr<IdentityTestEnvironmentProfileAdaptor>
identity_test_env_adaptor_;
content::TestWebUI web_ui_;
@@ -416,7 +413,6 @@ TEST_F(PeopleHandlerTest, DisplayConfigureWithEngineDisabledAndCancel) {
.WillByDefault(Return(true));
ON_CALL(*mock_pss_->GetUserSettingsMock(), IsFirstSetupComplete())
.WillByDefault(Return(false));
- error_ = GoogleServiceAuthError::AuthErrorNone();
ON_CALL(*mock_pss_, GetTransportState())
.WillByDefault(Return(syncer::SyncService::TransportState::INITIALIZING));
EXPECT_CALL(*mock_pss_->GetUserSettingsMock(), SetSyncRequested(true));
@@ -445,11 +441,10 @@ TEST_F(PeopleHandlerTest,
.WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NONE));
ON_CALL(*mock_pss_->GetUserSettingsMock(), IsSyncRequested())
.WillByDefault(Return(true));
- error_ = GoogleServiceAuthError::AuthErrorNone();
// Sync engine is stopped initially, and will start up.
ON_CALL(*mock_pss_, GetTransportState())
- .WillByDefault(Return(
- syncer::SyncService::TransportState::WAITING_FOR_START_REQUEST));
+ .WillByDefault(
+ Return(syncer::SyncService::TransportState::START_DEFERRED));
EXPECT_CALL(*mock_pss_->GetUserSettingsMock(), SetSyncRequested(true));
SetDefaultExpectationsForConfigPage();
@@ -463,8 +458,6 @@ TEST_F(PeopleHandlerTest,
SetDefaultExpectationsForConfigPage();
ON_CALL(*mock_pss_, GetTransportState())
.WillByDefault(Return(syncer::SyncService::TransportState::ACTIVE));
- error_ = GoogleServiceAuthError::AuthErrorNone();
- ON_CALL(*mock_pss_, GetAuthError()).WillByDefault(ReturnRef(error_));
handler_->SyncStartupCompleted();
EXPECT_EQ(2U, web_ui_.call_data().size());
@@ -489,7 +482,6 @@ TEST_F(PeopleHandlerTest,
.WillByDefault(Return(true));
ON_CALL(*mock_pss_->GetUserSettingsMock(), IsFirstSetupComplete())
.WillByDefault(Return(false));
- error_ = GoogleServiceAuthError::AuthErrorNone();
EXPECT_CALL(*mock_pss_, GetTransportState())
.WillOnce(Return(syncer::SyncService::TransportState::INITIALIZING))
.WillRepeatedly(Return(syncer::SyncService::TransportState::ACTIVE));
@@ -516,7 +508,6 @@ TEST_F(PeopleHandlerTest, DisplayConfigureWithEngineDisabledAndSigninFailed) {
.WillByDefault(Return(true));
ON_CALL(*mock_pss_->GetUserSettingsMock(), IsFirstSetupComplete())
.WillByDefault(Return(false));
- error_ = GoogleServiceAuthError::AuthErrorNone();
ON_CALL(*mock_pss_, GetTransportState())
.WillByDefault(Return(syncer::SyncService::TransportState::INITIALIZING));
EXPECT_CALL(*mock_pss_->GetUserSettingsMock(), SetSyncRequested(true));
@@ -524,9 +515,9 @@ TEST_F(PeopleHandlerTest, DisplayConfigureWithEngineDisabledAndSigninFailed) {
handler_->HandleShowSetupUI(nullptr);
ExpectPageStatusChanged(PeopleHandler::kSpinnerPageStatus);
Mock::VerifyAndClearExpectations(mock_pss_);
- error_ = GoogleServiceAuthError(
- GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
- ON_CALL(*mock_pss_, GetAuthError()).WillByDefault(ReturnRef(error_));
+ ON_CALL(*mock_pss_, GetAuthError())
+ .WillByDefault(Return(GoogleServiceAuthError(
+ GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS)));
NotifySyncListeners();
// On failure, the dialog will be closed.
@@ -870,13 +861,15 @@ TEST_F(PeopleHandlerTest, ShowSyncSetup) {
// We do not display signin on chromeos in the case of auth error.
TEST_F(PeopleHandlerTest, ShowSigninOnAuthError) {
// Initialize the system to a signed in state, but with an auth error.
- error_ = GoogleServiceAuthError(
- GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
+ ON_CALL(*mock_pss_, GetAuthError())
+ .WillByDefault(Return(GoogleServiceAuthError(
+ GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS)));
SetupInitializedProfileSyncService();
auto* identity_manager = identity_test_env()->identity_manager();
- AccountInfo primary_account_info = identity_manager->GetPrimaryAccountInfo();
+ CoreAccountInfo primary_account_info =
+ identity_manager->GetPrimaryAccountInfo();
DCHECK_EQ(primary_account_info.email, kTestUser);
auto* accounts_mutator = identity_manager->GetAccountsMutator();
@@ -888,7 +881,8 @@ TEST_F(PeopleHandlerTest, ShowSigninOnAuthError) {
signin_metrics::SourceForRefreshTokenOperation::kUnknown);
identity::UpdatePersistentErrorOfRefreshTokenForAccount(
- identity_manager, primary_account_info.account_id, error_);
+ identity_manager, primary_account_info.account_id,
+ GoogleServiceAuthError(GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS));
ON_CALL(*mock_pss_, GetDisableReasons())
.WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NONE));
@@ -1149,10 +1143,10 @@ TEST_P(PeopleHandlerDiceUnifiedConsentTest, StoredAccountsList) {
}
}
-INSTANTIATE_TEST_CASE_P(Test,
- PeopleHandlerDiceUnifiedConsentTest,
- ::testing::Combine(::testing::Bool(),
- ::testing::Bool()));
+INSTANTIATE_TEST_SUITE_P(Test,
+ PeopleHandlerDiceUnifiedConsentTest,
+ ::testing::Combine(::testing::Bool(),
+ ::testing::Bool()));
#endif // BUILDFLAG(ENABLE_DICE_SUPPORT)
} // namespace settings
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 145aa955d96..c108af6d6a1 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
@@ -7,6 +7,7 @@
#include <stddef.h>
#include <vector>
+#include "base/bind.h"
#include "base/feature_list.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
@@ -245,13 +246,15 @@ void ClearBrowsingDataHandler::HandleClearBrowsingData(
checked_other_types);
}
- // If Sync is running, prevent it from being paused during the operation.
- // However, if Sync is in error, clearing cookies should pause it.
std::unique_ptr<AccountReconcilor::ScopedSyncedDataDeletion>
scoped_data_deletion;
- sync_ui_util::MessageType sync_status = sync_ui_util::GetStatus(
- profile_, sync_service_, IdentityManagerFactory::GetForProfile(profile_));
- if (sync_status == sync_ui_util::SYNCED) {
+
+ // If Sync is running, prevent it from being paused during the operation.
+ // However, if Sync is in error, clearing cookies should pause it.
+ if (!profile_->IsGuestSession() &&
+ sync_ui_util::GetStatus(profile_) == sync_ui_util::SYNCED) {
+ // Settings can not be opened in incognito windows.
+ DCHECK(!profile_->IsOffTheRecord());
scoped_data_deletion = AccountReconcilorFactory::GetForProfile(profile_)
->GetScopedSyncDataDeletion();
}
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.h b/chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.h
index 96e239934ac..76d27cb783f 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.h
@@ -14,10 +14,10 @@
#include "base/scoped_observer.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
-#include "components/browser_sync/profile_sync_service.h"
#include "components/browsing_data/core/browsing_data_utils.h"
#include "components/browsing_data/core/counters/browsing_data_counter.h"
#include "components/signin/core/browser/account_reconcilor.h"
+#include "components/sync/driver/sync_service.h"
namespace base {
class ListValue;
@@ -92,9 +92,9 @@ class ClearBrowsingDataHandler : public SettingsPageUIHandler,
// Counters that calculate the data volume for individual data types.
std::vector<std::unique_ptr<browsing_data::BrowsingDataCounter>> counters_;
- // ProfileSyncService to observe sync state changes.
- browser_sync::ProfileSyncService* sync_service_;
- ScopedObserver<browser_sync::ProfileSyncService, syncer::SyncServiceObserver>
+ // SyncService to observe sync state changes.
+ syncer::SyncService* sync_service_;
+ ScopedObserver<syncer::SyncService, syncer::SyncServiceObserver>
sync_service_observer_;
// Whether we should show a dialog informing the user about other forms of
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler.cc b/chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler.cc
index 67db5ae7a92..47dd46f0888 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler.cc
@@ -390,7 +390,7 @@ void CookiesViewHandler::SendLocalDataList(const CookieTreeNode* parent) {
const CookieTreeNode* site = parent->GetChild(sorted_sites_[i].second);
base::string16 description;
for (int k = 0; k < site->child_count(); ++k) {
- if (description.size()) {
+ if (!description.empty()) {
description += base::ASCIIToUTF16(", ");
}
const CookieTreeNode* category = site->GetChild(k);
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 71096cd9445..fd96a72e558 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
@@ -121,19 +121,15 @@ void ManageProfileHandler::HandleGetAvailableIcons(
}
std::unique_ptr<base::ListValue> ManageProfileHandler::GetAvailableIcons() {
- std::unique_ptr<base::ListValue> avatars(
- profiles::GetDefaultProfileAvatarIconsAndLabels());
-
PrefService* pref_service = profile_->GetPrefs();
bool using_gaia = pref_service->GetBoolean(prefs::kProfileUsingGAIAAvatar);
+ size_t selected_avatar_idx =
+ using_gaia ? SIZE_MAX
+ : pref_service->GetInteger(prefs::kProfileAvatarIndex);
- // Select the avatar from the default set.
- if (!using_gaia) {
- size_t index = pref_service->GetInteger(prefs::kProfileAvatarIndex);
- base::DictionaryValue* avatar = nullptr;
- if (avatars->GetDictionary(index, &avatar))
- avatar->SetBoolean("selected", true);
- }
+ // Obtain a list of the default avatar icons.
+ std::unique_ptr<base::ListValue> avatars(
+ profiles::GetDefaultProfileAvatarIconsAndLabels(selected_avatar_idx));
// Add the GAIA picture to the beginning of the list if it is available.
ProfileAttributesEntry* entry;
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler.h b/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler.h
index 659ef79b1f8..32da11d3480 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler.h
@@ -44,6 +44,8 @@ class ManageProfileHandler : public settings::SettingsPageUIHandler,
FRIEND_TEST_ALL_PREFIXES(ManageProfileHandlerTest, HandleSetProfileName);
FRIEND_TEST_ALL_PREFIXES(ManageProfileHandlerTest, HandleGetAvailableIcons);
FRIEND_TEST_ALL_PREFIXES(ManageProfileHandlerTest,
+ HandleGetAvailableIconsOldIconSelected);
+ FRIEND_TEST_ALL_PREFIXES(ManageProfileHandlerTest,
HandleGetAvailableIconsGaiaAvatarSelected);
// Callback for the "getAvailableIcons" message.
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler_unittest.cc
index d981468902e..d7ee5c19f6d 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler_unittest.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/ui/webui/settings/settings_manage_profile_handler.h"
#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/profiles/profile_avatar_icon_util.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile_manager.h"
@@ -79,8 +80,10 @@ class ManageProfileHandlerTest : public testing::Test {
const base::DictionaryValue* icon = nullptr;
EXPECT_TRUE(icons->GetDictionary(i, &icon));
std::string icon_url;
+ size_t icon_index;
EXPECT_TRUE(icon->GetString("url", &icon_url));
EXPECT_FALSE(icon_url.empty());
+ EXPECT_TRUE(profiles::IsDefaultAvatarIconUrl(icon_url, &icon_index));
std::string icon_label;
EXPECT_TRUE(icon->GetString("label", &icon_label));
EXPECT_FALSE(icon_label.empty());
@@ -88,7 +91,7 @@ class ManageProfileHandlerTest : public testing::Test {
bool has_icon_selected = icon->GetBoolean("selected", &icon_selected);
if (all_not_selected) {
EXPECT_FALSE(has_icon_selected);
- } else if (selected_index == i) {
+ } else if (selected_index == icon_index) {
EXPECT_TRUE(has_icon_selected);
EXPECT_TRUE(icon_selected);
}
@@ -126,7 +129,7 @@ TEST_F(ManageProfileHandlerTest, HandleSetProfileName) {
TEST_F(ManageProfileHandlerTest, HandleGetAvailableIcons) {
PrefService* pref_service = profile()->GetPrefs();
- pref_service->SetInteger(prefs::kProfileAvatarIndex, 7);
+ pref_service->SetInteger(prefs::kProfileAvatarIndex, 27);
base::ListValue list_args_1;
list_args_1.AppendString("get-icons-callback-id");
@@ -141,12 +144,32 @@ TEST_F(ManageProfileHandlerTest, HandleGetAvailableIcons) {
ASSERT_TRUE(data_1.arg1()->GetAsString(&callback_id_1));
EXPECT_EQ("get-icons-callback-id", callback_id_1);
- VerifyIconListWithSingleSelection(data_1.arg3(), 7);
+ VerifyIconListWithSingleSelection(data_1.arg3(), 27);
}
-TEST_F(ManageProfileHandlerTest, HandleGetAvailableIconsGaiaAvatarSelected) {
+TEST_F(ManageProfileHandlerTest, HandleGetAvailableIconsOldIconSelected) {
PrefService* pref_service = profile()->GetPrefs();
pref_service->SetInteger(prefs::kProfileAvatarIndex, 7);
+
+ base::ListValue list_args;
+ list_args.AppendString("get-icons-callback-id");
+ handler()->HandleGetAvailableIcons(&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("get-icons-callback-id", callback_id);
+
+ VerifyIconListWithNoneSelected(data.arg3());
+}
+
+TEST_F(ManageProfileHandlerTest, HandleGetAvailableIconsGaiaAvatarSelected) {
+ PrefService* pref_service = profile()->GetPrefs();
+ pref_service->SetInteger(prefs::kProfileAvatarIndex, 27);
pref_service->SetBoolean(prefs::kProfileUsingGAIAAvatar, true);
base::ListValue list_args;
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_startup_pages_handler.cc b/chromium/chrome/browser/ui/webui/settings/settings_startup_pages_handler.cc
index 36037ef3dc4..4e299369dcf 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_startup_pages_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/settings_startup_pages_handler.cc
@@ -9,6 +9,7 @@
#include <utility>
#include <vector>
+#include "base/bind.h"
#include "chrome/browser/prefs/session_startup_pref.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/settings_utils.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 9e0d11e641c..3a6264360ce 100644
--- a/chromium/chrome/browser/ui/webui/settings/site_settings_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/site_settings_handler.cc
@@ -12,6 +12,7 @@
#include "base/bind.h"
#include "base/i18n/number_formatting.h"
#include "base/macros.h"
+#include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -75,6 +76,19 @@ constexpr char kOriginList[] = "origins";
constexpr char kNumCookies[] = "numCookies";
constexpr char kHasPermissionSettings[] = "hasPermissionSettings";
constexpr char kZoom[] = "zoom";
+// Placeholder value for ETLD+1 until a valid origin is added. If an ETLD+1
+// only has placeholder, then create an ETLD+1 origin.
+constexpr char kPlaceholder[] = "placeholder";
+
+// These values are persisted to logs. Entries should not be renumbered and
+// numeric values should never be reused.
+enum class AllSitesAction {
+ kLoadPage = 0,
+ kResetPermissions = 1,
+ kClearData = 2,
+ kEnterSiteDetails = 3,
+ kMaxValue = kEnterSiteDetails,
+};
// Return an appropriate API Permission ID for the given string name.
extensions::APIPermission::APIPermission::ID APIPermissionFromGroupName(
@@ -142,19 +156,53 @@ bool PatternAppliesToSingleOrigin(const ContentSettingPatternSource& pattern) {
// Groups |url| into sets of eTLD+1s in |site_group_map|, assuming |url| is an
// origin.
-void CreateOrAppendSiteGroupEntryForUrl(
+// There are three cases:
+// 1. The ETLD+1 of |url| is not yet in |site_group_map|. We add the ETLD+1
+// to |site_group_map|. If the |url| is an ETLD+1 cookie origin, put a
+// placeholder origin for the ETLD+1.
+// 2. The ETLD+1 of |url| is in |site_group_map|, and is equal to host of
+// |url|. This means case 1 has already happened and nothing more needs to
+// be done.
+// 3. The ETLD+1 of |url| is in |site_group_map| and is different to host of
+// |url|. For a cookies url, if a https origin with same host exists,
+// nothing more needs to be done.
+// In case 3, we try to add |url| to the set of origins for the ETLD+1. If an
+// existing origin is a placeholder, delete it, because the placeholder is no
+// longer needed.
+void CreateOrAppendSiteGroupEntry(
std::map<std::string, std::set<std::string>>* site_group_map,
- const GURL& url) {
+ const GURL& url,
+ bool url_is_origin_with_cookies = false) {
std::string etld_plus1_string =
net::registry_controlled_domains::GetDomainAndRegistry(
url, net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
auto entry = site_group_map->find(etld_plus1_string);
+ bool etld_plus1_cookie_url =
+ url_is_origin_with_cookies && url.host() == etld_plus1_string;
+
if (entry == site_group_map->end()) {
- site_group_map->emplace(etld_plus1_string,
- std::set<std::string>({url.spec()}));
+ // Case 1:
+ std::string origin = etld_plus1_cookie_url ? kPlaceholder : url.spec();
+ site_group_map->emplace(etld_plus1_string, std::set<std::string>({origin}));
return;
}
+ // Case 2:
+ if (etld_plus1_cookie_url)
+ return;
+ // Case 3:
+ if (url_is_origin_with_cookies) {
+ // Cookies ignore schemes, so try and see if a https schemed version
+ // already exists in the origin list, if not, then add the http schemed
+ // version into the map.
+ std::string https_url = std::string(url::kHttpsScheme) +
+ url::kStandardSchemeSeparator + url.host() + "/";
+ if (entry->second.find(https_url) != entry->second.end())
+ return;
+ }
entry->second.insert(url.spec());
+ auto placeholder = entry->second.find(kPlaceholder);
+ if (placeholder != entry->second.end())
+ entry->second.erase(placeholder);
}
// Update the storage data in |origin_size_map|.
@@ -165,54 +213,6 @@ void UpdateDataForOrigin(const GURL& url,
(*origin_size_map)[url.spec()] += size;
}
-// Groups |host| into sets of eTLD+1s in |site_group_map|, |host| can either
-// be an eTLD+1 or an origin.
-// There are three cases:
-// 1. The ETLD+1 of |host| is not yet in |site_group_map|. We add the ETLD+1
-// to |site_group_map|
-// 2. The ETLD+1 of |host| is in |site_group_map|, and is equal to |host|.
-// This means case 1 has already happened and nothing more needs to be
-// done.
-// 3. The ETLD+1 of |host| is in |site_group_map| and is different to |host|.
-// In case 3, we try to add |host| to the set of origins for the ETLD+1.
-// This requires adding a scheme. We initially check if a HTTPS scheme has
-// been added for the host, and fall back to HTTP if not.
-void CreateOrAppendSiteGroupEntryForCookieHost(
- const std::string& host,
- std::map<std::string, std::set<std::string>>* site_group_map) {
- std::string etld_plus1_string =
- net::registry_controlled_domains::GetDomainAndRegistry(
- host, net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
- auto entry = site_group_map->find(etld_plus1_string);
- if (entry == site_group_map->end()) {
- site_group_map->emplace(
- etld_plus1_string,
- // Add etld+1 origin as place holder.
- std::set<std::string>({std::string(url::kHttpScheme) +
- url::kStandardSchemeSeparator + host + "/"}));
- return;
- }
- // If |host| equals to etld_plus1_string that is already exists in
- // |site_group_map|, nothing need to be done.
- if (host == etld_plus1_string)
- return;
- // Cookies ignore schemes, so try and see if a https schemed version
- // already exists in the origin list, if not, then add the http schemed
- // version into the map.
- std::string https_url = std::string(url::kHttpsScheme) +
- url::kStandardSchemeSeparator + host + "/";
- if (entry->second.find(https_url) != entry->second.end())
- return;
- entry->second.insert(std::string(url::kHttpScheme) +
- url::kStandardSchemeSeparator + host + "/");
- // Check if we have an etld_plus1 url place holder, if there is, delete
- // that entry.
- std::string etld_plus1_url = std::string(url::kHttpScheme) +
- url::kStandardSchemeSeparator +
- etld_plus1_string + "/";
- entry->second.erase(etld_plus1_url);
-}
-
// Converts a given |site_group_map| to a list of base::DictionaryValues, adding
// the site engagement score for each origin.
void ConvertSiteGroupMapToListValue(
@@ -232,7 +232,15 @@ void ConvertSiteGroupMapToListValue(
base::Value origin_list(base::Value::Type::LIST);
for (const std::string& origin : entry.second) {
base::Value origin_object(base::Value::Type::DICTIONARY);
- origin_object.SetKey("origin", base::Value(origin));
+ // If origin is placeholder, create a http ETLD+1 origin for it.
+ if (origin == kPlaceholder) {
+ origin_object.SetKey(
+ "origin",
+ base::Value(std::string(url::kHttpScheme) +
+ url::kStandardSchemeSeparator + entry.first + "/"));
+ } else {
+ origin_object.SetKey("origin", base::Value(origin));
+ }
origin_object.SetKey(
"engagement",
base::Value(engagement_service->GetScore(GURL(origin))));
@@ -289,7 +297,11 @@ void UpdateDataFromCookiesTree(
const GURL& origin,
int64_t size) {
UpdateDataForOrigin(origin, size, origin_size_map);
- CreateOrAppendSiteGroupEntryForUrl(all_sites_map, origin);
+ CreateOrAppendSiteGroupEntry(all_sites_map, origin);
+}
+
+void LogAllSitesAction(AllSitesAction action) {
+ UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.AllSitesAction", action);
}
} // namespace
@@ -315,14 +327,6 @@ void SiteSettingsHandler::RegisterMessages() {
"clearUsage", base::BindRepeating(&SiteSettingsHandler::HandleClearUsage,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
- "fetchUsbDevices",
- base::BindRepeating(&SiteSettingsHandler::HandleFetchUsbDevices,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
- "removeUsbDevice",
- base::BindRepeating(&SiteSettingsHandler::HandleRemoveUsbDevice,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
"setDefaultValueForContentType",
base::BindRepeating(
&SiteSettingsHandler::HandleSetDefaultValueForContentType,
@@ -408,10 +412,16 @@ void SiteSettingsHandler::RegisterMessages() {
base::BindRepeating(
&SiteSettingsHandler::HandleClearEtldPlus1DataAndCookies,
base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "recordAction",
+ base::BindRepeating(&SiteSettingsHandler::HandleRecordAction,
+ base::Unretained(this)));
}
void SiteSettingsHandler::OnJavascriptAllowed() {
- ObserveSources();
+ ObserveSourcesForProfile(profile_);
+ if (profile_->HasOffTheRecordProfile())
+ ObserveSourcesForProfile(profile_->GetOffTheRecordProfile());
notification_registrar_.Add(
this, chrome::NOTIFICATION_PROFILE_CREATED,
@@ -462,17 +472,26 @@ void SiteSettingsHandler::OnGetUsageInfo() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
// Site Details Page does not display the number of cookies for the origin.
const CookieTreeNode* root = cookies_tree_model_->GetRoot();
+ std::string usage_string = "";
+ std::string cookie_string = "";
for (int i = 0; i < root->child_count(); ++i) {
const CookieTreeNode* site = root->GetChild(i);
std::string title = base::UTF16ToUTF8(site->GetTitle());
- if (title == usage_host_) {
- CallJavascriptFunction(
- "settings.WebsiteUsagePrivateApi.returnUsageTotal",
- base::Value(usage_host_),
- base::Value(ui::FormatBytes(site->InclusiveSize())));
- return;
+ if (title != usage_host_)
+ continue;
+ int64_t size = site->InclusiveSize();
+ if (size != 0)
+ usage_string = base::UTF16ToUTF8(ui::FormatBytes(size));
+ int num_cookies = site->NumberOfCookies();
+ if (num_cookies != 0) {
+ cookie_string = base::UTF16ToUTF8(l10n_util::GetPluralStringFUTF16(
+ IDS_SETTINGS_SITE_SETTINGS_NUM_COOKIES, num_cookies));
}
+ break;
}
+ CallJavascriptFunction("settings.WebsiteUsagePrivateApi.returnUsageTotal",
+ base::Value(usage_host_), base::Value(usage_string),
+ base::Value(cookie_string));
}
#if defined(OS_CHROMEOS)
@@ -524,13 +543,8 @@ void SiteSettingsHandler::Observe(
break;
SendIncognitoStatus(profile, /*was_destroyed=*/ true);
- HostContentSettingsMap* settings_map =
- HostContentSettingsMapFactory::GetForProfile(profile);
- if (profile->IsOffTheRecord() &&
- observer_.IsObserving(settings_map)) {
- observer_.Remove(settings_map);
- }
-
+ if (profile->IsOffTheRecord())
+ StopObservingSourcesForProfile(profile);
break;
}
@@ -540,7 +554,7 @@ void SiteSettingsHandler::Observe(
break;
SendIncognitoStatus(profile, /*was_destroyed=*/ false);
- observer_.Add(HostContentSettingsMapFactory::GetForProfile(profile));
+ ObserveSourcesForProfile(profile);
break;
}
}
@@ -575,12 +589,11 @@ void SiteSettingsHandler::HandleFetchUsageTotal(
usage_host_ = host;
update_site_details_ = true;
-
if (cookies_tree_model_ && !send_sites_list_) {
cookies_tree_model_->RemoveCookiesTreeObserver(this);
cookies_tree_model_.reset();
}
- EnsureCookiesTreeModelCreated(/*omit_cookies=*/true);
+ EnsureCookiesTreeModelCreated();
}
void SiteSettingsHandler::HandleClearUsage(
@@ -588,7 +601,6 @@ void SiteSettingsHandler::HandleClearUsage(
CHECK_EQ(1U, args->GetSize());
std::string origin;
CHECK(args->GetString(0, &origin));
-
GURL url(origin);
if (!url.is_valid())
return;
@@ -603,49 +615,6 @@ void SiteSettingsHandler::HandleClearUsage(
}
}
-void SiteSettingsHandler::HandleFetchUsbDevices(const base::ListValue* args) {
- AllowJavascript();
-
- CHECK_EQ(1U, args->GetSize());
- const base::Value* callback_id;
- CHECK(args->Get(0, &callback_id));
-
- base::ListValue exceptions;
- const std::string group_name = site_settings::ContentSettingsTypeToGroupName(
- CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA);
- const site_settings::ChooserTypeNameEntry* chooser_type =
- site_settings::ChooserTypeFromGroupName(group_name);
- // TODO(finnur): Figure out whether incognito permissions are also needed.
- site_settings::GetChooserExceptionsFromProfile(
- profile_, false, *chooser_type, &exceptions);
- ResolveJavascriptCallback(*callback_id, exceptions);
-}
-
-void SiteSettingsHandler::HandleRemoveUsbDevice(const base::ListValue* args) {
- CHECK_EQ(3U, args->GetSize());
-
- std::string origin_string;
- CHECK(args->GetString(0, &origin_string));
- GURL requesting_origin(origin_string);
- CHECK(requesting_origin.is_valid());
-
- std::string embedding_origin_string;
- CHECK(args->GetString(1, &embedding_origin_string));
- GURL embedding_origin(embedding_origin_string);
- CHECK(embedding_origin.is_valid());
-
- const base::DictionaryValue* object = nullptr;
- CHECK(args->GetDictionary(2, &object));
-
- const std::string group_name = site_settings::ContentSettingsTypeToGroupName(
- CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA);
- const site_settings::ChooserTypeNameEntry* chooser_type =
- site_settings::ChooserTypeFromGroupName(group_name);
- ChooserContextBase* chooser_context = chooser_type->get_context(profile_);
- chooser_context->RevokeObjectPermission(requesting_origin, embedding_origin,
- *object);
-}
-
void SiteSettingsHandler::HandleSetDefaultValueForContentType(
const base::ListValue* args) {
CHECK_EQ(2U, args->GetSize());
@@ -714,7 +683,6 @@ void SiteSettingsHandler::HandleGetAllSites(const base::ListValue* args) {
all_sites_map_.clear();
origin_permission_set_.clear();
-
// Convert |types| to a list of ContentSettingsTypes.
std::vector<ContentSettingsType> content_types;
for (size_t i = 0; i < types->GetSize(); ++i) {
@@ -750,7 +718,7 @@ void SiteSettingsHandler::HandleGetAllSites(const base::ListValue* args) {
permission_manager->GetPermissionStatus(content_type, url, url);
if (result.source == PermissionStatusSource::MULTIPLE_DISMISSALS ||
result.source == PermissionStatusSource::MULTIPLE_IGNORES) {
- CreateOrAppendSiteGroupEntryForUrl(&all_sites_map_, url);
+ CreateOrAppendSiteGroupEntry(&all_sites_map_, url);
origin_permission_set_.insert(url.spec());
break;
}
@@ -764,8 +732,8 @@ void SiteSettingsHandler::HandleGetAllSites(const base::ListValue* args) {
map->GetSettingsForOneType(content_type, std::string(), &entries);
for (const ContentSettingPatternSource& e : entries) {
if (PatternAppliesToSingleOrigin(e)) {
- CreateOrAppendSiteGroupEntryForUrl(&all_sites_map_,
- GURL(e.primary_pattern.ToString()));
+ CreateOrAppendSiteGroupEntry(&all_sites_map_,
+ GURL(e.primary_pattern.ToString()));
origin_permission_set_.insert(
GURL(e.primary_pattern.ToString()).spec());
}
@@ -786,6 +754,8 @@ void SiteSettingsHandler::HandleGetAllSites(const base::ListValue* args) {
ConvertSiteGroupMapToListValue(all_sites_map_, origin_permission_set_,
&result, profile);
+ LogAllSitesAction(AllSitesAction::kLoadPage);
+
send_sites_list_ = true;
ResolveJavascriptCallback(*callback_id, result);
@@ -805,7 +775,6 @@ base::Value SiteSettingsHandler::PopulateCookiesAndUsageData(Profile* profile) {
for (base::Value& site_group : list_value.GetList()) {
base::Value* origin_list = site_group.FindKey(kOriginList);
int cookie_num = 0;
-
const std::string& etld_plus1 =
site_group.FindKey(kEffectiveTopLevelDomainPlus1Name)->GetString();
const auto& etld_plus1_cookie_num_it = origin_cookie_map.find(etld_plus1);
@@ -821,12 +790,12 @@ base::Value SiteSettingsHandler::PopulateCookiesAndUsageData(Profile* profile) {
origin_info.SetKey("usage", base::Value(size_info_it->second));
const auto& origin_cookie_num_it =
origin_cookie_map.find(GURL(origin).host());
- // Add cookies numbers for origins that isn't an eTLD+1.
- if (GURL(origin).host() != etld_plus1 &&
- origin_cookie_num_it != origin_cookie_map.end()) {
+ if (origin_cookie_num_it != origin_cookie_map.end()) {
origin_info.SetKey(kNumCookies,
base::Value(origin_cookie_num_it->second));
- cookie_num += origin_cookie_num_it->second;
+ // Add cookies numbers for origins that isn't an eTLD+1.
+ if (GURL(origin).host() != etld_plus1)
+ cookie_num += origin_cookie_num_it->second;
}
}
site_group.SetKey(kNumCookies, base::Value(cookie_num));
@@ -906,7 +875,6 @@ void SiteSettingsHandler::HandleGetChooserExceptionList(
std::unique_ptr<base::ListValue> exceptions =
site_settings::GetChooserExceptionListFromProfile(profile_,
- /*incognito=*/false,
*chooser_type);
ResolveJavascriptCallback(*callback_id, *exceptions.get());
}
@@ -1387,29 +1355,31 @@ void SiteSettingsHandler::HandleSetBlockAutoplayEnabled(
profile_->GetPrefs()->SetBoolean(prefs::kBlockAutoplayEnabled, value);
}
-void SiteSettingsHandler::EnsureCookiesTreeModelCreated(bool omit_cookies) {
+void SiteSettingsHandler::EnsureCookiesTreeModelCreated() {
if (cookies_tree_model_)
return;
- cookies_tree_model_ =
- CookiesTreeModel::CreateForProfile(profile_, omit_cookies);
+ cookies_tree_model_ = CookiesTreeModel::CreateForProfile(profile_);
cookies_tree_model_->AddCookiesTreeObserver(this);
}
-void SiteSettingsHandler::ObserveSources() {
- observer_.Add(HostContentSettingsMapFactory::GetForProfile(profile_));
- chooser_observer_.Add(UsbChooserContextFactory::GetForProfile(profile_));
-
- if (!profile_->HasOffTheRecordProfile())
- return;
-
- // At the moment, off the record chooser permissions are not included in the
- // chooser permissions.
- // TODO(https://crbug.com/927372): When chooser permissions are included,
- // attach SiteSettingsHandler as an observer to the chooser contexts.
- auto* map = HostContentSettingsMapFactory::GetForProfile(
- profile_->GetOffTheRecordProfile());
+void SiteSettingsHandler::ObserveSourcesForProfile(Profile* profile) {
+ auto* map = HostContentSettingsMapFactory::GetForProfile(profile);
if (!observer_.IsObserving(map))
observer_.Add(map);
+
+ auto* usb_context = UsbChooserContextFactory::GetForProfile(profile);
+ if (!chooser_observer_.IsObserving(usb_context))
+ chooser_observer_.Add(usb_context);
+}
+
+void SiteSettingsHandler::StopObservingSourcesForProfile(Profile* profile) {
+ auto* map = HostContentSettingsMapFactory::GetForProfile(profile);
+ if (observer_.IsObserving(map))
+ observer_.Remove(map);
+
+ auto* usb_context = UsbChooserContextFactory::GetForProfile(profile);
+ if (chooser_observer_.IsObserving(usb_context))
+ chooser_observer_.Remove(usb_context);
}
void SiteSettingsHandler::TreeNodesAdded(ui::TreeModel* model,
@@ -1461,21 +1431,10 @@ void SiteSettingsHandler::GetOriginCookies(
const CookieTreeNode* root = cookies_tree_model_->GetRoot();
for (int i = 0; i < root->child_count(); ++i) {
const CookieTreeNode* site = root->GetChild(i);
- std::string title = base::UTF16ToUTF8(site->GetTitle());
- for (int j = 0; j < site->child_count(); ++j) {
- const CookieTreeNode* category = site->GetChild(j);
- if (category->GetDetailedInfo().node_type !=
- CookieTreeNode::DetailedInfo::TYPE_COOKIES)
- continue;
- for (int k = 0; k < category->child_count(); ++k) {
- const CookieTreeNode::DetailedInfo& detailedInfo =
- category->GetChild(k)->GetDetailedInfo();
- if (detailedInfo.node_type != CookieTreeNode::DetailedInfo::TYPE_COOKIE)
- continue;
- (*origin_cookie_map)[title] += 1;
- CreateOrAppendSiteGroupEntryForCookieHost(title, all_sites_map);
- }
- }
+ GURL url = site->GetDetailedInfo().origin.GetURL();
+ (*origin_cookie_map)[url.host()] = site->NumberOfCookies();
+ CreateOrAppendSiteGroupEntry(all_sites_map, url,
+ /*url_is_origin_with_cookies = */ true);
}
}
@@ -1502,6 +1461,18 @@ void SiteSettingsHandler::HandleClearEtldPlus1DataAndCookies(
for (auto* node : nodes_to_delete) {
cookies_tree_model_->DeleteCookieNode(node);
}
+
+ LogAllSitesAction(AllSitesAction::kClearData);
+}
+
+void SiteSettingsHandler::HandleRecordAction(const base::ListValue* args) {
+ CHECK_EQ(1U, args->GetSize());
+ int action;
+ CHECK(args->GetInteger(0, &action));
+ DCHECK_LE(action, static_cast<int>(AllSitesAction::kMaxValue));
+ DCHECK_GE(action, static_cast<int>(AllSitesAction::kLoadPage));
+
+ LogAllSitesAction(static_cast<AllSitesAction>(action));
}
void SiteSettingsHandler::SetCookiesTreeModelForTesting(
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 cac3cce681e..3bcce17eb02 100644
--- a/chromium/chrome/browser/ui/webui/settings/site_settings_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/site_settings_handler.h
@@ -123,10 +123,12 @@ class SiteSettingsHandler : public SettingsPageUIHandler,
HandleClearEtldPlus1DataAndCookies);
// Creates the CookiesTreeModel if necessary.
- void EnsureCookiesTreeModelCreated(bool omit_cookies = false);
+ void EnsureCookiesTreeModelCreated();
- // Add this class as an observer for content settings and chooser contexts.
- void ObserveSources();
+ // Add or remove this class as an observer for content settings and chooser
+ // contexts corresponding to |profile|.
+ void ObserveSourcesForProfile(Profile* profile);
+ void StopObservingSourcesForProfile(Profile* profile);
// Calculates the data storage that has been used for each origin, and
// stores the information in the |all_sites_map| and |origin_size_map|.
@@ -147,12 +149,6 @@ class SiteSettingsHandler : public SettingsPageUIHandler,
// Deletes the storage being used for a given host.
void HandleClearUsage(const base::ListValue* args);
- // Handles the request for a list of all USB devices.
- void HandleFetchUsbDevices(const base::ListValue* args);
-
- // Removes a particular USB device permission.
- void HandleRemoveUsbDevice(const base::ListValue* args);
-
// Gets and sets the default value for a particular content settings type.
void HandleSetDefaultValueForContentType(const base::ListValue* args);
void HandleGetDefaultValueForContentType(const base::ListValue* args);
@@ -232,6 +228,9 @@ class SiteSettingsHandler : public SettingsPageUIHandler,
// Clear web storage data and cookies from cookies tree model for an ETLD+1.
void HandleClearEtldPlus1DataAndCookies(const base::ListValue* args);
+ // Record metrics for actions on All Sites Page.
+ void HandleRecordAction(const base::ListValue* args);
+
void SetCookiesTreeModelForTesting(
std::unique_ptr<CookiesTreeModel> cookies_tree_model);
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 ba8af47af55..9f481b1a55b 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
@@ -7,11 +7,14 @@
#include <memory>
#include <string>
#include <utility>
+#include <vector>
+#include "base/bind_helpers.h"
#include "base/json/json_reader.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/simple_test_clock.h"
#include "base/values.h"
+#include "build/build_config.h"
#include "chrome/browser/browsing_data/browsing_data_flash_lso_helper.h"
#include "chrome/browser/browsing_data/mock_browsing_data_cookie_helper.h"
#include "chrome/browser/browsing_data/mock_browsing_data_local_storage_helper.h"
@@ -177,6 +180,7 @@ class SiteSettingsHandlerTest : public testing::Test {
}
TestingProfile* profile() { return &profile_; }
+ TestingProfile* incognito_profile() { return incognito_profile_; }
content::TestWebUI* web_ui() { return &web_ui_; }
SiteSettingsHandler* handler() { return &handler_; }
@@ -376,7 +380,7 @@ class SiteSettingsHandlerTest : public testing::Test {
incognito_profile_ = TestingProfile::Builder().BuildIncognito(&profile_);
}
- void DestroyIncognitoProfile() {
+ virtual void DestroyIncognitoProfile() {
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_PROFILE_DESTROYED,
content::Source<Profile>(static_cast<Profile*>(incognito_profile_)),
@@ -416,10 +420,10 @@ class SiteSettingsHandlerTest : public testing::Test {
std::move(container), profile()->GetExtensionSpecialStoragePolicy());
mock_browsing_data_local_storage_helper->AddLocalStorageForOrigin(
- GURL("https://www.example.com/"), 2);
+ url::Origin::Create(GURL("https://www.example.com/")), 2);
mock_browsing_data_local_storage_helper->AddLocalStorageForOrigin(
- GURL("https://www.google.com/"), 5);
+ url::Origin::Create(GURL("https://www.google.com/")), 5);
mock_browsing_data_local_storage_helper->Notify();
mock_browsing_data_cookie_helper->AddCookieSamples(
@@ -491,7 +495,13 @@ TEST_F(SiteSettingsHandlerTest, GetAndSetDefault) {
site_settings::SiteSettingSource::kDefault, 3U);
}
-TEST_F(SiteSettingsHandlerTest, GetAllSites) {
+// Flaky on CrOS and Linux. https://crbug.com/930481
+#if defined(OS_CHROMEOS) || defined(OS_LINUX)
+#define MAYBE_GetAllSites DISABLED_GetAllSites
+#else
+#define MAYBE_GetAllSites GetAllSites
+#endif
+TEST_F(SiteSettingsHandlerTest, MAYBE_GetAllSites) {
base::ListValue get_all_sites_args;
get_all_sites_args.AppendString(kCallbackId);
base::Value category_list(base::Value::Type::LIST);
@@ -768,7 +778,7 @@ TEST_F(SiteSettingsHandlerTest, OnStorageFetched) {
origin_info->FindKey("origin")->GetString());
EXPECT_EQ(0, origin_info->FindKey("engagement")->GetDouble());
EXPECT_EQ(0, origin_info->FindKey("usage")->GetDouble());
- EXPECT_EQ(0, origin_info->FindKey("numCookies")->GetDouble());
+ EXPECT_EQ(1, origin_info->FindKey("numCookies")->GetDouble());
}
TEST_F(SiteSettingsHandlerTest, Origins) {
@@ -1510,7 +1520,7 @@ class SiteSettingsHandlerChooserExceptionTest : public SiteSettingsHandlerTest {
*user_granted_device_info_);
// Add the policy granted permissions for testing.
- auto policy_value = base::JSONReader::Read(kUsbPolicySetting);
+ auto policy_value = base::JSONReader::ReadDeprecated(kUsbPolicySetting);
DCHECK(policy_value);
profile()->GetPrefs()->Set(prefs::kManagedWebUsbAllowDevicesForUrls,
*policy_value);
@@ -1519,6 +1529,35 @@ class SiteSettingsHandlerChooserExceptionTest : public SiteSettingsHandlerTest {
chooser_context->ChooserContextBase::AddObserver(&observer_);
}
+ void SetUpOffTheRecordUsbChooserContext() {
+ off_the_record_device_ = device_manager_.CreateAndAddDevice(
+ 6353, 8765, "Google", "Contraption", "A9B8C7");
+
+ CreateIncognitoProfile();
+ auto* chooser_context =
+ UsbChooserContextFactory::GetForProfile(incognito_profile());
+ device::mojom::UsbDeviceManagerPtr device_manager_ptr;
+ device_manager_.AddBinding(mojo::MakeRequest(&device_manager_ptr));
+ chooser_context->SetDeviceManagerForTesting(std::move(device_manager_ptr));
+ chooser_context->GetDevices(
+ base::DoNothing::Once<std::vector<device::mojom::UsbDeviceInfoPtr>>());
+ base::RunLoop().RunUntilIdle();
+
+ chooser_context->GrantDevicePermission(kChromiumOrigin, kAndroidOrigin,
+ *off_the_record_device_);
+
+ // Add the observer for permission changes.
+ chooser_context->ChooserContextBase::AddObserver(&observer_);
+ }
+
+ void DestroyIncognitoProfile() override {
+ auto* chooser_context =
+ UsbChooserContextFactory::GetForProfile(incognito_profile());
+ chooser_context->ChooserContextBase::RemoveObserver(&observer_);
+
+ SiteSettingsHandlerTest::DestroyIncognitoProfile();
+ }
+
// Call SiteSettingsHandler::HandleGetChooserExceptionList for |chooser_type|
// and return the exception list received by the WebUI.
void ValidateChooserExceptionList(const std::string& chooser_type,
@@ -1592,8 +1631,9 @@ class SiteSettingsHandlerChooserExceptionTest : public SiteSettingsHandlerTest {
return false;
}
- device::mojom::UsbDeviceInfoPtr persistent_device_info_;
device::mojom::UsbDeviceInfoPtr ephemeral_device_info_;
+ device::mojom::UsbDeviceInfoPtr off_the_record_device_;
+ device::mojom::UsbDeviceInfoPtr persistent_device_info_;
device::mojom::UsbDeviceInfoPtr user_granted_device_info_;
MockPermissionObserver observer_;
@@ -1614,6 +1654,42 @@ TEST_F(SiteSettingsHandlerChooserExceptionTest,
}
TEST_F(SiteSettingsHandlerChooserExceptionTest,
+ HandleGetChooserExceptionListForUsbOffTheRecord) {
+ const std::string kUsbChooserGroupName =
+ site_settings::ContentSettingsTypeToGroupName(
+ CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA);
+ SetUpOffTheRecordUsbChooserContext();
+ web_ui()->ClearTrackedCalls();
+
+ // The objects returned by GetChooserExceptionListFromProfile should also
+ // include the incognito permissions. The two extra objects represent the
+ // "Widget" device and the policy permission for "Unknown product 0x162E from
+ // Google Inc.". The policy granted permission shows up here because the off
+ // the record profile does not have a user granted permission for the
+ // |persistent_device_info_|, so it cannot use the name of that device.
+ {
+ const base::Value& exceptions = GetChooserExceptionListFromWebUiCallData(
+ kUsbChooserGroupName, /*expected_total_calls=*/1u);
+ EXPECT_EQ(exceptions.GetList().size(), 7u);
+ for (const auto& exception : exceptions.GetList()) {
+ LOG(INFO) << exception.FindKey(site_settings::kDisplayName)->GetString();
+ }
+ }
+
+ // Destroy the off the record profile and check that the objects returned do
+ // not include incognito permissions anymore. The destruction of the profile
+ // causes the "onIncognitoStatusChanged" WebUIListener callback to fire.
+ DestroyIncognitoProfile();
+ EXPECT_EQ(web_ui()->call_data().size(), 2u);
+
+ {
+ const base::Value& exceptions = GetChooserExceptionListFromWebUiCallData(
+ kUsbChooserGroupName, /*expected_total_calls=*/3u);
+ EXPECT_EQ(exceptions.GetList().size(), 5u);
+ }
+}
+
+TEST_F(SiteSettingsHandlerChooserExceptionTest,
HandleResetChooserExceptionForSiteForUsb) {
const std::string kUsbChooserGroupName =
site_settings::ContentSettingsTypeToGroupName(
diff --git a/chromium/chrome/browser/ui/webui/settings/tts_handler.cc b/chromium/chrome/browser/ui/webui/settings/tts_handler.cc
index c3f553c2ed5..440e917e224 100644
--- a/chromium/chrome/browser/ui/webui/settings/tts_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/tts_handler.cc
@@ -111,6 +111,7 @@ void TtsHandler::OnVoicesChanged() {
void TtsHandler::OnTtsEvent(content::TtsUtterance* utterance,
content::TtsEventType event_type,
int char_index,
+ int length,
const std::string& error_message) {
if (event_type == content::TTS_EVENT_END ||
event_type == content::TTS_EVENT_INTERRUPTED ||
@@ -131,7 +132,7 @@ void TtsHandler::HandlePreviewTtsVoice(const base::ListValue* args) {
return;
std::unique_ptr<base::DictionaryValue> json =
- base::DictionaryValue::From(base::JSONReader::Read(voice_id));
+ base::DictionaryValue::From(base::JSONReader::ReadDeprecated(voice_id));
std::string name;
std::string extension_id;
json->GetString("name", &name);
diff --git a/chromium/chrome/browser/ui/webui/settings/tts_handler.h b/chromium/chrome/browser/ui/webui/settings/tts_handler.h
index 93fd5b90acc..f26fbb230e5 100644
--- a/chromium/chrome/browser/ui/webui/settings/tts_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/tts_handler.h
@@ -37,6 +37,7 @@ class TtsHandler : public SettingsPageUIHandler,
void OnTtsEvent(content::TtsUtterance* utterance,
content::TtsEventType event_type,
int char_index,
+ int length,
const std::string& error_message) override;
private: