Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: content/public/browser/host_zoom_map.h

Issue 12039058: content: convert zoom notifications to observer usage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/content_browser.gypi ('k') | content/public/browser/host_zoom_map.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/common/content_export.h" 13 #include "content/common/content_export.h"
14 14
15 namespace content { 15 namespace content {
16 16
17 class BrowserContext; 17 class BrowserContext;
18 class HostZoomMapImpl;
18 class ResourceContext; 19 class ResourceContext;
19 20
20 // Maps hostnames to custom zoom levels. Written on the UI thread and read on 21 // 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 // 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 // thread, and it'll delete itself on the UI thread as well.
23 class HostZoomMap { 24 class HostZoomMap {
24 public: 25 public:
25 CONTENT_EXPORT static HostZoomMap* GetForBrowserContext( 26 CONTENT_EXPORT static HostZoomMap* GetForBrowserContext(
26 BrowserContext* browser_context); 27 BrowserContext* browser_context);
27 28
29 class Observer {
jam 2013/01/24 01:28:35 nit: per c++ style guide, and convention, prefer t
Paweł Hajdan Jr. 2013/01/24 19:42:38 Done.
30 public:
31 Observer();
32 explicit Observer(HostZoomMap* map);
33 virtual ~Observer();
34
35 // Called when the zoom level changes. |host| is a string of the hostname
36 // for which the zoom changed (empty string for temporary changes).
37 virtual void OnZoomLevelChanged(const std::string& host) = 0;
38
39 protected:
40 void Observe(HostZoomMap* map);
41
42 private:
43 friend class HostZoomMapImpl;
44
45 void HostZoomMapImplDestroyed();
46
47 HostZoomMapImpl* host_zoom_map_;
48
49 DISALLOW_COPY_AND_ASSIGN(Observer);
50 };
51
28 // Copy the zoom levels from the given map. Can only be called on the UI 52 // Copy the zoom levels from the given map. Can only be called on the UI
29 // thread. 53 // thread.
30 virtual void CopyFrom(HostZoomMap* copy) = 0; 54 virtual void CopyFrom(HostZoomMap* copy) = 0;
31 55
32 // Returns the zoom level for the host or spec for a given url. The zoom 56 // Returns the zoom level for the host or spec for a given url. The zoom
33 // level is determined by the host portion of the URL, or (in the absence of 57 // level is determined by the host portion of the URL, or (in the absence of
34 // a host) the complete spec of the URL. In most cases, there is no custom 58 // a host) the complete spec of the URL. In most cases, there is no custom
35 // zoom level, and this returns the user's default zoom level. Otherwise, 59 // zoom level, and this returns the user's default zoom level. Otherwise,
36 // returns the saved zoom level, which may be positive (to zoom in) or 60 // returns the saved zoom level, which may be positive (to zoom in) or
37 // negative (to zoom out). 61 // negative (to zoom out).
(...skipping 12 matching lines...) Expand all
50 virtual double GetDefaultZoomLevel() const = 0; 74 virtual double GetDefaultZoomLevel() const = 0;
51 virtual void SetDefaultZoomLevel(double level) = 0;; 75 virtual void SetDefaultZoomLevel(double level) = 0;;
52 76
53 protected: 77 protected:
54 virtual ~HostZoomMap() {} 78 virtual ~HostZoomMap() {}
55 }; 79 };
56 80
57 } // namespace content 81 } // namespace content
58 82
59 #endif // CONTENT_PUBLIC_BROWSER_HOST_ZOOM_MAP_H_ 83 #endif // CONTENT_PUBLIC_BROWSER_HOST_ZOOM_MAP_H_
OLDNEW
« no previous file with comments | « content/content_browser.gypi ('k') | content/public/browser/host_zoom_map.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698