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

Side by Side Diff: chrome/browser/host_zoom_map.h

Issue 437077: Remember zoom on a per-host basis.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years 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 | « chrome/browser/browser_prefs.cc ('k') | chrome/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')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2009 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 // Maps hostnames to custom zoom levels. Written on the UI thread and read on
6 // the IO thread. One instance per profile.
7
8 #ifndef CHROME_BROWSER_HOST_ZOOM_MAP_H_
9 #define CHROME_BROWSER_HOST_ZOOM_MAP_H_
10
11 #include <map>
12 #include <string>
13
14 #include "base/basictypes.h"
15 #include "base/lock.h"
16 #include "base/ref_counted.h"
17
18 class PrefService;
19 class Profile;
20
21 class HostZoomMap : public base::RefCountedThreadSafe<HostZoomMap> {
22 public:
23 explicit HostZoomMap(Profile* profile);
24
25 static void RegisterUserPrefs(PrefService* prefs);
26
27 // Returns the zoom level for a given hostname. In most cases, there is no
28 // custom zoom level, and this returns 0. Otherwise, returns the saved zoom
29 // level, which may be positive (to zoom in) or negative (to zoom out).
30 //
31 // This may be called on any thread.
32 int GetZoomLevel(const std::string& host) const;
33
34 // Sets the zoom level for a given hostname to |level|. If the level is 0,
35 // the host is erased from the saved preferences; otherwise the new value is
36 // written out.
37 //
38 // This should only be called on the UI thread.
39 void SetZoomLevel(const std::string& host, int level);
40
41 private:
42 friend class base::RefCountedThreadSafe<HostZoomMap>;
43
44 typedef std::map<std::string, int> HostZoomLevels;
45
46 ~HostZoomMap();
47
48 // The profile we're associated with.
49 Profile* profile_;
50
51 // Copy of the pref data, so that we can read it on the IO thread.
52 HostZoomLevels host_zoom_levels_;
53
54 // Used around accesses to |host_zoom_levels_| to guarantee thread safety.
55 mutable Lock lock_;
56
57 DISALLOW_COPY_AND_ASSIGN(HostZoomMap);
58 };
59
60 #endif // CHROME_BROWSER_HOST_ZOOM_MAP_H_
OLDNEW
« no previous file with comments | « chrome/browser/browser_prefs.cc ('k') | chrome/browser/host_zoom_map.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698