Chromium Code Reviews| 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_PUBLIC_BROWSER_HOST_ZOOM_MAP_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_HOST_ZOOM_MAP_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_HOST_ZOOM_MAP_H_ | 6 #define CONTENT_PUBLIC_BROWSER_HOST_ZOOM_MAP_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/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/callback_list.h" | 14 #include "base/callback_list.h" |
| 15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
| 16 #include "url/gurl.h" | |
| 16 | 17 |
| 17 namespace content { | 18 namespace content { |
| 18 | 19 |
| 20 class NavigationEntry; | |
| 19 class BrowserContext; | 21 class BrowserContext; |
| 20 class ResourceContext; | 22 class ResourceContext; |
| 21 class WebContents; | 23 class WebContents; |
| 22 | 24 |
| 23 // Maps hostnames to custom zoom levels. Written on the UI thread and read on | 25 // Maps hostnames to custom zoom levels. Written on the UI thread and read on |
| 24 // any thread. One instance per browser context. Must be created on the UI | 26 // any thread. One instance per browser context. Must be created on the UI |
| 25 // thread, and it'll delete itself on the UI thread as well. | 27 // thread, and it'll delete itself on the UI thread as well. |
| 26 // Zoom can be defined at three levels: default zoom, zoom for host, and zoom | 28 // Zoom can be defined at three levels: default zoom, zoom for host, and zoom |
| 27 // for host with specific scheme. Setting any of the levels leaves settings | 29 // for host with specific scheme. Setting any of the levels leaves settings |
| 28 // for other settings intact. Getting the zoom level starts at the most | 30 // for other settings intact. Getting the zoom level starts at the most |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 45 // if not applicable to |mode|. | 47 // if not applicable to |mode|. |
| 46 struct ZoomLevelChange { | 48 struct ZoomLevelChange { |
| 47 ZoomLevelChangeMode mode; | 49 ZoomLevelChangeMode mode; |
| 48 std::string host; | 50 std::string host; |
| 49 std::string scheme; | 51 std::string scheme; |
| 50 double zoom_level; | 52 double zoom_level; |
| 51 }; | 53 }; |
| 52 | 54 |
| 53 typedef std::vector<ZoomLevelChange> ZoomLevelVector; | 55 typedef std::vector<ZoomLevelChange> ZoomLevelVector; |
| 54 | 56 |
| 57 CONTENT_EXPORT static GURL GetURLFromEntry(const NavigationEntry*); | |
|
Charlie Reis
2014/10/28 16:36:22
nit: Always name parameters.
Also add a comment h
wjmaclean
2014/10/28 17:37:04
Done.
| |
| 58 | |
| 55 CONTENT_EXPORT static HostZoomMap* GetDefaultForBrowserContext( | 59 CONTENT_EXPORT static HostZoomMap* GetDefaultForBrowserContext( |
| 56 BrowserContext* browser_context); | 60 BrowserContext* browser_context); |
| 57 | 61 |
| 58 // Returns the current zoom level for the specified WebContents. May be | 62 // Returns the current zoom level for the specified WebContents. May be |
| 59 // temporary or host-specific. | 63 // temporary or host-specific. |
| 60 CONTENT_EXPORT static double GetZoomLevel(const WebContents* web_contents); | 64 CONTENT_EXPORT static double GetZoomLevel(const WebContents* web_contents); |
| 61 | 65 |
| 62 // Sets the current zoom level for the specified WebContents. The level may | 66 // Sets the current zoom level for the specified WebContents. The level may |
| 63 // be temporary or host-specific depending on the particular WebContents. | 67 // be temporary or host-specific depending on the particular WebContents. |
| 64 CONTENT_EXPORT static void SetZoomLevel(const WebContents* web_contents, | 68 CONTENT_EXPORT static void SetZoomLevel(const WebContents* web_contents, |
| 65 double level); | 69 double level); |
| 66 | 70 |
| 71 // Send an IPC to refresh any displayed error page's zoom levels. Needs to | |
| 72 // be called since error pages don't get loaded via the normal channel. | |
| 73 CONTENT_EXPORT static void SendErrorPageZoomLevelRefresh( | |
|
Charlie Reis
2014/10/28 16:36:22
This doesn't appear to be called outside of conten
wjmaclean
2014/10/28 17:37:04
With the moving of the code out of NavigationContr
| |
| 74 const WebContents* web_contents); | |
| 75 | |
| 67 // Copy the zoom levels from the given map. Can only be called on the UI | 76 // Copy the zoom levels from the given map. Can only be called on the UI |
| 68 // thread. | 77 // thread. |
| 69 virtual void CopyFrom(HostZoomMap* copy) = 0; | 78 virtual void CopyFrom(HostZoomMap* copy) = 0; |
| 70 | 79 |
| 71 // Here |host| is the host portion of URL, or (in the absence of a host) | 80 // Here |host| is the host portion of URL, or (in the absence of a host) |
| 72 // the complete spec of the URL. | 81 // the complete spec of the URL. |
| 73 // Returns the zoom for the specified |scheme| and |host|. See class | 82 // Returns the zoom for the specified |scheme| and |host|. See class |
| 74 // description for details. | 83 // description for details. |
| 75 // | 84 // |
| 76 // This may be called on any thread. | 85 // This may be called on any thread. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 virtual scoped_ptr<Subscription> AddZoomLevelChangedCallback( | 148 virtual scoped_ptr<Subscription> AddZoomLevelChangedCallback( |
| 140 const ZoomLevelChangedCallback& callback) = 0; | 149 const ZoomLevelChangedCallback& callback) = 0; |
| 141 | 150 |
| 142 protected: | 151 protected: |
| 143 virtual ~HostZoomMap() {} | 152 virtual ~HostZoomMap() {} |
| 144 }; | 153 }; |
| 145 | 154 |
| 146 } // namespace content | 155 } // namespace content |
| 147 | 156 |
| 148 #endif // CONTENT_PUBLIC_BROWSER_HOST_ZOOM_MAP_H_ | 157 #endif // CONTENT_PUBLIC_BROWSER_HOST_ZOOM_MAP_H_ |
| OLD | NEW |