Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / ui / exclusive_access / exclusive_access_controller_base.h
blob1d127c4a6f540c6d22970c5a89b144282ff61581
1 // Copyright (c) 2015 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.
5 #ifndef CHROME_BROWSER_UI_EXCLUSIVE_ACCESS_EXCLUSIVE_ACCESS_CONTROLLER_BASE_H_
6 #define CHROME_BROWSER_UI_EXCLUSIVE_ACCESS_EXCLUSIVE_ACCESS_CONTROLLER_BASE_H_
8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h"
10 #include "chrome/browser/ui/exclusive_access/exclusive_access_bubble_type.h"
11 #include "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_registrar.h"
14 class ExclusiveAccessManager;
15 class GURL;
16 class Profile;
18 namespace content {
19 class WebContents;
22 // The base class for the different exclusive access controllers like the
23 // FullscreenController, and MouseLockController which controls lifetime for
24 // which the resource (screen/mouse) is held exclusively.
25 class ExclusiveAccessControllerBase : public content::NotificationObserver {
26 public:
27 explicit ExclusiveAccessControllerBase(ExclusiveAccessManager* manager);
28 ~ExclusiveAccessControllerBase() override;
30 GURL GetExclusiveAccessBubbleURL() const;
31 virtual GURL GetURLForExclusiveAccessBubble() const;
33 content::WebContents* exclusive_access_tab() const {
34 return tab_with_exclusive_access_;
37 // Functions implemented by derived classes:
39 // Control behavior when escape is pressed returning true if it was handled.
40 virtual bool HandleUserPressedEscape() = 0;
42 // Called by Browser in response to call from ExclusiveAccessBubble.
43 virtual void ExitExclusiveAccessToPreviousState() = 0;
45 // Called to indicate that the permission for this exclusive access has been
46 // granted if requested. Returns true if the exit bubble content should be
47 // updated.
48 virtual bool OnAcceptExclusiveAccessPermission() = 0;
50 // Called to indicate that the permission for the exclusive access has been
51 // denied if requested. Returns true if the exit bubble content should be
52 // updated.
53 virtual bool OnDenyExclusiveAccessPermission() = 0;
55 // Called by ExclusiveAccessManager in response to calls from Browser.
56 virtual void OnTabDeactivated(content::WebContents* web_contents);
57 virtual void OnTabDetachedFromView(content::WebContents* web_contents);
58 virtual void OnTabClosing(content::WebContents* web_contents);
60 // Callbacks ////////////////////////////////////////////////////////////////
62 // content::NotificationObserver to detect page navigation and exit exclusive
63 // access.
64 void Observe(int type,
65 const content::NotificationSource& source,
66 const content::NotificationDetails& details) override;
68 protected:
69 void SetTabWithExclusiveAccess(content::WebContents* tab);
71 ExclusiveAccessManager* exclusive_access_manager() const { return manager_; }
73 // Exits exclusive access mode for the tab if currently exclusive.
74 virtual void ExitExclusiveAccessIfNecessary() = 0;
76 // Notifies the tab that it has been forced out of exclusive access mode
77 // if necessary.
78 virtual void NotifyTabExclusiveAccessLost() = 0;
80 private:
81 void UpdateNotificationRegistrations();
83 ExclusiveAccessManager* const manager_;
85 content::NotificationRegistrar registrar_;
87 content::WebContents* tab_with_exclusive_access_;
89 DISALLOW_COPY_AND_ASSIGN(ExclusiveAccessControllerBase);
92 #endif // CHROME_BROWSER_UI_EXCLUSIVE_ACCESS_EXCLUSIVE_ACCESS_CONTROLLER_BASE_H_