Commit d3a5e4ea authored by Alex Ilin's avatar Alex Ilin Committed by Commit Bot

[ProfilePicker] Disable context menu in the profile picker window

Standard context menu options aren't available in profile picker web
contents. For example, "View page source" and "Inspect" don't work at
all in the system profile.

This change also helps fix the bug when the profile picker window closes
after dismissing the context menu (I don't know what's the cause of this
though).

Bug: 1121543, 1121541
Change-Id: Iad91145481c8b5d8184f0bf600cea5a8a39f158c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2374451Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Commit-Queue: Alex Ilin <alexilin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801477}
parent 5a949335
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
#include "chrome/common/webui_url_constants.h" #include "chrome/common/webui_url_constants.h"
#include "chrome/grit/chromium_strings.h" #include "chrome/grit/chromium_strings.h"
#include "chrome/grit/google_chrome_strings.h" #include "chrome/grit/google_chrome_strings.h"
#include "content/public/browser/context_menu_params.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/render_widget_host_view.h"
#include "ui/views/controls/webview/webview.h" #include "ui/views/controls/webview/webview.h"
#include "ui/views/layout/fill_layout.h" #include "ui/views/layout/fill_layout.h"
...@@ -112,6 +114,7 @@ void ProfilePickerView::OnSystemProfileCreated(ProfilePicker::Page init_page, ...@@ -112,6 +114,7 @@ void ProfilePickerView::OnSystemProfileCreated(ProfilePicker::Page init_page,
void ProfilePickerView::Init(ProfilePicker::Page init_page, void ProfilePickerView::Init(ProfilePicker::Page init_page,
Profile* system_profile) { Profile* system_profile) {
web_view_ = new views::WebView(system_profile); web_view_ = new views::WebView(system_profile);
web_view_->GetWebContents()->SetDelegate(this);
AddChildView(web_view_); AddChildView(web_view_);
SetLayoutManager(std::make_unique<views::FillLayout>()); SetLayoutManager(std::make_unique<views::FillLayout>());
...@@ -157,3 +160,10 @@ gfx::Size ProfilePickerView::GetMinimumSize() const { ...@@ -157,3 +160,10 @@ gfx::Size ProfilePickerView::GetMinimumSize() const {
minimum_size.SetToMin(ProfilePickerUI::GetMinimumSize()); minimum_size.SetToMin(ProfilePickerUI::GetMinimumSize());
return minimum_size; return minimum_size;
} }
bool ProfilePickerView::HandleContextMenu(
content::RenderFrameHost* render_frame_host,
const content::ContextMenuParams& params) {
// Ignores context menu.
return true;
}
...@@ -7,11 +7,18 @@ ...@@ -7,11 +7,18 @@
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/profile_picker.h" #include "chrome/browser/ui/profile_picker.h"
#include "content/public/browser/web_contents_delegate.h"
#include "ui/views/controls/webview/webview.h" #include "ui/views/controls/webview/webview.h"
#include "ui/views/window/dialog_delegate.h" #include "ui/views/window/dialog_delegate.h"
namespace content {
struct ContextMenuParams;
class RenderFrameHost;
} // namespace content
// Dialog widget that contains the Desktop Profile picker webui. // Dialog widget that contains the Desktop Profile picker webui.
class ProfilePickerView : public views::DialogDelegateView { class ProfilePickerView : public views::DialogDelegateView,
public content::WebContentsDelegate {
private: private:
friend class ProfilePicker; friend class ProfilePicker;
...@@ -45,6 +52,10 @@ class ProfilePickerView : public views::DialogDelegateView { ...@@ -45,6 +52,10 @@ class ProfilePickerView : public views::DialogDelegateView {
// views::View; // views::View;
gfx::Size GetMinimumSize() const override; gfx::Size GetMinimumSize() const override;
// content::WebContentsDelegate:
bool HandleContextMenu(content::RenderFrameHost* render_frame_host,
const content::ContextMenuParams& params) override;
views::WebView* web_view_; views::WebView* web_view_;
InitState initialized_; InitState initialized_;
base::WeakPtrFactory<ProfilePickerView> weak_ptr_factory_{this}; base::WeakPtrFactory<ProfilePickerView> weak_ptr_factory_{this};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment