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

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: Fix mac build break after rebase 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 controller like the
scheib 2015/01/22 22:54:04 controller -> controllers
Sriram 2015/01/23 07:13:43 Done.
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 // Return true if bubble content should be updated.
scheib 2015/01/22 22:54:04 Return -> Returns http://google-styleguide.googl
Sriram 2015/01/23 07:13:43 Done.
49 virtual bool OnAcceptExclusiveAccessPermission() = 0;
50
51 // Return true if bubble content should be updated.
52 virtual bool OnDenyExclusiveAccessPermission() = 0;
53
54 // Called by ExclusiveAccessManager in response to calls from Browser.
55 virtual void OnTabDeactivated(content::WebContents* web_contents);
56 virtual void OnTabDetachedFromView(content::WebContents* web_contents);
57 virtual void OnTabClosing(content::WebContents* web_contents);
58
59 // Callbacks ////////////////////////////////////////////////////////////////
60
61 // content::NotificationObserver to detect page navigation and exit exclusive
62 // access.
39 void Observe(int type, 63 void Observe(int type,
40 const content::NotificationSource& source, 64 const content::NotificationSource& source,
41 const content::NotificationDetails& details) override; 65 const content::NotificationDetails& details) override;
42 66
43 // SessionsSyncManager::LocalEventRouter implementation. 67 protected:
44 void StartRoutingTo(LocalSessionEventHandler* handler) override; 68 void SetTabWithExclusiveAccess(content::WebContents* tab);
45 void Stop() override; 69
70 ExclusiveAccessManager* exclusive_access_manager() const { return manager_; }
71
72 Browser* browser() const { return browser_; }
73
74 Profile* profile() const { return profile_; }
75
76 // Make the current tab exit exclusive access mode if it is in it.
scheib 2015/01/22 22:54:04 (Descriptive vs Imperative) // Exits exclusive acc
Sriram 2015/01/23 07:13:43 Done.
77 virtual void ExitExclusiveAccessIfNecessary() = 0;
78
79 // Notifies the tab that it has been forced out of exclusive access mode
80 // if necessary.
81 virtual void NotifyTabOfExclusiveAccessChange() = 0;
scheib 2015/01/22 22:54:04 The implementations are for exiting exclusive acce
Sriram 2015/01/23 07:13:43 Done.
46 82
47 private: 83 private:
48 // Called when the URL visited in |web_contents| was blocked by the 84 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 85
55 // Called when the urls of favicon changed. 86 ExclusiveAccessManager* const manager_;
56 void OnFaviconChanged(const std::set<GURL>& changed_favicons); 87 Browser* const browser_;
88 Profile* const profile_;
57 89
58 LocalSessionEventHandler* handler_;
59 content::NotificationRegistrar registrar_; 90 content::NotificationRegistrar registrar_;
60 Profile* const profile_;
61 syncer::SyncableService::StartSyncFlare flare_;
62 91
63 scoped_ptr<base::CallbackList<void(const std::set<GURL>&)>::Subscription> 92 content::WebContents* tab_with_exclusive_access_;
64 favicon_changed_subscription_;
65 93
66 base::WeakPtrFactory<NotificationServiceSessionsRouter> weak_ptr_factory_; 94 DISALLOW_COPY_AND_ASSIGN(ExclusiveAccessControllerBase);
67
68 DISALLOW_COPY_AND_ASSIGN(NotificationServiceSessionsRouter);
69 }; 95 };
70 96
71 } // namespace browser_sync 97 #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