OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <cmath> | 5 #include <cmath> |
6 | 6 |
7 #include "content/browser/host_zoom_map.h" | 7 #include "content/browser/host_zoom_map.h" |
8 | 8 |
9 #include "base/string_piece.h" | 9 #include "base/string_piece.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "content/browser/renderer_host/render_process_host.h" | 12 #include "content/browser/renderer_host/render_process_host.h" |
13 #include "content/browser/renderer_host/render_view_host.h" | 13 #include "content/browser/renderer_host/render_view_host.h" |
14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
15 #include "content/public/browser/notification_service.h" | 15 #include "content/public/browser/notification_service.h" |
16 #include "content/public/browser/notification_types.h" | 16 #include "content/public/browser/notification_types.h" |
| 17 #include "content/public/common/page_zoom.h" |
17 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
18 #include "net/base/net_util.h" | 19 #include "net/base/net_util.h" |
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
20 | 21 |
21 using content::BrowserThread; | 22 using content::BrowserThread; |
22 using WebKit::WebView; | 23 using WebKit::WebView; |
23 | 24 |
24 HostZoomMap::HostZoomMap() | 25 HostZoomMap::HostZoomMap() |
25 : default_zoom_level_(0.0), | 26 : default_zoom_level_(0.0), |
26 original_(this) { | 27 original_(this) { |
(...skipping 22 matching lines...) Expand all Loading... |
49 base::AutoLock auto_lock(lock_); | 50 base::AutoLock auto_lock(lock_); |
50 HostZoomLevels::const_iterator i(host_zoom_levels_.find(host)); | 51 HostZoomLevels::const_iterator i(host_zoom_levels_.find(host)); |
51 return (i == host_zoom_levels_.end()) ? default_zoom_level_ : i->second; | 52 return (i == host_zoom_levels_.end()) ? default_zoom_level_ : i->second; |
52 } | 53 } |
53 | 54 |
54 void HostZoomMap::SetZoomLevel(std::string host, double level) { | 55 void HostZoomMap::SetZoomLevel(std::string host, double level) { |
55 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 56 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
56 | 57 |
57 { | 58 { |
58 base::AutoLock auto_lock(lock_); | 59 base::AutoLock auto_lock(lock_); |
59 if (level == default_zoom_level_) | 60 |
| 61 if (content::ZoomValuesEqual(level, default_zoom_level_)) |
60 host_zoom_levels_.erase(host); | 62 host_zoom_levels_.erase(host); |
61 else | 63 else |
62 host_zoom_levels_[host] = level; | 64 host_zoom_levels_[host] = level; |
63 } | 65 } |
64 | 66 |
65 content::NotificationService::current()->Notify( | 67 content::NotificationService::current()->Notify( |
66 content::NOTIFICATION_ZOOM_LEVEL_CHANGED, | 68 content::NOTIFICATION_ZOOM_LEVEL_CHANGED, |
67 content::Source<HostZoomMap>(this), | 69 content::Source<HostZoomMap>(this), |
68 content::Details<const std::string>(&host)); | 70 content::Details<const std::string>(&host)); |
69 } | 71 } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 } | 141 } |
140 break; | 142 break; |
141 } | 143 } |
142 default: | 144 default: |
143 NOTREACHED() << "Unexpected preference observed."; | 145 NOTREACHED() << "Unexpected preference observed."; |
144 } | 146 } |
145 } | 147 } |
146 | 148 |
147 HostZoomMap::~HostZoomMap() { | 149 HostZoomMap::~HostZoomMap() { |
148 } | 150 } |
OLD | NEW |