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