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 CONTENT_BROWSER_HOST_ZOOM_LEVEL_CONTEXT_H_ 6 #define CONTENT_BROWSER_HOST_ZOOM_LEVEL_CONTEXT_H_ 7 8 #include <memory> 9 10 #include "base/macros.h" 11 #include "content/browser/host_zoom_map_impl.h" 12 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/zoom_level_delegate.h" 14 15 namespace content { 16 17 // This class manages a HostZoomMap and associates it with a ZoomLevelDelegate, 18 // if one is provided. It also serves to keep the zoom level machinery details 19 // separate from the owning StoragePartitionImpl. It must be destroyed on the 20 // UI thread. 21 class HostZoomLevelContext { 22 public: 23 explicit HostZoomLevelContext( 24 std::unique_ptr<ZoomLevelDelegate> zoom_level_delegate); 25 GetHostZoomMap()26 HostZoomMap* GetHostZoomMap() const { return host_zoom_map_impl_.get(); } GetZoomLevelDelegate()27 ZoomLevelDelegate* GetZoomLevelDelegate() const { 28 return zoom_level_delegate_.get(); 29 } 30 31 private: 32 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; 33 friend class base::DeleteHelper<HostZoomLevelContext>; 34 35 ~HostZoomLevelContext(); 36 37 std::unique_ptr<HostZoomMapImpl> host_zoom_map_impl_; 38 // Release the delegate before the HostZoomMap, in case it is carrying 39 // any HostZoomMap::Subscription pointers. 40 std::unique_ptr<ZoomLevelDelegate> zoom_level_delegate_; 41 42 DISALLOW_COPY_AND_ASSIGN(HostZoomLevelContext); 43 }; 44 45 } // namespace content 46 47 #endif // CONTENT_BROWSER_HOST_ZOOM_LEVEL_CONTEXT_H_ 48