| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_ZOOM_ZOOM_EVENT_MANAGER_H_ | |
| 6 #define CHROME_BROWSER_UI_ZOOM_ZOOM_EVENT_MANAGER_H_ | |
| 7 | |
| 8 #include "base/callback_list.h" | |
| 9 #include "base/memory/weak_ptr.h" | |
| 10 #include "base/supports_user_data.h" | |
| 11 #include "content/public/browser/host_zoom_map.h" | |
| 12 | |
| 13 namespace content { | |
| 14 class BrowserContext; | |
| 15 } // namespace content | |
| 16 | |
| 17 // This class serves as a target for event notifications from all ZoomController | |
| 18 // objects. Classes that need to know about browser-specific zoom events (e.g. | |
| 19 // manual-mode zoom) should subscribe here. | |
| 20 class ZoomEventManager : public base::SupportsUserData::Data { | |
| 21 public: | |
| 22 ZoomEventManager(); | |
| 23 ~ZoomEventManager() override; | |
| 24 | |
| 25 // Returns the ZoomEventManager for the specified BrowserContext. This | |
| 26 // function creates the ZoomEventManager if it hasn't been created already. | |
| 27 static ZoomEventManager* GetForBrowserContext( | |
| 28 content::BrowserContext* context); | |
| 29 | |
| 30 // Called by ZoomControllers when changes are made to zoom levels in manual | |
| 31 // mode in order that browser listeners can be notified. | |
| 32 void OnZoomLevelChanged(const content::HostZoomMap::ZoomLevelChange& change); | |
| 33 | |
| 34 // Add and remove zoom level changed callbacks. | |
| 35 scoped_ptr<content::HostZoomMap::Subscription> AddZoomLevelChangedCallback( | |
| 36 const content::HostZoomMap::ZoomLevelChangedCallback& callback); | |
| 37 | |
| 38 // Get a weak ptr to be used by clients who may themselves be UserData for | |
| 39 // the context, since the order of destruction is undefined between the client | |
| 40 // and this class. | |
| 41 base::WeakPtr<ZoomEventManager> GetWeakPtr() { | |
| 42 return weak_ptr_factory_.GetWeakPtr(); | |
| 43 } | |
| 44 | |
| 45 private: | |
| 46 base::CallbackList<void(const content::HostZoomMap::ZoomLevelChange&)> | |
| 47 zoom_level_changed_callbacks_; | |
| 48 base::WeakPtrFactory<ZoomEventManager> weak_ptr_factory_; | |
| 49 | |
| 50 DISALLOW_COPY_AND_ASSIGN(ZoomEventManager); | |
| 51 }; | |
| 52 | |
| 53 #endif // CHROME_BROWSER_UI_ZOOM_ZOOM_EVENT_MANAGER_H_ | |
| OLD | NEW |