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 <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 for (SchemeHostZoomLevels::const_iterator i(copy-> | 136 for (SchemeHostZoomLevels::const_iterator i(copy-> |
137 scheme_host_zoom_levels_.begin()); | 137 scheme_host_zoom_levels_.begin()); |
138 i != copy->scheme_host_zoom_levels_.end(); ++i) { | 138 i != copy->scheme_host_zoom_levels_.end(); ++i) { |
139 scheme_host_zoom_levels_[i->first] = HostZoomLevels(); | 139 scheme_host_zoom_levels_[i->first] = HostZoomLevels(); |
140 scheme_host_zoom_levels_[i->first]. | 140 scheme_host_zoom_levels_[i->first]. |
141 insert(i->second.begin(), i->second.end()); | 141 insert(i->second.begin(), i->second.end()); |
142 } | 142 } |
143 default_zoom_level_ = copy->default_zoom_level_; | 143 default_zoom_level_ = copy->default_zoom_level_; |
144 } | 144 } |
145 | 145 |
| 146 void HostZoomMapImpl::PreserveTemporaryZoomLevelFrom( |
| 147 const HostZoomMap* copy_interface, RenderFrameHost* old_host, |
| 148 RenderFrameHost* new_host) { |
| 149 const HostZoomMapImpl* copy = |
| 150 static_cast<const HostZoomMapImpl*>(copy_interface); |
| 151 const RenderViewHost* old_view_host = old_host->GetRenderViewHost(); |
| 152 const RenderViewHost* new_view_host = new_host->GetRenderViewHost(); |
| 153 |
| 154 DCHECK(copy->UsesTemporaryZoomLevel(old_view_host->GetProcess()->GetID(), |
| 155 old_view_host->GetRoutingID())); |
| 156 |
| 157 const double level = copy->GetTemporaryZoomLevel( |
| 158 old_view_host->GetProcess()->GetID(), old_view_host->GetRoutingID()); |
| 159 SetTemporaryZoomLevel( |
| 160 new_view_host->GetProcess()->GetID(), new_view_host->GetRoutingID(), |
| 161 level); |
| 162 } |
| 163 |
146 double HostZoomMapImpl::GetZoomLevelForHost(const std::string& host) const { | 164 double HostZoomMapImpl::GetZoomLevelForHost(const std::string& host) const { |
147 base::AutoLock auto_lock(lock_); | 165 base::AutoLock auto_lock(lock_); |
148 return GetZoomLevelForHostInternal(host); | 166 return GetZoomLevelForHostInternal(host); |
149 } | 167 } |
150 | 168 |
151 double HostZoomMapImpl::GetZoomLevelForHostInternal( | 169 double HostZoomMapImpl::GetZoomLevelForHostInternal( |
152 const std::string& host) const { | 170 const std::string& host) const { |
153 HostZoomLevels::const_iterator i(host_zoom_levels_.find(host)); | 171 HostZoomLevels::const_iterator i(host_zoom_levels_.find(host)); |
154 return (i == host_zoom_levels_.end()) ? default_zoom_level_ : i->second; | 172 return (i == host_zoom_levels_.end()) ? default_zoom_level_ : i->second; |
155 } | 173 } |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 double error_page_zoom_level = GetZoomLevelForHost(host); | 569 double error_page_zoom_level = GetZoomLevelForHost(host); |
552 | 570 |
553 SendZoomLevelChange(std::string(), host, error_page_zoom_level); | 571 SendZoomLevelChange(std::string(), host, error_page_zoom_level); |
554 } | 572 } |
555 | 573 |
556 HostZoomMapImpl::~HostZoomMapImpl() { | 574 HostZoomMapImpl::~HostZoomMapImpl() { |
557 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 575 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
558 } | 576 } |
559 | 577 |
560 } // namespace content | 578 } // namespace content |
OLD | NEW |