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

Side by Side Diff: chrome/browser/ui/exclusive_access/exclusive_access_controller_base.h

Issue 836933005: Refactor fullscreen_controller. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync to TOT Created 5 years, 11 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_SYNC_SESSIONS_NOTIFICATION_SERVICE_SESSIONS_ROUTER_H_ 5 #ifndef CHROME_BROWSER_UI_EXCLUSIVE_ACCESS_EXCLUSIVE_ACCESS_CONTROLLER_BASE_H_
6 #define CHROME_BROWSER_SYNC_SESSIONS_NOTIFICATION_SERVICE_SESSIONS_ROUTER_H_ 6 #define CHROME_BROWSER_UI_EXCLUSIVE_ACCESS_EXCLUSIVE_ACCESS_CONTROLLER_BASE_H_
7 7
8 #include <set> 8 #include "base/basictypes.h"
9
10 #include "base/callback_list.h"
11 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/sync/sessions/sessions_sync_manager.h" 10 #include "chrome/browser/ui/exclusive_access/exclusive_access_bubble_type.h"
13 #include "content/public/browser/notification_observer.h" 11 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h" 12 #include "content/public/browser/notification_registrar.h"
15 13
14 class Browser;
15 class BrowserWindow;
16 class ExclusiveAccessManager;
16 class GURL; 17 class GURL;
17 class HistoryService;
18 class Profile; 18 class Profile;
19 19
20 namespace content { 20 namespace content {
21 class WebContents; 21 class WebContents;
22 } 22 }
23 23
24 namespace browser_sync { 24 // The base class for the different exclusive access controllers like the
25 // FullscreenController, and MouseLockController which controls lifetime for
26 // which the resource (screen/mouse) is held exclusively.
27 class ExclusiveAccessControllerBase : public content::NotificationObserver {
28 public:
29 explicit ExclusiveAccessControllerBase(ExclusiveAccessManager* manager,
30 Browser* browser);
31 ~ExclusiveAccessControllerBase() override;
25 32
26 // A SessionsSyncManager::LocalEventRouter that drives session sync via 33 GURL GetExclusiveAccessBubbleURL() const;
27 // the NotificationService. 34 virtual GURL GetURLForExclusiveAccessBubble() const;
28 class NotificationServiceSessionsRouter
29 : public LocalSessionEventRouter,
30 public content::NotificationObserver {
31 public:
32 NotificationServiceSessionsRouter(
33 Profile* profile,
34 const syncer::SyncableService::StartSyncFlare& flare);
35 ~NotificationServiceSessionsRouter() override;
36 35
37 // content::NotificationObserver implementation. 36 content::WebContents* exclusive_access_tab() const {
38 // BrowserSessionProvider -> sync API model change application. 37 return tab_with_exclusive_access_;
38 }
39
40 // Functions implemented by derived classes:
41
42 // Control behavior when escape is pressed returning true if it was handled.
43 virtual bool HandleUserPressedEscape() = 0;
44
45 // Called by Browser in response to call from ExclusiveAccessBubble.
46 virtual void ExitExclusiveAccessToPreviousState() = 0;
47
48 // Called to indicate that the permission for this exclusive access has been
49 // granted if requested. Returns true if the exit bubble content should be
50 // updated.
51 virtual bool OnAcceptExclusiveAccessPermission() = 0;
52
53 // Called to indicate that the permission for the exclusive access has been
54 // denied if requested. Returns true if the exit bubble content should be
55 // updated.
56 virtual bool OnDenyExclusiveAccessPermission() = 0;
57
58 // Called by ExclusiveAccessManager in response to calls from Browser.
59 virtual void OnTabDeactivated(content::WebContents* web_contents);
60 virtual void OnTabDetachedFromView(content::WebContents* web_contents);
61 virtual void OnTabClosing(content::WebContents* web_contents);
62
63 // Callbacks ////////////////////////////////////////////////////////////////
64
65 // content::NotificationObserver to detect page navigation and exit exclusive
66 // access.
39 void Observe(int type, 67 void Observe(int type,
40 const content::NotificationSource& source, 68 const content::NotificationSource& source,
41 const content::NotificationDetails& details) override; 69 const content::NotificationDetails& details) override;
42 70
43 // SessionsSyncManager::LocalEventRouter implementation. 71 protected:
44 void StartRoutingTo(LocalSessionEventHandler* handler) override; 72 void SetTabWithExclusiveAccess(content::WebContents* tab);
45 void Stop() override; 73
74 ExclusiveAccessManager* exclusive_access_manager() const { return manager_; }
75
76 Browser* browser() const { return browser_; }
77
78 Profile* profile() const { return profile_; }
79
80 // Exits exclusive access mode for the tab if currently exclusive.
81 virtual void ExitExclusiveAccessIfNecessary() = 0;
82
83 // Notifies the tab that it has been forced out of exclusive access mode
84 // if necessary.
85 virtual void NotifyTabExclusiveAccessLost() = 0;
46 86
47 private: 87 private:
48 // Called when the URL visited in |web_contents| was blocked by the 88 void UpdateNotificationRegistrations();
49 // SupervisedUserService. We forward this on to our handler_ via the
50 // normal OnLocalTabModified, but pass through here via a WeakPtr
51 // callback from SupervisedUserService and to extract the tab delegate
52 // from WebContents.
53 void OnNavigationBlocked(content::WebContents* web_contents);
54 89
55 // Called when the urls of favicon changed. 90 ExclusiveAccessManager* const manager_;
56 void OnFaviconChanged(const std::set<GURL>& changed_favicons); 91 Browser* const browser_;
92 Profile* const profile_;
57 93
58 LocalSessionEventHandler* handler_;
59 content::NotificationRegistrar registrar_; 94 content::NotificationRegistrar registrar_;
60 Profile* const profile_;
61 syncer::SyncableService::StartSyncFlare flare_;
62 95
63 scoped_ptr<base::CallbackList<void(const std::set<GURL>&)>::Subscription> 96 content::WebContents* tab_with_exclusive_access_;
64 favicon_changed_subscription_;
65 97
66 base::WeakPtrFactory<NotificationServiceSessionsRouter> weak_ptr_factory_; 98 DISALLOW_COPY_AND_ASSIGN(ExclusiveAccessControllerBase);
67
68 DISALLOW_COPY_AND_ASSIGN(NotificationServiceSessionsRouter);
69 }; 99 };
70 100
71 } // namespace browser_sync 101 #endif // CHROME_BROWSER_UI_EXCLUSIVE_ACCESS_EXCLUSIVE_ACCESS_CONTROLLER_BASE_H _
72
73 #endif // CHROME_BROWSER_SYNC_SESSIONS_NOTIFICATION_SERVICE_SESSIONS_ROUTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698