| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ |
| 6 #define CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ | 6 #define CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/sequenced_task_runner_helpers.h" | 13 #include "base/sequenced_task_runner_helpers.h" |
| 14 #include "base/supports_user_data.h" | 14 #include "base/supports_user_data.h" |
| 15 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
| 16 #include "content/public/browser/host_zoom_map.h" | 16 #include "content/public/browser/host_zoom_map.h" |
| 17 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
| 18 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
| 19 | 19 |
| 20 namespace base { |
| 21 class DictionaryValue; |
| 22 } |
| 23 |
| 20 namespace content { | 24 namespace content { |
| 21 | 25 |
| 22 class WebContentsImpl; | 26 class WebContentsImpl; |
| 23 | 27 |
| 24 // HostZoomMap needs to be deleted on the UI thread because it listens | 28 // HostZoomMap needs to be deleted on the UI thread because it listens |
| 25 // to notifications on there (and holds a NotificationRegistrar). | 29 // to notifications on there (and holds a NotificationRegistrar). |
| 26 class CONTENT_EXPORT HostZoomMapImpl : public NON_EXPORTED_BASE(HostZoomMap), | 30 class CONTENT_EXPORT HostZoomMapImpl : public NON_EXPORTED_BASE(HostZoomMap), |
| 27 public NotificationObserver, | 31 public NotificationObserver { |
| 28 public base::SupportsUserData::Data { | |
| 29 public: | 32 public: |
| 30 HostZoomMapImpl(); | 33 explicit HostZoomMapImpl(double default_zoom_level); |
| 31 virtual ~HostZoomMapImpl(); | 34 virtual ~HostZoomMapImpl(); |
| 32 | 35 |
| 33 // HostZoomMap implementation: | 36 // HostZoomMap implementation: |
| 34 virtual void CopyFrom(HostZoomMap* copy) OVERRIDE; | 37 virtual void CopyFrom(HostZoomMap* copy) OVERRIDE; |
| 35 virtual double GetZoomLevelForHostAndScheme( | 38 virtual double GetZoomLevelForHostAndScheme( |
| 36 const std::string& scheme, | 39 const std::string& scheme, |
| 37 const std::string& host) const OVERRIDE; | 40 const std::string& host) const OVERRIDE; |
| 38 // TODO(wjmaclean) Should we use a GURL here? crbug.com/384486 | 41 // TODO(wjmaclean) Should we use a GURL here? crbug.com/384486 |
| 39 virtual bool HasZoomLevel(const std::string& scheme, | 42 virtual bool HasZoomLevel(const std::string& scheme, |
| 40 const std::string& host) const OVERRIDE; | 43 const std::string& host) const OVERRIDE; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 52 int render_view_id, | 55 int render_view_id, |
| 53 double level) OVERRIDE; | 56 double level) OVERRIDE; |
| 54 | 57 |
| 55 virtual void ClearTemporaryZoomLevel(int render_process_id, | 58 virtual void ClearTemporaryZoomLevel(int render_process_id, |
| 56 int render_view_id) OVERRIDE; | 59 int render_view_id) OVERRIDE; |
| 57 virtual double GetDefaultZoomLevel() const OVERRIDE; | 60 virtual double GetDefaultZoomLevel() const OVERRIDE; |
| 58 virtual void SetDefaultZoomLevel(double level) OVERRIDE; | 61 virtual void SetDefaultZoomLevel(double level) OVERRIDE; |
| 59 virtual scoped_ptr<Subscription> AddZoomLevelChangedCallback( | 62 virtual scoped_ptr<Subscription> AddZoomLevelChangedCallback( |
| 60 const ZoomLevelChangedCallback& callback) OVERRIDE; | 63 const ZoomLevelChangedCallback& callback) OVERRIDE; |
| 61 | 64 |
| 65 // Returns a dictionary of ZoomLevels. Schemes are stripped away, but |
| 66 // scheme+host zoom levels are included. Caller assumes ownership of the |
| 67 // returned pointer. |
| 68 // TODO(wjmaclean) Should we return an owned pointer here? |
| 69 scoped_ptr<base::DictionaryValue> ZoomLevelDictionary() const; |
| 70 |
| 62 // Returns the current zoom level for the specified WebContents. This may | 71 // Returns the current zoom level for the specified WebContents. This may |
| 63 // be a temporary zoom level, depending on UsesTemporaryZoomLevel(). | 72 // be a temporary zoom level, depending on UsesTemporaryZoomLevel(). |
| 64 double GetZoomLevelForWebContents( | 73 double GetZoomLevelForWebContents( |
| 65 const WebContentsImpl& web_contents_impl) const; | 74 const WebContentsImpl& web_contents_impl) const; |
| 66 | 75 |
| 67 // Sets the zoom level for this WebContents. If this WebContents is using | 76 // Sets the zoom level for this WebContents. If this WebContents is using |
| 68 // a temporary zoom level, then level is only applied to this WebContents. | 77 // a temporary zoom level, then level is only applied to this WebContents. |
| 69 // Otherwise, the level will be applied on a host level. | 78 // Otherwise, the level will be applied on a host level. |
| 70 void SetZoomLevelForWebContents(const WebContentsImpl& web_contents_impl, | 79 void SetZoomLevelForWebContents(const WebContentsImpl& web_contents_impl, |
| 71 double level); | 80 double level); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 mutable base::Lock lock_; | 145 mutable base::Lock lock_; |
| 137 | 146 |
| 138 NotificationRegistrar registrar_; | 147 NotificationRegistrar registrar_; |
| 139 | 148 |
| 140 DISALLOW_COPY_AND_ASSIGN(HostZoomMapImpl); | 149 DISALLOW_COPY_AND_ASSIGN(HostZoomMapImpl); |
| 141 }; | 150 }; |
| 142 | 151 |
| 143 } // namespace content | 152 } // namespace content |
| 144 | 153 |
| 145 #endif // CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ | 154 #endif // CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ |
| OLD | NEW |