webview_app_state_observer.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef ANDROID_WEBVIEW_BROWSER_LIFECYCLE_WEBVIEW_APP_STATE_OBSERVER_H_
  5. #define ANDROID_WEBVIEW_BROWSER_LIFECYCLE_WEBVIEW_APP_STATE_OBSERVER_H_
  6. namespace android_webview {
  7. // The interface for being notified of app state change, the implementation
  8. // shall be added to observer list through AwContentsLifecycleNotifier.
  9. class WebViewAppStateObserver {
  10. public:
  11. enum class State {
  12. // All WebViews are detached from window.
  13. kUnknown,
  14. // At least one WebView is foreground.
  15. kForeground,
  16. // No WebView is foreground and at least one WebView is background.
  17. kBackground,
  18. // All WebViews are destroyed or no WebView has been created.
  19. // Observers shall use
  20. // AwContentsLifecycleNotifier::has_aw_contents_ever_created() to find if A
  21. // WebView has ever been created.
  22. kDestroyed,
  23. };
  24. WebViewAppStateObserver();
  25. virtual ~WebViewAppStateObserver();
  26. // Invoked when app state is changed or right after this observer is added
  27. // into observer list.
  28. virtual void OnAppStateChanged(State state) = 0;
  29. };
  30. } // namespace android_webview
  31. #endif // ANDROID_WEBVIEW_BROWSER_LIFECYCLE_WEBVIEW_APP_STATE_OBSERVER_H_