OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 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_PUBLIC_BROWSER_HOST_ZOOM_MAP_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_HOST_ZOOM_MAP_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <map> |
| 10 #include <string> |
| 11 #include <vector> |
| 12 |
| 13 #include "base/basictypes.h" |
| 14 #include "base/memory/ref_counted.h" |
| 15 #include "content/common/content_export.h" |
| 16 #include "content/public/browser/browser_thread.h" |
| 17 |
| 18 namespace content { |
| 19 |
| 20 // Maps hostnames to custom zoom levels. Written on the UI thread and read on |
| 21 // any thread. One instance per browser context. Must be created on the UI |
| 22 // thread, and it'll delete itself on the UI thread as well. |
| 23 class HostZoomMap |
| 24 : public base::RefCountedThreadSafe< |
| 25 HostZoomMap, content::BrowserThread::DeleteOnUIThread> { |
| 26 public: |
| 27 CONTENT_EXPORT static HostZoomMap* Create(); |
| 28 |
| 29 // Copy the zoom levels from the given map. Can only be called on the UI |
| 30 // thread. |
| 31 virtual void CopyFrom(HostZoomMap* copy) = 0; |
| 32 |
| 33 // Returns the zoom level for the host or spec for a given url. The zoom |
| 34 // level is determined by the host portion of the URL, or (in the absence of |
| 35 // a host) the complete spec of the URL. In most cases, there is no custom |
| 36 // zoom level, and this returns the user's default zoom level. Otherwise, |
| 37 // returns the saved zoom level, which may be positive (to zoom in) or |
| 38 // negative (to zoom out). |
| 39 // |
| 40 // This may be called on any thread. |
| 41 virtual double GetZoomLevel(const std::string& host) const = 0; |
| 42 |
| 43 // Sets the zoom level for the host or spec for a given url to |level|. If |
| 44 // the level matches the current default zoom level, the host is erased |
| 45 // from the saved preferences; otherwise the new value is written out. |
| 46 // |
| 47 // This should only be called on the UI thread. |
| 48 virtual void SetZoomLevel(std::string host, double level) = 0; |
| 49 |
| 50 // Get/Set the default zoom level for pages that don't override it. |
| 51 virtual double GetDefaultZoomLevel() const = 0; |
| 52 virtual void SetDefaultZoomLevel(double level) = 0;; |
| 53 |
| 54 protected: |
| 55 virtual ~HostZoomMap() {} |
| 56 |
| 57 private: |
| 58 friend class base::RefCountedThreadSafe< |
| 59 HostZoomMap, content::BrowserThread::DeleteOnUIThread>; |
| 60 friend struct content::BrowserThread::DeleteOnThread< |
| 61 content::BrowserThread::UI>; |
| 62 friend class base::DeleteHelper<HostZoomMap>; |
| 63 }; |
| 64 |
| 65 } // namespace content |
| 66 |
| 67 #endif // CONTENT_PUBLIC_BROWSER_HOST_ZOOM_MAP_H_ |
OLD | NEW |