| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/web_contents/web_contents_impl.h" | 5 #include "content/browser/web_contents/web_contents_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 last_dialog_suppressed_(false), | 504 last_dialog_suppressed_(false), |
| 505 geolocation_service_context_(new device::GeolocationServiceContext()), | 505 geolocation_service_context_(new device::GeolocationServiceContext()), |
| 506 accessibility_mode_( | 506 accessibility_mode_( |
| 507 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()), | 507 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()), |
| 508 audio_stream_monitor_(this), | 508 audio_stream_monitor_(this), |
| 509 bluetooth_connected_device_count_(0), | 509 bluetooth_connected_device_count_(0), |
| 510 virtual_keyboard_requested_(false), | 510 virtual_keyboard_requested_(false), |
| 511 page_scale_factor_is_one_(true), | 511 page_scale_factor_is_one_(true), |
| 512 mouse_lock_widget_(nullptr), | 512 mouse_lock_widget_(nullptr), |
| 513 is_overlay_content_(false), | 513 is_overlay_content_(false), |
| 514 showing_context_menu_(false), |
| 514 loading_weak_factory_(this), | 515 loading_weak_factory_(this), |
| 515 weak_factory_(this) { | 516 weak_factory_(this) { |
| 516 frame_tree_.SetFrameRemoveListener( | 517 frame_tree_.SetFrameRemoveListener( |
| 517 base::Bind(&WebContentsImpl::OnFrameRemoved, | 518 base::Bind(&WebContentsImpl::OnFrameRemoved, |
| 518 base::Unretained(this))); | 519 base::Unretained(this))); |
| 519 #if defined(OS_ANDROID) | 520 #if defined(OS_ANDROID) |
| 520 media_web_contents_observer_.reset(new MediaWebContentsObserverAndroid(this)); | 521 media_web_contents_observer_.reset(new MediaWebContentsObserverAndroid(this)); |
| 521 #else | 522 #else |
| 522 media_web_contents_observer_.reset(new MediaWebContentsObserver(this)); | 523 media_web_contents_observer_.reset(new MediaWebContentsObserver(this)); |
| 523 #endif | 524 #endif |
| (...skipping 3841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4365 is_notifying_observers_ = false; | 4366 is_notifying_observers_ = false; |
| 4366 #if BUILDFLAG(ENABLE_PLUGINS) | 4367 #if BUILDFLAG(ENABLE_PLUGINS) |
| 4367 pepper_playback_observer_->RenderFrameDeleted(render_frame_host); | 4368 pepper_playback_observer_->RenderFrameDeleted(render_frame_host); |
| 4368 #endif | 4369 #endif |
| 4369 } | 4370 } |
| 4370 | 4371 |
| 4371 void WebContentsImpl::ShowContextMenu(RenderFrameHost* render_frame_host, | 4372 void WebContentsImpl::ShowContextMenu(RenderFrameHost* render_frame_host, |
| 4372 const ContextMenuParams& params) { | 4373 const ContextMenuParams& params) { |
| 4373 // If a renderer fires off a second command to show a context menu before the | 4374 // If a renderer fires off a second command to show a context menu before the |
| 4374 // first context menu is closed, just ignore it. https://crbug.com/707534 | 4375 // first context menu is closed, just ignore it. https://crbug.com/707534 |
| 4375 if (GetRenderWidgetHostView()->IsShowingContextMenu()) | 4376 if (showing_context_menu_) |
| 4376 return; | 4377 return; |
| 4377 | 4378 |
| 4378 ContextMenuParams context_menu_params(params); | 4379 ContextMenuParams context_menu_params(params); |
| 4379 // Allow WebContentsDelegates to handle the context menu operation first. | 4380 // Allow WebContentsDelegates to handle the context menu operation first. |
| 4380 if (delegate_ && delegate_->HandleContextMenu(context_menu_params)) | 4381 if (delegate_ && delegate_->HandleContextMenu(context_menu_params)) |
| 4381 return; | 4382 return; |
| 4382 | 4383 |
| 4383 render_view_host_delegate_view_->ShowContextMenu(render_frame_host, | 4384 render_view_host_delegate_view_->ShowContextMenu(render_frame_host, |
| 4384 context_menu_params); | 4385 context_menu_params); |
| 4385 } | 4386 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4477 | 4478 |
| 4478 bool WebContentsImpl::HasActiveEffectivelyFullscreenVideo() const { | 4479 bool WebContentsImpl::HasActiveEffectivelyFullscreenVideo() const { |
| 4479 return media_web_contents_observer_->HasActiveEffectivelyFullscreenVideo(); | 4480 return media_web_contents_observer_->HasActiveEffectivelyFullscreenVideo(); |
| 4480 } | 4481 } |
| 4481 | 4482 |
| 4482 bool WebContentsImpl::IsFocusedElementEditable() { | 4483 bool WebContentsImpl::IsFocusedElementEditable() { |
| 4483 RenderFrameHostImpl* frame = GetFocusedFrame(); | 4484 RenderFrameHostImpl* frame = GetFocusedFrame(); |
| 4484 return frame && frame->has_focused_editable_element(); | 4485 return frame && frame->has_focused_editable_element(); |
| 4485 } | 4486 } |
| 4486 | 4487 |
| 4488 bool WebContentsImpl::IsShowingContextMenu() const { |
| 4489 return showing_context_menu_; |
| 4490 } |
| 4491 |
| 4492 void WebContentsImpl::SetShowingContextMenu(bool showing) { |
| 4493 DCHECK_NE(showing_context_menu_, showing); |
| 4494 showing_context_menu_ = showing; |
| 4495 #if defined(OS_MACOSX) |
| 4496 if (auto* view = GetRenderWidgetHostView()) { |
| 4497 static_cast<RenderWidgetHostViewBase*>(view)->SetShowingContextMenu( |
| 4498 showing); |
| 4499 } |
| 4500 #endif |
| 4501 } |
| 4502 |
| 4487 void WebContentsImpl::ClearFocusedElement() { | 4503 void WebContentsImpl::ClearFocusedElement() { |
| 4488 if (auto* frame = GetFocusedFrame()) | 4504 if (auto* frame = GetFocusedFrame()) |
| 4489 frame->ClearFocusedElement(); | 4505 frame->ClearFocusedElement(); |
| 4490 } | 4506 } |
| 4491 | 4507 |
| 4492 bool WebContentsImpl::IsNeverVisible() { | 4508 bool WebContentsImpl::IsNeverVisible() { |
| 4493 if (!delegate_) | 4509 if (!delegate_) |
| 4494 return false; | 4510 return false; |
| 4495 return delegate_->IsNeverVisible(this); | 4511 return delegate_->IsNeverVisible(this); |
| 4496 } | 4512 } |
| (...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5621 | 5637 |
| 5622 GetMainFrame()->AddMessageToConsole( | 5638 GetMainFrame()->AddMessageToConsole( |
| 5623 content::CONSOLE_MESSAGE_LEVEL_WARNING, | 5639 content::CONSOLE_MESSAGE_LEVEL_WARNING, |
| 5624 base::StringPrintf("This site does not have a valid SSL " | 5640 base::StringPrintf("This site does not have a valid SSL " |
| 5625 "certificate! Without SSL, your site's and " | 5641 "certificate! Without SSL, your site's and " |
| 5626 "visitors' data is vulnerable to theft and " | 5642 "visitors' data is vulnerable to theft and " |
| 5627 "tampering. Get a valid SSL certificate before" | 5643 "tampering. Get a valid SSL certificate before" |
| 5628 " releasing your website to the public.")); | 5644 " releasing your website to the public.")); |
| 5629 } | 5645 } |
| 5630 | 5646 |
| 5647 bool WebContentsImpl::IsShowingContextMenuOnPage() const { |
| 5648 return showing_context_menu_; |
| 5649 } |
| 5650 |
| 5631 void WebContentsImpl::NotifyPreferencesChanged() { | 5651 void WebContentsImpl::NotifyPreferencesChanged() { |
| 5632 std::set<RenderViewHost*> render_view_host_set; | 5652 std::set<RenderViewHost*> render_view_host_set; |
| 5633 for (FrameTreeNode* node : frame_tree_.Nodes()) { | 5653 for (FrameTreeNode* node : frame_tree_.Nodes()) { |
| 5634 RenderWidgetHost* render_widget_host = | 5654 RenderWidgetHost* render_widget_host = |
| 5635 node->current_frame_host()->GetRenderWidgetHost(); | 5655 node->current_frame_host()->GetRenderWidgetHost(); |
| 5636 if (!render_widget_host) | 5656 if (!render_widget_host) |
| 5637 continue; | 5657 continue; |
| 5638 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host); | 5658 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host); |
| 5639 if (!render_view_host) | 5659 if (!render_view_host) |
| 5640 continue; | 5660 continue; |
| 5641 render_view_host_set.insert(render_view_host); | 5661 render_view_host_set.insert(render_view_host); |
| 5642 } | 5662 } |
| 5643 for (RenderViewHost* render_view_host : render_view_host_set) | 5663 for (RenderViewHost* render_view_host : render_view_host_set) |
| 5644 render_view_host->OnWebkitPreferencesChanged(); | 5664 render_view_host->OnWebkitPreferencesChanged(); |
| 5645 } | 5665 } |
| 5646 | 5666 |
| 5647 } // namespace content | 5667 } // namespace content |
| OLD | NEW |