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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
235 net::GetHostOrSpecFromURL(url)); | 235 net::GetHostOrSpecFromURL(url)); |
236 } | 236 } |
237 | 237 |
238 void HostZoomMapImpl::SetZoomLevelForWebContents( | 238 void HostZoomMapImpl::SetZoomLevelForWebContents( |
239 const WebContentsImpl& web_contents_impl, | 239 const WebContentsImpl& web_contents_impl, |
240 double level) { | 240 double level) { |
241 int render_process_id = web_contents_impl.GetRenderProcessHost()->GetID(); | 241 int render_process_id = web_contents_impl.GetRenderProcessHost()->GetID(); |
242 int render_view_id = web_contents_impl.GetRenderViewHost()->GetRoutingID(); | 242 int render_view_id = web_contents_impl.GetRenderViewHost()->GetRoutingID(); |
243 if (UsesTemporaryZoomLevel(render_process_id, render_view_id)) { | 243 if (UsesTemporaryZoomLevel(render_process_id, render_view_id)) { |
244 SetTemporaryZoomLevel(render_process_id, render_view_id, level); | 244 SetTemporaryZoomLevel(render_process_id, render_view_id, level); |
245 } else { | 245 } else { |
Peter Kasting
2014/06/09 18:17:57
Tiny nit: For parallel structure with the function
| |
246 // Get the url from the navigation controller directly, as calling | 246 // Get the url from the navigation controller directly, as calling |
247 // WebContentsImpl::GetLastCommittedURL() may give us a virtual url that | 247 // WebContentsImpl::GetLastCommittedURL() may give us a virtual url that |
248 // is different than what the render view is using. If the two don't match, | 248 // is different than what the render view is using. If the two don't match, |
249 // the attempt to set the zoom will fail. | 249 // the attempt to set the zoom will fail. |
250 GURL url; | 250 GURL url; |
251 NavigationEntry* entry = | 251 NavigationEntry* entry = |
252 web_contents_impl.GetController().GetLastCommittedEntry(); | 252 web_contents_impl.GetController().GetLastCommittedEntry(); |
253 DCHECK(entry); | 253 if (entry) { |
Peter Kasting
2014/06/09 18:17:57
Nit: Add a comment about why this can be NULL. Id
| |
254 url = entry->GetURL(); | 254 url = entry->GetURL(); |
wjmaclean
2014/06/09 17:35:59
Actually, this should be
GURL url = ...
No need
| |
255 SetZoomLevelForHost(net::GetHostOrSpecFromURL(url), level); | 255 SetZoomLevelForHost(net::GetHostOrSpecFromURL(url), level); |
256 } | |
256 } | 257 } |
257 } | 258 } |
258 | 259 |
259 void HostZoomMapImpl::SetZoomLevelForView(int render_process_id, | 260 void HostZoomMapImpl::SetZoomLevelForView(int render_process_id, |
260 int render_view_id, | 261 int render_view_id, |
261 double level, | 262 double level, |
262 const std::string& host) { | 263 const std::string& host) { |
263 if (UsesTemporaryZoomLevel(render_process_id, render_view_id)) | 264 if (UsesTemporaryZoomLevel(render_process_id, render_view_id)) |
264 SetTemporaryZoomLevel(render_process_id, render_view_id, level); | 265 SetTemporaryZoomLevel(render_process_id, render_view_id, level); |
265 else | 266 else |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
384 zoom_level(0.0) { | 385 zoom_level(0.0) { |
385 } | 386 } |
386 | 387 |
387 bool HostZoomMapImpl::TemporaryZoomLevel::operator==( | 388 bool HostZoomMapImpl::TemporaryZoomLevel::operator==( |
388 const TemporaryZoomLevel& other) const { | 389 const TemporaryZoomLevel& other) const { |
389 return other.render_process_id == render_process_id && | 390 return other.render_process_id == render_process_id && |
390 other.render_view_id == render_view_id; | 391 other.render_view_id == render_view_id; |
391 } | 392 } |
392 | 393 |
393 } // namespace content | 394 } // namespace content |
OLD | NEW |