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/common/url_constants.h" | 10 #include "content/public/common/url_constants.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 const GURL& embedder_site_url, | 71 const GURL& embedder_site_url, |
72 const base::DictionaryValue& create_params, | 72 const base::DictionaryValue& create_params, |
73 const WebContentsCreatedCallback& callback) { | 73 const WebContentsCreatedCallback& callback) { |
74 std::string orig_mime_type; | 74 std::string orig_mime_type; |
75 create_params.GetString(mime_handler_view::kMimeType, &orig_mime_type); | 75 create_params.GetString(mime_handler_view::kMimeType, &orig_mime_type); |
76 DCHECK(!orig_mime_type.empty()); | 76 DCHECK(!orig_mime_type.empty()); |
77 | 77 |
78 std::string extension_src; | 78 std::string extension_src; |
79 create_params.GetString(mime_handler_view::kSrc, &extension_src); | 79 create_params.GetString(mime_handler_view::kSrc, &extension_src); |
80 DCHECK(!extension_src.empty()); | 80 DCHECK(!extension_src.empty()); |
| 81 std::string content_url_str; |
| 82 create_params.GetString(mime_handler_view::kContentUrl, &content_url_str); |
| 83 content_url_ = GURL(content_url_str); |
| 84 if (!content_url_.is_valid()) { |
| 85 content_url_ = GURL(); |
| 86 callback.Run(nullptr); |
| 87 return; |
| 88 } |
81 | 89 |
82 GURL mime_handler_extension_url(extension_src); | 90 GURL mime_handler_extension_url(extension_src); |
83 if (!mime_handler_extension_url.is_valid()) { | 91 if (!mime_handler_extension_url.is_valid()) { |
84 callback.Run(NULL); | 92 callback.Run(NULL); |
85 return; | 93 return; |
86 } | 94 } |
87 | 95 |
88 const Extension* mime_handler_extension = | 96 const Extension* mime_handler_extension = |
89 // TODO(lazyboy): Do we need handle the case where the extension is | 97 // TODO(lazyboy): Do we need handle the case where the extension is |
90 // terminated (ExtensionRegistry::TERMINATED)? | 98 // terminated (ExtensionRegistry::TERMINATED)? |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 return; | 185 return; |
178 | 186 |
179 embedder_web_contents()->GetDelegate()->FindReply(embedder_web_contents(), | 187 embedder_web_contents()->GetDelegate()->FindReply(embedder_web_contents(), |
180 request_id, | 188 request_id, |
181 number_of_matches, | 189 number_of_matches, |
182 selection_rect, | 190 selection_rect, |
183 active_match_ordinal, | 191 active_match_ordinal, |
184 final_update); | 192 final_update); |
185 } | 193 } |
186 | 194 |
| 195 bool MimeHandlerViewGuest::SaveFrame(const GURL& url, |
| 196 const content::Referrer& referrer) { |
| 197 if (!attached()) |
| 198 return false; |
| 199 |
| 200 embedder_web_contents()->SaveFrame(content_url_, referrer); |
| 201 return true; |
| 202 } |
| 203 |
187 bool MimeHandlerViewGuest::OnMessageReceived(const IPC::Message& message) { | 204 bool MimeHandlerViewGuest::OnMessageReceived(const IPC::Message& message) { |
188 bool handled = true; | 205 bool handled = true; |
189 IPC_BEGIN_MESSAGE_MAP(MimeHandlerViewGuest, message) | 206 IPC_BEGIN_MESSAGE_MAP(MimeHandlerViewGuest, message) |
190 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) | 207 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) |
191 IPC_MESSAGE_UNHANDLED(handled = false) | 208 IPC_MESSAGE_UNHANDLED(handled = false) |
192 IPC_END_MESSAGE_MAP() | 209 IPC_END_MESSAGE_MAP() |
193 return handled; | 210 return handled; |
194 } | 211 } |
195 | 212 |
196 void MimeHandlerViewGuest::OnRequest( | 213 void MimeHandlerViewGuest::OnRequest( |
197 const ExtensionHostMsg_Request_Params& params) { | 214 const ExtensionHostMsg_Request_Params& params) { |
198 if (extension_function_dispatcher_) { | 215 if (extension_function_dispatcher_) { |
199 extension_function_dispatcher_->Dispatch( | 216 extension_function_dispatcher_->Dispatch( |
200 params, web_contents()->GetRenderViewHost()); | 217 params, web_contents()->GetRenderViewHost()); |
201 } | 218 } |
202 } | 219 } |
203 | 220 |
204 } // namespace extensions | 221 } // namespace extensions |
OLD | NEW |