Commit 0a26ad31 authored by Findit's avatar Findit

Revert "Fix crash when right clicking link in CastUI"

This reverts commit 0ea2267a.

Reason for revert:

Findit (https://goo.gl/kROfz5) identified CL at revision 580029 as the
culprit for failures in the build cycles as shown on:
https://findit-for-me.appspot.com/waterfall/culprit?key=ag9zfmZpbmRpdC1mb3ItbWVyRAsSDVdmU3VzcGVjdGVkQ0wiMWNocm9taXVtLzBlYTIyNjdhN2NlZmE0OWZmZDNmMzA4MGRjZWEyNDFkOWJiY2RmZDcM

Sample Failed Build: https://ci.chromium.org/buildbot/chromium.memory/Linux%20CFI/9359

Sample Failed Step: not_site_per_process_browser_tests

Original change's description:
> Fix crash when right clicking link in CastUI
> 
> This CL adds a null check to RenderViewContextMenu::AppendLinkItems()
> ensuring we have an associated Browser before attempting to use it.
> 
> Bug: 869280
> Change-Id: Ib1ffecd9dfbe27fb4fc6f6c77762c6337c36d4d4
> Reviewed-on: https://chromium-review.googlesource.com/1158110
> Reviewed-by: Avi Drissman <avi@chromium.org>
> Reviewed-by: Giovanni Ortuño Urquidi <ortuno@chromium.org>
> Commit-Queue: Alan Cutter <alancutter@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#580029}

Change-Id: Ie3a0067047c42fc8682ca8663eede8f1195afaed
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 869280
Reviewed-on: https://chromium-review.googlesource.com/1159804
Cr-Commit-Position: refs/heads/master@{#580095}
parent 64ab6403
......@@ -22,7 +22,6 @@ include_rules = [
"+components/policy/throttle/",
"+content/public/browser",
"+content/public/common",
"+content/test",
"+courgette",
"+device/base",
"+device/bluetooth",
......
......@@ -1032,16 +1032,13 @@ void RenderViewContextMenu::AppendDevtoolsForUnpackedExtensions() {
void RenderViewContextMenu::AppendLinkItems() {
if (!params_.link_url.is_empty()) {
if (base::FeatureList::IsEnabled(features::kDesktopPWAWindowing)) {
const Browser* browser = GetBrowser();
const bool is_app = browser && browser->is_app();
AppendOpenInBookmarkAppLinkItems();
menu_model_.AddItemWithStringId(
IDC_CONTENT_CONTEXT_OPENLINKNEWTAB,
is_app ? IDS_CONTENT_CONTEXT_OPENLINKNEWTAB_INAPP
: IDS_CONTENT_CONTEXT_OPENLINKNEWTAB);
if (!is_app) {
GetBrowser()->is_app() ? IDS_CONTENT_CONTEXT_OPENLINKNEWTAB_INAPP
: IDS_CONTENT_CONTEXT_OPENLINKNEWTAB);
if (!GetBrowser()->is_app()) {
menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW,
IDS_CONTENT_CONTEXT_OPENLINKNEWWINDOW);
}
......@@ -1052,8 +1049,9 @@ void RenderViewContextMenu::AppendLinkItems() {
menu_model_.AddItemWithStringId(
IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD,
is_app ? IDS_CONTENT_CONTEXT_OPENLINKOFFTHERECORD_INAPP
: IDS_CONTENT_CONTEXT_OPENLINKOFFTHERECORD);
GetBrowser()->is_app()
? IDS_CONTENT_CONTEXT_OPENLINKOFFTHERECORD_INAPP
: IDS_CONTENT_CONTEXT_OPENLINKOFFTHERECORD);
} else {
menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKNEWTAB,
......@@ -1195,10 +1193,8 @@ void RenderViewContextMenu::AppendOpenInBookmarkAppLinkItems() {
return;
int open_in_app_string_id;
const Browser* browser = GetBrowser();
if (browser &&
browser->app_name() ==
web_app::GenerateApplicationNameFromExtensionId(pwa->id())) {
if (GetBrowser()->app_name() ==
web_app::GenerateApplicationNameFromExtensionId(pwa->id())) {
open_in_app_string_id = IDS_CONTENT_CONTEXT_OPENLINKBOOKMARKAPP_SAMEAPP;
} else {
open_in_app_string_id = IDS_CONTENT_CONTEXT_OPENLINKBOOKMARKAPP;
......
......@@ -81,8 +81,6 @@ class RenderViewContextMenu : public RenderViewContextMenuBase {
protected:
Profile* GetProfile() const;
// This may return nullptr (e.g. for WebUI dialogs).
Browser* GetBrowser() const;
// Returns a (possibly truncated) version of the current selection text
......
......@@ -62,7 +62,6 @@
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_utils.h"
#include "content/test/test_web_contents.h"
#include "extensions/browser/api/extensions_api_client.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
......@@ -1245,17 +1244,4 @@ IN_PROC_BROWSER_TEST_F(ContextMenuBrowserTest,
EXPECT_TRUE(menu.IsItemChecked(IDC_CONTENT_CONTEXT_PICTUREINPICTURE));
}
// This test checks that we don't crash when creating a context menu for a
// WebContents with no Browser.
IN_PROC_BROWSER_TEST_F(ContextMenuBrowserTest, BrowserlessWebContentsCrash) {
base::test::ScopedFeatureList feature_list;
feature_list.InitAndEnableFeature(features::kDesktopPWAWindowing);
std::unique_ptr<content::TestWebContents> web_contents =
content::TestWebContents::Create(browser()->profile(), nullptr);
CreateContextMenuInWebContents(
web_contents.get(), GURL("http://www.google.com/"),
GURL("http://www.google.com/"), base::ASCIIToUTF16("Google"),
blink::WebContextMenuData::kMediaTypeNone, ui::MENU_SOURCE_MOUSE);
}
} // namespace
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