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/transfer_navigation_resource_throttle.h" | 5 #include "chrome/browser/renderer_host/transfer_navigation_resource_throttle.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "chrome/browser/profiles/profile_io_data.h" | 8 #include "chrome/browser/profiles/profile_io_data.h" |
9 #include "chrome/browser/extensions/extension_info_map.h" | 9 #include "chrome/browser/extensions/extension_info_map.h" |
10 #include "chrome/common/extensions/extension_process_policy.h" | 10 #include "chrome/common/extensions/extension_process_policy.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 // TODO(darin): Move this logic into src/content. | 56 // TODO(darin): Move this logic into src/content. |
57 | 57 |
58 ResourceDispatcherHostRequestInfo* info = | 58 ResourceDispatcherHostRequestInfo* info = |
59 ResourceDispatcherHost::InfoForRequest(request_); | 59 ResourceDispatcherHost::InfoForRequest(request_); |
60 | 60 |
61 // If a toplevel request is redirecting across extension extents, we want to | 61 // If a toplevel request is redirecting across extension extents, we want to |
62 // switch processes. We do this by deferring the redirect and resuming the | 62 // switch processes. We do this by deferring the redirect and resuming the |
63 // request once the navigation controller properly assigns the right process | 63 // request once the navigation controller properly assigns the right process |
64 // to host the new URL. | 64 // to host the new URL. |
65 // TODO(mpcomplete): handle for cases other than extensions (e.g. WebUI). | 65 // TODO(mpcomplete): handle for cases other than extensions (e.g. WebUI). |
66 const content::ResourceContext& resource_context = *info->context(); | 66 content::ResourceContext* resource_context = info->context(); |
67 ProfileIOData* io_data = | 67 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); |
68 reinterpret_cast<ProfileIOData*>(resource_context.GetUserData(NULL)); | |
69 | |
70 if (extensions::CrossesExtensionProcessBoundary( | 68 if (extensions::CrossesExtensionProcessBoundary( |
71 io_data->GetExtensionInfoMap()->extensions(), | 69 io_data->GetExtensionInfoMap()->extensions(), |
72 ExtensionURLInfo(request_->url()), ExtensionURLInfo(new_url))) { | 70 ExtensionURLInfo(request_->url()), ExtensionURLInfo(new_url))) { |
73 int render_process_id, render_view_id; | 71 int render_process_id, render_view_id; |
74 if (ResourceDispatcherHost::RenderViewForRequest( | 72 if (ResourceDispatcherHost::RenderViewForRequest( |
75 request_, &render_process_id, &render_view_id)) { | 73 request_, &render_process_id, &render_view_id)) { |
76 | 74 |
77 GlobalRequestID global_id(info->child_id(), info->request_id()); | 75 GlobalRequestID global_id(info->child_id(), info->request_id()); |
78 ResourceDispatcherHost::Get()->MarkAsTransferredNavigation(global_id, | 76 ResourceDispatcherHost::Get()->MarkAsTransferredNavigation(global_id, |
79 request_); | 77 request_); |
80 | 78 |
81 content::BrowserThread::PostTask( | 79 content::BrowserThread::PostTask( |
82 content::BrowserThread::UI, | 80 content::BrowserThread::UI, |
83 FROM_HERE, | 81 FROM_HERE, |
84 base::Bind(&RequestTransferURLOnUIThread, | 82 base::Bind(&RequestTransferURLOnUIThread, |
85 render_process_id, render_view_id, | 83 render_process_id, render_view_id, |
86 new_url, | 84 new_url, |
87 content::Referrer(GURL(request_->referrer()), | 85 content::Referrer(GURL(request_->referrer()), |
88 info->referrer_policy()), | 86 info->referrer_policy()), |
89 CURRENT_TAB, info->frame_id(), global_id)); | 87 CURRENT_TAB, info->frame_id(), global_id)); |
90 | 88 |
91 *defer = true; | 89 *defer = true; |
92 } | 90 } |
93 } | 91 } |
94 } | 92 } |
OLD | NEW |