Skip to content

Commit

Permalink
Remove several references to BrowserPlugin from content
Browse files Browse the repository at this point in the history
Since BrowserPlugin has been removed, references to BrowserPlugin are
now either dead code or misnomers due to also being used in the OOPIF
based guest view implementation. To help reduce confusion, we remove
noticeably dead code from BrowserPlugin related classes in content,
remove BrowserPlugin related delegates or delegate methods no longer
used by content, and move delegate methods still called by code outside
content to the derived guest view classes.

Bug: 533069
Change-Id: I049ba6595fe86a44078051a12d341ee5b99a8c23
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2401031
Commit-Queue: Kevin McNee <mcnee@chromium.org>
Reviewed-by: James MacLean <wjmaclean@chromium.org>
Reviewed-by: Sean Topping <seantopping@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Reviewed-by: Istiaque Ahmed <lazyboy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810711}
  • Loading branch information
kjmcnee authored and Commit Bot committed Sep 25, 2020
1 parent e696cf9 commit 8cc687a
Show file tree
Hide file tree
Showing 51 changed files with 62 additions and 445 deletions.
1 change: 0 additions & 1 deletion WATCHLISTS
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,6 @@
'chrome/renderer/resources/extensions/web_view|'\
'components/guest_view|'\
'content/browser/browser_plugin|'\
'content/renderer/browser_plugin|'\
'extensions/browser/api/guest_view|'\
'extensions/browser/guest_view|'\
'extensions/common/guest_view|'\
Expand Down
14 changes: 0 additions & 14 deletions chrome/renderer/chrome_content_renderer_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1445,20 +1445,6 @@ bool ChromeContentRendererClient::IsPluginAllowedToUseCameraDeviceAPI(
return false;
}

content::BrowserPluginDelegate*
ChromeContentRendererClient::CreateBrowserPluginDelegate(
content::RenderFrame* render_frame,
const content::WebPluginInfo& info,
const std::string& mime_type,
const GURL& original_url) {
#if BUILDFLAG(ENABLE_EXTENSIONS)
return ChromeExtensionsRendererClient::CreateBrowserPluginDelegate(
render_frame, info, mime_type, original_url);
#else
return nullptr;
#endif
}

void ChromeContentRendererClient::RunScriptsAtDocumentStart(
content::RenderFrame* render_frame) {
#if BUILDFLAG(ENABLE_EXTENSIONS)
Expand Down
6 changes: 0 additions & 6 deletions chrome/renderer/chrome_content_renderer_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ class WebRtcLoggingAgentImpl;
} // namespace chrome

namespace content {
class BrowserPluginDelegate;
struct WebPluginInfo;
} // namespace content

Expand Down Expand Up @@ -159,11 +158,6 @@ class ChromeContentRendererClient
override;
bool IsKeySystemsUpdateNeeded() override;
bool IsPluginAllowedToUseCameraDeviceAPI(const GURL& url) override;
content::BrowserPluginDelegate* CreateBrowserPluginDelegate(
content::RenderFrame* render_frame,
const content::WebPluginInfo& info,
const std::string& mime_type,
const GURL& original_url) override;
void RunScriptsAtDocumentStart(content::RenderFrame* render_frame) override;
void RunScriptsAtDocumentEnd(content::RenderFrame* render_frame) override;
void RunScriptsAtDocumentIdle(content::RenderFrame* render_frame) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ ChromeExtensionsRendererClient::GetExtensionDispatcherForTest() {
}

// static
content::BrowserPluginDelegate*
guest_view::GuestViewContainer*
ChromeExtensionsRendererClient::CreateBrowserPluginDelegate(
content::RenderFrame* render_frame,
const content::WebPluginInfo& info,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ class WebURL;
}

namespace content {
class BrowserPluginDelegate;
class RenderFrame;
struct WebPluginInfo;
}

namespace guest_view {
class GuestViewContainer;
}

namespace extensions {
class Dispatcher;
class ExtensionsGuestViewContainerDispatcher;
Expand Down Expand Up @@ -97,11 +100,13 @@ class ChromeExtensionsRendererClient
std::unique_ptr<extensions::Dispatcher> extension_dispatcher);
extensions::Dispatcher* GetExtensionDispatcherForTest();

static content::BrowserPluginDelegate* CreateBrowserPluginDelegate(
// TODO(533069): Remove since BrowserPlugin has been removed.
static guest_view::GuestViewContainer* CreateBrowserPluginDelegate(
content::RenderFrame* render_frame,
const content::WebPluginInfo& info,
const std::string& mime_type,
const GURL& original_url);

static void DidBlockMimeHandlerViewForDisallowedPlugin(
const blink::WebElement& plugin_element);
static bool MaybeCreateMimeHandlerView(
Expand Down
15 changes: 0 additions & 15 deletions chromecast/renderer/cast_content_renderer_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
#include "extensions/common/extension_urls.h" // nogncheck
#include "extensions/renderer/dispatcher.h" // nogncheck
#include "extensions/renderer/extension_frame_helper.h" // nogncheck
#include "extensions/renderer/guest_view/extensions_guest_view_container.h" // nogncheck
#include "extensions/renderer/guest_view/extensions_guest_view_container_dispatcher.h" // nogncheck
#endif

Expand Down Expand Up @@ -222,20 +221,6 @@ void CastContentRendererClient::RenderFrameCreated(
render_frame->GetRoutingID())));
}

content::BrowserPluginDelegate*
CastContentRendererClient::CreateBrowserPluginDelegate(
content::RenderFrame* render_frame,
const content::WebPluginInfo& info,
const std::string& mime_type,
const GURL& original_url) {
#if BUILDFLAG(ENABLE_CHROMECAST_EXTENSIONS)
if (mime_type == content::kBrowserPluginMimeType) {
return new extensions::ExtensionsGuestViewContainer(render_frame);
}
#endif
return nullptr;
}

void CastContentRendererClient::RunScriptsAtDocumentStart(
content::RenderFrame* render_frame) {
#if BUILDFLAG(ENABLE_CHROMECAST_EXTENSIONS)
Expand Down
5 changes: 0 additions & 5 deletions chromecast/renderer/cast_content_renderer_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ class CastContentRendererClient
void RenderThreadStarted() override;
void RenderViewCreated(content::RenderView* render_view) override;
void RenderFrameCreated(content::RenderFrame* render_frame) override;
content::BrowserPluginDelegate* CreateBrowserPluginDelegate(
content::RenderFrame* render_frame,
const content::WebPluginInfo& info,
const std::string& mime_type,
const GURL& original_url) override;
void RunScriptsAtDocumentStart(content::RenderFrame* render_frame) override;
void RunScriptsAtDocumentEnd(content::RenderFrame* render_frame) override;
void AddSupportedKeySystems(
Expand Down
19 changes: 5 additions & 14 deletions components/guest_view/browser/guest_view_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,7 @@ GuestViewBase::GuestViewBase(WebContents* owner_web_contents)
is_being_destroyed_(false),
guest_host_(nullptr),
auto_size_enabled_(false),
is_full_page_plugin_(false),
guest_proxy_routing_id_(MSG_ROUTING_NONE) {
is_full_page_plugin_(false) {
SetOwnerHost();
}

Expand Down Expand Up @@ -246,14 +245,6 @@ void GuestViewBase::InitWithWebContents(
DidInitialize(create_params);
}

void GuestViewBase::LoadURLWithParams(
const content::NavigationController::LoadURLParams& load_params) {
int guest_proxy_routing_id = host()->LoadURLWithParams(load_params);
DCHECK(guest_proxy_routing_id_ == MSG_ROUTING_NONE ||
guest_proxy_routing_id == guest_proxy_routing_id_);
guest_proxy_routing_id_ = guest_proxy_routing_id;
}

void GuestViewBase::DispatchOnResizeEvent(const gfx::Size& old_size,
const gfx::Size& new_size) {
if (new_size == old_size)
Expand Down Expand Up @@ -408,10 +399,6 @@ void GuestViewBase::DidAttach(int guest_proxy_routing_id) {
// Clear this flag here, as functions called below may check attached().
attach_in_progress_ = false;

DCHECK(guest_proxy_routing_id_ == MSG_ROUTING_NONE ||
guest_proxy_routing_id == guest_proxy_routing_id_);
guest_proxy_routing_id_ = guest_proxy_routing_id;

opener_lifetime_observer_.reset();

SetUpSizing(*attach_params());
Expand Down Expand Up @@ -936,4 +923,8 @@ void GuestViewBase::SetOwnerHost() {
: std::string();
}

bool GuestViewBase::CanBeEmbeddedInsideCrossProcessFrames() {
return false;
}

} // namespace guest_view
40 changes: 17 additions & 23 deletions components/guest_view/browser/guest_view_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,6 @@ class GuestViewBase : public content::BrowserPluginGuestDelegate,
return owner_web_contents_;
}

content::GuestHost* host() const {
return guest_host_;
}

// Returns the parameters associated with the element hosting this GuestView
// passed in from JavaScript.
base::DictionaryValue* attach_params() const { return attach_params_.get(); }
Expand Down Expand Up @@ -192,10 +188,6 @@ class GuestViewBase : public content::BrowserPluginGuestDelegate,
// Whether the guest view is inside a plugin document.
bool is_full_page_plugin() const { return is_full_page_plugin_; }

// Returns the routing ID of the guest proxy in the owner's renderer process.
// This value is only valid after attachment or first navigation.
int proxy_routing_id() const { return guest_proxy_routing_id_; }

// Destroy this guest.
void Destroy(bool also_delete);

Expand All @@ -208,9 +200,11 @@ class GuestViewBase : public content::BrowserPluginGuestDelegate,
void SetAttachParams(const base::DictionaryValue& params);
void SetOpener(GuestViewBase* opener);

// BrowserPluginGuestDelegate implementation.
content::RenderWidgetHost* GetOwnerRenderWidgetHost() override;
content::SiteInstance* GetOwnerSiteInstance() override;
// Returns the RenderWidgetHost corresponding to the owner frame.
virtual content::RenderWidgetHost* GetOwnerRenderWidgetHost();

// The SiteInstance of the owner frame.
virtual content::SiteInstance* GetOwnerSiteInstance();

// Starts the attaching process for a (frame-based) GuestView.
// |embedder_frame| is a frame in the embedder WebContents (owned by a
Expand All @@ -220,6 +214,10 @@ class GuestViewBase : public content::BrowserPluginGuestDelegate,
int32_t element_instance_id,
bool is_full_page_plugin);

// Returns true if the corresponding guest is allowed to be embedded inside an
// <iframe> which is cross process.
virtual bool CanBeEmbeddedInsideCrossProcessFrames();

protected:
explicit GuestViewBase(content::WebContents* owner_web_contents);

Expand Down Expand Up @@ -319,9 +317,6 @@ class GuestViewBase : public content::BrowserPluginGuestDelegate,
// to destruction.
virtual void WillDestroy() {}

void LoadURLWithParams(
const content::NavigationController::LoadURLParams& load_params);

// Convert sizes in pixels from logical to physical numbers of pixels.
// Note that a size can consist of a fractional number of logical pixels
// (hence |logical_pixels| is represented as a double), but will always
Expand All @@ -342,17 +337,19 @@ class GuestViewBase : public content::BrowserPluginGuestDelegate,
class OwnerContentsObserver;
class OpenerLifetimeObserver;

// TODO(533069): Remove since BrowserPlugin has been removed.
void DidAttach(int guest_proxy_routing_id);
void DidDetach();
void WillAttach(content::WebContents* embedder_web_contents,
int browser_plugin_instance_id,
bool is_full_page_plugin,
base::OnceClosure completion_callback);

// BrowserPluginGuestDelegate implementation.
content::WebContents* CreateNewGuestWindow(
const content::WebContents::CreateParams& create_params) final;
void DidAttach(int guest_proxy_routing_id) final;
void DidDetach() final;
content::WebContents* GetOwnerWebContents() final;
void SetGuestHost(content::GuestHost* guest_host) final;
void WillAttach(content::WebContents* embedder_web_contents,
int browser_plugin_instance_id,
bool is_full_page_plugin,
base::OnceClosure completion_callback) final;

// WebContentsDelegate implementation.
void ActivateContents(content::WebContents* contents) final;
Expand Down Expand Up @@ -497,9 +494,6 @@ class GuestViewBase : public content::BrowserPluginGuestDelegate,
// Whether the guest view is inside a plugin document.
bool is_full_page_plugin_;

// The routing ID of the proxy to the guest in the owner's renderer process.
int guest_proxy_routing_id_;

// This is used to ensure pending tasks will not fire after this object is
// destroyed.
base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_{this};
Expand Down
6 changes: 3 additions & 3 deletions components/guest_view/browser/guest_view_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ class GuestViewManager : public content::BrowserPluginGuestManager,
content::SiteInstance* GetGuestSiteInstance(
const GURL& guest_site);

content::WebContents* GetGuestByInstanceID(int owner_process_id,
int element_instance_id);

// BrowserPluginGuestManager implementation.
content::WebContents* GetGuestByInstanceID(
int owner_process_id,
int element_instance_id) override;
bool ForEachGuest(content::WebContents* owner_web_contents,
const GuestCallback& callback) override;
content::WebContents* GetFullPageGuest(
Expand Down
1 change: 0 additions & 1 deletion components/guest_view/common/guest_view_constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const char kEventResize[] = "guestViewInternal.onResize";

// Parameters/properties on events.
const char kCode[] = "code";
const char kContentWindowID[] = "contentWindowId";
const char kID[] = "id";
const char kIsTopLevel[] = "isTopLevel";
const char kNewWidth[] = "newWidth";
Expand Down
1 change: 0 additions & 1 deletion components/guest_view/common/guest_view_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ extern const char kEventResize[];

// Parameters/properties on events.
extern const char kCode[];
extern const char kContentWindowID[];
extern const char kID[];
extern const char kIsTopLevel[];
extern const char kNewWidth[];
Expand Down
6 changes: 1 addition & 5 deletions components/guest_view/renderer/guest_view_container.cc
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ void GuestViewContainer::RunDestructionCallback(bool embedder_frame_destroyed) {
}

void GuestViewContainer::OnHandleCallback(const IPC::Message& message) {
base::WeakPtr<content::BrowserPluginDelegate> weak_ptr(GetWeakPtr());
base::WeakPtr<GuestViewContainer> weak_ptr(weak_ptr_factory_.GetWeakPtr());

// Handle the callback for the current request with a pending response.
HandlePendingResponseCallback(message);
Expand Down Expand Up @@ -274,8 +274,4 @@ void GuestViewContainer::CallElementResizeCallback(
.FromMaybe(v8::Local<v8::Value>());
}

base::WeakPtr<content::BrowserPluginDelegate> GuestViewContainer::GetWeakPtr() {
return weak_ptr_factory_.GetWeakPtr();
}

} // namespace guest_view
23 changes: 13 additions & 10 deletions components/guest_view/renderer/guest_view_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@

#include "base/containers/circular_deque.h"
#include "base/macros.h"
#include "content/public/renderer/browser_plugin_delegate.h"
#include "ipc/ipc_message.h"
#include "v8/include/v8.h"

namespace gfx {
class Size;
}

namespace content {
class RenderFrame;
}
Expand All @@ -21,7 +24,7 @@ namespace guest_view {

class GuestViewRequest;

class GuestViewContainer : public content::BrowserPluginDelegate {
class GuestViewContainer {
public:
explicit GuestViewContainer(content::RenderFrame* render_frame);

Expand Down Expand Up @@ -64,13 +67,13 @@ class GuestViewContainer : public content::BrowserPluginDelegate {
// Note that this should be called exactly once.
virtual void OnDestroy(bool embedder_frame_destroyed) {}

// BrowserPluginGuestDelegate public implementation.
void SetElementInstanceID(int element_instance_id) final;
void DidResizeElement(const gfx::Size& new_size) override;
base::WeakPtr<BrowserPluginDelegate> GetWeakPtr() final;
void SetElementInstanceID(int element_instance_id);

// TODO(533069): Remove since BrowserPlugin has been removed.
void DidResizeElement(const gfx::Size& new_size);

protected:
~GuestViewContainer() override;
virtual ~GuestViewContainer();

bool ready_;

Expand All @@ -88,9 +91,9 @@ class GuestViewContainer : public content::BrowserPluginDelegate {
void RunDestructionCallback(bool embedder_frame_destroyed);
void CallElementResizeCallback(const gfx::Size& new_size);

// BrowserPluginDelegate implementation.
void Ready() final;
void DidDestroyElement() final;
// TODO(533069): Remove since BrowserPlugin has been removed.
void Ready();
void DidDestroyElement();

int element_instance_id_;
content::RenderFrame* render_frame_;
Expand Down
4 changes: 0 additions & 4 deletions content/browser/browser_plugin/browser_plugin_embedder.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ class CONTENT_EXPORT BrowserPluginEmbedder {

void ClearGuestDragStateIfApplicable();

static bool DidSendScreenRectsCallback(WebContents* guest_web_contents);

// Closes modal dialogs in |guest_web_contents|.
static bool CancelDialogs(WebContents* guest_web_contents);

Expand All @@ -111,8 +109,6 @@ class CONTENT_EXPORT BrowserPluginEmbedder {
// Keeps track of "dragend" state.
bool guest_drag_ending_;

base::WeakPtrFactory<BrowserPluginEmbedder> weak_ptr_factory_{this};

DISALLOW_COPY_AND_ASSIGN(BrowserPluginEmbedder);
};

Expand Down
Loading

0 comments on commit 8cc687a

Please sign in to comment.