| 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/render_process_host.h" | 9 #include "content/public/browser/render_process_host.h" |
| 10 #include "content/public/browser/stream_handle.h" | 10 #include "content/public/browser/stream_handle.h" |
| 11 #include "content/public/browser/stream_info.h" | 11 #include "content/public/browser/stream_info.h" |
| 12 #include "content/public/common/service_registry.h" |
| 12 #include "content/public/common/url_constants.h" | 13 #include "content/public/common/url_constants.h" |
| 13 #include "extensions/browser/api/extensions_api_client.h" | 14 #include "extensions/browser/api/extensions_api_client.h" |
| 15 #include "extensions/browser/api/mime_handler/mime_handler.h" |
| 14 #include "extensions/browser/extension_registry.h" | 16 #include "extensions/browser/extension_registry.h" |
| 15 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_stream_ma
nager.h" | 17 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_stream_ma
nager.h" |
| 16 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_cons
tants.h" | 18 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_cons
tants.h" |
| 17 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues
t_delegate.h" | 19 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues
t_delegate.h" |
| 18 #include "extensions/browser/process_manager.h" | 20 #include "extensions/browser/process_manager.h" |
| 19 #include "extensions/common/extension_messages.h" | 21 #include "extensions/common/extension_messages.h" |
| 20 #include "extensions/common/guest_view/guest_view_constants.h" | 22 #include "extensions/common/guest_view/guest_view_constants.h" |
| 21 #include "extensions/strings/grit/extensions_strings.h" | 23 #include "extensions/strings/grit/extensions_strings.h" |
| 22 #include "ipc/ipc_message_macros.h" | 24 #include "ipc/ipc_message_macros.h" |
| 23 #include "net/base/url_util.h" | 25 #include "net/base/url_util.h" |
| 24 | 26 |
| 25 using content::WebContents; | 27 using content::WebContents; |
| 26 | 28 |
| 27 namespace extensions { | 29 namespace extensions { |
| 28 | 30 |
| 29 StreamContainer::StreamContainer(scoped_ptr<content::StreamInfo> stream, | 31 StreamContainer::StreamContainer(scoped_ptr<content::StreamInfo> stream, |
| 32 int tab_id, |
| 33 int64_t expected_content_size, |
| 34 bool embedded, |
| 30 const GURL& handler_url, | 35 const GURL& handler_url, |
| 31 const std::string& extension_id) | 36 const std::string& extension_id) |
| 32 : stream_(stream.Pass()), | 37 : stream_(stream.Pass()), |
| 38 embedded_(embedded), |
| 39 expected_content_size_(expected_content_size), |
| 40 tab_id_(tab_id), |
| 33 handler_url_(handler_url), | 41 handler_url_(handler_url), |
| 34 extension_id_(extension_id), | 42 extension_id_(extension_id), |
| 35 weak_factory_(this) { | 43 weak_factory_(this) { |
| 36 } | 44 } |
| 37 | 45 |
| 38 StreamContainer::~StreamContainer() { | 46 StreamContainer::~StreamContainer() { |
| 39 } | 47 } |
| 40 | 48 |
| 41 void StreamContainer::Abort() { | 49 void StreamContainer::Abort() { |
| 42 stream_->handle.reset(); | 50 stream_->handle.reset(); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 133 |
| 126 WebContents::CreateParams params(browser_context(), guest_site_instance); | 134 WebContents::CreateParams params(browser_context(), guest_site_instance); |
| 127 params.guest_delegate = this; | 135 params.guest_delegate = this; |
| 128 callback.Run(WebContents::Create(params)); | 136 callback.Run(WebContents::Create(params)); |
| 129 } | 137 } |
| 130 | 138 |
| 131 void MimeHandlerViewGuest::DidAttachToEmbedder() { | 139 void MimeHandlerViewGuest::DidAttachToEmbedder() { |
| 132 web_contents()->GetController().LoadURL( | 140 web_contents()->GetController().LoadURL( |
| 133 stream_->handler_url(), content::Referrer(), | 141 stream_->handler_url(), content::Referrer(), |
| 134 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string()); | 142 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string()); |
| 143 web_contents()->GetMainFrame()->GetServiceRegistry()->AddService( |
| 144 base::Bind(&MimeHandlerServiceImpl::Create, stream_->GetWeakPtr())); |
| 135 } | 145 } |
| 136 | 146 |
| 137 void MimeHandlerViewGuest::DidInitialize() { | 147 void MimeHandlerViewGuest::DidInitialize() { |
| 138 extension_function_dispatcher_.reset( | 148 extension_function_dispatcher_.reset( |
| 139 new ExtensionFunctionDispatcher(browser_context(), this)); | 149 new ExtensionFunctionDispatcher(browser_context(), this)); |
| 140 if (delegate_) | 150 if (delegate_) |
| 141 delegate_->AttachHelpers(); | 151 delegate_->AttachHelpers(); |
| 142 } | 152 } |
| 143 | 153 |
| 144 bool MimeHandlerViewGuest::ZoomPropagatesFromEmbedderToGuest() const { | 154 bool MimeHandlerViewGuest::ZoomPropagatesFromEmbedderToGuest() const { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 | 251 |
| 242 void MimeHandlerViewGuest::OnRequest( | 252 void MimeHandlerViewGuest::OnRequest( |
| 243 const ExtensionHostMsg_Request_Params& params) { | 253 const ExtensionHostMsg_Request_Params& params) { |
| 244 if (extension_function_dispatcher_) { | 254 if (extension_function_dispatcher_) { |
| 245 extension_function_dispatcher_->Dispatch( | 255 extension_function_dispatcher_->Dispatch( |
| 246 params, web_contents()->GetRenderViewHost()); | 256 params, web_contents()->GetRenderViewHost()); |
| 247 } | 257 } |
| 248 } | 258 } |
| 249 | 259 |
| 250 } // namespace extensions | 260 } // namespace extensions |
| OLD | NEW |