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

Side by Side Diff: content/browser/loader/async_resource_handler.cc

Issue 1804023002: Fix page zoom to be frame-centric for out-of-process frames. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Send zoom change notifications for updates triggered by default page zoom changes. Created 4 years, 8 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 #include "content/browser/loader/async_resource_handler.h" 5 #include "content/browser/loader/async_resource_handler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h"
10 #include "base/command_line.h" 11 #include "base/command_line.h"
11 #include "base/containers/hash_tables.h" 12 #include "base/containers/hash_tables.h"
12 #include "base/debug/alias.h" 13 #include "base/debug/alias.h"
13 #include "base/feature_list.h" 14 #include "base/feature_list.h"
14 #include "base/logging.h" 15 #include "base/logging.h"
15 #include "base/macros.h" 16 #include "base/macros.h"
16 #include "base/memory/shared_memory.h" 17 #include "base/memory/shared_memory.h"
17 #include "base/metrics/histogram_macros.h" 18 #include "base/metrics/histogram_macros.h"
18 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
19 #include "base/time/time.h" 20 #include "base/time/time.h"
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 response->head.request_start = request()->creation_time(); 308 response->head.request_start = request()->creation_time();
308 response->head.response_start = TimeTicks::Now(); 309 response->head.response_start = TimeTicks::Now();
309 // TODO(davidben): Is it necessary to pass the new first party URL for 310 // TODO(davidben): Is it necessary to pass the new first party URL for
310 // cookies? The only case where it can change is top-level navigation requests 311 // cookies? The only case where it can change is top-level navigation requests
311 // and hopefully those will eventually all be owned by the browser. It's 312 // and hopefully those will eventually all be owned by the browser. It's
312 // possible this is still needed while renderer-owned ones exist. 313 // possible this is still needed while renderer-owned ones exist.
313 return info->filter()->Send(new ResourceMsg_ReceivedRedirect( 314 return info->filter()->Send(new ResourceMsg_ReceivedRedirect(
314 GetRequestID(), redirect_info, response->head)); 315 GetRequestID(), redirect_info, response->head));
315 } 316 }
316 317
318 namespace {
319
320 // Defined here to be close to OnResponseStarted(), which is the only caller.
321 void SetZoomLevelForViewFromWebContents(
322 ResourceRequestInfo::WebContentsGetter request_web_contents_getter,
323 base::WeakPtr<ResourceMessageFilter> filter,
324 int render_view_id,
325 const GURL request_url) {
326 DCHECK_CURRENTLY_ON(BrowserThread::UI);
327
328 WebContents* web_contents = request_web_contents_getter.Run();
329 if (!web_contents)
330 return;
331
332 double zoom_level = HostZoomMap::GetZoomLevel(web_contents);
333
334 if (filter) {
335 filter->Send(new ViewMsg_SetZoomLevelForLoadingURL(
336 render_view_id, request_url, zoom_level));
337 }
338 }
339
340 } // namespace anonymous
341
317 bool AsyncResourceHandler::OnResponseStarted(ResourceResponse* response, 342 bool AsyncResourceHandler::OnResponseStarted(ResourceResponse* response,
318 bool* defer) { 343 bool* defer) {
319 // For changes to the main frame, inform the renderer of the new URL's 344 // For changes to the main frame, inform the renderer of the new URL's
320 // per-host settings before the request actually commits. This way the 345 // per-host settings before the request actually commits. This way the
321 // renderer will be able to set these precisely at the time the 346 // renderer will be able to set these precisely at the time the
322 // request commits, avoiding the possibility of e.g. zooming the old content 347 // request commits, avoiding the possibility of e.g. zooming the old content
323 // or of having to layout the new content twice. 348 // or of having to layout the new content twice.
324 349
325 response_started_ticks_ = base::TimeTicks::Now(); 350 response_started_ticks_ = base::TimeTicks::Now();
326 351
(...skipping 23 matching lines...) Expand all
350 if (info->GetResourceType() == RESOURCE_TYPE_MAIN_FRAME && host_zoom_map) { 375 if (info->GetResourceType() == RESOURCE_TYPE_MAIN_FRAME && host_zoom_map) {
351 const GURL& request_url = request()->url(); 376 const GURL& request_url = request()->url();
352 int render_process_id = info->GetChildID(); 377 int render_process_id = info->GetChildID();
353 int render_view_id = info->GetRouteID(); 378 int render_view_id = info->GetRouteID();
354 379
355 double zoom_level = host_zoom_map->GetZoomLevelForView( 380 double zoom_level = host_zoom_map->GetZoomLevelForView(
356 request_url, render_process_id, render_view_id); 381 request_url, render_process_id, render_view_id);
357 382
358 info->filter()->Send(new ViewMsg_SetZoomLevelForLoadingURL( 383 info->filter()->Send(new ViewMsg_SetZoomLevelForLoadingURL(
359 render_view_id, request_url, zoom_level)); 384 render_view_id, request_url, zoom_level));
385 } else if (info->GetResourceType() == RESOURCE_TYPE_SUB_FRAME &&
386 host_zoom_map) {
387 // Sub-frames should use the zoom level of their web-contents, regardless of
388 // their URL. We must access the WebContents on the UI thread.
389 BrowserThread::PostTask(
390 BrowserThread::UI, FROM_HERE,
391 base::Bind(
392 &SetZoomLevelForViewFromWebContents,
393 info->GetWebContentsGetterForRequest(),
394 info->filter()->GetWeakPtr(),
395 info->GetRouteID(),
396 request()->url()));
360 } 397 }
361 398
362 // If the parent handler downloaded the resource to a file, grant the child 399 // If the parent handler downloaded the resource to a file, grant the child
363 // read permissions on it. 400 // read permissions on it.
364 if (!response->head.download_file_path.empty()) { 401 if (!response->head.download_file_path.empty()) {
365 rdh_->RegisterDownloadedTempFile( 402 rdh_->RegisterDownloadedTempFile(
366 info->GetChildID(), info->GetRequestID(), 403 info->GetChildID(), info->GetRequestID(),
367 response->head.download_file_path); 404 response->head.download_file_path);
368 } 405 }
369 406
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 } else { 638 } else {
602 UMA_HISTOGRAM_CUSTOM_COUNTS( 639 UMA_HISTOGRAM_CUSTOM_COUNTS(
603 "Net.ResourceLoader.ResponseStartToEnd.Over_512kB", 640 "Net.ResourceLoader.ResponseStartToEnd.Over_512kB",
604 elapsed_time, 1, 100000, 100); 641 elapsed_time, 1, 100000, 100);
605 } 642 }
606 643
607 inlining_helper_->RecordHistogram(elapsed_time); 644 inlining_helper_->RecordHistogram(elapsed_time);
608 } 645 }
609 646
610 } // namespace content 647 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698