OLD | NEW |
---|---|
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 ExclusiveAccessControllerManager; | |
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 // Base class for different exclusive_access controller class that implements |
scheib
2015/01/14 22:37:59
Later readers will be fairly confused by what "Exc
Sriram
2015/01/15 00:34:28
Done.
| |
25 // common behaviours. | |
26 class ExclusiveAccessControllerBase : public content::NotificationObserver { | |
27 public: | |
28 explicit ExclusiveAccessControllerBase( | |
29 ExclusiveAccessControllerManager* 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 | 35 content::WebContents* GetExclusiveAccessTab() const; |
29 : public LocalSessionEventRouter, | |
30 public content::NotificationObserver { | |
31 public: | |
32 NotificationServiceSessionsRouter( | |
33 Profile* profile, | |
34 const syncer::SyncableService::StartSyncFlare& flare); | |
35 ~NotificationServiceSessionsRouter() override; | |
36 | 36 |
37 // content::NotificationObserver implementation. | 37 // Functions implemented by derived class: |
38 // BrowserSessionProvider -> sync API model change application. | 38 |
39 // Control behavior when escape is pressed. | |
40 virtual bool HandleUserPressedEscape() = 0; | |
41 | |
42 // Called by Browser in response to call from ExclusiveAccessBubble. | |
43 virtual void ExitExclusiveAccessToPreviousState() = 0; | |
44 | |
45 // Return true if bubble content should be updated. | |
46 virtual bool OnAcceptExclusiveAccessPermission() = 0; | |
47 | |
48 // Return true if bubble content should be updated. | |
49 virtual bool OnDenyExclusiveAccessPermission() = 0; | |
50 | |
51 // Callbacks //////////////////////////////////////////////////////////////// | |
52 virtual void OnTabDeactivated(content::WebContents* web_contents); | |
53 virtual void OnTabDetachedFromView(content::WebContents* web_contents); | |
54 virtual void OnTabClosing(content::WebContents* web_contents); | |
55 | |
56 // content::NotificationObserver: | |
scheib
2015/01/14 22:37:59
Might as well explain why:
content:NotificationObs
Sriram
2015/01/15 00:34:28
Done.
| |
39 void Observe(int type, | 57 void Observe(int type, |
40 const content::NotificationSource& source, | 58 const content::NotificationSource& source, |
41 const content::NotificationDetails& details) override; | 59 const content::NotificationDetails& details) override; |
42 | 60 |
43 // SessionsSyncManager::LocalEventRouter implementation. | 61 protected: |
44 void StartRoutingTo(LocalSessionEventHandler* handler) override; | 62 void SetTabWithExclusiveAccess(content::WebContents* tab); |
45 void Stop() override; | 63 ExclusiveAccessControllerManager* GetManager() const; |
64 Browser* GetBrowser() const; | |
65 Profile* GetProfile() const; | |
66 BrowserWindow* GetWindow() const; | |
67 | |
68 void UpdateExclusiveAccessExitBubbleContent(); | |
69 ExclusiveAccessBubbleType GetExclusiveAccessExitBubbleType(); | |
70 | |
71 // Make the current tab exit exclusive access mode if it is in it. | |
72 virtual void ExitExclusiveAccessIfNecessary() = 0; | |
73 | |
74 // Notifies the tab that it has been forced out of exclusive access mode | |
75 // if necessary. | |
76 virtual void NotifyTabOfExclusiveAccessChange() = 0; | |
46 | 77 |
47 private: | 78 private: |
48 // Called when the URL visited in |web_contents| was blocked by the | 79 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 | 80 |
55 // Called when the urls of favicon changed. | 81 ExclusiveAccessControllerManager* manager_; |
56 void OnFaviconChanged(const std::set<GURL>& changed_favicons); | 82 Browser* const browser_; |
83 BrowserWindow* const window_; | |
84 Profile* const profile_; | |
57 | 85 |
58 LocalSessionEventHandler* handler_; | |
59 content::NotificationRegistrar registrar_; | 86 content::NotificationRegistrar registrar_; |
60 Profile* const profile_; | |
61 syncer::SyncableService::StartSyncFlare flare_; | |
62 | 87 |
63 scoped_ptr<base::CallbackList<void(const std::set<GURL>&)>::Subscription> | 88 content::WebContents* tab_with_exclusive_access_; |
64 favicon_changed_subscription_; | |
65 | 89 |
66 base::WeakPtrFactory<NotificationServiceSessionsRouter> weak_ptr_factory_; | 90 DISALLOW_COPY_AND_ASSIGN(ExclusiveAccessControllerBase); |
67 | |
68 DISALLOW_COPY_AND_ASSIGN(NotificationServiceSessionsRouter); | |
69 }; | 91 }; |
70 | 92 |
71 } // namespace browser_sync | 93 #endif // CHROME_BROWSER_UI_EXCLUSIVE_ACCESS_EXCLUSIVE_ACCESS_CONTROLLER_BASE_H _ |
72 | |
73 #endif // CHROME_BROWSER_SYNC_SESSIONS_NOTIFICATION_SERVICE_SESSIONS_ROUTER_H_ | |
OLD | NEW |