Commit f07bb46f authored by Michael Hansen's avatar Michael Hansen Committed by Chromium LUCI CQ

[Nearby] Fix "manage contacts" link within sharesheet.

The "Manage Contacts" button doesn't work when viewing the contact
visibility page from the sharesheet flow. We need a custom subclass of
views::WebView to perform the navigation.

Bug: 1138445
Change-Id: Id90e83b6e307d136bd0114ee51fc42c53b2c8510
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2567759
Commit-Queue: Michael Hansen <hansenmichael@google.com>
Reviewed-by: default avatarJames Vecore <vecore@google.com>
Cr-Commit-Position: refs/heads/master@{#833522}
parent 96d3c30a
......@@ -4380,6 +4380,8 @@ static_library("browser") {
"nearby_sharing/share_target_info.h",
"nearby_sharing/sharesheet/nearby_share_action.cc",
"nearby_sharing/sharesheet/nearby_share_action.h",
"nearby_sharing/sharesheet/nearby_share_web_view.cc",
"nearby_sharing/sharesheet/nearby_share_web_view.h",
"nearby_sharing/transfer_metadata.cc",
"nearby_sharing/transfer_metadata.h",
"nearby_sharing/transfer_metadata_builder.cc",
......
......@@ -14,6 +14,7 @@
#include "chrome/browser/chromeos/file_manager/fileapi_util.h"
#include "chrome/browser/nearby_sharing/attachment.h"
#include "chrome/browser/nearby_sharing/file_attachment.h"
#include "chrome/browser/nearby_sharing/sharesheet/nearby_share_web_view.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/sharesheet/sharesheet_types.h"
#include "chrome/browser/ui/webui/nearby_share/nearby_share_dialog_ui.h"
......@@ -93,7 +94,7 @@ void NearbyShareAction::LaunchAction(
controller->SetSharesheetSize(size.width(), size.height());
auto* profile = controller->GetProfile();
auto view = std::make_unique<views::WebView>(profile);
auto view = std::make_unique<NearbyShareWebView>(profile);
// If this is not done, we don't see anything in our view.
view->SetPreferredSize(size);
views::WebView* web_view = root_view->AddChildView(std::move(view));
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/nearby_sharing/sharesheet/nearby_share_web_view.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_navigator_params.h"
#include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
NearbyShareWebView::NearbyShareWebView(content::BrowserContext* browser_context)
: WebView(browser_context) {}
void NearbyShareWebView::WebContentsCreated(
content::WebContents* source_contents,
int opener_render_process_id,
int opener_render_frame_id,
const std::string& frame_name,
const GURL& target_url,
content::WebContents* new_contents) {
chrome::ScopedTabbedBrowserDisplayer displayer(
Profile::FromBrowserContext(GetBrowserContext()));
NavigateParams nav_params(displayer.browser(), target_url,
ui::PageTransition::PAGE_TRANSITION_LINK);
Navigate(&nav_params);
}
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_NEARBY_SHARING_SHARESHEET_NEARBY_SHARE_WEB_VIEW_H_
#define CHROME_BROWSER_NEARBY_SHARING_SHARESHEET_NEARBY_SHARE_WEB_VIEW_H_
#include "ui/views/controls/webview/webview.h"
namespace content {
class BrowserContext;
class WebContents;
} // namespace content
// NearbyShareWebView is used in place of the general views::WebView when
// creating the UI for the sharesheet action so that we can handle navigation
// to open a new tab when a link is clicked.
class NearbyShareWebView : public views::WebView {
public:
explicit NearbyShareWebView(content::BrowserContext* browser_context);
~NearbyShareWebView() override = default;
// content::WebContentsDelegate:
void WebContentsCreated(content::WebContents* source_contents,
int opener_render_process_id,
int opener_render_frame_id,
const std::string& frame_name,
const GURL& target_url,
content::WebContents* new_contents) override;
};
#endif // CHROME_BROWSER_NEARBY_SHARING_SHARESHEET_NEARBY_SHARE_WEB_VIEW_H_
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