| 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/extensions/api/streams_private/streams_private_api.h" | 5 #include "chrome/browser/extensions/api/streams_private/streams_private_api.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 StreamsPrivateAPI::~StreamsPrivateAPI() { | 63 StreamsPrivateAPI::~StreamsPrivateAPI() { |
| 64 } | 64 } |
| 65 | 65 |
| 66 void StreamsPrivateAPI::ExecuteMimeTypeHandler( | 66 void StreamsPrivateAPI::ExecuteMimeTypeHandler( |
| 67 const std::string& extension_id, | 67 const std::string& extension_id, |
| 68 content::WebContents* web_contents, | 68 content::WebContents* web_contents, |
| 69 std::unique_ptr<content::StreamInfo> stream, | 69 std::unique_ptr<content::StreamInfo> stream, |
| 70 const std::string& view_id, | 70 const std::string& view_id, |
| 71 int64_t expected_content_size, | 71 int64_t expected_content_size, |
| 72 bool embedded, | 72 bool embedded, |
| 73 int frame_tree_node_id, |
| 73 int render_process_id, | 74 int render_process_id, |
| 74 int render_frame_id) { | 75 int render_frame_id) { |
| 75 const Extension* extension = ExtensionRegistry::Get(browser_context_) | 76 const Extension* extension = ExtensionRegistry::Get(browser_context_) |
| 76 ->enabled_extensions() | 77 ->enabled_extensions() |
| 77 .GetByID(extension_id); | 78 .GetByID(extension_id); |
| 78 if (!extension) | 79 if (!extension) |
| 79 return; | 80 return; |
| 80 | 81 |
| 81 MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); | 82 MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); |
| 82 // If the mime handler uses MimeHandlerViewGuest, the MimeHandlerViewGuest | 83 // If the mime handler uses MimeHandlerViewGuest, the MimeHandlerViewGuest |
| 83 // will take ownership of the stream. Otherwise, store the stream handle in | 84 // will take ownership of the stream. Otherwise, store the stream handle in |
| 84 // |streams_| and fire an event notifying the extension. | 85 // |streams_| and fire an event notifying the extension. |
| 85 if (handler->HasPlugin()) { | 86 if (handler->HasPlugin()) { |
| 86 GURL handler_url(Extension::GetBaseURLFromExtensionId(extension_id).spec() + | 87 GURL handler_url(Extension::GetBaseURLFromExtensionId(extension_id).spec() + |
| 87 handler->handler_url()); | 88 handler->handler_url()); |
| 88 int tab_id = ExtensionTabUtil::GetTabId(web_contents); | 89 int tab_id = ExtensionTabUtil::GetTabId(web_contents); |
| 89 std::unique_ptr<StreamContainer> stream_container(new StreamContainer( | 90 std::unique_ptr<StreamContainer> stream_container(new StreamContainer( |
| 90 std::move(stream), tab_id, embedded, handler_url, extension_id)); | 91 std::move(stream), tab_id, embedded, handler_url, extension_id)); |
| 91 MimeHandlerStreamManager::Get(browser_context_) | 92 MimeHandlerStreamManager::Get(browser_context_) |
| 92 ->AddStream(view_id, std::move(stream_container), render_process_id, | 93 ->AddStream(view_id, std::move(stream_container), web_contents, |
| 93 render_frame_id); | 94 frame_tree_node_id, render_process_id, render_frame_id); |
| 94 return; | 95 return; |
| 95 } | 96 } |
| 96 // Create the event's arguments value. | 97 // Create the event's arguments value. |
| 97 streams_private::StreamInfo info; | 98 streams_private::StreamInfo info; |
| 98 info.mime_type = stream->mime_type; | 99 info.mime_type = stream->mime_type; |
| 99 info.original_url = stream->original_url.spec(); | 100 info.original_url = stream->original_url.spec(); |
| 100 info.stream_url = stream->handle->GetURL().spec(); | 101 info.stream_url = stream->handle->GetURL().spec(); |
| 101 info.tab_id = ExtensionTabUtil::GetTabId(web_contents); | 102 info.tab_id = ExtensionTabUtil::GetTabId(web_contents); |
| 102 info.embedded = embedded; | 103 info.embedded = embedded; |
| 103 | 104 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 static base::LazyInstance<BrowserContextKeyedAPIFactory<StreamsPrivateAPI> > | 173 static base::LazyInstance<BrowserContextKeyedAPIFactory<StreamsPrivateAPI> > |
| 173 g_factory = LAZY_INSTANCE_INITIALIZER; | 174 g_factory = LAZY_INSTANCE_INITIALIZER; |
| 174 | 175 |
| 175 // static | 176 // static |
| 176 BrowserContextKeyedAPIFactory<StreamsPrivateAPI>* | 177 BrowserContextKeyedAPIFactory<StreamsPrivateAPI>* |
| 177 StreamsPrivateAPI::GetFactoryInstance() { | 178 StreamsPrivateAPI::GetFactoryInstance() { |
| 178 return g_factory.Pointer(); | 179 return g_factory.Pointer(); |
| 179 } | 180 } |
| 180 | 181 |
| 181 } // namespace extensions | 182 } // namespace extensions |
| OLD | NEW |