tree: d999b764f6cb06b5960cc8cb8aaddbbe8b7b81ee [path history] [tgz]
  1. fake_webpage_controller.h
  2. fake_webpage_controller.mm
  3. history_bridge.h
  4. history_bridge.mm
  5. history_bridge_factory.h
  6. history_bridge_factory.mm
  7. history_bridge_unittest.cc
  8. history_deleter.h
  9. history_deleter_impl.h
  10. history_deleter_impl.mm
  11. README.md
  12. screentime_features.cc
  13. screentime_features.h
  14. screentime_policy.cc
  15. screentime_policy.h
  16. screentime_tab_helper_unittest.mm
  17. tab_helper.h
  18. tab_helper.mm
  19. webpage_controller.h
  20. webpage_controller_impl.h
  21. webpage_controller_impl.mm
chrome/browser/ui/cocoa/screentime/README.md

Screen Time

This directory contains the integration between Chromium and the macOS ScreenTime system, which is a digital wellbeing tool allowing users to restrict their own use of apps and websites by category.

The ScreenTime system API is documented on apple.com. The most pertinent class is STWebpageController, which is an NSViewController subclass. Clients of ScreenTime construct a single STWebpageController per tab and splice its corresponding NSView into their view tree in such a way that it covers the web contents. The NSView becomes opaque when screen time for that tab or website has been used up.

The public interface to ScreenTime within Chromium is the screentime::TabHelper class, which is a TabHelper that binds an STWebpageController to a WebContents.

There is also a key private class, called screentime::HistoryBridge, which connects a HistoryService to the ScreenTime history deletion controller. HistoryBridge is a profile-keyed service, so one exists for each Profile.

Testing

So that tests can avoid depending on the real ScreenTime system, STWebpageController is wrapped by a C++ class called screentime::WebpageController, which has a testing fake called screentime::FakeWebpageController, and STWebHistory is wrapped by a C++ class called screentime::HistoryDeleter.