Chromium Code Reviews| 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 213 if (!guest) | 213 if (!guest) |
| 214 return guestview::kInstanceIDNone; | 214 return guestview::kInstanceIDNone; |
| 215 | 215 |
| 216 return guest->view_instance_id(); | 216 return guest->view_instance_id(); |
| 217 } | 217 } |
| 218 | 218 |
| 219 bool WebViewGuest::CanRunInDetachedState() const { | 219 bool WebViewGuest::CanRunInDetachedState() const { |
| 220 return true; | 220 return true; |
| 221 } | 221 } |
| 222 | 222 |
| 223 void WebViewGuest::EnterFullscreenModeForTab( | |
| 224 content::WebContents* web_contents, const GURL& origin) { | |
| 225 printf("++++ %s\n", __PRETTY_FUNCTION__); | |
| 226 base::DictionaryValue request_info; | |
| 227 request_info.SetString(guestview::kUrl, origin.spec()); | |
| 228 web_view_permission_helper_->RequestPermission( | |
| 229 WEB_VIEW_PERMISSION_TYPE_FULLSCREEN, | |
| 230 request_info, | |
| 231 base::Bind(&WebViewGuest::OnFullscreenPermissionDecided, | |
| 232 weak_ptr_factory_.GetWeakPtr(), | |
| 233 origin), | |
| 234 false /* allowed_by_default */); | |
| 235 } | |
| 236 | |
| 237 void WebViewGuest::OnFullscreenPermissionDecided( | |
| 238 const GURL& origin, | |
| 239 bool allowed, | |
| 240 const std::string& user_input) { | |
| 241 printf("________ %s, allowed: %d\n", __PRETTY_FUNCTION__, allowed); | |
| 242 // TODO: Explain. | |
| 243 is_fullscreen_ = true; | |
| 244 if (allowed) { | |
|
Fady Samuel
2015/03/13 01:43:06
Only do this if attached.
| |
| 245 // Ask the embedder to go fullscreen. | |
| 246 owner_web_contents()->GetDelegate()->EnterFullscreenModeForTab( | |
| 247 web_contents(), origin); | |
| 248 } | |
| 249 } | |
| 250 | |
| 251 void WebViewGuest::ExitFullscreenModeForTab(content::WebContents* web_contents) { | |
| 252 printf("+++ %s\n", __PRETTY_FUNCTION__); | |
| 253 bool was_fullscren = is_fullscreen_; | |
| 254 is_fullscreen_ = false; | |
| 255 | |
| 256 if (was_fullscren) { | |
| 257 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | |
| 258 args->SetString(guestview::kUrl, "teststuff"); | |
| 259 DispatchEventToView( | |
| 260 new GuestViewBase::Event(webview::kEventExitFullscreen, args.Pass())); | |
| 261 } | |
| 262 } | |
| 263 | |
| 264 bool WebViewGuest::IsFullscreenForTabOrPending( | |
| 265 const content::WebContents* web_contents) const { | |
| 266 return is_fullscreen_; | |
| 267 } | |
| 268 | |
| 269 void WebViewGuest::EmbedderFullscreenToggled( | |
| 270 bool entered_fullscreen) { | |
| 271 printf("____ %s, entered_fullscreen: %d\n", | |
| 272 __PRETTY_FUNCTION__, entered_fullscreen); | |
| 273 if (!entered_fullscreen) { | |
| 274 is_fullscreen_ = false; | |
| 275 } | |
| 276 } | |
| 277 | |
| 223 void WebViewGuest::CreateWebContents( | 278 void WebViewGuest::CreateWebContents( |
| 224 const base::DictionaryValue& create_params, | 279 const base::DictionaryValue& create_params, |
| 225 const WebContentsCreatedCallback& callback) { | 280 const WebContentsCreatedCallback& callback) { |
| 226 content::RenderProcessHost* owner_render_process_host = | 281 content::RenderProcessHost* owner_render_process_host = |
| 227 owner_web_contents()->GetRenderProcessHost(); | 282 owner_web_contents()->GetRenderProcessHost(); |
| 228 std::string storage_partition_id; | 283 std::string storage_partition_id; |
| 229 bool persist_storage = false; | 284 bool persist_storage = false; |
| 230 ParsePartitionParam(create_params, &storage_partition_id, &persist_storage); | 285 ParsePartitionParam(create_params, &storage_partition_id, &persist_storage); |
| 231 // Validate that the partition id coming from the renderer is valid UTF-8, | 286 // Validate that the partition id coming from the renderer is valid UTF-8, |
| 232 // since we depend on this in other parts of the code, such as FilePath | 287 // since we depend on this in other parts of the code, such as FilePath |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 644 | 699 |
| 645 WebViewGuest::WebViewGuest(content::WebContents* owner_web_contents) | 700 WebViewGuest::WebViewGuest(content::WebContents* owner_web_contents) |
| 646 : GuestView<WebViewGuest>(owner_web_contents), | 701 : GuestView<WebViewGuest>(owner_web_contents), |
| 647 rules_registry_id_(RulesRegistryService::kInvalidRulesRegistryID), | 702 rules_registry_id_(RulesRegistryService::kInvalidRulesRegistryID), |
| 648 find_helper_(this), | 703 find_helper_(this), |
| 649 is_overriding_user_agent_(false), | 704 is_overriding_user_agent_(false), |
| 650 guest_opaque_(true), | 705 guest_opaque_(true), |
| 651 javascript_dialog_helper_(this), | 706 javascript_dialog_helper_(this), |
| 652 current_zoom_factor_(1.0), | 707 current_zoom_factor_(1.0), |
| 653 allow_scaling_(false), | 708 allow_scaling_(false), |
| 709 is_fullscreen_(false), | |
| 654 weak_ptr_factory_(this) { | 710 weak_ptr_factory_(this) { |
| 655 web_view_guest_delegate_.reset( | 711 web_view_guest_delegate_.reset( |
| 656 ExtensionsAPIClient::Get()->CreateWebViewGuestDelegate(this)); | 712 ExtensionsAPIClient::Get()->CreateWebViewGuestDelegate(this)); |
| 657 } | 713 } |
| 658 | 714 |
| 659 WebViewGuest::~WebViewGuest() { | 715 WebViewGuest::~WebViewGuest() { |
| 660 } | 716 } |
| 661 | 717 |
| 662 void WebViewGuest::DidCommitProvisionalLoadForFrame( | 718 void WebViewGuest::DidCommitProvisionalLoadForFrame( |
| 663 content::RenderFrameHost* render_frame_host, | 719 content::RenderFrameHost* render_frame_host, |
| (...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1269 WebViewGuest::From(owner_web_contents()->GetRenderProcessHost()->GetID(), | 1325 WebViewGuest::From(owner_web_contents()->GetRenderProcessHost()->GetID(), |
| 1270 new_window_instance_id); | 1326 new_window_instance_id); |
| 1271 if (!guest) | 1327 if (!guest) |
| 1272 return; | 1328 return; |
| 1273 | 1329 |
| 1274 if (!allow) | 1330 if (!allow) |
| 1275 guest->Destroy(); | 1331 guest->Destroy(); |
| 1276 } | 1332 } |
| 1277 | 1333 |
| 1278 } // namespace extensions | 1334 } // namespace extensions |
| OLD | NEW |