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 #include "content/browser/host_zoom_map_impl.h" | 5 #include "content/browser/host_zoom_map_impl.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/strings/string_piece.h" | 9 #include "base/strings/string_piece.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 scheme_host_zoom_levels_.find(scheme)); | 77 scheme_host_zoom_levels_.find(scheme)); |
78 if (scheme_iterator != scheme_host_zoom_levels_.end()) { | 78 if (scheme_iterator != scheme_host_zoom_levels_.end()) { |
79 HostZoomLevels::const_iterator i(scheme_iterator->second.find(host)); | 79 HostZoomLevels::const_iterator i(scheme_iterator->second.find(host)); |
80 if (i != scheme_iterator->second.end()) | 80 if (i != scheme_iterator->second.end()) |
81 return i->second; | 81 return i->second; |
82 } | 82 } |
83 } | 83 } |
84 return GetZoomLevelForHost(host); | 84 return GetZoomLevelForHost(host); |
85 } | 85 } |
86 | 86 |
87 HostZoomMap::ZoomLevelVector HostZoomMapImpl::GetAllZoomLevels() const { | |
88 std::vector<HostZoomMap::ZoomLevelChange> result; | |
markusheintz_
2014/03/12 16:31:06
Can't you use HostZoomMap::ZoomLevelVector as typ
battre
2014/03/13 09:22:14
Done.
| |
89 { | |
90 base::AutoLock auto_lock(lock_); | |
91 result.reserve(host_zoom_levels_.size() + scheme_host_zoom_levels_.size()); | |
92 for (HostZoomLevels::const_iterator i = host_zoom_levels_.begin(); | |
93 i != host_zoom_levels_.end(); | |
94 ++i) { | |
95 ZoomLevelChange change = {HostZoomMap::ZOOM_CHANGED_FOR_HOST, | |
96 i->first, // host | |
97 std::string(), // scheme | |
98 i->second // zoom level | |
99 }; | |
100 result.push_back(change); | |
101 } | |
102 for (SchemeHostZoomLevels::const_iterator i = | |
103 scheme_host_zoom_levels_.begin(); | |
104 i != scheme_host_zoom_levels_.end(); | |
105 ++i) { | |
106 const std::string& scheme = i->first; | |
107 const HostZoomLevels& host_zoom_levels = i->second; | |
108 for (HostZoomLevels::const_iterator j = host_zoom_levels.begin(); | |
109 j != host_zoom_levels.end(); | |
110 ++j) { | |
111 ZoomLevelChange change = {HostZoomMap::ZOOM_CHANGED_FOR_SCHEME_AND_HOST, | |
112 j->first, // host | |
113 scheme, // scheme | |
114 j->second // zoom level | |
115 }; | |
116 result.push_back(change); | |
117 } | |
118 } | |
119 } | |
120 return result; | |
121 } | |
122 | |
87 void HostZoomMapImpl::SetZoomLevelForHost(const std::string& host, | 123 void HostZoomMapImpl::SetZoomLevelForHost(const std::string& host, |
88 double level) { | 124 double level) { |
89 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 125 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
90 | 126 |
91 { | 127 { |
92 base::AutoLock auto_lock(lock_); | 128 base::AutoLock auto_lock(lock_); |
93 | 129 |
94 if (ZoomValuesEqual(level, default_zoom_level_)) | 130 if (ZoomValuesEqual(level, default_zoom_level_)) |
95 host_zoom_levels_.erase(host); | 131 host_zoom_levels_.erase(host); |
96 else | 132 else |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
227 } | 263 } |
228 default: | 264 default: |
229 NOTREACHED() << "Unexpected preference observed."; | 265 NOTREACHED() << "Unexpected preference observed."; |
230 } | 266 } |
231 } | 267 } |
232 | 268 |
233 HostZoomMapImpl::~HostZoomMapImpl() { | 269 HostZoomMapImpl::~HostZoomMapImpl() { |
234 } | 270 } |
235 | 271 |
236 } // namespace content | 272 } // namespace content |
OLD | NEW |