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 "chrome/browser/guest_view/web_view/web_view_guest.h" | 5 #include "chrome/browser/guest_view/web_view/web_view_guest.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 } | 291 } |
292 WebContents::CreateParams params( | 292 WebContents::CreateParams params( |
293 embedder_render_process_host->GetBrowserContext(), | 293 embedder_render_process_host->GetBrowserContext(), |
294 guest_site_instance); | 294 guest_site_instance); |
295 params.guest_delegate = this; | 295 params.guest_delegate = this; |
296 callback.Run(WebContents::Create(params)); | 296 callback.Run(WebContents::Create(params)); |
297 } | 297 } |
298 | 298 |
299 void WebViewGuest::DidAttachToEmbedder() { | 299 void WebViewGuest::DidAttachToEmbedder() { |
300 std::string name; | 300 std::string name; |
301 if (extra_params()->GetString(webview::kName, &name)) { | 301 if (attach_params()->GetString(webview::kName, &name)) { |
302 // If the guest window's name is empty, then the WebView tag's name is | 302 // If the guest window's name is empty, then the WebView tag's name is |
303 // assigned. Otherwise, the guest window's name takes precedence over the | 303 // assigned. Otherwise, the guest window's name takes precedence over the |
304 // WebView tag's name. | 304 // WebView tag's name. |
305 if (name_.empty()) | 305 if (name_.empty()) |
306 name_ = name; | 306 name_ = name; |
307 } | 307 } |
308 ReportFrameNameChange(name_); | 308 ReportFrameNameChange(name_); |
309 | 309 |
310 std::string user_agent_override; | 310 std::string user_agent_override; |
311 if (extra_params()->GetString(webview::kParameterUserAgentOverride, | 311 if (attach_params()->GetString(webview::kParameterUserAgentOverride, |
312 &user_agent_override)) { | 312 &user_agent_override)) { |
313 SetUserAgentOverride(user_agent_override); | 313 SetUserAgentOverride(user_agent_override); |
314 } else { | 314 } else { |
315 SetUserAgentOverride(""); | 315 SetUserAgentOverride(""); |
316 } | 316 } |
317 | 317 |
318 std::string src; | 318 std::string src; |
319 if (extra_params()->GetString("src", &src) && !src.empty()) | 319 if (attach_params()->GetString("src", &src) && !src.empty()) |
320 NavigateGuest(src); | 320 NavigateGuest(src); |
321 | 321 |
322 if (GetOpener()) { | 322 if (GetOpener()) { |
323 // We need to do a navigation here if the target URL has changed between | 323 // We need to do a navigation here if the target URL has changed between |
324 // the time the WebContents was created and the time it was attached. | 324 // the time the WebContents was created and the time it was attached. |
325 // We also need to do an initial navigation if a RenderView was never | 325 // We also need to do an initial navigation if a RenderView was never |
326 // created for the new window in cases where there is no referrer. | 326 // created for the new window in cases where there is no referrer. |
327 PendingWindowMap::iterator it = | 327 PendingWindowMap::iterator it = |
328 GetOpener()->pending_new_windows_.find(this); | 328 GetOpener()->pending_new_windows_.find(this); |
329 if (it != GetOpener()->pending_new_windows_.end()) { | 329 if (it != GetOpener()->pending_new_windows_.end()) { |
(...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1239 bool allow, | 1239 bool allow, |
1240 const std::string& user_input) { | 1240 const std::string& user_input) { |
1241 WebViewGuest* guest = | 1241 WebViewGuest* guest = |
1242 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); | 1242 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); |
1243 if (!guest) | 1243 if (!guest) |
1244 return; | 1244 return; |
1245 | 1245 |
1246 if (!allow) | 1246 if (!allow) |
1247 guest->Destroy(); | 1247 guest->Destroy(); |
1248 } | 1248 } |
OLD | NEW |