Skip to content

Commit

Permalink
Merge pull request #17 from chromium/master
Browse files Browse the repository at this point in the history
Daily Merge
  • Loading branch information
FrankEnderman committed Oct 27, 2021
2 parents eecf090 + c47dbb5 commit 4636d75
Show file tree
Hide file tree
Showing 326 changed files with 5,331 additions and 3,304 deletions.
4 changes: 0 additions & 4 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -842,10 +842,6 @@ group("gn_all") {
}
}

if (enable_vulkan) {
deps += [ "//gpu/vulkan/demo" ]
}

if (use_atk) {
deps += [
"//tools/accessibility/inspect:ax_dump_events",
Expand Down
18 changes: 9 additions & 9 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,11 @@ vars = {
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling V8
# and whatever else without interference from each other.
'v8_revision': 'fabb677a3acc3dbe8882e632c3071ef04cd2b9d4',
'v8_revision': '91620f530425632c1dc447522d4486789a7fbb7c',
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling ANGLE
# and whatever else without interference from each other.
'angle_revision': '421dbf200d361f661a7a79cb6d9cdc83df74ef6d',
'angle_revision': 'bc09d119479d13e3419715e6bcf52ec7fa2109a7',
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling SwiftShader
# and whatever else without interference from each other.
Expand Down Expand Up @@ -309,7 +309,7 @@ vars = {
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling devtools-frontend
# and whatever else without interference from each other.
'devtools_frontend_revision': 'd71219e53cc8373c2e43583a1825b637a4abf02a',
'devtools_frontend_revision': 'b1733e82bcf88755f1e4746743c0ab67ca0d2637',
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling libprotobuf-mutator
# and whatever else without interference from each other.
Expand Down Expand Up @@ -1029,7 +1029,7 @@ deps = {
},

'src/third_party/depot_tools':
Var('chromium_git') + '/chromium/tools/depot_tools.git' + '@' + '480c91d40b45432c6916b5767a478753abcbd47d',
Var('chromium_git') + '/chromium/tools/depot_tools.git' + '@' + '45a7f406aba65d5bc662a6c0422c0829a06b78ff',

'src/third_party/devtools-frontend/src':
Var('chromium_git') + '/devtools/devtools-frontend' + '@' + Var('devtools_frontend_revision'),
Expand Down Expand Up @@ -1493,7 +1493,7 @@ deps = {
'packages': [
{
'package': 'fuchsia/third_party/aemu/linux-amd64',
'version': 'anmoXU7qoa185RNsOxsBoD0U-T6rHNnNeGfdCNx1LB0C'
'version': 'xjSUP3twlka9ZIZ4qo7-8nAAUVM2zC9x-F2vYkkO1-EC'
},
],
'condition': 'host_os == "linux" and checkout_fuchsia',
Expand All @@ -1512,7 +1512,7 @@ deps = {
},

'src/third_party/re2/src':
Var('chromium_git') + '/external/github.com/google/re2.git' + '@' + 'e90569de09a9a3dd1f2dec189f77b52d17e4faea',
Var('chromium_git') + '/external/github.com/google/re2.git' + '@' + '7424791d0865cd09893af2b9aec19a2b7f77c763',

'src/third_party/r8': {
'packages': [
Expand Down Expand Up @@ -1636,7 +1636,7 @@ deps = {
Var('chromium_git') + '/external/github.com/gpuweb/cts.git' + '@' + '7c6749771b96d008cbc9877c618bf9f9a7f127da',

'src/third_party/webrtc':
Var('webrtc_git') + '/src.git' + '@' + '519c15de2b860ea6114a4abf54625041f5784465',
Var('webrtc_git') + '/src.git' + '@' + 'af09c13096523ff78e9c63efd4d42d5876d648e0',

'src/third_party/libgifcodec':
Var('skia_git') + '/libgifcodec' + '@'+ Var('libgifcodec_revision'),
Expand Down Expand Up @@ -1694,7 +1694,7 @@ deps = {
Var('chromium_git') + '/v8/v8.git' + '@' + Var('v8_revision'),

'src-internal': {
'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@786f6d4dff85e0206f53d0aa2cab6c3d5c4caa59',
'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@fab82b09dd7f4c69ecf0bd7cb06b1257c5c2d11c',
'condition': 'checkout_src_internal',
},

Expand Down Expand Up @@ -1735,7 +1735,7 @@ deps = {
'packages': [
{
'package': 'chromeos_internal/apps/projector_app/app',
'version': '7y5Wzbh0-QW3lu02uUMHOTcXkxjv1MGZQHE-ODseWSwC',
'version': 'ZXIcQJhEIO97vrK-zObnZPkmSXnXLXsuZmY1p5A_rDUC',
},
],
'condition': 'checkout_chromeos and checkout_src_internal',
Expand Down
2 changes: 2 additions & 0 deletions ash/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2518,6 +2518,7 @@ test("ash_unittests") {
"system/tray/tri_view_unittest.cc",
"system/unified/camera_mic_tray_item_view_unittest.cc",
"system/unified/feature_pods_container_view_unittest.cc",
"system/unified/hps_notify_view_unittest.cc",
"system/unified/notification_counter_view_unittest.cc",
"system/unified/notification_icons_controller_unittest.cc",
"system/unified/page_indicator_view_unittest.cc",
Expand Down Expand Up @@ -2682,6 +2683,7 @@ test("ash_unittests") {
"//chromeos/dbus/hammerd",
"//chromeos/dbus/hermes:hermes_clients",
"//chromeos/dbus/hermes:hermes_fakes",
"//chromeos/dbus/hps",
"//chromeos/dbus/power",
"//chromeos/dbus/power:power_manager_proto",
"//chromeos/dbus/services:test_support",
Expand Down
2 changes: 2 additions & 0 deletions ash/ash_prefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "ash/system/power/power_prefs.h"
#include "ash/system/session/logout_button_tray.h"
#include "ash/system/session/logout_confirmation_controller.h"
#include "ash/system/unified/hps_notify_view.h"
#include "ash/system/unified/top_shortcuts_view.h"
#include "ash/touch/touch_devices_controller.h"
#include "ash/wallpaper/wallpaper_controller_impl.h"
Expand Down Expand Up @@ -78,6 +79,7 @@ void RegisterProfilePrefs(PrefRegistrySimple* registry, bool for_test) {
GestureEducationNotificationController::RegisterProfilePrefs(registry,
for_test);
holding_space_prefs::RegisterProfilePrefs(registry);
HpsNotifyView::RegisterProfilePrefs(registry);
LoginScreenController::RegisterProfilePrefs(registry, for_test);
LogoutButtonTray::RegisterProfilePrefs(registry);
LogoutConfirmationController::RegisterProfilePrefs(registry);
Expand Down
5 changes: 5 additions & 0 deletions ash/constants/ash_pref_names.cc
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,11 @@ const char kCanCellularSetupNotificationBeShown[] =
const char kManagedGuestSessionPrivacyWarningsEnabled[] =
"managed_session.privacy_warning_enabled";

// Boolean pref indicating whether the user has enabled detection of snooping
// over their shoulder.
const char kSnoopingProtectionEnabled[] =
"ash.privacy.snooping_protection_enabled";

// A string pref storing the type of lock screen notification mode.
// "show" -> show notifications on the lock screen
// "hide" -> hide notifications at all on the lock screen (default)
Expand Down
3 changes: 3 additions & 0 deletions ash/constants/ash_pref_names.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ extern const char kCanCellularSetupNotificationBeShown[];
COMPONENT_EXPORT(ASH_CONSTANTS)
extern const char kManagedGuestSessionPrivacyWarningsEnabled[];

COMPONENT_EXPORT(ASH_CONSTANTS)
extern const char kSnoopingProtectionEnabled[];

// Lock screen notification settings.
COMPONENT_EXPORT(ASH_CONSTANTS)
extern const char kMessageCenterLockScreenMode[];
Expand Down
102 changes: 71 additions & 31 deletions ash/system/unified/hps_notify_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "ash/system/unified/hps_notify_view.h"

#include "ash/constants/ash_pref_names.h"
#include "ash/public/cpp/session/session_observer.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/session/session_controller_impl.h"
Expand All @@ -13,6 +14,12 @@
#include "ash/system/tray/tray_utils.h"
#include "base/bind.h"
#include "base/callback.h"
#include "base/logging.h"
#include "components/account_id/account_id.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_change_registrar.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
#include "components/session_manager/session_manager_types.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/skia/include/core/SkColor.h"
Expand All @@ -23,39 +30,68 @@

namespace ash {

HpsNotifyView::HpsNotifyView(Shelf* shelf)
: TrayItemView(shelf),
hps_state_(false),
is_oobe_(false),
first_signal_received_(false),
session_observation_(this),
hps_dbus_observation_(this),
weak_ptr_factory_(this) {
HpsNotifyView::HpsNotifyView(Shelf* shelf) : TrayItemView(shelf) {
SessionControllerImpl* session_controller =
Shell::Get()->session_controller();

CreateImageView();
UpdateIconColor(Shell::Get()->session_controller()->GetSessionState());
SetVisible(false);

session_observation_.Observe(Shell::Get()->session_controller());
hps_dbus_observation_.Observe(chromeos::HpsDBusClient::Get());
OnSessionStateChanged(session_controller->GetSessionState());

// Poll the current preference state if the pref service is already loaded for
// an active user. Then, from now on, observe changes to the active user pref
// service.
const AccountId& account_id = session_controller->GetActiveAccountId();
PrefService* pref_service =
session_controller->GetUserPrefServiceForUser(account_id);
OnActiveUserPrefServiceChanged(pref_service);
session_observation_.Observe(session_controller);

// Poll the current HPS notify state if the daemon is active. Then, from now
// on, observe changes to the HPS notify signal.
chromeos::HpsDBusClient::Get()->GetResultHpsNotify(base::BindOnce(
&HpsNotifyView::OnHpsPollResult, weak_ptr_factory_.GetWeakPtr()));
hps_dbus_observation_.Observe(chromeos::HpsDBusClient::Get());
}

HpsNotifyView::~HpsNotifyView() = default;

// static
void HpsNotifyView::RegisterProfilePrefs(PrefRegistrySimple* registry) {
registry->RegisterBooleanPref(
prefs::kSnoopingProtectionEnabled,
/*default_value=*/false,
user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PREF);
}

void HpsNotifyView::HandleLocaleChange() {}

void HpsNotifyView::OnSessionStateChanged(
session_manager::SessionState session_state) {
UpdateIconColor(session_state);
UpdateIconVisibility(session_state == session_manager::SessionState::OOBE,
hps_state_);
hps_state_, is_enabled_);
}

void HpsNotifyView::OnActiveUserPrefServiceChanged(PrefService* pref_service) {
UpdateIconVisibility(is_oobe_, hps_state_,
pref_service && pref_service->GetBoolean(
prefs::kSnoopingProtectionEnabled));

if (!pref_service)
return;

// Re-subscribe to pref changes.
pref_change_registrar_ = std::make_unique<PrefChangeRegistrar>();
pref_change_registrar_->Init(pref_service);
pref_change_registrar_->Add(
prefs::kSnoopingProtectionEnabled,
base::BindRepeating(&HpsNotifyView::OnPrefChanged,
weak_ptr_factory_.GetWeakPtr()));
}

void HpsNotifyView::OnHpsNotifyChanged(bool hps_state) {
first_signal_received_ = true;
UpdateIconVisibility(is_oobe_, hps_state);
UpdateIconVisibility(is_oobe_, hps_state, is_enabled_);
}

void HpsNotifyView::OnThemeChanged() {
Expand All @@ -75,32 +111,36 @@ void HpsNotifyView::UpdateIconColor(
image_view()->SetImage(new_icon);
}

void HpsNotifyView::UpdateIconVisibility(bool is_oobe, bool hps_state) {
if (is_oobe_ == is_oobe && hps_state_ == hps_state)
void HpsNotifyView::UpdateIconVisibility(bool is_oobe,
bool hps_state,
bool is_enabled) {
if (is_oobe_ == is_oobe && hps_state_ == hps_state &&
is_enabled_ == is_enabled)
return;

is_oobe_ = is_oobe;
hps_state_ = hps_state;
SetVisible(!is_oobe_ && hps_state_);
is_enabled_ = is_enabled;

SetVisible(!is_oobe_ && hps_state_ && is_enabled);
}

void HpsNotifyView::OnHpsPollResult(absl::optional<bool> result) {
// A race: we have received a signal before we had a chance to establish our
// initial state (from the result of our DBus method call). The signal could
// have originated from either before our DBus method call, or after.
//
// If the two states are the same, there is no problem. If they are different,
// we should always ignore the DBus method response because:
// a) If the signal originated before the DBus method call, the state of the
// daemon has changed since the signal was sent and an updated signal
// will be forthcoming.
// b) If the signal originated after the DBus method call, then the signal
// is newer and reflects the current state of the daemon.
if (first_signal_received_ || !result.has_value()) {
if (!result.has_value()) {
LOG(WARNING) << "Polling the presence daemon failed";
return;
}

UpdateIconVisibility(is_oobe_, *result);
UpdateIconVisibility(is_oobe_, *result, is_enabled_);
}

void HpsNotifyView::OnPrefChanged() {
DCHECK(pref_change_registrar_);
DCHECK(pref_change_registrar_->prefs());

UpdateIconVisibility(is_oobe_, hps_state_,
pref_change_registrar_->prefs()->GetBoolean(
prefs::kSnoopingProtectionEnabled));
}

} // namespace ash
47 changes: 29 additions & 18 deletions ash/system/unified/hps_notify_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,34 @@
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/skia/include/core/SkColor.h"

class PrefChangeRegistrar;
class PrefRegistrySimple;

namespace ash {

// The icon in the system tray notifying a user that a second person has been
// detected looking over their shoulder.
class HpsNotifyView : public TrayItemView,
public SessionObserver,
public chromeos::HpsDBusClient::Observer {
class ASH_EXPORT HpsNotifyView : public TrayItemView,
public SessionObserver,
public chromeos::HpsDBusClient::Observer {
public:
explicit HpsNotifyView(Shelf* shelf);
HpsNotifyView(const HpsNotifyView&) = delete;
HpsNotifyView& operator=(const HpsNotifyView&) = delete;
~HpsNotifyView() override;

// TODO(crbug.com/1241704): refactor this class into a controller that
// provides access to a TrayItemView* for the snooping icon.
static void RegisterProfilePrefs(PrefRegistrySimple* registry);

// views::TrayItemView:
const char* GetClassName() const override;
void HandleLocaleChange() override;
void OnThemeChanged() override;

// SessionObserver:
void OnSessionStateChanged(session_manager::SessionState state) override;
void OnActiveUserPrefServiceChanged(PrefService* pref_service) override;

// chromeos::HpsDBusClient::Observer:
void OnHpsNotifyChanged(bool state) override;
Expand All @@ -43,31 +51,34 @@ class HpsNotifyView : public TrayItemView,
// session state (e.g. darker during OOBE).
void UpdateIconColor(session_manager::SessionState session_state);

// Shows or hides the system tray icon as appropriate given the signal and
// session state. Also updates the current cached states.
void UpdateIconVisibility(bool is_oobe, bool hps_state);
// Shows or hides the system tray icon as appropriate given the signal,
// session and preference state. Also updates the current cached states.
void UpdateIconVisibility(bool is_oobe, bool hps_state, bool is_enabled);

// A callback to set our initial state by polling the presence daemon. If we
// have received a signal before the callback is executed, this becomes a
// no-op.
// A callback to set our initial state by polling the presence daemon.
void OnHpsPollResult(absl::optional<bool> result);

// Used to track whether a signal should actually trigger a visibility change.
bool hps_state_;
bool is_oobe_;
// A callback to update visibility when the user enables or disables the
// feature.
void OnPrefChanged();

// Used to avoid a race between polling and being signaled by the presence
// daemon.
bool first_signal_received_;
// Used to track whether a signal should actually trigger a visibility:
bool hps_state_ = false; // The state last reported by the daemon.
bool is_oobe_ = false; // Whether or not we're in the OOBE.
bool is_enabled_ = false; // Whether or not the user has enabled the feature.

base::ScopedObservation<SessionController, SessionObserver>
session_observation_;
session_observation_{this};
base::ScopedObservation<chromeos::HpsDBusClient,
chromeos::HpsDBusClient::Observer>
hps_dbus_observation_;
hps_dbus_observation_{this};

// Used to notify ourselves of changes to the pref that enables / disables
// this feature.
std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_;

// Must be last.
base::WeakPtrFactory<HpsNotifyView> weak_ptr_factory_;
base::WeakPtrFactory<HpsNotifyView> weak_ptr_factory_{this};
};

} // namespace ash
Expand Down
Loading

0 comments on commit 4636d75

Please sign in to comment.