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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 embedder_render_process_host->GetBrowserContext(), | 283 embedder_render_process_host->GetBrowserContext(), |
284 guest_site_instance); | 284 guest_site_instance); |
285 params.guest_delegate = this; | 285 params.guest_delegate = this; |
286 callback.Run(WebContents::Create(params)); | 286 callback.Run(WebContents::Create(params)); |
287 } | 287 } |
288 | 288 |
289 void WebViewGuest::DidAttachToEmbedder() { | 289 void WebViewGuest::DidAttachToEmbedder() { |
290 SetUpAutoSize(); | 290 SetUpAutoSize(); |
291 | 291 |
292 std::string name; | 292 std::string name; |
293 if (extra_params()->GetString(webview::kName, &name)) { | 293 if (attach_params()->GetString(webview::kName, &name)) { |
294 // If the guest window's name is empty, then the WebView tag's name is | 294 // If the guest window's name is empty, then the WebView tag's name is |
295 // assigned. Otherwise, the guest window's name takes precedence over the | 295 // assigned. Otherwise, the guest window's name takes precedence over the |
296 // WebView tag's name. | 296 // WebView tag's name. |
297 if (name_.empty()) | 297 if (name_.empty()) |
298 name_ = name; | 298 name_ = name; |
299 } | 299 } |
300 ReportFrameNameChange(name_); | 300 ReportFrameNameChange(name_); |
301 | 301 |
302 std::string user_agent_override; | 302 std::string user_agent_override; |
303 if (extra_params()->GetString(webview::kParameterUserAgentOverride, | 303 if (attach_params()->GetString(webview::kParameterUserAgentOverride, |
304 &user_agent_override)) { | 304 &user_agent_override)) { |
305 SetUserAgentOverride(user_agent_override); | 305 SetUserAgentOverride(user_agent_override); |
306 } else { | 306 } else { |
307 SetUserAgentOverride(""); | 307 SetUserAgentOverride(""); |
308 } | 308 } |
309 | 309 |
310 std::string src; | 310 std::string src; |
311 if (extra_params()->GetString("src", &src) && !src.empty()) | 311 if (attach_params()->GetString("src", &src) && !src.empty()) |
312 NavigateGuest(src); | 312 NavigateGuest(src); |
313 | 313 |
314 if (GetOpener()) { | 314 if (GetOpener()) { |
315 // We need to do a navigation here if the target URL has changed between | 315 // We need to do a navigation here if the target URL has changed between |
316 // the time the WebContents was created and the time it was attached. | 316 // the time the WebContents was created and the time it was attached. |
317 // We also need to do an initial navigation if a RenderView was never | 317 // We also need to do an initial navigation if a RenderView was never |
318 // created for the new window in cases where there is no referrer. | 318 // created for the new window in cases where there is no referrer. |
319 PendingWindowMap::iterator it = | 319 PendingWindowMap::iterator it = |
320 GetOpener()->pending_new_windows_.find(this); | 320 GetOpener()->pending_new_windows_.find(this); |
321 if (it != GetOpener()->pending_new_windows_.end()) { | 321 if (it != GetOpener()->pending_new_windows_.end()) { |
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1039 return true; | 1039 return true; |
1040 } | 1040 } |
1041 #endif | 1041 #endif |
1042 | 1042 |
1043 return false; | 1043 return false; |
1044 } | 1044 } |
1045 | 1045 |
1046 void WebViewGuest::SetUpAutoSize() { | 1046 void WebViewGuest::SetUpAutoSize() { |
1047 // Read the autosize parameters passed in from the embedder. | 1047 // Read the autosize parameters passed in from the embedder. |
1048 bool auto_size_enabled = false; | 1048 bool auto_size_enabled = false; |
1049 extra_params()->GetBoolean(webview::kAttributeAutoSize, &auto_size_enabled); | 1049 attach_params()->GetBoolean(webview::kAttributeAutoSize, &auto_size_enabled); |
1050 | 1050 |
1051 int max_height = 0; | 1051 int max_height = 0; |
1052 int max_width = 0; | 1052 int max_width = 0; |
1053 extra_params()->GetInteger(webview::kAttributeMaxHeight, &max_height); | 1053 attach_params()->GetInteger(webview::kAttributeMaxHeight, &max_height); |
1054 extra_params()->GetInteger(webview::kAttributeMaxWidth, &max_width); | 1054 attach_params()->GetInteger(webview::kAttributeMaxWidth, &max_width); |
1055 | 1055 |
1056 int min_height = 0; | 1056 int min_height = 0; |
1057 int min_width = 0; | 1057 int min_width = 0; |
1058 extra_params()->GetInteger(webview::kAttributeMinHeight, &min_height); | 1058 attach_params()->GetInteger(webview::kAttributeMinHeight, &min_height); |
1059 extra_params()->GetInteger(webview::kAttributeMinWidth, &min_width); | 1059 attach_params()->GetInteger(webview::kAttributeMinWidth, &min_width); |
1060 | 1060 |
1061 // Call SetAutoSize to apply all the appropriate validation and clipping of | 1061 // Call SetAutoSize to apply all the appropriate validation and clipping of |
1062 // values. | 1062 // values. |
1063 SetAutoSize(auto_size_enabled, | 1063 SetAutoSize(auto_size_enabled, |
1064 gfx::Size(min_width, min_height), | 1064 gfx::Size(min_width, min_height), |
1065 gfx::Size(max_width, max_height)); | 1065 gfx::Size(max_width, max_height)); |
1066 } | 1066 } |
1067 | 1067 |
1068 void WebViewGuest::ShowContextMenu(int request_id, | 1068 void WebViewGuest::ShowContextMenu(int request_id, |
1069 const MenuItemVector* items) { | 1069 const MenuItemVector* items) { |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1252 bool allow, | 1252 bool allow, |
1253 const std::string& user_input) { | 1253 const std::string& user_input) { |
1254 WebViewGuest* guest = | 1254 WebViewGuest* guest = |
1255 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); | 1255 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); |
1256 if (!guest) | 1256 if (!guest) |
1257 return; | 1257 return; |
1258 | 1258 |
1259 if (!allow) | 1259 if (!allow) |
1260 guest->Destroy(); | 1260 guest->Destroy(); |
1261 } | 1261 } |
OLD | NEW |