Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Side by Side Diff: components/keyboard_lock/page_observer.h

Issue 2879033002: Keyboard Lock Host implementation
Patch Set: Remove useless files Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 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
5 #ifndef COMPONENTS_KEYBOARD_LOCK_PAGE_OBSERVER_H_
6 #define COMPONENTS_KEYBOARD_LOCK_PAGE_OBSERVER_H_
7
8 #include "content/public/browser/notification_observer.h"
9 #include "content/public/browser/notification_registrar.h"
10 #include "content/public/browser/web_contents_observer.h"
11
12 namespace content {
13 class NotificationDetails;
14 class NotificationSource;
15 class WebContents;
16 } // namespace content
17
18 namespace keyboard_lock {
19
20 class KeyHookActivator;
21 class KeyHookActivatorCollection;
22
23 // A PageObserver instance keeps a reference of a KeyHookActivator (usually a
24 // KeyHookActivatorThreadProxy wrapped KeyHookStateKeeper instance) and a
25 // WebContents. Once an interesting event, e.g. page taking or losing focus,
26 // entering or exiting fullscreen, PageObserver calls
27 // KeyHookActivator::Activate() or KeyHookActivator::Deactivate() functions.
28 // A PageObserver instance has the same lifetime with its WebContents, it
29 // deletes itself once WebContentsObserver::WebContentsDestroyed() is called.
30 // This class must be instantiated in UI thread to ensure correct signals can be
31 // received.
32 class PageObserver final
33 : public content::NotificationObserver,
34 public content::WebContentsObserver {
35 public:
36 // |collection| must outlive current instance.
37 static void Observe(content::WebContents* web_contents,
38 KeyHookActivatorCollection* collection);
39
40 private:
41 PageObserver(content::WebContents* web_contents,
42 KeyHookActivatorCollection* collection);
43 ~PageObserver() override;
44
45 // NotificationObserver implementations
46 void Observe(int type,
47 const content::NotificationSource& source,
48 const content::NotificationDetails& details) override;
49
50 // WebContentsObserver implementations
51 void OnWebContentsLostFocus() override;
52 void OnWebContentsFocused() override;
53 void WebContentsDestroyed() override;
54
55 void TriggerActivator();
56
57 bool is_fullscreen_ = false;
58 bool is_focused_ = false;
59 content::NotificationRegistrar registrar_;
60 KeyHookActivatorCollection* const collection_;
61 };
62
63 } // namespace keyboard_lock
64
65 #endif // COMPONENTS_KEYBOARD_LOCK_PAGE_OBSERVER_H_
OLDNEW
« no previous file with comments | « components/keyboard_lock/keyboard_lock_host_x11.cc ('k') | components/keyboard_lock/page_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698