OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues
t.h" | 5 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues
t.h" |
6 | 6 |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
| 9 #include "content/public/browser/host_zoom_map.h" |
9 #include "content/public/browser/render_process_host.h" | 10 #include "content/public/browser/render_process_host.h" |
10 #include "content/public/browser/stream_handle.h" | 11 #include "content/public/browser/stream_handle.h" |
11 #include "content/public/browser/stream_info.h" | 12 #include "content/public/browser/stream_info.h" |
12 #include "content/public/common/service_registry.h" | 13 #include "content/public/common/service_registry.h" |
13 #include "content/public/common/url_constants.h" | 14 #include "content/public/common/url_constants.h" |
14 #include "extensions/browser/api/extensions_api_client.h" | 15 #include "extensions/browser/api/extensions_api_client.h" |
15 #include "extensions/browser/api/mime_handler_private/mime_handler_private.h" | 16 #include "extensions/browser/api/mime_handler_private/mime_handler_private.h" |
16 #include "extensions/browser/extension_registry.h" | 17 #include "extensions/browser/extension_registry.h" |
17 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_stream_ma
nager.h" | 18 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_stream_ma
nager.h" |
18 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_cons
tants.h" | 19 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_cons
tants.h" |
19 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues
t_delegate.h" | 20 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues
t_delegate.h" |
20 #include "extensions/browser/process_manager.h" | 21 #include "extensions/browser/process_manager.h" |
| 22 #include "extensions/common/constants.h" |
21 #include "extensions/common/extension_messages.h" | 23 #include "extensions/common/extension_messages.h" |
22 #include "extensions/common/guest_view/guest_view_constants.h" | 24 #include "extensions/common/guest_view/guest_view_constants.h" |
23 #include "extensions/strings/grit/extensions_strings.h" | 25 #include "extensions/strings/grit/extensions_strings.h" |
24 #include "ipc/ipc_message_macros.h" | 26 #include "ipc/ipc_message_macros.h" |
25 #include "net/base/url_util.h" | 27 #include "net/base/url_util.h" |
26 | 28 |
27 using content::WebContents; | 29 using content::WebContents; |
28 | 30 |
29 namespace extensions { | 31 namespace extensions { |
30 | 32 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 LOG(ERROR) << "Extension for mime_type not found, mime_type = " | 118 LOG(ERROR) << "Extension for mime_type not found, mime_type = " |
117 << stream_->stream_info()->mime_type; | 119 << stream_->stream_info()->mime_type; |
118 callback.Run(nullptr); | 120 callback.Run(nullptr); |
119 return; | 121 return; |
120 } | 122 } |
121 | 123 |
122 // Use the mime handler extension's SiteInstance to create the guest so it | 124 // Use the mime handler extension's SiteInstance to create the guest so it |
123 // goes under the same process as the extension. | 125 // goes under the same process as the extension. |
124 ProcessManager* process_manager = ProcessManager::Get(browser_context()); | 126 ProcessManager* process_manager = ProcessManager::Get(browser_context()); |
125 content::SiteInstance* guest_site_instance = | 127 content::SiteInstance* guest_site_instance = |
126 process_manager->GetSiteInstanceForURL( | 128 process_manager->GetSiteInstanceForURL(stream_->handler_url()); |
127 Extension::GetBaseURLFromExtensionId(GetOwnerSiteURL().host())); | 129 |
| 130 // Clear the zoom level for the mime handler extension. The extension is |
| 131 // responsible for managing its own zoom. This is necessary for OOP PDF, as |
| 132 // otherwise the UI is zoomed and the calculations to determine the PDF size |
| 133 // mix zoomed and unzoomed units. |
| 134 content::HostZoomMap::Get(guest_site_instance) |
| 135 ->SetZoomLevelForHostAndScheme(kExtensionScheme, stream_->extension_id(), |
| 136 0); |
128 | 137 |
129 WebContents::CreateParams params(browser_context(), guest_site_instance); | 138 WebContents::CreateParams params(browser_context(), guest_site_instance); |
130 params.guest_delegate = this; | 139 params.guest_delegate = this; |
131 callback.Run(WebContents::Create(params)); | 140 callback.Run(WebContents::Create(params)); |
132 } | 141 } |
133 | 142 |
134 void MimeHandlerViewGuest::DidAttachToEmbedder() { | 143 void MimeHandlerViewGuest::DidAttachToEmbedder() { |
135 web_contents()->GetController().LoadURL( | 144 web_contents()->GetController().LoadURL( |
136 stream_->handler_url(), content::Referrer(), | 145 stream_->handler_url(), content::Referrer(), |
137 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string()); | 146 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string()); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 | 235 |
227 void MimeHandlerViewGuest::OnRequest( | 236 void MimeHandlerViewGuest::OnRequest( |
228 const ExtensionHostMsg_Request_Params& params) { | 237 const ExtensionHostMsg_Request_Params& params) { |
229 if (extension_function_dispatcher_) { | 238 if (extension_function_dispatcher_) { |
230 extension_function_dispatcher_->Dispatch( | 239 extension_function_dispatcher_->Dispatch( |
231 params, web_contents()->GetRenderViewHost()); | 240 params, web_contents()->GetRenderViewHost()); |
232 } | 241 } |
233 } | 242 } |
234 | 243 |
235 } // namespace extensions | 244 } // namespace extensions |
OLD | NEW |