Chromium Code Reviews| 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 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 |
| 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 | 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 classes: |
| 38 // BrowserSessionProvider -> sync API model change application. | 38 |
| 39 // Control behavior when escape is pressed. | |
|
miu
2015/01/16 22:17:38
Add to comment, something like: Returns true if an
Sriram
2015/01/21 01:38:56
Done.
| |
| 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); | |
|
miu
2015/01/16 22:17:38
style: These three should be:
void Foo(...) ove
Sriram
2015/01/21 01:38:56
They are not callbacks but actual function calls.
miu
2015/01/22 00:47:15
OIC, these are not overriding a virtual method fro
| |
| 53 virtual void OnTabDetachedFromView(content::WebContents* web_contents); | |
| 54 virtual void OnTabClosing(content::WebContents* web_contents); | |
| 55 | |
| 56 // content::NotificationObserver to detect page navigation and exit exclusive | |
| 57 // access. | |
| 39 void Observe(int type, | 58 void Observe(int type, |
| 40 const content::NotificationSource& source, | 59 const content::NotificationSource& source, |
| 41 const content::NotificationDetails& details) override; | 60 const content::NotificationDetails& details) override; |
| 42 | 61 |
| 43 // SessionsSyncManager::LocalEventRouter implementation. | 62 protected: |
| 44 void StartRoutingTo(LocalSessionEventHandler* handler) override; | 63 void SetTabWithExclusiveAccess(content::WebContents* tab); |
| 45 void Stop() override; | 64 ExclusiveAccessManager* GetManager() const; |
| 65 Browser* GetBrowser() const; | |
|
miu
2015/01/16 22:17:38
IMO, you should inline these getters since they ju
Sriram
2015/01/21 01:38:57
Done.
| |
| 66 Profile* GetProfile() const; | |
| 67 BrowserWindow* GetWindow() const; | |
| 68 | |
| 69 // Make the current tab exit exclusive access mode if it is in it. | |
| 70 virtual void ExitExclusiveAccessIfNecessary() = 0; | |
| 71 | |
| 72 // Notifies the tab that it has been forced out of exclusive access mode | |
| 73 // if necessary. | |
| 74 virtual void NotifyTabOfExclusiveAccessChange() = 0; | |
| 46 | 75 |
| 47 private: | 76 private: |
| 48 // Called when the URL visited in |web_contents| was blocked by the | 77 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 | 78 |
| 55 // Called when the urls of favicon changed. | 79 ExclusiveAccessManager* manager_; |
|
miu
2015/01/16 22:17:38
This can be const too.
Sriram
2015/01/21 01:38:56
Done.
| |
| 56 void OnFaviconChanged(const std::set<GURL>& changed_favicons); | 80 Browser* const browser_; |
| 81 BrowserWindow* const window_; | |
|
miu
2015/01/16 22:17:38
Is the window_ member necessary? Code can always
Sriram
2015/01/21 01:38:56
Done.
| |
| 82 Profile* const profile_; | |
| 57 | 83 |
| 58 LocalSessionEventHandler* handler_; | |
| 59 content::NotificationRegistrar registrar_; | 84 content::NotificationRegistrar registrar_; |
| 60 Profile* const profile_; | |
| 61 syncer::SyncableService::StartSyncFlare flare_; | |
| 62 | 85 |
| 63 scoped_ptr<base::CallbackList<void(const std::set<GURL>&)>::Subscription> | 86 content::WebContents* tab_with_exclusive_access_; |
| 64 favicon_changed_subscription_; | |
| 65 | 87 |
| 66 base::WeakPtrFactory<NotificationServiceSessionsRouter> weak_ptr_factory_; | 88 DISALLOW_COPY_AND_ASSIGN(ExclusiveAccessControllerBase); |
| 67 | |
| 68 DISALLOW_COPY_AND_ASSIGN(NotificationServiceSessionsRouter); | |
| 69 }; | 89 }; |
| 70 | 90 |
| 71 } // namespace browser_sync | 91 #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 |