Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 2890143003: Move ContextMenu show/hide state tracking to WebContents (Closed)
Patch Set: Addressing kenrb@'s comments Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 accessibility_mode_( 509 accessibility_mode_(
510 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()), 510 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()),
511 audio_stream_monitor_(this), 511 audio_stream_monitor_(this),
512 bluetooth_connected_device_count_(0), 512 bluetooth_connected_device_count_(0),
513 virtual_keyboard_requested_(false), 513 virtual_keyboard_requested_(false),
514 #if !defined(OS_ANDROID) 514 #if !defined(OS_ANDROID)
515 page_scale_factor_is_one_(true), 515 page_scale_factor_is_one_(true),
516 #endif // !defined(OS_ANDROID) 516 #endif // !defined(OS_ANDROID)
517 mouse_lock_widget_(nullptr), 517 mouse_lock_widget_(nullptr),
518 is_overlay_content_(false), 518 is_overlay_content_(false),
519 showing_context_menu_(false),
519 loading_weak_factory_(this), 520 loading_weak_factory_(this),
520 weak_factory_(this) { 521 weak_factory_(this) {
521 frame_tree_.SetFrameRemoveListener( 522 frame_tree_.SetFrameRemoveListener(
522 base::Bind(&WebContentsImpl::OnFrameRemoved, 523 base::Bind(&WebContentsImpl::OnFrameRemoved,
523 base::Unretained(this))); 524 base::Unretained(this)));
524 #if defined(OS_ANDROID) 525 #if defined(OS_ANDROID)
525 media_web_contents_observer_.reset(new MediaWebContentsObserverAndroid(this)); 526 media_web_contents_observer_.reset(new MediaWebContentsObserverAndroid(this));
526 #else 527 #else
527 media_web_contents_observer_.reset(new MediaWebContentsObserver(this)); 528 media_web_contents_observer_.reset(new MediaWebContentsObserver(this));
528 #endif 529 #endif
(...skipping 3864 matching lines...) Expand 10 before | Expand all | Expand 10 after
4393 is_notifying_observers_ = false; 4394 is_notifying_observers_ = false;
4394 #if BUILDFLAG(ENABLE_PLUGINS) 4395 #if BUILDFLAG(ENABLE_PLUGINS)
4395 pepper_playback_observer_->RenderFrameDeleted(render_frame_host); 4396 pepper_playback_observer_->RenderFrameDeleted(render_frame_host);
4396 #endif 4397 #endif
4397 } 4398 }
4398 4399
4399 void WebContentsImpl::ShowContextMenu(RenderFrameHost* render_frame_host, 4400 void WebContentsImpl::ShowContextMenu(RenderFrameHost* render_frame_host,
4400 const ContextMenuParams& params) { 4401 const ContextMenuParams& params) {
4401 // If a renderer fires off a second command to show a context menu before the 4402 // If a renderer fires off a second command to show a context menu before the
4402 // first context menu is closed, just ignore it. https://crbug.com/707534 4403 // first context menu is closed, just ignore it. https://crbug.com/707534
4403 if (GetRenderWidgetHostView()->IsShowingContextMenu()) 4404 if (showing_context_menu_)
4404 return; 4405 return;
4405 4406
4406 ContextMenuParams context_menu_params(params); 4407 ContextMenuParams context_menu_params(params);
4407 // Allow WebContentsDelegates to handle the context menu operation first. 4408 // Allow WebContentsDelegates to handle the context menu operation first.
4408 if (delegate_ && delegate_->HandleContextMenu(context_menu_params)) 4409 if (delegate_ && delegate_->HandleContextMenu(context_menu_params))
4409 return; 4410 return;
4410 4411
4411 render_view_host_delegate_view_->ShowContextMenu(render_frame_host, 4412 render_view_host_delegate_view_->ShowContextMenu(render_frame_host,
4412 context_menu_params); 4413 context_menu_params);
4413 } 4414 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
4507 4508
4508 bool WebContentsImpl::HasActiveEffectivelyFullscreenVideo() const { 4509 bool WebContentsImpl::HasActiveEffectivelyFullscreenVideo() const {
4509 return media_web_contents_observer_->HasActiveEffectivelyFullscreenVideo(); 4510 return media_web_contents_observer_->HasActiveEffectivelyFullscreenVideo();
4510 } 4511 }
4511 4512
4512 bool WebContentsImpl::IsFocusedElementEditable() { 4513 bool WebContentsImpl::IsFocusedElementEditable() {
4513 RenderFrameHostImpl* frame = GetFocusedFrame(); 4514 RenderFrameHostImpl* frame = GetFocusedFrame();
4514 return frame && frame->has_focused_editable_element(); 4515 return frame && frame->has_focused_editable_element();
4515 } 4516 }
4516 4517
4518 bool WebContentsImpl::IsShowingContextMenu() const {
4519 return showing_context_menu_;
4520 }
4521
4522 void WebContentsImpl::SetShowingContextMenu(bool showing) {
4523 DCHECK_NE(showing_context_menu_, showing);
4524 showing_context_menu_ = showing;
4525 #if defined(OS_MACOSX)
4526 if (auto* view = GetRenderWidgetHostView()) {
4527 static_cast<RenderWidgetHostViewBase*>(view)->SetShowingContextMenu(
4528 showing);
Avi (use Gerrit) 2017/06/06 14:18:30 This concerns me. The function |SetShowingContextM
EhsanK 2017/06/06 16:17:38 Thanks! I agree the mismatch does not look nice. B
4529 }
4530 #endif
4531 }
4532
4517 void WebContentsImpl::ClearFocusedElement() { 4533 void WebContentsImpl::ClearFocusedElement() {
4518 if (auto* frame = GetFocusedFrame()) 4534 if (auto* frame = GetFocusedFrame())
4519 frame->ClearFocusedElement(); 4535 frame->ClearFocusedElement();
4520 } 4536 }
4521 4537
4522 bool WebContentsImpl::IsNeverVisible() { 4538 bool WebContentsImpl::IsNeverVisible() {
4523 if (!delegate_) 4539 if (!delegate_)
4524 return false; 4540 return false;
4525 return delegate_->IsNeverVisible(this); 4541 return delegate_->IsNeverVisible(this);
4526 } 4542 }
(...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after
5659 5675
5660 GetMainFrame()->AddMessageToConsole( 5676 GetMainFrame()->AddMessageToConsole(
5661 content::CONSOLE_MESSAGE_LEVEL_WARNING, 5677 content::CONSOLE_MESSAGE_LEVEL_WARNING,
5662 base::StringPrintf("This site does not have a valid SSL " 5678 base::StringPrintf("This site does not have a valid SSL "
5663 "certificate! Without SSL, your site's and " 5679 "certificate! Without SSL, your site's and "
5664 "visitors' data is vulnerable to theft and " 5680 "visitors' data is vulnerable to theft and "
5665 "tampering. Get a valid SSL certificate before" 5681 "tampering. Get a valid SSL certificate before"
5666 " releasing your website to the public.")); 5682 " releasing your website to the public."));
5667 } 5683 }
5668 5684
5685 bool WebContentsImpl::IsShowingContextMenuOnPage() const {
5686 return showing_context_menu_;
5687 }
5688
5669 void WebContentsImpl::NotifyPreferencesChanged() { 5689 void WebContentsImpl::NotifyPreferencesChanged() {
5670 std::set<RenderViewHost*> render_view_host_set; 5690 std::set<RenderViewHost*> render_view_host_set;
5671 for (FrameTreeNode* node : frame_tree_.Nodes()) { 5691 for (FrameTreeNode* node : frame_tree_.Nodes()) {
5672 RenderWidgetHost* render_widget_host = 5692 RenderWidgetHost* render_widget_host =
5673 node->current_frame_host()->GetRenderWidgetHost(); 5693 node->current_frame_host()->GetRenderWidgetHost();
5674 if (!render_widget_host) 5694 if (!render_widget_host)
5675 continue; 5695 continue;
5676 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host); 5696 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host);
5677 if (!render_view_host) 5697 if (!render_view_host)
5678 continue; 5698 continue;
5679 render_view_host_set.insert(render_view_host); 5699 render_view_host_set.insert(render_view_host);
5680 } 5700 }
5681 for (RenderViewHost* render_view_host : render_view_host_set) 5701 for (RenderViewHost* render_view_host : render_view_host_set)
5682 render_view_host->OnWebkitPreferencesChanged(); 5702 render_view_host->OnWebkitPreferencesChanged();
5683 } 5703 }
5684 5704
5685 } // namespace content 5705 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/public/browser/render_widget_host_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698