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/web_view/web_view_guest.h" | 5 #include "extensions/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 "content/public/browser/browser_context.h" | 10 #include "content/public/browser/browser_context.h" |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 | 370 |
371 void WebViewGuest::GuestReady() { | 371 void WebViewGuest::GuestReady() { |
372 // The guest RenderView should always live in an isolated guest process. | 372 // The guest RenderView should always live in an isolated guest process. |
373 CHECK(web_contents()->GetRenderProcessHost()->IsIsolatedGuest()); | 373 CHECK(web_contents()->GetRenderProcessHost()->IsIsolatedGuest()); |
374 Send(new ExtensionMsg_SetFrameName(web_contents()->GetRoutingID(), name_)); | 374 Send(new ExtensionMsg_SetFrameName(web_contents()->GetRoutingID(), name_)); |
375 | 375 |
376 // We don't want to accidentally set the opacity of an interstitial page. | 376 // We don't want to accidentally set the opacity of an interstitial page. |
377 // WebContents::GetRenderWidgetHostView will return the RWHV of an | 377 // WebContents::GetRenderWidgetHostView will return the RWHV of an |
378 // interstitial page if one is showing at this time. We only want opacity | 378 // interstitial page if one is showing at this time. We only want opacity |
379 // to apply to web pages. | 379 // to apply to web pages. |
380 if (guest_opaque_) { | 380 web_contents()->GetRenderViewHost()->GetView()-> |
381 web_contents() | 381 SetBackgroundOpaque(guest_opaque_); |
382 ->GetRenderViewHost() | |
383 ->GetView() | |
384 ->SetBackgroundColorToDefault(); | |
385 } else { | |
386 web_contents()->GetRenderViewHost()->GetView()->SetBackgroundColor( | |
387 SK_ColorTRANSPARENT); | |
388 } | |
389 if (web_view_guest_delegate_) | 382 if (web_view_guest_delegate_) |
390 web_view_guest_delegate_->OnGuestReady(); | 383 web_view_guest_delegate_->OnGuestReady(); |
391 } | 384 } |
392 | 385 |
393 void WebViewGuest::GuestSizeChangedDueToAutoSize(const gfx::Size& old_size, | 386 void WebViewGuest::GuestSizeChangedDueToAutoSize(const gfx::Size& old_size, |
394 const gfx::Size& new_size) { | 387 const gfx::Size& new_size) { |
395 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 388 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
396 args->SetInteger(webview::kOldHeight, old_size.height()); | 389 args->SetInteger(webview::kOldHeight, old_size.height()); |
397 args->SetInteger(webview::kOldWidth, old_size.width()); | 390 args->SetInteger(webview::kOldWidth, old_size.width()); |
398 args->SetInteger(webview::kNewHeight, new_size.height()); | 391 args->SetInteger(webview::kNewHeight, new_size.height()); |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1032 } | 1025 } |
1033 | 1026 |
1034 void WebViewGuest::SetAllowTransparency(bool allow) { | 1027 void WebViewGuest::SetAllowTransparency(bool allow) { |
1035 if (guest_opaque_ != allow) | 1028 if (guest_opaque_ != allow) |
1036 return; | 1029 return; |
1037 | 1030 |
1038 guest_opaque_ = !allow; | 1031 guest_opaque_ = !allow; |
1039 if (!web_contents()->GetRenderViewHost()->GetView()) | 1032 if (!web_contents()->GetRenderViewHost()->GetView()) |
1040 return; | 1033 return; |
1041 | 1034 |
1042 if (guest_opaque_) { | 1035 web_contents()->GetRenderViewHost()->GetView()->SetBackgroundOpaque(!allow); |
1043 web_contents() | |
1044 ->GetRenderViewHost() | |
1045 ->GetView() | |
1046 ->SetBackgroundColorToDefault(); | |
1047 } else { | |
1048 web_contents()->GetRenderViewHost()->GetView()->SetBackgroundColor( | |
1049 SK_ColorTRANSPARENT); | |
1050 } | |
1051 } | 1036 } |
1052 | 1037 |
1053 bool WebViewGuest::LoadDataWithBaseURL(const std::string& data_url, | 1038 bool WebViewGuest::LoadDataWithBaseURL(const std::string& data_url, |
1054 const std::string& base_url, | 1039 const std::string& base_url, |
1055 const std::string& virtual_url, | 1040 const std::string& virtual_url, |
1056 std::string* error) { | 1041 std::string* error) { |
1057 // Make GURLs from URLs. | 1042 // Make GURLs from URLs. |
1058 const GURL data_gurl = GURL(data_url); | 1043 const GURL data_gurl = GURL(data_url); |
1059 const GURL base_gurl = GURL(base_url); | 1044 const GURL base_gurl = GURL(base_url); |
1060 const GURL virtual_gurl = GURL(virtual_url); | 1045 const GURL virtual_gurl = GURL(virtual_url); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1240 WebViewGuest* guest = | 1225 WebViewGuest* guest = |
1241 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); | 1226 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); |
1242 if (!guest) | 1227 if (!guest) |
1243 return; | 1228 return; |
1244 | 1229 |
1245 if (!allow) | 1230 if (!allow) |
1246 guest->Destroy(); | 1231 guest->Destroy(); |
1247 } | 1232 } |
1248 | 1233 |
1249 } // namespace extensions | 1234 } // namespace extensions |
OLD | NEW |