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 "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.
h" | 5 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.
h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "chrome/browser/ui/login/login_prompt.h" | 30 #include "chrome/browser/ui/login/login_prompt.h" |
31 #include "chrome/browser/ui/sync/one_click_signin_helper.h" | 31 #include "chrome/browser/ui/sync/one_click_signin_helper.h" |
32 #include "chrome/common/chrome_notification_types.h" | 32 #include "chrome/common/chrome_notification_types.h" |
33 #include "chrome/common/extensions/user_script.h" | 33 #include "chrome/common/extensions/user_script.h" |
34 #include "chrome/common/metrics/experiments_helper.h" | 34 #include "chrome/common/metrics/experiments_helper.h" |
35 #include "chrome/common/metrics/proto/chrome_experiments.pb.h" | 35 #include "chrome/common/metrics/proto/chrome_experiments.pb.h" |
36 #include "chrome/common/render_messages.h" | 36 #include "chrome/common/render_messages.h" |
37 #include "content/public/browser/browser_thread.h" | 37 #include "content/public/browser/browser_thread.h" |
38 #include "content/public/browser/notification_service.h" | 38 #include "content/public/browser/notification_service.h" |
39 #include "content/public/browser/render_view_host.h" | 39 #include "content/public/browser/render_view_host.h" |
| 40 #include "content/public/browser/render_view_host_delegate.h" |
| 41 #include "content/public/browser/render_widget_host_view.h" |
40 #include "content/public/browser/resource_context.h" | 42 #include "content/public/browser/resource_context.h" |
41 #include "content/public/browser/resource_dispatcher_host.h" | 43 #include "content/public/browser/resource_dispatcher_host.h" |
42 #include "content/public/browser/resource_request_info.h" | 44 #include "content/public/browser/resource_request_info.h" |
| 45 #include "content/public/browser/web_contents.h" |
| 46 #include "content/public/browser/web_contents_view.h" |
43 #include "net/base/load_flags.h" | 47 #include "net/base/load_flags.h" |
44 #include "net/base/ssl_config_service.h" | 48 #include "net/base/ssl_config_service.h" |
45 #include "net/url_request/url_request.h" | 49 #include "net/url_request/url_request.h" |
| 50 #include "ui/gfx/size.h" |
46 #include "third_party/protobuf/src/google/protobuf/repeated_field.h" | 51 #include "third_party/protobuf/src/google/protobuf/repeated_field.h" |
47 | 52 |
48 // TODO(oshima): Enable this for other platforms. | 53 // TODO(oshima): Enable this for other platforms. |
49 #if defined(OS_CHROMEOS) | 54 #if defined(OS_CHROMEOS) |
50 #include "chrome/browser/renderer_host/offline_resource_throttle.h" | 55 #include "chrome/browser/renderer_host/offline_resource_throttle.h" |
51 #endif | 56 #endif |
52 | 57 |
53 using content::BrowserThread; | 58 using content::BrowserThread; |
54 using content::RenderViewHost; | 59 using content::RenderViewHost; |
55 using content::ResourceDispatcherHostLoginDelegate; | 60 using content::ResourceDispatcherHostLoginDelegate; |
56 using content::ResourceRequestInfo; | 61 using content::ResourceRequestInfo; |
57 | 62 |
58 namespace { | 63 namespace { |
59 | 64 |
| 65 // TODO(gavinp): Remove this after https://bugs.webkit.org/show_bug.cgi?id=85005 |
| 66 // lands in WebKit. |
60 void AddPrerenderOnUI( | 67 void AddPrerenderOnUI( |
61 int render_process_id, int render_view_id, | 68 int render_process_id, int render_view_id, |
62 const GURL& url, const content::Referrer& referrer) { | 69 const GURL& url, const content::Referrer& referrer) { |
63 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 70 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
64 prerender::PrerenderManager* prerender_manager = | 71 prerender::PrerenderManager* prerender_manager = |
65 prerender::FindPrerenderManagerUsingRenderProcessId(render_process_id); | 72 prerender::FindPrerenderManagerUsingRenderProcessId(render_process_id); |
66 if (!prerender_manager) | 73 if (!prerender_manager) |
67 return; | 74 return; |
68 | 75 |
69 prerender_manager->AddPrerenderFromLinkRelPrerender(render_process_id, | 76 RenderViewHost* render_view_host = |
70 render_view_id, | 77 RenderViewHost::FromID(render_process_id, render_view_id); |
71 url, | 78 if (!render_view_host) |
72 referrer); | 79 return; |
| 80 gfx::Rect tab_bounds; |
| 81 if (content::WebContents* source_wc = |
| 82 render_view_host->GetDelegate()->GetAsWebContents()) |
| 83 source_wc->GetView()->GetContainerBounds(&tab_bounds); |
| 84 gfx::Size view_size = tab_bounds.size(); |
| 85 if (view_size.IsEmpty()) |
| 86 view_size = prerender_manager->config().default_tab_bounds.size(); |
| 87 prerender_manager->AddPrerenderFromLinkRelPrerender( |
| 88 render_process_id, render_view_id, url, referrer, view_size); |
73 } | 89 } |
74 | 90 |
75 void NotifyDownloadInitiatedOnUI(int render_process_id, int render_view_id) { | 91 void NotifyDownloadInitiatedOnUI(int render_process_id, int render_view_id) { |
76 RenderViewHost* rvh = RenderViewHost::FromID(render_process_id, | 92 RenderViewHost* rvh = RenderViewHost::FromID(render_process_id, |
77 render_view_id); | 93 render_view_id); |
78 if (!rvh) | 94 if (!rvh) |
79 return; | 95 return; |
80 | 96 |
81 content::NotificationService::current()->Notify( | 97 content::NotificationService::current()->Notify( |
82 chrome::NOTIFICATION_DOWNLOAD_INITIATED, | 98 chrome::NOTIFICATION_DOWNLOAD_INITIATED, |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 if (base::Base64Encode(serialized, &hashed)) { | 455 if (base::Base64Encode(serialized, &hashed)) { |
440 // If successful, swap the header value with the new one. | 456 // If successful, swap the header value with the new one. |
441 // Note that the list of IDs and the header could be temporarily out of sync | 457 // Note that the list of IDs and the header could be temporarily out of sync |
442 // if IDs are added as we are recreating the header, but we're OK with those | 458 // if IDs are added as we are recreating the header, but we're OK with those |
443 // descrepancies. | 459 // descrepancies. |
444 variation_ids_header_ = hashed; | 460 variation_ids_header_ = hashed; |
445 } else { | 461 } else { |
446 DVLOG(1) << "Failed to base64 encode Variation IDs value: " << serialized; | 462 DVLOG(1) << "Failed to base64 encode Variation IDs value: " << serialized; |
447 } | 463 } |
448 } | 464 } |
OLD | NEW |