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

Side by Side Diff: content/browser/host_zoom_map_impl.h

Issue 11866004: Add scheme to HostZoomMap (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix Nikita's comments 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
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_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>
(...skipping 14 matching lines...) Expand all
25 public NotificationObserver, 25 public NotificationObserver,
26 public base::SupportsUserData::Data { 26 public base::SupportsUserData::Data {
27 public: 27 public:
28 HostZoomMapImpl(); 28 HostZoomMapImpl();
29 virtual ~HostZoomMapImpl(); 29 virtual ~HostZoomMapImpl();
30 30
31 // HostZoomMap implementation: 31 // HostZoomMap implementation:
32 virtual void CopyFrom(HostZoomMap* copy) OVERRIDE; 32 virtual void CopyFrom(HostZoomMap* copy) OVERRIDE;
33 virtual double GetZoomLevel(const std::string& host) const OVERRIDE; 33 virtual double GetZoomLevel(const std::string& host) const OVERRIDE;
34 virtual void SetZoomLevel(const std::string& host, double level) OVERRIDE; 34 virtual void SetZoomLevel(const std::string& host, double level) OVERRIDE;
35 virtual double GetZoomLevel(const std::string& scheme,
Jói 2013/01/11 17:41:09 Order these the same as in HostZoomMap.
Denis Kuznetsov (DE-MUC) 2013/01/17 13:23:47 Done.
36 const std::string& host) const OVERRIDE;
37 virtual void SetZoomLevel(const std::string& scheme,
38 const std::string& host,
39 double level) OVERRIDE;
35 virtual double GetDefaultZoomLevel() const OVERRIDE; 40 virtual double GetDefaultZoomLevel() const OVERRIDE;
36 virtual void SetDefaultZoomLevel(double level) OVERRIDE; 41 virtual void SetDefaultZoomLevel(double level) OVERRIDE;
37 42
38 // Returns the temporary zoom level that's only valid for the lifetime of 43 // Returns the temporary zoom level that's only valid for the lifetime of
39 // the given WebContents (i.e. isn't saved and doesn't affect other 44 // the given WebContents (i.e. isn't saved and doesn't affect other
40 // WebContentses) if it exists, the default zoom level otherwise. 45 // WebContentses) if it exists, the default zoom level otherwise.
41 // 46 //
42 // This may be called on any thread. 47 // This may be called on any thread.
43 double GetTemporaryZoomLevel(int render_process_id, 48 double GetTemporaryZoomLevel(int render_process_id,
44 int render_view_id) const; 49 int render_view_id) const;
45 50
46 // Sets the temporary zoom level that's only valid for the lifetime of this 51 // Sets the temporary zoom level that's only valid for the lifetime of this
47 // WebContents. 52 // WebContents.
48 // 53 //
49 // This should only be called on the UI thread. 54 // This should only be called on the UI thread.
50 void SetTemporaryZoomLevel(int render_process_id, 55 void SetTemporaryZoomLevel(int render_process_id,
51 int render_view_id, 56 int render_view_id,
52 double level); 57 double level);
53 58
54 // NotificationObserver implementation. 59 // NotificationObserver implementation.
55 virtual void Observe(int type, 60 virtual void Observe(int type,
56 const NotificationSource& source, 61 const NotificationSource& source,
57 const NotificationDetails& details) OVERRIDE; 62 const NotificationDetails& details) OVERRIDE;
58 63
59 private: 64 private:
60 typedef std::map<std::string, double> HostZoomLevels; 65 typedef std::map<std::string, double> HostZoomLevels;
66 typedef std::map<std::string, HostZoomLevels> SchemeHostZoomLevels;
61 67
62 // Copy of the pref data, so that we can read it on the IO thread. 68 // Copy of the pref data, so that we can read it on the IO thread.
63 HostZoomLevels host_zoom_levels_; 69 HostZoomLevels host_zoom_levels_;
70 SchemeHostZoomLevels scheme_host_zoom_levels_;
64 double default_zoom_level_; 71 double default_zoom_level_;
65 72
66 struct TemporaryZoomLevel { 73 struct TemporaryZoomLevel {
67 int render_process_id; 74 int render_process_id;
68 int render_view_id; 75 int render_view_id;
69 double zoom_level; 76 double zoom_level;
70 }; 77 };
71 78
72 // Don't expect more than a couple of tabs that are using a temporary zoom 79 // Don't expect more than a couple of tabs that are using a temporary zoom
73 // level, so vector is fine for now. 80 // level, so vector is fine for now.
74 std::vector<TemporaryZoomLevel> temporary_zoom_levels_; 81 std::vector<TemporaryZoomLevel> temporary_zoom_levels_;
75 82
76 // Used around accesses to |host_zoom_levels_|, |default_zoom_level_| and 83 // Used around accesses to |host_zoom_levels_|, |default_zoom_level_| and
77 // |temporary_zoom_levels_| to guarantee thread safety. 84 // |temporary_zoom_levels_| to guarantee thread safety.
78 mutable base::Lock lock_; 85 mutable base::Lock lock_;
79 86
80 NotificationRegistrar registrar_; 87 NotificationRegistrar registrar_;
81 88
89 void CopyHostZoomLevels(const HostZoomLevels &source,
sky 2013/01/11 20:33:32 & close to type, and HostZoomLevels should be a *
90 HostZoomLevels &dest);
91
92
sky 2013/01/11 20:33:32 nit: only one newline here.
Denis Kuznetsov (DE-MUC) 2013/01/17 13:23:47 Done.
82 DISALLOW_COPY_AND_ASSIGN(HostZoomMapImpl); 93 DISALLOW_COPY_AND_ASSIGN(HostZoomMapImpl);
83 }; 94 };
84 95
85 } // namespace content 96 } // namespace content
86 97
87 #endif // CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ 98 #endif // CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698