diff options
author | piman <piman@chromium.org> | 2016-03-18 14:32:58 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-18 21:35:03 +0000 |
commit | bfb2cebc0c8dacff0b93a37a822babe8c2bc0f5e (patch) | |
tree | e92e098c0eb14a14f4bcb0c2bafca9b0193f9521 | |
parent | 69da898ef90feb49e414476934abf708ed04c093 (diff) | |
download | chromium_src-bfb2cebc0c8dacff0b93a37a822babe8c2bc0f5e.zip chromium_src-bfb2cebc0c8dacff0b93a37a822babe8c2bc0f5e.tar.gz chromium_src-bfb2cebc0c8dacff0b93a37a822babe8c2bc0f5e.tar.bz2 |
Remove windowed NPAPI code
BUG=493212
CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:linux_site_isolation
Review URL: https://codereview.chromium.org/1815593002
Cr-Commit-Position: refs/heads/master@{#382094}
53 files changed, 30 insertions, 1773 deletions
diff --git a/chrome/browser/hang_monitor/hung_plugin_action.cc b/chrome/browser/hang_monitor/hung_plugin_action.cc index 0e28687..75cf98f 100644 --- a/chrome/browser/hang_monitor/hung_plugin_action.cc +++ b/chrome/browser/hang_monitor/hung_plugin_action.cc @@ -17,46 +17,6 @@ #include "ui/base/l10n/l10n_util.h" #include "ui/gfx/win/hwnd_util.h" -namespace { - -const wchar_t kGTalkPluginName[] = L"Google Talk Plugin"; -const int kGTalkPluginLogMinVersion = 26; // For version 2.6 and below. - -enum GTalkPluginLogVersion { - GTALK_PLUGIN_VERSION_MIN = 0, - GTALK_PLUGIN_VERSION_27, - GTALK_PLUGIN_VERSION_28, - GTALK_PLUGIN_VERSION_29, - GTALK_PLUGIN_VERSION_30, - GTALK_PLUGIN_VERSION_31, - GTALK_PLUGIN_VERSION_32, - GTALK_PLUGIN_VERSION_33, - GTALK_PLUGIN_VERSION_34, - GTALK_PLUGIN_VERSION_MAX -}; - -// Converts the version string of Google Talk Plugin to a version enum. The -// version format is "major(1 digit).minor(1 digit).sub(1 or 2 digits)", -// for example, "2.7.10" and "2.8.1". Converts the string to a number as -// 10 * major + minor - kGTalkPluginLogMinVersion. -GTalkPluginLogVersion GetGTalkPluginVersion(const base::string16& version) { - int gtalk_plugin_version = GTALK_PLUGIN_VERSION_MIN; - Version plugin_version; - content::WebPluginInfo::CreateVersionFromString(version, &plugin_version); - if (plugin_version.IsValid() && plugin_version.components().size() >= 2) { - gtalk_plugin_version = 10 * plugin_version.components()[0] + - plugin_version.components()[1] - kGTalkPluginLogMinVersion; - } - - if (gtalk_plugin_version < GTALK_PLUGIN_VERSION_MIN) - return GTALK_PLUGIN_VERSION_MIN; - if (gtalk_plugin_version > GTALK_PLUGIN_VERSION_MAX) - return GTALK_PLUGIN_VERSION_MAX; - return static_cast<GTalkPluginLogVersion>(gtalk_plugin_version); -} - -} // namespace - HungPluginAction::HungPluginAction() : current_hung_plugin_window_(NULL) { } @@ -82,18 +42,8 @@ bool HungPluginAction::OnHungWindowDetected(HWND hung_window, *action = HungWindowNotification::HUNG_WINDOW_IGNORE; if (top_level_window_process_id != hung_window_process_id) { - base::string16 plugin_name; - base::string16 plugin_version; - - content::PluginService::GetInstance()->GetPluginInfoFromWindow( - hung_window, &plugin_name, &plugin_version); - if (plugin_name.empty()) { - plugin_name = l10n_util::GetStringUTF16(IDS_UNKNOWN_PLUGIN_NAME); - } else if (kGTalkPluginName == plugin_name) { - UMA_HISTOGRAM_ENUMERATION("GTalkPlugin.Hung", - GetGTalkPluginVersion(plugin_version), - GTALK_PLUGIN_VERSION_MAX + 1); - } + base::string16 plugin_name = + l10n_util::GetStringUTF16(IDS_UNKNOWN_PLUGIN_NAME); if (logging::DialogsAreSuppressed()) { NOTREACHED() << "Terminated a hung plugin process."; diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index b2e976f..63487ff 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc @@ -464,6 +464,7 @@ BrowserView::BrowserView() handling_theme_changed_(false), in_process_fullscreen_(false), #if defined(OS_WIN) + // TODO(piman): is this still useful now that windowed plugins are gone? ticker_(0), hung_window_detector_(&hung_plugin_action_), #endif diff --git a/content/browser/frame_host/render_widget_host_view_child_frame.cc b/content/browser/frame_host/render_widget_host_view_child_frame.cc index 3784209..7641553 100644 --- a/content/browser/frame_host/render_widget_host_view_child_frame.cc +++ b/content/browser/frame_host/render_widget_host_view_child_frame.cc @@ -172,10 +172,6 @@ void RenderWidgetHostViewChildFrame::ImeCompositionRangeChanged( // TODO(kenrb): Fix OOPIF Ime. } -void RenderWidgetHostViewChildFrame::MovePluginWindows( - const std::vector<WebPluginGeometry>& moves) { -} - void RenderWidgetHostViewChildFrame::UpdateCursor(const WebCursor& cursor) { if (frame_connector_) frame_connector_->UpdateCursor(cursor); diff --git a/content/browser/frame_host/render_widget_host_view_child_frame.h b/content/browser/frame_host/render_widget_host_view_child_frame.h index 748b59a..a6818d3 100644 --- a/content/browser/frame_host/render_widget_host_view_child_frame.h +++ b/content/browser/frame_host/render_widget_host_view_child_frame.h @@ -94,7 +94,6 @@ class CONTENT_EXPORT RenderWidgetHostViewChildFrame void InitAsPopup(RenderWidgetHostView* parent_host_view, const gfx::Rect& bounds) override; void InitAsFullscreen(RenderWidgetHostView* reference_host_view) override; - void MovePluginWindows(const std::vector<WebPluginGeometry>& moves) override; void UpdateCursor(const WebCursor& cursor) override; void SetIsLoading(bool is_loading) override; void TextInputStateChanged( diff --git a/content/browser/frame_host/render_widget_host_view_guest.cc b/content/browser/frame_host/render_widget_host_view_guest.cc index 1312e52..d92ce3b 100644 --- a/content/browser/frame_host/render_widget_host_view_guest.cc +++ b/content/browser/frame_host/render_widget_host_view_guest.cc @@ -327,11 +327,6 @@ gfx::NativeViewAccessible RenderWidgetHostViewGuest::GetNativeViewAccessible() { return rwhv->GetNativeViewAccessible(); } -void RenderWidgetHostViewGuest::MovePluginWindows( - const std::vector<WebPluginGeometry>& moves) { - platform_view_->MovePluginWindows(moves); -} - void RenderWidgetHostViewGuest::UpdateCursor(const WebCursor& cursor) { // InterstitialPages are not WebContents so we cannot intercept // ViewHostMsg_SetCursor for interstitial pages in BrowserPluginGuest. diff --git a/content/browser/frame_host/render_widget_host_view_guest.h b/content/browser/frame_host/render_widget_host_view_guest.h index 0d1a114..c46b6ef 100644 --- a/content/browser/frame_host/render_widget_host_view_guest.h +++ b/content/browser/frame_host/render_widget_host_view_guest.h @@ -76,7 +76,6 @@ class CONTENT_EXPORT RenderWidgetHostViewGuest void InitAsPopup(RenderWidgetHostView* parent_host_view, const gfx::Rect& bounds) override; void InitAsFullscreen(RenderWidgetHostView* reference_host_view) override; - void MovePluginWindows(const std::vector<WebPluginGeometry>& moves) override; void UpdateCursor(const WebCursor& cursor) override; void SetIsLoading(bool is_loading) override; void TextInputStateChanged( diff --git a/content/browser/plugin_process_host.cc b/content/browser/plugin_process_host.cc index cb14fa7..de7c934 100644 --- a/content/browser/plugin_process_host.cc +++ b/content/browser/plugin_process_host.cc @@ -79,24 +79,6 @@ bool PluginProcessHost::GetWebPluginInfoFromPluginPid(base::ProcessId pid, return true; } -#if defined(OS_WIN) -void PluginProcessHost::OnPluginWindowDestroyed(HWND window, HWND parent) { - // The window is destroyed at this point, we just care about its parent, which - // is the intermediate window we created. - std::set<HWND>::iterator window_index = - plugin_parent_windows_set_.find(parent); - if (window_index == plugin_parent_windows_set_.end()) - return; - - plugin_parent_windows_set_.erase(window_index); - PostMessage(parent, WM_CLOSE, 0, 0); -} - -void PluginProcessHost::AddWindow(HWND window) { - plugin_parent_windows_set_.insert(window); -} -#endif // defined(OS_WIN) - // NOTE: changes to this class need to be reviewed by the security team. class PluginSandboxedProcessLauncherDelegate : public SandboxedProcessLauncherDelegate { @@ -136,20 +118,7 @@ PluginProcessHost::PluginProcessHost() } PluginProcessHost::~PluginProcessHost() { -#if defined(OS_WIN) - // We erase HWNDs from the plugin_parent_windows_set_ when we receive a - // notification that the window is being destroyed. If we don't receive this - // notification and the PluginProcessHost instance is being destroyed, it - // means that the plugin process crashed. We paint a sad face in this case in - // the renderer process. To ensure that the sad face shows up, and we don't - // leak HWNDs, we should destroy existing plugin parent windows. - std::set<HWND>::iterator window_index; - for (window_index = plugin_parent_windows_set_.begin(); - window_index != plugin_parent_windows_set_.end(); - ++window_index) { - PostMessage(*window_index, WM_CLOSE, 0, 0); - } -#elif defined(OS_MACOSX) +#if defined(OS_MACOSX) DCHECK_CURRENTLY_ON(BrowserThread::IO); // If the plugin process crashed but had fullscreen windows open at the time, // make sure that the menu bar is visible. @@ -289,10 +258,6 @@ bool PluginProcessHost::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(PluginProcessHostMsg_ChannelCreated, OnChannelCreated) IPC_MESSAGE_HANDLER(PluginProcessHostMsg_ChannelDestroyed, OnChannelDestroyed) -#if defined(OS_WIN) - IPC_MESSAGE_HANDLER(PluginProcessHostMsg_PluginWindowDestroyed, - OnPluginWindowDestroyed) -#endif #if defined(OS_MACOSX) IPC_MESSAGE_HANDLER(PluginProcessHostMsg_PluginShowWindow, OnPluginShowWindow) diff --git a/content/browser/plugin_process_host.h b/content/browser/plugin_process_host.h index 66ec73d..d96499c 100644 --- a/content/browser/plugin_process_host.h +++ b/content/browser/plugin_process_host.h @@ -138,10 +138,6 @@ class CONTENT_EXPORT PluginProcessHost : public BrowserChildProcessHostDelegate, void OnChannelCreated(const IPC::ChannelHandle& channel_handle); void OnChannelDestroyed(int renderer_id); -#if defined(OS_WIN) - void OnPluginWindowDestroyed(HWND window, HWND parent); -#endif - #if defined(OS_MACOSX) void OnPluginShowWindow(uint32_t window_id, gfx::Rect window_rect, @@ -175,10 +171,6 @@ class CONTENT_EXPORT PluginProcessHost : public BrowserChildProcessHostDelegate, // The pid of the plugin process. int pid_; -#if defined(OS_WIN) - // Tracks plugin parent windows created on the UI thread. - std::set<HWND> plugin_parent_windows_set_; -#endif #if defined(OS_MACOSX) // Tracks plugin windows currently visible. std::set<uint32_t> plugin_visible_windows_set_; diff --git a/content/browser/plugin_service_impl.cc b/content/browser/plugin_service_impl.cc index 700d304..d8a5909 100644 --- a/content/browser/plugin_service_impl.cc +++ b/content/browser/plugin_service_impl.cc @@ -826,46 +826,6 @@ void PluginServiceImpl::AppActivated() { BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind(&NotifyPluginsOfActivation)); } -#elif defined(OS_WIN) - -bool GetPluginPropertyFromWindow( - HWND window, const wchar_t* plugin_atom_property, - base::string16* plugin_property) { - ATOM plugin_atom = static_cast<ATOM>( - reinterpret_cast<uintptr_t>(GetPropW(window, plugin_atom_property))); - if (plugin_atom != 0) { - WCHAR plugin_property_local[MAX_PATH] = {0}; - GlobalGetAtomNameW(plugin_atom, - plugin_property_local, - ARRAYSIZE(plugin_property_local)); - *plugin_property = plugin_property_local; - return true; - } - return false; -} - -bool PluginServiceImpl::GetPluginInfoFromWindow( - HWND window, - base::string16* plugin_name, - base::string16* plugin_version) { - if (!IsPluginWindow(window)) - return false; - - - DWORD process_id = 0; - GetWindowThreadProcessId(window, &process_id); - WebPluginInfo info; - if (!PluginProcessHost::GetWebPluginInfoFromPluginPid(process_id, &info)) - return false; - - *plugin_name = info.name; - *plugin_version = info.version; - return true; -} - -bool PluginServiceImpl::IsPluginWindow(HWND window) { - return gfx::GetClassName(window) == base::string16(kNativeWindowClassName); -} #endif bool PluginServiceImpl::PpapiDevChannelSupported( diff --git a/content/browser/plugin_service_impl.h b/content/browser/plugin_service_impl.h index 644a262..a05e4eb 100644 --- a/content/browser/plugin_service_impl.h +++ b/content/browser/plugin_service_impl.h @@ -109,13 +109,6 @@ class CONTENT_EXPORT PluginServiceImpl void DisablePluginsDiscoveryForTesting() override; #if defined(OS_MACOSX) void AppActivated() override; -#elif defined(OS_WIN) - bool GetPluginInfoFromWindow(HWND window, - base::string16* plugin_name, - base::string16* plugin_version) override; - - // Returns true iff the given HWND is a plugin. - bool IsPluginWindow(HWND window); #endif bool PpapiDevChannelSupported(BrowserContext* browser_context, const GURL& document_url) override; diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc index e4ec586..ea33039 100644 --- a/content/browser/renderer_host/render_widget_host_impl.cc +++ b/content/browser/renderer_host/render_widget_host_impl.cc @@ -1679,14 +1679,6 @@ void RenderWidgetHostImpl::DidUpdateBackingStore( TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::DidUpdateBackingStore"); TimeTicks update_start = TimeTicks::Now(); - // Move the plugins if the view hasn't already been destroyed. Plugin moves - // will not be re-issued, so must move them now, regardless of whether we - // paint or not. MovePluginWindows attempts to move the plugin windows and - // in the process could dispatch other window messages which could cause the - // view to be destroyed. - if (view_) - view_->MovePluginWindows(params.plugin_window_moves); - NotificationService::current()->Notify( NOTIFICATION_RENDER_WIDGET_HOST_DID_UPDATE_BACKING_STORE, Source<RenderWidgetHost>(this), diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc index feb9930..aa4bb6a 100644 --- a/content/browser/renderer_host/render_widget_host_view_android.cc +++ b/content/browser/renderer_host/render_widget_host_view_android.cc @@ -468,13 +468,6 @@ RenderWidgetHostViewAndroid::GetNativeViewAccessible() { return NULL; } -void RenderWidgetHostViewAndroid::MovePluginWindows( - const std::vector<WebPluginGeometry>& moves) { - // We don't have plugin windows on Android. Do nothing. Note: this is called - // from RenderWidgetHost::OnUpdateRect which is itself invoked while - // processing the corresponding message from Renderer. -} - void RenderWidgetHostViewAndroid::Focus() { host_->Focus(); if (overscroll_controller_) diff --git a/content/browser/renderer_host/render_widget_host_view_android.h b/content/browser/renderer_host/render_widget_host_view_android.h index 872e427..ed0cd31 100644 --- a/content/browser/renderer_host/render_widget_host_view_android.h +++ b/content/browser/renderer_host/render_widget_host_view_android.h @@ -96,7 +96,6 @@ class CONTENT_EXPORT RenderWidgetHostViewAndroid gfx::NativeView GetNativeView() const override; gfx::NativeViewId GetNativeViewId() const override; gfx::NativeViewAccessible GetNativeViewAccessible() override; - void MovePluginWindows(const std::vector<WebPluginGeometry>& moves) override; void Focus() override; bool HasFocus() const override; bool IsSurfaceAvailableForCopy() const override; diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index 849dd8b..7608c7b 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -141,97 +141,6 @@ const int kMouseLockBorderPercentage = 15; const int kResizeLockTimeoutMs = 67; #if defined(OS_WIN) -// Used to associate a plugin HWND with its RenderWidgetHostViewAura instance. -const wchar_t kWidgetOwnerProperty[] = L"RenderWidgetHostViewAuraOwner"; - -BOOL CALLBACK WindowDestroyingCallback(HWND window, LPARAM param) { - RenderWidgetHostViewAura* widget = - reinterpret_cast<RenderWidgetHostViewAura*>(param); - if (GetProp(window, kWidgetOwnerProperty) == widget) { - // Properties set on HWNDs must be removed to avoid leaks. - RemoveProp(window, kWidgetOwnerProperty); - RenderWidgetHostViewBase::DetachPluginWindowsCallback(window); - } - return TRUE; -} - -BOOL CALLBACK HideWindowsCallback(HWND window, LPARAM param) { - RenderWidgetHostViewAura* widget = - reinterpret_cast<RenderWidgetHostViewAura*>(param); - if (GetProp(window, kWidgetOwnerProperty) == widget) - SetParent(window, ui::GetHiddenWindow()); - return TRUE; -} - -BOOL CALLBACK ShowWindowsCallback(HWND window, LPARAM param) { - RenderWidgetHostViewAura* widget = - reinterpret_cast<RenderWidgetHostViewAura*>(param); - - if (GetProp(window, kWidgetOwnerProperty) == widget && - widget->GetNativeView()->GetHost()) { - HWND parent = widget->GetNativeView()->GetHost()->GetAcceleratedWidget(); - SetParent(window, parent); - } - return TRUE; -} - -struct CutoutRectsParams { - RenderWidgetHostViewAura* widget; - std::vector<gfx::Rect> cutout_rects; - std::map<HWND, WebPluginGeometry>* geometry; -}; - -// Used to update the region for the windowed plugin to draw in. We start with -// the clip rect from the renderer, then remove the cutout rects from the -// renderer, and then remove the transient windows from the root window and the -// constrained windows from the parent window. -BOOL CALLBACK SetCutoutRectsCallback(HWND window, LPARAM param) { - CutoutRectsParams* params = reinterpret_cast<CutoutRectsParams*>(param); - - if (GetProp(window, kWidgetOwnerProperty) == params->widget) { - // First calculate the offset of this plugin from the root window, since - // the cutouts are relative to the root window. - HWND parent = - params->widget->GetNativeView()->GetHost()->GetAcceleratedWidget(); - POINT offset; - offset.x = offset.y = 0; - MapWindowPoints(window, parent, &offset, 1); - - // Now get the cached clip rect and cutouts for this plugin window that came - // from the renderer. - std::map<HWND, WebPluginGeometry>::iterator i = params->geometry->begin(); - while (i != params->geometry->end() && - i->second.window != window && - GetParent(i->second.window) != window) { - ++i; - } - - if (i == params->geometry->end()) { - NOTREACHED(); - return TRUE; - } - - HRGN hrgn = CreateRectRgn(i->second.clip_rect.x(), - i->second.clip_rect.y(), - i->second.clip_rect.right(), - i->second.clip_rect.bottom()); - // We start with the cutout rects that came from the renderer, then add the - // ones that came from transient and constrained windows. - std::vector<gfx::Rect> cutout_rects = i->second.cutout_rects; - for (size_t i = 0; i < params->cutout_rects.size(); ++i) { - gfx::Rect offset_cutout = params->cutout_rects[i]; - offset_cutout.Offset(-offset.x, -offset.y); - cutout_rects.push_back(offset_cutout); - } - gfx::SubtractRectanglesFromRegion(hrgn, cutout_rects); - // If we don't have any cutout rects then no point in messing with the - // window region. - if (cutout_rects.size()) - SetWindowRgn(window, hrgn, TRUE); - } - return TRUE; -} - // A callback function for EnumThreadWindows to enumerate and dismiss // any owned popup windows. BOOL CALLBACK DismissOwnedPopups(HWND window, LPARAM arg) { @@ -659,12 +568,8 @@ void RenderWidgetHostViewAura::Show() { GetNativeView()->GetHost()->GetAcceleratedWidget()); legacy_render_widget_host_HWND_->SetBounds( window_->GetBoundsInRootWindow()); - } - LPARAM lparam = reinterpret_cast<LPARAM>(this); - EnumChildWindows(ui::GetHiddenWindow(), ShowWindowsCallback, lparam); - - if (legacy_render_widget_host_HWND_) legacy_render_widget_host_HWND_->Show(); + } #endif } @@ -677,12 +582,8 @@ void RenderWidgetHostViewAura::Hide() { delegated_frame_host_->WasHidden(); #if defined(OS_WIN) - constrained_rects_.clear(); aura::WindowTreeHost* host = window_->GetHost(); if (host) { - HWND parent = host->GetAcceleratedWidget(); - LPARAM lparam = reinterpret_cast<LPARAM>(this); - EnumChildWindows(parent, HideWindowsCallback, lparam); // We reparent the legacy Chrome_RenderWidgetHostHWND window to the global // hidden window on the same lines as Windowed plugin windows. if (legacy_render_widget_host_HWND_) @@ -901,58 +802,6 @@ void RenderWidgetHostViewAura::ParentHierarchyChanged() { HandleParentBoundsChanged(); } -void RenderWidgetHostViewAura::MovePluginWindows( - const std::vector<WebPluginGeometry>& plugin_window_moves) { -#if defined(OS_WIN) - // We need to clip the rectangle to the tab's viewport, otherwise we will draw - // over the browser UI. - if (!window_->GetRootWindow()) { - DCHECK(plugin_window_moves.empty()); - return; - } - HWND parent = window_->GetHost()->GetAcceleratedWidget(); - gfx::Rect view_bounds = window_->GetBoundsInRootWindow(); - std::vector<WebPluginGeometry> moves = plugin_window_moves; - - gfx::Rect view_port(view_bounds.size()); - - for (size_t i = 0; i < moves.size(); ++i) { - gfx::Rect clip(moves[i].clip_rect); - gfx::Vector2d view_port_offset( - moves[i].window_rect.OffsetFromOrigin()); - clip.Offset(view_port_offset); - clip.Intersect(view_port); - clip.Offset(-view_port_offset); - moves[i].clip_rect = clip; - - moves[i].window_rect.Offset(view_bounds.OffsetFromOrigin()); - - plugin_window_moves_[moves[i].window] = moves[i]; - - // constrained_rects_ are relative to the root window. We want to convert - // them to be relative to the plugin window. - for (size_t j = 0; j < constrained_rects_.size(); ++j) { - gfx::Rect offset_cutout = constrained_rects_[j]; - offset_cutout -= moves[i].window_rect.OffsetFromOrigin(); - moves[i].cutout_rects.push_back(offset_cutout); - } - } - - MovePluginWindowsHelper(parent, moves); - - // Make sure each plugin window (or its wrapper if it exists) has a pointer to - // |this|. - for (size_t i = 0; i < moves.size(); ++i) { - HWND window = moves[i].window; - if (GetParent(window) != parent) { - window = GetParent(window); - } - if (!GetProp(window, kWidgetOwnerProperty)) - SetProp(window, kWidgetOwnerProperty, this); - } -#endif // defined(OS_WIN) -} - void RenderWidgetHostViewAura::Focus() { // Make sure we have a FocusClient before attempting to Focus(). In some // situations we may not yet be in a valid Window hierarchy (such as reloading @@ -1177,27 +1026,6 @@ bool RenderWidgetHostViewAura::UsesNativeWindowFrame() const { return (legacy_render_widget_host_HWND_ != NULL); } -void RenderWidgetHostViewAura::UpdateConstrainedWindowRects( - const std::vector<gfx::Rect>& rects) { - // Check this before setting constrained_rects_, so that next time they're set - // and we have a root window we don't early return. - if (!window_->GetHost()) - return; - - if (rects == constrained_rects_) - return; - - constrained_rects_ = rects; - - HWND parent = window_->GetHost()->GetAcceleratedWidget(); - CutoutRectsParams params; - params.widget = this; - params.cutout_rects = constrained_rects_; - params.geometry = &plugin_window_moves_; - LPARAM lparam = reinterpret_cast<LPARAM>(¶ms); - EnumChildWindows(parent, SetCutoutRectsCallback, lparam); -} - void RenderWidgetHostViewAura::UpdateMouseLockRegion() { RECT window_rect = gfx::win::DIPToScreenRect(window_->GetBoundsInScreen()).ToRECT(); @@ -1951,17 +1779,6 @@ void RenderWidgetHostViewAura::OnDeviceScaleFactorChanged( void RenderWidgetHostViewAura::OnWindowDestroying(aura::Window* window) { #if defined(OS_WIN) - HWND parent = NULL; - // If the tab was hidden and it's closed, host_->is_hidden would have been - // reset to false in RenderWidgetHostImpl::RendererExited. - if (!window_->GetRootWindow() || host_->is_hidden()) { - parent = ui::GetHiddenWindow(); - } else { - parent = window_->GetHost()->GetAcceleratedWidget(); - } - LPARAM lparam = reinterpret_cast<LPARAM>(this); - EnumChildWindows(parent, WindowDestroyingCallback, lparam); - // The LegacyRenderWidgetHostHWND instance is destroyed when its window is // destroyed. Normally we control when that happens via the Destroy call // in the dtor. However there may be cases where the window is destroyed @@ -2771,11 +2588,6 @@ void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) { // Create the legacy dummy window which corresponds to the bounds of the // webcontents. This will be passed as the container window for windowless // plugins. - // Plugins like Flash assume the container window which is returned via the - // NPNVnetscapeWindow property corresponds to the bounds of the webpage. - // This is not true in Aura where we have only HWND which is the main Aura - // window. If we return this window to plugins like Flash then it causes the - // coordinate translations done by these plugins to break. // Additonally the legacy dummy window is needed for accessibility and for // scrolling to work in legacy drivers for trackpoints/trackpads, etc. if (!legacy_window_destroyed_ && GetNativeViewId()) { diff --git a/content/browser/renderer_host/render_widget_host_view_aura.h b/content/browser/renderer_host/render_widget_host_view_aura.h index 456cd477..932fd37 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.h +++ b/content/browser/renderer_host/render_widget_host_view_aura.h @@ -133,7 +133,6 @@ class CONTENT_EXPORT RenderWidgetHostViewAura void InitAsPopup(RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) override; void InitAsFullscreen(RenderWidgetHostView* reference_host_view) override; - void MovePluginWindows(const std::vector<WebPluginGeometry>& moves) override; void Focus() override; void UpdateCursor(const WebCursor& cursor) override; void SetIsLoading(bool is_loading) override; @@ -291,11 +290,6 @@ class CONTENT_EXPORT RenderWidgetHostViewAura const gfx::Point& new_origin) override; #if defined(OS_WIN) - // Sets the cutout rects from constrained windows. These are rectangles that - // windowed NPAPI plugins shouldn't paint in. Overwrites any previous cutout - // rects. - void UpdateConstrainedWindowRects(const std::vector<gfx::Rect>& rects); - // Updates the cursor clip region. Used for mouse locking. void UpdateMouseLockRegion(); @@ -638,17 +632,6 @@ class CONTENT_EXPORT RenderWidgetHostViewAura CursorVisibilityState cursor_visibility_state_in_renderer_; #if defined(OS_WIN) - // The list of rectangles from constrained windows over this view. Windowed - // NPAPI plugins shouldn't draw over them. - std::vector<gfx::Rect> constrained_rects_; - - typedef std::map<HWND, WebPluginGeometry> PluginWindowMoves; - // Contains information about each windowed plugin's clip and cutout rects ( - // from the renderer). This is needed because when the transient windows - // over this view changes, we need this information in order to create a new - // region for the HWND. - PluginWindowMoves plugin_window_moves_; - // The LegacyRenderWidgetHostHWND class provides a dummy HWND which is used // for accessibility, as the container for windowless plugins like // Flash/Silverlight, etc and for legacy drivers for trackpoints/trackpads, diff --git a/content/browser/renderer_host/render_widget_host_view_base.cc b/content/browser/renderer_host/render_widget_host_view_base.cc index 8a4e0ed..d3dd8d0 100644 --- a/content/browser/renderer_host/render_widget_host_view_base.cc +++ b/content/browser/renderer_host/render_widget_host_view_base.cc @@ -21,346 +21,8 @@ #include "ui/gfx/geometry/size_f.h" #include "ui/gfx/screen.h" -#if defined(OS_WIN) -#include "base/command_line.h" -#include "base/message_loop/message_loop.h" -#include "base/win/wrapped_window_proc.h" -#include "content/browser/plugin_process_host.h" -#include "content/browser/plugin_service_impl.h" -#include "content/common/plugin_constants_win.h" -#include "content/common/webplugin_geometry.h" -#include "content/public/browser/browser_thread.h" -#include "content/public/browser/child_process_data.h" -#include "content/public/common/content_switches.h" -#include "ui/gfx/gdi_util.h" -#include "ui/gfx/win/dpi.h" -#include "ui/gfx/win/hwnd_util.h" -#endif - namespace content { -#if defined(OS_WIN) - -namespace { - -// |window| is the plugin HWND, created and destroyed in the plugin process. -// |parent| is the parent HWND, created and destroyed on the browser UI thread. -void NotifyPluginProcessHostHelper(HWND window, HWND parent, int tries) { - // How long to wait between each try. - static const int kTryDelayMs = 200; - - DWORD plugin_process_id; - bool found_starting_plugin_process = false; - GetWindowThreadProcessId(window, &plugin_process_id); - for (PluginProcessHostIterator iter; !iter.Done(); ++iter) { - if (!iter.GetData().handle) { - found_starting_plugin_process = true; - continue; - } - if (base::GetProcId(iter.GetData().handle) == plugin_process_id) { - iter->AddWindow(parent); - return; - } - } - - if (found_starting_plugin_process) { - // A plugin process has started but we don't have its handle yet. Since - // it's most likely the one for this plugin, try a few more times after a - // delay. - if (tries > 0) { - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::Bind(&NotifyPluginProcessHostHelper, window, parent, tries - 1), - base::TimeDelta::FromMilliseconds(kTryDelayMs)); - return; - } - } - - // The plugin process might have died in the time to execute the task, don't - // leak the HWND. - PostMessage(parent, WM_CLOSE, 0, 0); -} - -// The plugin wrapper window which lives in the browser process has this proc -// as its window procedure. We only handle the WM_PARENTNOTIFY message sent by -// windowed plugins for mouse input. This is forwarded off to the wrappers -// parent which is typically the RVH window which turns on user gesture. -LRESULT CALLBACK PluginWrapperWindowProc(HWND window, unsigned int message, - WPARAM wparam, LPARAM lparam) { - if (message == WM_PARENTNOTIFY) { - switch (LOWORD(wparam)) { - case WM_LBUTTONDOWN: - case WM_RBUTTONDOWN: - case WM_MBUTTONDOWN: - ::SendMessage(GetParent(window), message, wparam, lparam); - return 0; - default: - break; - } - } - return ::DefWindowProc(window, message, wparam, lparam); -} - -bool IsPluginWrapperWindow(HWND window) { - return gfx::GetClassNameW(window) == - base::string16(kWrapperNativeWindowClassName); -} - -// Create an intermediate window between the given HWND and its parent. -HWND ReparentWindow(HWND window, HWND parent) { - static ATOM atom = 0; - static HMODULE instance = NULL; - if (!atom) { - WNDCLASSEX window_class; - base::win::InitializeWindowClass( - kWrapperNativeWindowClassName, - &base::win::WrappedWindowProc<PluginWrapperWindowProc>, - CS_DBLCLKS, - 0, - 0, - NULL, - // xxx reinterpret_cast<HBRUSH>(COLOR_WINDOW+1), - reinterpret_cast<HBRUSH>(COLOR_GRAYTEXT+1), - NULL, - NULL, - NULL, - &window_class); - instance = window_class.hInstance; - atom = RegisterClassEx(&window_class); - } - DCHECK(atom); - - HWND new_parent = CreateWindowEx( - WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR, - MAKEINTATOM(atom), 0, - WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, - 0, 0, 0, 0, parent, 0, instance, 0); - gfx::CheckWindowCreated(new_parent); - ::SetParent(window, new_parent); - // How many times we try to find a PluginProcessHost whose process matches - // the HWND. - static const int kMaxTries = 5; - BrowserThread::PostTask( - BrowserThread::IO, - FROM_HERE, - base::Bind(&NotifyPluginProcessHostHelper, window, new_parent, - kMaxTries)); - return new_parent; -} - -BOOL CALLBACK PaintEnumChildProc(HWND hwnd, LPARAM lparam) { - if (!PluginServiceImpl::GetInstance()->IsPluginWindow(hwnd)) - return TRUE; - - gfx::Rect* rect = reinterpret_cast<gfx::Rect*>(lparam); - gfx::Rect rect_in_pixels = gfx::win::DIPToScreenRect(*rect); - static UINT msg = RegisterWindowMessage(kPaintMessageName); - WPARAM wparam = MAKEWPARAM(rect_in_pixels.x(), rect_in_pixels.y()); - lparam = MAKELPARAM(rect_in_pixels.width(), rect_in_pixels.height()); - - // SendMessage gets the message across much quicker than PostMessage, since it - // doesn't get queued. When the plugin thread calls PeekMessage or other - // Win32 APIs, sent messages are dispatched automatically. - SendNotifyMessage(hwnd, msg, wparam, lparam); - - return TRUE; -} - -// Windows callback for OnDestroy to detach the plugin windows. -BOOL CALLBACK DetachPluginWindowsCallbackInternal(HWND window, LPARAM param) { - RenderWidgetHostViewBase::DetachPluginWindowsCallback(window); - return TRUE; -} - -} // namespace - -// static -void RenderWidgetHostViewBase::DetachPluginWindowsCallback(HWND window) { - if (PluginServiceImpl::GetInstance()->IsPluginWindow(window) && - !IsHungAppWindow(window)) { - ::ShowWindow(window, SW_HIDE); - SetParent(window, NULL); - } -} - -// static -void RenderWidgetHostViewBase::MovePluginWindowsHelper( - HWND parent, - const std::vector<WebPluginGeometry>& moves) { - if (moves.empty()) - return; - - bool oop_plugins = !base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kSingleProcess); - - HDWP defer_window_pos_info = - ::BeginDeferWindowPos(static_cast<int>(moves.size())); - - if (!defer_window_pos_info) { - NOTREACHED(); - return; - } - -#if defined(USE_AURA) - std::vector<RECT> invalidate_rects; -#endif - - for (size_t i = 0; i < moves.size(); ++i) { - unsigned long flags = 0; - const WebPluginGeometry& move = moves[i]; - HWND window = move.window; - - // As the plugin parent window which lives on the browser UI thread is - // destroyed asynchronously, it is possible that we have a stale window - // sent in by the renderer for moving around. - // Note: get the parent before checking if the window is valid, to avoid a - // race condition where the window is destroyed after the check but before - // the GetParent call. - HWND cur_parent = ::GetParent(window); - if (!::IsWindow(window)) - continue; - - if (!PluginServiceImpl::GetInstance()->IsPluginWindow(window)) { - // The renderer should only be trying to move plugin windows. However, - // this may happen as a result of a race condition (i.e. even after the - // check right above), so we ignore it. - continue; - } - - if (oop_plugins) { - if (cur_parent == GetDesktopWindow()) { - // The plugin window hasn't been parented yet, add an intermediate - // window that lives on this thread to speed up scrolling. Note this - // only works with out of process plugins since we depend on - // PluginProcessHost to destroy the intermediate HWNDs. - cur_parent = ReparentWindow(window, parent); - ::ShowWindow(window, SW_SHOW); // Window was created hidden. - } else if (!IsPluginWrapperWindow(cur_parent)) { - continue; // Race if plugin process is shutting down. - } - - // We move the intermediate parent window which doesn't result in cross- - // process synchronous Windows messages. - window = cur_parent; - } else { - if (cur_parent == GetDesktopWindow()) - SetParent(window, parent); - } - - if (move.visible) - flags |= SWP_SHOWWINDOW; - else - flags |= SWP_HIDEWINDOW; - -#if defined(USE_AURA) - if (GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) { - // Without this flag, Windows repaints the parent area uncovered by this - // move. However when software compositing is used the clipping region is - // ignored. Since in Aura the browser chrome could be under the plugin, if - // if Windows tries to paint it synchronously inside EndDeferWindowsPos - // then it won't have the data and it will flash white. So instead we - // manually redraw the plugin. - // Why not do this for native Windows? Not sure if there are any - // performance issues with this. - flags |= SWP_NOREDRAW; - } -#endif - - if (move.rects_valid) { - gfx::Rect clip_rect_in_pixel = gfx::win::DIPToScreenRect(move.clip_rect); - HRGN hrgn = ::CreateRectRgn(clip_rect_in_pixel.x(), - clip_rect_in_pixel.y(), - clip_rect_in_pixel.right(), - clip_rect_in_pixel.bottom()); - gfx::SubtractRectanglesFromRegion(hrgn, move.cutout_rects); - - // Note: System will own the hrgn after we call SetWindowRgn, - // so we don't need to call DeleteObject(hrgn) - ::SetWindowRgn(window, hrgn, - !move.clip_rect.IsEmpty() && (flags & SWP_NOREDRAW) == 0); - -#if defined(USE_AURA) - // When using the software compositor, if the clipping rectangle is empty - // then DeferWindowPos won't redraw the newly uncovered area under the - // plugin. - if (clip_rect_in_pixel.IsEmpty() && - !GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) { - RECT r; - GetClientRect(window, &r); - MapWindowPoints(window, parent, reinterpret_cast<POINT*>(&r), 2); - invalidate_rects.push_back(r); - } -#endif - } else { - flags |= SWP_NOMOVE; - flags |= SWP_NOSIZE; - } - - gfx::Rect window_rect_in_pixel = - gfx::win::DIPToScreenRect(move.window_rect); - defer_window_pos_info = ::DeferWindowPos(defer_window_pos_info, - window, NULL, - window_rect_in_pixel.x(), - window_rect_in_pixel.y(), - window_rect_in_pixel.width(), - window_rect_in_pixel.height(), - flags); - - if (!defer_window_pos_info) { - DCHECK(false) << "DeferWindowPos failed, so all plugin moves ignored."; - return; - } - } - - ::EndDeferWindowPos(defer_window_pos_info); - -#if defined(USE_AURA) - if (GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) { - for (size_t i = 0; i < moves.size(); ++i) { - const WebPluginGeometry& move = moves[i]; - RECT r; - GetWindowRect(move.window, &r); - gfx::Rect gr(r); - PaintEnumChildProc(move.window, reinterpret_cast<LPARAM>(&gr)); - } - } else { - for (size_t i = 0; i < invalidate_rects.size(); ++i) { - ::RedrawWindow( - parent, &invalidate_rects[i], NULL, - // These flags are from WebPluginDelegateImpl::NativeWndProc. - RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_FRAME | RDW_UPDATENOW); - } - } -#endif -} - -// static -void RenderWidgetHostViewBase::PaintPluginWindowsHelper( - HWND parent, const gfx::Rect& damaged_screen_rect) { - LPARAM lparam = reinterpret_cast<LPARAM>(&damaged_screen_rect); - EnumChildWindows(parent, PaintEnumChildProc, lparam); -} - -// static -void RenderWidgetHostViewBase::DetachPluginsHelper(HWND parent) { - // When a tab is closed all its child plugin windows are destroyed - // automatically. This happens before plugins get any notification that its - // instances are tearing down. - // - // Plugins like Quicktime assume that their windows will remain valid as long - // as they have plugin instances active. Quicktime crashes in this case - // because its windowing code cleans up an internal data structure that the - // handler for NPP_DestroyStream relies on. - // - // The fix is to detach plugin windows from web contents when it is going - // away. This will prevent the plugin windows from getting destroyed - // automatically. The detached plugin windows will get cleaned up in proper - // sequence as part of the usual cleanup when the plugin instance goes away. - EnumChildWindows(parent, DetachPluginWindowsCallbackInternal, NULL); -} - -#endif // OS_WIN - namespace { // How many microseconds apart input events should be flushed. diff --git a/content/browser/renderer_host/render_widget_host_view_base.h b/content/browser/renderer_host/render_widget_host_view_base.h index 637b022..0422f82 100644 --- a/content/browser/renderer_host/render_widget_host_view_base.h +++ b/content/browser/renderer_host/render_widget_host_view_base.h @@ -258,11 +258,6 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView, // helps to position the full screen widget on the correct monitor. virtual void InitAsFullscreen(RenderWidgetHostView* reference_host_view) = 0; - // Moves all plugin windows as described in the given list. - // |scroll_offset| is the scroll offset of the render view. - virtual void MovePluginWindows( - const std::vector<WebPluginGeometry>& moves) = 0; - // Sets the cursor to the one associated with the specified cursor_type virtual void UpdateCursor(const WebCursor& cursor) = 0; @@ -390,10 +385,6 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView, // Returns an HWND that's given as the parent window for windowless Flash to // workaround crbug.com/301548. virtual gfx::NativeViewId GetParentForWindowlessPlugin() const = 0; - - // The callback that DetachPluginsHelper calls for each child window. Call - // this directly if you want to do custom filtering on plugin windows first. - static void DetachPluginWindowsCallback(HWND window); #endif // Add and remove observers for lifetime event notifications. The order in @@ -411,21 +402,6 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView, void NotifyObserversAboutShutdown(); -#if defined(OS_WIN) - // Shared implementation of MovePluginWindows for use by win and aura/wina. - static void MovePluginWindowsHelper( - HWND parent, - const std::vector<WebPluginGeometry>& moves); - - static void PaintPluginWindowsHelper( - HWND parent, - const gfx::Rect& damaged_screen_rect); - - // Needs to be called before the HWND backing the view goes away to avoid - // crashes in Windowed plugins. - static void DetachPluginsHelper(HWND parent); -#endif - // Whether this view is a popup and what kind of popup it is (select, // autofill...). blink::WebPopupType popup_type_; diff --git a/content/browser/renderer_host/render_widget_host_view_mac.h b/content/browser/renderer_host/render_widget_host_view_mac.h index 7fd192c..f475bc5 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.h +++ b/content/browser/renderer_host/render_widget_host_view_mac.h @@ -298,7 +298,6 @@ class CONTENT_EXPORT RenderWidgetHostViewMac void InitAsPopup(RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) override; void InitAsFullscreen(RenderWidgetHostView* reference_host_view) override; - void MovePluginWindows(const std::vector<WebPluginGeometry>& moves) override; void Focus() override; void UpdateCursor(const WebCursor& cursor) override; void SetIsLoading(bool is_loading) override; diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm index 5ddc4ab..9765fb6 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.mm +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm @@ -967,14 +967,6 @@ gfx::NativeViewAccessible RenderWidgetHostViewMac::GetNativeViewAccessible() { return cocoa_view_; } -void RenderWidgetHostViewMac::MovePluginWindows( - const std::vector<WebPluginGeometry>& moves) { - // Must be overridden, but unused on this platform. Core Animation - // plugins are drawn by the GPU process (through the compositor), - // and Core Graphics plugins are drawn by the renderer process. - DCHECK_CURRENTLY_ON(BrowserThread::UI); -} - void RenderWidgetHostViewMac::Focus() { [[cocoa_view_ window] makeFirstResponder:cocoa_view_]; } diff --git a/content/browser/renderer_host/render_widget_host_view_mus.cc b/content/browser/renderer_host/render_widget_host_view_mus.cc index 01097ad..9d2d21f 100644 --- a/content/browser/renderer_host/render_widget_host_view_mus.cc +++ b/content/browser/renderer_host/render_widget_host_view_mus.cc @@ -179,10 +179,6 @@ gfx::NativeViewAccessible RenderWidgetHostViewMus::GetNativeViewAccessible() { return gfx::NativeViewAccessible(); } -void RenderWidgetHostViewMus::MovePluginWindows( - const std::vector<WebPluginGeometry>& moves) { -} - void RenderWidgetHostViewMus::UpdateCursor(const WebCursor& cursor) { // TODO(fsamuel): Implement cursors in Mus. NOTIMPLEMENTED(); diff --git a/content/browser/renderer_host/render_widget_host_view_mus.h b/content/browser/renderer_host/render_widget_host_view_mus.h index 0db6d73..69b1686 100644 --- a/content/browser/renderer_host/render_widget_host_view_mus.h +++ b/content/browser/renderer_host/render_widget_host_view_mus.h @@ -65,7 +65,6 @@ class CONTENT_EXPORT RenderWidgetHostViewMus : public RenderWidgetHostViewBase { void InitAsPopup(RenderWidgetHostView* parent_host_view, const gfx::Rect& bounds) override; void InitAsFullscreen(RenderWidgetHostView* reference_host_view) override; - void MovePluginWindows(const std::vector<WebPluginGeometry>& moves) override; void UpdateCursor(const WebCursor& cursor) override; void SetIsLoading(bool is_loading) override; void TextInputStateChanged( diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc index 5974715..7053c50 100644 --- a/content/browser/web_contents/web_contents_view_aura.cc +++ b/content/browser/web_contents/web_contents_view_aura.cc @@ -406,11 +406,6 @@ class WebContentsViewAura::WindowObserver : view_(view), host_window_(NULL) { view_->window_->AddObserver(this); - -#if defined(OS_WIN) - if (view_->window_->GetRootWindow()) - view_->window_->GetRootWindow()->AddObserver(this); -#endif } ~WindowObserver() override { @@ -419,64 +414,8 @@ class WebContentsViewAura::WindowObserver view_->window_->GetHost()->RemoveObserver(this); if (host_window_) host_window_->RemoveObserver(this); -#if defined(OS_WIN) - if (host_window_) { - const aura::Window::Windows& children = host_window_->children(); - for (size_t i = 0; i < children.size(); ++i) - children[i]->RemoveObserver(this); - } - - aura::Window* root_window = view_->window_->GetRootWindow(); - if (root_window) { - root_window->RemoveObserver(this); - const aura::Window::Windows& root_children = root_window->children(); - for (size_t i = 0; i < root_children.size(); ++i) - root_children[i]->RemoveObserver(this); - } -#endif - } - -#if defined(OS_WIN) - // Constrained windows are added as children of the parent's parent's view - // which may overlap with windowed NPAPI plugins. In that case, tell the RWHV - // so that it can update the plugins' cutout rects accordingly. - // Note: this is hard coding how Chrome layer adds its dialogs. Since NPAPI is - // going to be deprecated in a year, this is ok for now. The test for this is - // PrintPreviewTest.WindowedNPAPIPluginHidden. - void OnWindowAdded(aura::Window* new_window) override { - if (!new_window->Contains(view_->window_.get())) { - // Skip the case when the parent moves to the root window. - if (new_window != host_window_) { - // Observe sibling windows of the WebContents, or children of the root - // window. - if (new_window->parent() == host_window_ || - new_window->parent() == view_->window_->GetRootWindow()) { - new_window->AddObserver(this); - } - } - } - - if (new_window->parent() == host_window_) { - UpdateConstrainedWindows(NULL); - } } - void OnWillRemoveWindow(aura::Window* window) override { - if (window == view_->window_.get()) - return; - - window->RemoveObserver(this); - UpdateConstrainedWindows(window); - } - - void OnWindowVisibilityChanged(aura::Window* window, bool visible) override { - if (window == view_->window_.get() || window->parent() == host_window_ || - window->parent() == view_->window_->GetRootWindow()) { - UpdateConstrainedWindows(NULL); - } - } -#endif - void OnWindowParentChanged(aura::Window* window, aura::Window* parent) override { if (window != view_->window_.get()) @@ -490,46 +429,9 @@ class WebContentsViewAura::WindowObserver if (host_window_) host_window_->RemoveObserver(this); -#if defined(OS_WIN) - if (host_window_) { - const aura::Window::Windows& children = host_window_->children(); - for (size_t i = 0; i < children.size(); ++i) - children[i]->RemoveObserver(this); - RenderWidgetHostViewAura* rwhv = ToRenderWidgetHostViewAura( - view_->web_contents_->GetRenderWidgetHostView()); - if (rwhv) - rwhv->UpdateConstrainedWindowRects(std::vector<gfx::Rect>()); - } - - // When we get parented to the root window, the code below will watch the - // host window, aka root window. Since we already watch the root window on - // Windows, unregister first so that the debug check doesn't fire. - if (host_window && host_window == window->GetRootWindow()) - host_window->RemoveObserver(this); - - // We need to undo the above if we were parented to the root window and then - // got parented to another window. At that point, the code before the ifdef - // would have stopped watching the root window. - if (window->GetRootWindow() && - host_window != window->GetRootWindow() && - !window->GetRootWindow()->HasObserver(this)) { - window->GetRootWindow()->AddObserver(this); - } -#endif - host_window_ = host_window; - if (host_window) { + if (host_window) host_window->AddObserver(this); -#if defined(OS_WIN) - if (host_window != window->GetRootWindow()) { - const aura::Window::Windows& children = host_window->children(); - for (size_t i = 0; i < children.size(); ++i) { - if (!children[i]->Contains(view_->window_.get())) - children[i]->AddObserver(this); - } - } -#endif - } } void OnWindowBoundsChanged(aura::Window* window, @@ -543,10 +445,6 @@ class WebContentsViewAura::WindowObserver if (selection_controller_client) selection_controller_client->OnWindowMoved(); } -#if defined(OS_WIN) - } else { - UpdateConstrainedWindows(NULL); -#endif } } @@ -558,32 +456,14 @@ class WebContentsViewAura::WindowObserver } void OnWindowAddedToRootWindow(aura::Window* window) override { - if (window == view_->window_.get()) { + if (window == view_->window_.get()) window->GetHost()->AddObserver(this); -#if defined(OS_WIN) - if (!window->GetRootWindow()->HasObserver(this)) - window->GetRootWindow()->AddObserver(this); -#endif - } } void OnWindowRemovingFromRootWindow(aura::Window* window, aura::Window* new_root) override { - if (window == view_->window_.get()) { + if (window == view_->window_.get()) window->GetHost()->RemoveObserver(this); -#if defined(OS_WIN) - window->GetRootWindow()->RemoveObserver(this); - - const aura::Window::Windows& root_children = - window->GetRootWindow()->children(); - for (size_t i = 0; i < root_children.size(); ++i) { - if (root_children[i] != view_->window_.get() && - root_children[i] != host_window_) { - root_children[i]->RemoveObserver(this); - } - } -#endif - } } // Overridden WindowTreeHostObserver: @@ -600,41 +480,6 @@ class WebContentsViewAura::WindowObserver private: void SendScreenRects() { view_->web_contents_->SendScreenRects(); } -#if defined(OS_WIN) - void UpdateConstrainedWindows(aura::Window* exclude) { - RenderWidgetHostViewAura* view = ToRenderWidgetHostViewAura( - view_->web_contents_->GetRenderWidgetHostView()); - if (!view) - return; - - std::vector<gfx::Rect> constrained_windows; - if (host_window_) { - const aura::Window::Windows& children = host_window_->children(); - for (size_t i = 0; i < children.size(); ++i) { - if (!children[i]->Contains(view_->window_.get()) && - children[i] != exclude && - children[i]->IsVisible()) { - constrained_windows.push_back(children[i]->GetBoundsInRootWindow()); - } - } - } - - aura::Window* root_window = view_->window_->GetRootWindow(); - const aura::Window::Windows& root_children = root_window->children(); - if (root_window) { - for (size_t i = 0; i < root_children.size(); ++i) { - if (root_children[i]->IsVisible() && - !root_children[i]->Contains(view_->window_.get())) { - constrained_windows.push_back( - root_children[i]->GetBoundsInRootWindow()); - } - } - } - - view->UpdateConstrainedWindowRects(constrained_windows); - } -#endif - WebContentsViewAura* view_; // The parent window that hosts the constrained windows. We cache the old host diff --git a/content/child/npapi/plugin_host.cc b/content/child/npapi/plugin_host.cc index 47467ae..f5a04ef 100644 --- a/content/child/npapi/plugin_host.cc +++ b/content/child/npapi/plugin_host.cc @@ -464,17 +464,6 @@ void NPN_InvalidateRect(NPP id, NPRect *invalidRect) { scoped_refptr<PluginInstance> plugin(FindInstance(id)); if (plugin.get() && plugin->webplugin()) { if (invalidRect) { -#if defined(OS_WIN) - if (!plugin->windowless()) { - RECT rect = {0}; - rect.left = invalidRect->left; - rect.right = invalidRect->right; - rect.top = invalidRect->top; - rect.bottom = invalidRect->bottom; - ::InvalidateRect(plugin->window_handle(), &rect, false); - return; - } -#endif gfx::Rect rect(invalidRect->left, invalidRect->top, invalidRect->right - invalidRect->left, @@ -669,15 +658,6 @@ NPError NPN_SetValue(NPP id, NPPVariable variable, void* value) { return NPERR_INVALID_INSTANCE_ERROR; } switch(variable) { - case NPPVpluginWindowBool: { - // Sets windowless mode for display of the plugin - // Note: the documentation at - // http://developer.mozilla.org/en/docs/NPN_SetValue is wrong. When - // value is NULL, the mode is set to true. This is the same way Mozilla - // works. - plugin->set_windowless(value == 0); - return NPERR_NO_ERROR; - } case NPPVpluginTransparentBool: { // Sets transparent mode for display of the plugin // diff --git a/content/child/npapi/plugin_instance.cc b/content/child/npapi/plugin_instance.cc index d353196..3889bd7 100644 --- a/content/child/npapi/plugin_instance.cc +++ b/content/child/npapi/plugin_instance.cc @@ -36,7 +36,6 @@ PluginInstance::PluginInstance(PluginLib* plugin, const std::string& mime_type) host_(PluginHost::Singleton()), npp_functions_(plugin->functions()), window_handle_(0), - windowless_(false), transparent_(true), webplugin_(0), mime_type_(mime_type), diff --git a/content/child/npapi/plugin_instance.h b/content/child/npapi/plugin_instance.h index 2cf931e..75a1e99 100644 --- a/content/child/npapi/plugin_instance.h +++ b/content/child/npapi/plugin_instance.h @@ -82,11 +82,6 @@ class PluginInstance : public base::RefCountedThreadSafe<PluginInstance> { window_handle_ = value; } - // Get/Set whether this instance is in Windowless mode. - // Default is false. - bool windowless() { return windowless_; } - void set_windowless(bool value) { windowless_ = value; } - // Get/Set whether this instance is transparent. This only applies to // windowless plugins. Transparent plugins require that webkit paint the // background. @@ -233,7 +228,6 @@ class PluginInstance : public base::RefCountedThreadSafe<PluginInstance> { scoped_refptr<PluginHost> host_; NPPluginFuncs* npp_functions_; gfx::PluginWindowHandle window_handle_; - bool windowless_; bool transparent_; WebPlugin* webplugin_; std::string mime_type_; diff --git a/content/child/npapi/webplugin.h b/content/child/npapi/webplugin.h index 690967b..9e7f1ed 100644 --- a/content/child/npapi/webplugin.h +++ b/content/child/npapi/webplugin.h @@ -36,19 +36,6 @@ class WebPlugin { public: virtual ~WebPlugin() {} - // Called by the plugin delegate to let the WebPlugin know if the plugin is - // windowed (i.e. handle is not NULL) or windowless (handle is NULL). This - // tells the WebPlugin to send mouse/keyboard events to the plugin delegate, - // as well as the information about the HDC for paint operations. - virtual void SetWindow(gfx::PluginWindowHandle window) = 0; - - // Whether input events should be sent to the delegate. - virtual void SetAcceptsInputEvents(bool accepts) = 0; - - // Called by the plugin delegate to let it know that the window is being - // destroyed. - virtual void WillDestroyWindow(gfx::PluginWindowHandle window) = 0; - virtual void Invalidate() = 0; virtual void InvalidateRect(const gfx::Rect& rect) = 0; diff --git a/content/child/npapi/webplugin_delegate_impl.cc b/content/child/npapi/webplugin_delegate_impl.cc index 1854ea4..06ff316 100644 --- a/content/child/npapi/webplugin_delegate_impl.cc +++ b/content/child/npapi/webplugin_delegate_impl.cc @@ -86,14 +86,6 @@ bool WebPluginDelegateImpl::Initialize( return false; } - windowless_ = instance_->windowless(); - if (!windowless_) { - if (!WindowedCreatePlugin()) { - VLOG(1) << "Couldn't create windowed plugin"; - return false; - } - } - bool should_load = PlatformInitialize(); plugin_url_ = url.spec(); @@ -133,15 +125,10 @@ void WebPluginDelegateImpl::UpdateGeometry( return; } - if (windowless_) { - WindowlessUpdateGeometry(window_rect, clip_rect); - } else { - WindowedUpdateGeometry(window_rect, clip_rect); - } + WindowlessUpdateGeometry(window_rect, clip_rect); } void WebPluginDelegateImpl::SetFocus(bool focused) { - DCHECK(windowless_); // This is called when internal WebKit focus (the focused element on the page) // changes, but plugins need to know about OS-level focus, so we have an extra // layer of focus tracking. @@ -169,8 +156,6 @@ void WebPluginDelegateImpl::SetPluginHasFocus(bool focused) { void WebPluginDelegateImpl::SetContentAreaHasFocus(bool has_focus) { containing_view_has_focus_ = has_focus; - if (!windowless_) - return; #if !defined(OS_WIN) // See SetFocus above. SetPluginHasFocus(containing_view_has_focus_ && has_webkit_focus_); #endif @@ -197,21 +182,9 @@ base::FilePath WebPluginDelegateImpl::GetPluginPath() { return instance()->plugin_lib()->plugin_info().path; } -void WebPluginDelegateImpl::WindowedUpdateGeometry( - const gfx::Rect& window_rect, - const gfx::Rect& clip_rect) { - if (WindowedReposition(window_rect, clip_rect) || - !windowed_did_set_window_) { - // Let the plugin know that it has been moved - WindowedSetWindow(); - } -} - bool WebPluginDelegateImpl::HandleInputEvent( const WebInputEvent& event, WebCursor::CursorInfo* cursor_info) { - DCHECK(windowless_) << "events should only be received in windowless mode"; - bool pop_user_gesture = false; if (IsUserGesture(event)) { pop_user_gesture = true; diff --git a/content/child/npapi/webplugin_delegate_impl.h b/content/child/npapi/webplugin_delegate_impl.h index f6dae16..f07256b 100644 --- a/content/child/npapi/webplugin_delegate_impl.h +++ b/content/child/npapi/webplugin_delegate_impl.h @@ -98,8 +98,6 @@ class WebPluginDelegateImpl : public WebPluginDelegate { int GetProcessId() override; // End of WebPluginDelegate implementation. - gfx::PluginWindowHandle windowed_handle() const { return windowed_handle_; } - bool IsWindowless() const { return windowless_; } PluginInstance* instance() { return instance_.get(); } gfx::Rect GetRect() const { return window_rect_; } gfx::Rect GetClipRect() const { return clip_rect_; } @@ -177,36 +175,8 @@ class WebPluginDelegateImpl : public WebPluginDelegate { // Called by DestroyInstance(), used for platform-specific destruction. void PlatformDestroyInstance(); - //-------------------------- - // used for windowed plugins - void WindowedUpdateGeometry(const gfx::Rect& window_rect, - const gfx::Rect& clip_rect); - // Create the native window. - // Returns true if the window is created (or already exists). - // Returns false if unable to create the window. - bool WindowedCreatePlugin(); - - // Destroy the native window. - void WindowedDestroyWindow(); - - // Reposition the native window to be in sync with the given geometry. - // Returns true if the native window has moved or been clipped differently. - bool WindowedReposition(const gfx::Rect& window_rect, - const gfx::Rect& clip_rect); - - // Tells the plugin about the current state of the window. - // See NPAPI NPP_SetWindow for more information. - void WindowedSetWindow(); - #if defined(OS_WIN) - // Registers the window class for our window - ATOM RegisterNativeWindowClass(); - // Our WndProc functions. - static LRESULT CALLBACK WrapperWindowProc( - HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); - static LRESULT CALLBACK NativeWndProc( - HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); static LRESULT CALLBACK FlashWindowlessWndProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); static LRESULT CALLBACK DummyWindowProc( @@ -249,30 +219,15 @@ class WebPluginDelegateImpl : public WebPluginDelegate { void DestroyInstance(); - // used for windowed plugins // Note: on Mac OS X, the only time the windowed handle is non-zero // is the case of accelerated rendering, which uses a fake window handle to // identify itself back to the browser. It still performs all of its // work offscreen. - gfx::PluginWindowHandle windowed_handle_; - gfx::Rect windowed_last_pos_; - - bool windowed_did_set_window_; - - // used by windowed and windowless plugins - bool windowless_; WebPlugin* plugin_; scoped_refptr<PluginInstance> instance_; #if defined(OS_WIN) - // Original wndproc before we subclassed. - WNDPROC plugin_wnd_proc_; - - // Used to throttle WM_USER+1 messages in Flash. - uint32_t last_message_; - bool is_calling_wndproc; - // An IME emulator used by a windowless plugin to retrieve IME data through // IMM32 functions. scoped_ptr<WebPluginIMEWin> plugin_ime_; @@ -332,13 +287,6 @@ class WebPluginDelegateImpl : public WebPluginDelegate { // window for Aura to ensure that these conversions occur correctly. static HWND WINAPI WindowFromPointPatch(POINT point); - // The mouse hook proc which handles mouse capture in windowed plugins. - static LRESULT CALLBACK MouseHookProc(int code, WPARAM wParam, - LPARAM lParam); - - // Calls SetCapture/ReleaseCapture based on the message type. - static void HandleCaptureForMessage(HWND window, UINT message); - #elif defined(OS_MACOSX) && !defined(USE_AURA) // Sets window_rect_ to |rect| void SetPluginRect(const gfx::Rect& rect); @@ -393,22 +341,12 @@ class WebPluginDelegateImpl : public WebPluginDelegate { std::string plugin_url_; #if defined(OS_WIN) - // Indicates the end of a user gesture period. - void OnUserGestureEnd(); - // Handle to the message filter hook HHOOK handle_event_message_filter_hook_; // Event which is set when the plugin enters a modal loop in the course // of a NPP_HandleEvent call. HANDLE handle_event_pump_messages_event_; - - // This flag indicates whether we started tracking a user gesture message. - bool user_gesture_message_posted_; - - // Handle to the mouse hook installed for certain windowed plugins like - // flash. - HHOOK mouse_hook_; #endif // Holds the depth of the HandleEvent callstack. diff --git a/content/child/npapi/webplugin_delegate_impl_android.cc b/content/child/npapi/webplugin_delegate_impl_android.cc index ed562b3..7458f05 100644 --- a/content/child/npapi/webplugin_delegate_impl_android.cc +++ b/content/child/npapi/webplugin_delegate_impl_android.cc @@ -18,10 +18,7 @@ namespace content { WebPluginDelegateImpl::WebPluginDelegateImpl( WebPlugin* plugin, PluginInstance* instance) - : windowed_handle_(0), - windowed_did_set_window_(false), - windowless_(false), - plugin_(plugin), + : plugin_(plugin), instance_(instance), quirks_(0), handle_event_depth_(0), @@ -43,22 +40,6 @@ void WebPluginDelegateImpl::PlatformDestroyInstance() { void WebPluginDelegateImpl::Paint(SkCanvas* canvas, const gfx::Rect& rect) { } -bool WebPluginDelegateImpl::WindowedCreatePlugin() { - return false; -} - -void WebPluginDelegateImpl::WindowedDestroyWindow() { -} - -bool WebPluginDelegateImpl::WindowedReposition( - const gfx::Rect& window_rect, - const gfx::Rect& clip_rect) { - return false; -} - -void WebPluginDelegateImpl::WindowedSetWindow() { -} - void WebPluginDelegateImpl::WindowlessUpdateGeometry( const gfx::Rect& window_rect, const gfx::Rect& clip_rect) { diff --git a/content/child/npapi/webplugin_delegate_impl_aura.cc b/content/child/npapi/webplugin_delegate_impl_aura.cc index a700e7c..db0a816 100644 --- a/content/child/npapi/webplugin_delegate_impl_aura.cc +++ b/content/child/npapi/webplugin_delegate_impl_aura.cc @@ -29,22 +29,6 @@ void WebPluginDelegateImpl::PlatformDestroyInstance() { void WebPluginDelegateImpl::Paint(SkCanvas* canvas, const gfx::Rect& rect) { } -bool WebPluginDelegateImpl::WindowedCreatePlugin() { - return true; -} - -void WebPluginDelegateImpl::WindowedDestroyWindow() { -} - -bool WebPluginDelegateImpl::WindowedReposition( - const gfx::Rect& window_rect, - const gfx::Rect& clip_rect) { - return true; -} - -void WebPluginDelegateImpl::WindowedSetWindow() { -} - void WebPluginDelegateImpl::WindowlessUpdateGeometry( const gfx::Rect& window_rect, const gfx::Rect& clip_rect) { diff --git a/content/child/npapi/webplugin_delegate_impl_mac.mm b/content/child/npapi/webplugin_delegate_impl_mac.mm index 4a39d1d..d17a48e 100644 --- a/content/child/npapi/webplugin_delegate_impl_mac.mm +++ b/content/child/npapi/webplugin_delegate_impl_mac.mm @@ -149,10 +149,7 @@ int ExternalDragTracker::WebEventButtonModifierMask() { WebPluginDelegateImpl::WebPluginDelegateImpl( WebPlugin* plugin, PluginInstance* instance) - : windowed_handle_(gfx::kNullPluginWindow), - // all Mac plugins are "windowless" in the Windows/X11 sense - windowless_(true), - plugin_(plugin), + : plugin_(plugin), instance_(instance), quirks_(0), use_buffer_context_(true), @@ -174,7 +171,6 @@ WebPluginDelegateImpl::WebPluginDelegateImpl( containing_view_has_focus_(true), creation_succeeded_(false) { memset(&window_, 0, sizeof(window_)); - instance->set_windowless(true); } WebPluginDelegateImpl::~WebPluginDelegateImpl() { @@ -252,13 +248,6 @@ bool WebPluginDelegateImpl::PlatformInitialize() { break; } - // Let the WebPlugin know that we are windowless, unless this is a Core - // Animation plugin, in which case AcceleratedPluginEnabledRendering - // calls SetWindow. Rendering breaks if SetWindow is called before - // accelerated rendering is enabled. - if (!layer_) - plugin_->SetWindow(gfx::kNullPluginWindow); - return true; } @@ -508,25 +497,6 @@ void WebPluginDelegateImpl::WindowlessSetWindow() { #pragma mark - -bool WebPluginDelegateImpl::WindowedCreatePlugin() { - NOTREACHED(); - return false; -} - -void WebPluginDelegateImpl::WindowedDestroyWindow() { - NOTREACHED(); -} - -bool WebPluginDelegateImpl::WindowedReposition(const gfx::Rect& window_rect, - const gfx::Rect& clip_rect) { - NOTREACHED(); - return false; -} - -void WebPluginDelegateImpl::WindowedSetWindow() { - NOTREACHED(); -} - #pragma mark - #pragma mark Mac Extensions diff --git a/content/child/npapi/webplugin_delegate_impl_win.cc b/content/child/npapi/webplugin_delegate_impl_win.cc index 5cd6e5c..f0213e3 100644 --- a/content/child/npapi/webplugin_delegate_impl_win.cc +++ b/content/child/npapi/webplugin_delegate_impl_win.cc @@ -58,12 +58,6 @@ const wchar_t kWebPluginDelegateProperty[] = L"WebPluginDelegateProperty"; // this seems to work well enough. const int kFlashWMUSERMessageThrottleDelayMs = 5; -// Flash displays popups in response to user clicks by posting a WM_USER -// message to the plugin window. The handler for this message displays -// the popup. To ensure that the popups allowed state is sent correctly -// to the renderer we reset the popups allowed state in a timer. -const int kWindowedPluginPopupTimerMs = 50; - // The current instance of the plugin which entered the modal loop. WebPluginDelegateImpl* g_current_plugin_instance = NULL; @@ -212,35 +206,16 @@ LRESULT CALLBACK WebPluginDelegateImpl::HandleEventMessageFilterHook( return CallNextHookEx(NULL, code, wParam, lParam); } -LRESULT CALLBACK WebPluginDelegateImpl::MouseHookProc( - int code, WPARAM wParam, LPARAM lParam) { - if (code == HC_ACTION) { - MOUSEHOOKSTRUCT* hook_struct = reinterpret_cast<MOUSEHOOKSTRUCT*>(lParam); - if (hook_struct) - HandleCaptureForMessage(hook_struct->hwnd, wParam); - } - - return CallNextHookEx(NULL, code, wParam, lParam); -} - WebPluginDelegateImpl::WebPluginDelegateImpl(WebPlugin* plugin, PluginInstance* instance) - : windowed_handle_(NULL), - windowed_did_set_window_(false), - windowless_(false), - plugin_(plugin), + : plugin_(plugin), instance_(instance), - plugin_wnd_proc_(NULL), - last_message_(0), - is_calling_wndproc(false), quirks_(0), dummy_window_for_activation_(NULL), dummy_window_parent_(NULL), old_dummy_window_proc_(NULL), handle_event_message_filter_hook_(NULL), handle_event_pump_messages_event_(NULL), - user_gesture_message_posted_(false), - mouse_hook_(NULL), handle_event_depth_(0), first_set_window_call_(true), plugin_has_focus_(false), @@ -333,24 +308,17 @@ WebPluginDelegateImpl::~WebPluginDelegateImpl() { DestroyInstance(); - if (!windowless_) - WindowedDestroyWindow(); - if (handle_event_pump_messages_event_) { CloseHandle(handle_event_pump_messages_event_); } } bool WebPluginDelegateImpl::PlatformInitialize() { - plugin_->SetWindow(windowed_handle_); - - if (windowless_) { - CreateDummyWindowForActivation(); - handle_event_pump_messages_event_ = CreateEvent(NULL, TRUE, FALSE, NULL); - plugin_->SetWindowlessData( - handle_event_pump_messages_event_, - reinterpret_cast<gfx::NativeViewId>(dummy_window_for_activation_)); - } + CreateDummyWindowForActivation(); + handle_event_pump_messages_event_ = CreateEvent(NULL, TRUE, FALSE, NULL); + plugin_->SetWindowlessData( + handle_event_pump_messages_event_, + reinterpret_cast<gfx::NativeViewId>(dummy_window_for_activation_)); // Windowless plugins call the WindowFromPoint API and passes the result of // that to the TrackPopupMenu API call as the owner window. This causes the @@ -358,7 +326,7 @@ bool WebPluginDelegateImpl::PlatformInitialize() { // thread as the caller. It works in the other browsers as the plugin lives // on the browser thread. Our workaround is to intercept the TrackPopupMenu // API and replace the window handle with the dummy activation window. - if (windowless_ && !g_iat_patch_track_popup_menu.Pointer()->is_patched()) { + if (!g_iat_patch_track_popup_menu.Pointer()->is_patched()) { g_iat_patch_track_popup_menu.Pointer()->Patch( GetPluginPath().value().c_str(), "user32.dll", "TrackPopupMenu", WebPluginDelegateImpl::TrackPopupMenuPatch); @@ -371,28 +339,13 @@ bool WebPluginDelegateImpl::PlatformInitialize() { // browser in the HandleEvent call, which ensures that the cursor does not // change when a windowless plugin instance changes the cursor // in a background tab. - if (windowless_ && !g_iat_patch_set_cursor.Pointer()->is_patched() && + if (!g_iat_patch_set_cursor.Pointer()->is_patched() && (quirks_ & PLUGIN_QUIRK_PATCH_SETCURSOR)) { g_iat_patch_set_cursor.Pointer()->Patch( GetPluginPath().value().c_str(), "user32.dll", "SetCursor", WebPluginDelegateImpl::SetCursorPatch); } - // The windowed flash plugin has a bug which occurs when the plugin enters - // fullscreen mode. It basically captures the mouse on WM_LBUTTONDOWN and - // does not release capture correctly causing it to stop receiving - // subsequent mouse events. This problem is also seen in Safari where there - // is code to handle this in the wndproc. However the plugin subclasses the - // window again in WM_LBUTTONDOWN before entering full screen. As a result - // Safari does not receive the WM_LBUTTONUP message. To workaround this - // issue we use a per thread mouse hook. This bug does not occur in Firefox - // and opera. Firefox has code similar to Safari. It could well be a bug in - // the flash plugin, which only occurs in webkit based browsers. - if (quirks_ & PLUGIN_QUIRK_HANDLE_MOUSE_CAPTURE) { - mouse_hook_ = SetWindowsHookEx(WH_MOUSE, MouseHookProc, NULL, - GetCurrentThreadId()); - } - // On XP, WMP will use its old UI unless a registry key under HKLM has the // name of the current process. We do it in the installer for admin users, // for the rest patch this function. @@ -418,7 +371,7 @@ bool WebPluginDelegateImpl::PlatformInitialize() { GetProcAddressPatch); } - if (windowless_ && !g_iat_patch_window_from_point.Pointer()->is_patched() && + if (!g_iat_patch_window_from_point.Pointer()->is_patched() && (quirks_ & PLUGIN_QUIRK_FAKE_WINDOW_FROM_POINT)) { g_iat_patch_window_from_point.Pointer()->Patch( GetPluginPath().value().c_str(), "user32.dll", "WindowFromPoint", @@ -447,86 +400,16 @@ void WebPluginDelegateImpl::PlatformDestroyInstance() { if (g_iat_patch_window_from_point.Pointer()->is_patched()) g_iat_patch_window_from_point.Pointer()->Unpatch(); - - if (mouse_hook_) { - UnhookWindowsHookEx(mouse_hook_); - mouse_hook_ = NULL; - } } void WebPluginDelegateImpl::Paint(SkCanvas* canvas, const gfx::Rect& rect) { - if (windowless_ && skia::SupportsPlatformPaint(canvas)) { + if (skia::SupportsPlatformPaint(canvas)) { skia::ScopedPlatformPaint scoped_platform_paint(canvas); HDC hdc = scoped_platform_paint.GetPlatformSurface(); WindowlessPaint(hdc, rect); } } -bool WebPluginDelegateImpl::WindowedCreatePlugin() { - DCHECK(!windowed_handle_); - - RegisterNativeWindowClass(); - - // The window will be sized and shown later. - windowed_handle_ = CreateWindowEx( - WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR, - kNativeWindowClassName, - 0, - WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, - 0, - 0, - 0, - 0, - GetDesktopWindow(), - 0, - GetModuleHandle(NULL), - 0); - if (windowed_handle_ == 0) - return false; - - // This is a tricky workaround for Issue 2673 in chromium "Flash: IME not - // available". To use IMEs in this window, we have to make Windows attach - // IMEs to this window (i.e. load IME DLLs, attach them to this process, and - // add their message hooks to this window). Windows attaches IMEs while this - // process creates a top-level window. On the other hand, to layout this - // window correctly in the given parent window (RenderWidgetHostViewWin or - // RenderWidgetHostViewAura), this window should be a child window of the - // parent window. To satisfy both of the above conditions, this code once - // creates a top-level window and change it to a child window of the parent - // window (in the browser process). - SetWindowLongPtr(windowed_handle_, GWL_STYLE, - WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); - - BOOL result = SetProp(windowed_handle_, kWebPluginDelegateProperty, this); - DCHECK(result == TRUE) << "SetProp failed, last error = " << GetLastError(); - - // Calling SetWindowLongPtrA here makes the window proc ASCII, which is - // required by at least the Shockwave Director plugin. - SetWindowLongPtrA(windowed_handle_, - GWLP_WNDPROC, - reinterpret_cast<LONG_PTR>(DefWindowProcA)); - - return true; -} - -void WebPluginDelegateImpl::WindowedDestroyWindow() { - if (windowed_handle_ != NULL) { - // Unsubclass the window. - WNDPROC current_wnd_proc = reinterpret_cast<WNDPROC>( - GetWindowLongPtr(windowed_handle_, GWLP_WNDPROC)); - if (current_wnd_proc == NativeWndProc) { - SetWindowLongPtr(windowed_handle_, - GWLP_WNDPROC, - reinterpret_cast<LONG_PTR>(plugin_wnd_proc_)); - } - - plugin_->WillDestroyWindow(windowed_handle_); - - DestroyWindow(windowed_handle_); - windowed_handle_ = 0; - } -} - // Erase all messages in the queue destined for a particular window. // When windows are closing, callers should use this function to clear // the queue. @@ -755,129 +638,6 @@ bool WebPluginDelegateImpl::CreateDummyWindowForActivation() { return true; } -bool WebPluginDelegateImpl::WindowedReposition( - const gfx::Rect& window_rect_in_dip, - const gfx::Rect& clip_rect_in_dip) { - if (!windowed_handle_) { - NOTREACHED(); - return false; - } - - gfx::Rect window_rect = gfx::win::DIPToScreenRect(window_rect_in_dip); - gfx::Rect clip_rect = gfx::win::DIPToScreenRect(clip_rect_in_dip); - if (window_rect_ == window_rect && clip_rect_ == clip_rect) - return false; - - // We only set the plugin's size here. Its position is moved elsewhere, which - // allows the window moves/scrolling/clipping to be synchronized with the page - // and other windows. - // If the plugin window has no parent, then don't focus it because it isn't - // being displayed anywhere. See: - // http://code.google.com/p/chromium/issues/detail?id=32658 - if (window_rect.size() != window_rect_.size()) { - UINT flags = SWP_NOMOVE | SWP_NOZORDER; - if (!GetParent(windowed_handle_)) - flags |= SWP_NOACTIVATE; - ::SetWindowPos(windowed_handle_, - NULL, - 0, - 0, - window_rect.width(), - window_rect.height(), - flags); - } - - window_rect_ = window_rect; - clip_rect_ = clip_rect; - - // Ensure that the entire window gets repainted. - ::InvalidateRect(windowed_handle_, NULL, FALSE); - - return true; -} - -void WebPluginDelegateImpl::WindowedSetWindow() { - if (!instance_.get()) - return; - - if (!windowed_handle_) { - NOTREACHED(); - return; - } - - instance()->set_window_handle(windowed_handle_); - - DCHECK(!instance()->windowless()); - - window_.clipRect.top = std::max(0, clip_rect_.y()); - window_.clipRect.left = std::max(0, clip_rect_.x()); - window_.clipRect.bottom = std::max(0, clip_rect_.y() + clip_rect_.height()); - window_.clipRect.right = std::max(0, clip_rect_.x() + clip_rect_.width()); - window_.height = window_rect_.height(); - window_.width = window_rect_.width(); - window_.x = 0; - window_.y = 0; - - window_.window = windowed_handle_; - window_.type = NPWindowTypeWindow; - - // Reset this flag before entering the instance in case of side-effects. - windowed_did_set_window_ = true; - - instance()->NPP_SetWindow(&window_); - if (quirks_ & PLUGIN_QUIRK_SETWINDOW_TWICE) - instance()->NPP_SetWindow(&window_); - - WNDPROC current_wnd_proc = reinterpret_cast<WNDPROC>( - GetWindowLongPtr(windowed_handle_, GWLP_WNDPROC)); - if (current_wnd_proc != NativeWndProc) { - plugin_wnd_proc_ = reinterpret_cast<WNDPROC>( - SetWindowLongPtr(windowed_handle_, - GWLP_WNDPROC, - reinterpret_cast<LONG_PTR>(NativeWndProc))); - } -} - -ATOM WebPluginDelegateImpl::RegisterNativeWindowClass() { - static bool have_registered_window_class = false; - if (have_registered_window_class == true) - return true; - - have_registered_window_class = true; - - WNDCLASSEX wcex; - wcex.cbSize = sizeof(WNDCLASSEX); - wcex.style = CS_DBLCLKS; - wcex.lpfnWndProc = WrapperWindowProc; - wcex.cbClsExtra = 0; - wcex.cbWndExtra = 0; - wcex.hInstance = GetModuleHandle(NULL); - wcex.hIcon = 0; - wcex.hCursor = 0; - // Some plugins like windows media player 11 create child windows parented - // by our plugin window, where the media content is rendered. These plugins - // dont implement WM_ERASEBKGND, which causes painting issues, when the - // window where the media is rendered is moved around. DefWindowProc does - // implement WM_ERASEBKGND correctly if we have a valid background brush. - wcex.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_WINDOW+1); - wcex.lpszMenuName = 0; - wcex.lpszClassName = kNativeWindowClassName; - wcex.hIconSm = 0; - - return RegisterClassEx(&wcex); -} - -LRESULT CALLBACK WebPluginDelegateImpl::WrapperWindowProc( - HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - // This is another workaround for Issue 2673 in chromium "Flash: IME not - // available". Somehow, the CallWindowProc() function does not dispatch - // window messages when its first parameter is a handle representing the - // DefWindowProc() function. To avoid this problem, this code creates a - // wrapper function which just encapsulates the DefWindowProc() function - // and set it as the window procedure of a windowed plugin. - return DefWindowProc(hWnd, message, wParam, lParam); -} - // Returns true if the message passed in corresponds to a user gesture. static bool IsUserGestureMessage(unsigned int message) { switch (message) { @@ -898,115 +658,6 @@ static bool IsUserGestureMessage(unsigned int message) { return false; } -LRESULT CALLBACK WebPluginDelegateImpl::NativeWndProc( - HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { - WebPluginDelegateImpl* delegate = reinterpret_cast<WebPluginDelegateImpl*>( - GetProp(hwnd, kWebPluginDelegateProperty)); - if (!delegate) { - NOTREACHED(); - return 0; - } - - if (message == delegate->last_message_ && - delegate->GetQuirks() & PLUGIN_QUIRK_DONT_CALL_WND_PROC_RECURSIVELY && - delegate->is_calling_wndproc) { - // Real may go into a state where it recursively dispatches the same event - // when subclassed. See https://bugzilla.mozilla.org/show_bug.cgi?id=192914 - // We only do the recursive check for Real because it's possible and valid - // for a plugin to synchronously dispatch a message to itself such that it - // looks like it's in recursion. - return TRUE; - } - - // Flash may flood the message queue with WM_USER+1 message causing 100% CPU - // usage. See https://bugzilla.mozilla.org/show_bug.cgi?id=132759. We - // prevent this by throttling the messages. - if (message == WM_USER + 1 && - delegate->GetQuirks() & PLUGIN_QUIRK_THROTTLE_WM_USER_PLUS_ONE) { - WebPluginDelegateImpl::ThrottleMessage(delegate->plugin_wnd_proc_, hwnd, - message, wparam, lparam); - return FALSE; - } - - LRESULT result; - uint32_t old_message = delegate->last_message_; - delegate->last_message_ = message; - - static UINT custom_msg = RegisterWindowMessage(kPaintMessageName); - if (message == custom_msg) { - // Get the invalid rect which is in screen coordinates and convert to - // window coordinates. - gfx::Rect invalid_rect; - invalid_rect.set_x(static_cast<short>(LOWORD(wparam))); - invalid_rect.set_y(static_cast<short>(HIWORD(wparam))); - invalid_rect.set_width(static_cast<short>(LOWORD(lparam))); - invalid_rect.set_height(static_cast<short>(HIWORD(lparam))); - - RECT window_rect; - GetWindowRect(hwnd, &window_rect); - invalid_rect.Offset(-window_rect.left, -window_rect.top); - - // The plugin window might have non-client area. If we don't pass in - // RDW_FRAME then the children don't receive WM_NCPAINT messages while - // scrolling, which causes painting problems (http://b/issue?id=923945). - uint32_t flags = RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_FRAME; - - // If a plugin (like Google Earth or Java) has child windows that are hosted - // in a different process, then RedrawWindow with UPDATENOW will - // synchronously wait for this call to complete. Some messages are pumped - // but not others, which could lead to a deadlock. So avoid reentrancy by - // only synchronously calling RedrawWindow once at a time. - if (old_message != custom_msg) - flags |= RDW_UPDATENOW; - RECT rect = invalid_rect.ToRECT(); - RedrawWindow(hwnd, &rect, NULL, flags); - result = FALSE; - } else { - delegate->is_calling_wndproc = true; - - if (!delegate->user_gesture_message_posted_ && - IsUserGestureMessage(message)) { - delegate->user_gesture_message_posted_ = true; - - delegate->instance()->PushPopupsEnabledState(true); - - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::Bind(&WebPluginDelegateImpl::OnUserGestureEnd, - delegate->user_gesture_msg_factory_.GetWeakPtr()), - base::TimeDelta::FromMilliseconds(kWindowedPluginPopupTimerMs)); - } - - HandleCaptureForMessage(hwnd, message); - - // Maintain a local/global stack for the g_current_plugin_instance variable - // as this may be a nested invocation. - WebPluginDelegateImpl* last_plugin_instance = g_current_plugin_instance; - - g_current_plugin_instance = delegate; - - result = CallWindowProc( - delegate->plugin_wnd_proc_, hwnd, message, wparam, lparam); - - // The plugin instance may have been destroyed in the CallWindowProc call - // above. This will also destroy the plugin window. Before attempting to - // access the WebPluginDelegateImpl instance we validate if the window is - // still valid. - if (::IsWindow(hwnd)) - delegate->is_calling_wndproc = false; - - g_current_plugin_instance = last_plugin_instance; - - if (message == WM_NCDESTROY) { - RemoveProp(hwnd, kWebPluginDelegateProperty); - ClearThrottleQueueForWindow(hwnd); - } - } - if (::IsWindow(hwnd)) - delegate->last_message_ = old_message; - return result; -} - void WebPluginDelegateImpl::WindowlessUpdateGeometry( const gfx::Rect& window_rect, const gfx::Rect& clip_rect) { @@ -1065,8 +716,6 @@ void WebPluginDelegateImpl::WindowlessSetWindow() { if (window_rect_.IsEmpty()) // wait for geometry to be set. return; - DCHECK(instance()->windowless()); - window_.clipRect.top = clip_rect_.y(); window_.clipRect.left = clip_rect_.x(); window_.clipRect.bottom = clip_rect_.y() + clip_rect_.height(); @@ -1083,8 +732,6 @@ void WebPluginDelegateImpl::WindowlessSetWindow() { } bool WebPluginDelegateImpl::PlatformSetPluginHasFocus(bool focused) { - DCHECK(instance()->windowless()); - NPEvent focus_event; focus_event.event = focused ? WM_SETFOCUS : WM_KILLFOCUS; focus_event.wParam = 0; @@ -1353,11 +1000,6 @@ bool WebPluginDelegateImpl::ShouldTrackEventForModalLoops(NPEvent* event) { return false; } -void WebPluginDelegateImpl::OnUserGestureEnd() { - user_gesture_message_posted_ = false; - instance()->PopPopupsEnabledState(); -} - BOOL WINAPI WebPluginDelegateImpl::TrackPopupMenuPatch( HMENU menu, unsigned int flags, int x, int y, int reserved, HWND window, const RECT* rect) { @@ -1464,33 +1106,4 @@ HWND WINAPI WebPluginDelegateImpl::WindowFromPointPatch(POINT point) { return window; } -void WebPluginDelegateImpl::HandleCaptureForMessage(HWND window, - UINT message) { - if (gfx::GetClassName(window) != base::string16(kNativeWindowClassName)) - return; - - switch (message) { - case WM_LBUTTONDOWN: - case WM_MBUTTONDOWN: - case WM_RBUTTONDOWN: - ::SetCapture(window); - // As per documentation the WM_PARENTNOTIFY message is sent to the parent - // window chain if mouse input is received by the child window. However - // the parent receives the WM_PARENTNOTIFY message only if we doubleclick - // on the window. We send the WM_PARENTNOTIFY message for mouse input - // messages to the parent to indicate that user action is expected. - ::SendMessage(::GetParent(window), WM_PARENTNOTIFY, message, 0); - break; - - case WM_LBUTTONUP: - case WM_MBUTTONUP: - case WM_RBUTTONUP: - ::ReleaseCapture(); - break; - - default: - break; - } -} - } // namespace content diff --git a/content/child/npapi/webplugin_ime_win.cc b/content/child/npapi/webplugin_ime_win.cc index 94d1a92..7523495 100644 --- a/content/child/npapi/webplugin_ime_win.cc +++ b/content/child/npapi/webplugin_ime_win.cc @@ -267,19 +267,6 @@ LONG WINAPI WebPluginIMEWin::ImmGetCompositionStringW(HIMC context, // static HIMC WINAPI WebPluginIMEWin::ImmGetContext(HWND window) { - // Call the original ImmGetContext() function if the given window is the one - // created in WebPluginDelegateImpl::WindowedCreatePlugin(). (We attached IME - // context only with the windows created in this function.) On the other hand, - // some windowless plugins (such as Flash) call this function with a dummy - // window handle. We return our dummy IME context for these plugins so they - // can use our IME emulator. - if (IsWindow(window)) { - wchar_t name[128]; - GetClassName(window, &name[0], arraysize(name)); - if (!wcscmp(&name[0], kNativeWindowClassName)) - return ::ImmGetContext(window); - } - WebPluginIMEWin* instance = instance_; if (instance) instance->support_ime_messages_ = true; diff --git a/content/child/plugin_messages.h b/content/child/plugin_messages.h index 501dfdb..f6ceca2 100644 --- a/content/child/plugin_messages.h +++ b/content/child/plugin_messages.h @@ -145,11 +145,6 @@ IPC_MESSAGE_ROUTED1(PluginMsg_ImeCompositionCompleted, // PluginHost messages // These are messages sent from the plugin process to the renderer process. // They all map to the corresponding WebPlugin methods. -// Sends the plugin window information to the renderer. -// The window parameter is a handle to the window if the plugin is a windowed -// plugin. It is NULL for windowless plugins. -IPC_SYNC_MESSAGE_ROUTED1_0(PluginHostMsg_SetWindow, - gfx::PluginWindowHandle /* window */) IPC_MESSAGE_ROUTED1(PluginHostMsg_InvalidateRect, gfx::Rect /* rect */) diff --git a/content/common/plugin_constants_win.cc b/content/common/plugin_constants_win.cc index 0268856..9330c81 100644 --- a/content/common/plugin_constants_win.cc +++ b/content/common/plugin_constants_win.cc @@ -6,11 +6,7 @@ namespace content { -const base::char16 kNativeWindowClassName[] = L"NativeWindowClass"; -const base::char16 kWrapperNativeWindowClassName[] = - L"WrapperNativeWindowClass"; const base::char16 kDummyActivationWindowName[] = L"DummyWindowForActivation"; -const base::char16 kPaintMessageName[] = L"Chrome_CustomPaintil"; const base::char16 kRegistryMozillaPlugins[] = L"SOFTWARE\\MozillaPlugins"; const base::char16 kMozillaActiveXPlugin[] = L"npmozax.dll"; const base::char16 kNewWMPPlugin[] = L"np-mswmp.dll"; diff --git a/content/common/plugin_constants_win.h b/content/common/plugin_constants_win.h index 2269592..815cbf4 100644 --- a/content/common/plugin_constants_win.h +++ b/content/common/plugin_constants_win.h @@ -14,20 +14,8 @@ namespace content { -// The window class name for a plugin window. -extern const base::char16 kNativeWindowClassName[]; - -// The name of the window class name for the wrapper HWND around the actual -// plugin window that's used when running in multi-process mode. This window -// is created on the browser UI thread. -extern const base::char16 kWrapperNativeWindowClassName[]; - extern const base::char16 kDummyActivationWindowName[]; -// The name of the custom window message that the browser uses to tell the -// plugin process to paint a window. -extern const base::char16 kPaintMessageName[]; - // The name of the registry key which NPAPI plugins update on installation. extern const base::char16 kRegistryMozillaPlugins[]; diff --git a/content/common/plugin_process_messages.h b/content/common/plugin_process_messages.h index a815b55..f07774b 100644 --- a/content/common/plugin_process_messages.h +++ b/content/common/plugin_process_messages.h @@ -56,13 +56,6 @@ IPC_MESSAGE_CONTROL1(PluginProcessHostMsg_ChannelDestroyed, IPC_MESSAGE_CONTROL1(PluginProcessHostMsg_ClearSiteDataResult, bool /* success */) -#if defined(OS_WIN) -// Destroys the given window's parent on the UI thread. -IPC_MESSAGE_CONTROL2(PluginProcessHostMsg_PluginWindowDestroyed, - HWND /* window */, - HWND /* parent */) -#endif - #if defined(OS_MACOSX) // On Mac OS X, we need the browser to keep track of plugin windows so // that it can add and remove them from stacking groups, hide and show the diff --git a/content/common/view_messages.h b/content/common/view_messages.h index d509db6..9346980 100644 --- a/content/common/view_messages.h +++ b/content/common/view_messages.h @@ -285,15 +285,6 @@ IPC_STRUCT_TRAITS_BEGIN(content::RendererPreferences) IPC_STRUCT_TRAITS_MEMBER(default_font_size) IPC_STRUCT_TRAITS_END() -IPC_STRUCT_TRAITS_BEGIN(content::WebPluginGeometry) - IPC_STRUCT_TRAITS_MEMBER(window) - IPC_STRUCT_TRAITS_MEMBER(window_rect) - IPC_STRUCT_TRAITS_MEMBER(clip_rect) - IPC_STRUCT_TRAITS_MEMBER(cutout_rects) - IPC_STRUCT_TRAITS_MEMBER(rects_valid) - IPC_STRUCT_TRAITS_MEMBER(visible) -IPC_STRUCT_TRAITS_END() - IPC_STRUCT_TRAITS_BEGIN(media::MediaLogEvent) IPC_STRUCT_TRAITS_MEMBER(id) IPC_STRUCT_TRAITS_MEMBER(type) @@ -469,10 +460,6 @@ IPC_STRUCT_BEGIN(ViewHostMsg_UpdateRect_Params) // view size. IPC_STRUCT_MEMBER(gfx::Size, view_size) - // New window locations for plugin child windows. - IPC_STRUCT_MEMBER(std::vector<content::WebPluginGeometry>, - plugin_window_moves) - // The following describes the various bits that may be set in flags: // // ViewHostMsg_UpdateRect_Flags::IS_RESIZE_ACK diff --git a/content/common/webplugin_geometry.cc b/content/common/webplugin_geometry.cc index 800f79d..03ec1e8 100644 --- a/content/common/webplugin_geometry.cc +++ b/content/common/webplugin_geometry.cc @@ -7,8 +7,7 @@ namespace content { WebPluginGeometry::WebPluginGeometry() - : window(gfx::kNullPluginWindow), - rects_valid(false), + : rects_valid(false), visible(false) { } @@ -18,8 +17,7 @@ WebPluginGeometry::~WebPluginGeometry() { } bool WebPluginGeometry::Equals(const WebPluginGeometry& rhs) const { - return window == rhs.window && - window_rect == rhs.window_rect && + return window_rect == rhs.window_rect && clip_rect == rhs.clip_rect && cutout_rects == rhs.cutout_rects && rects_valid == rhs.rects_valid && diff --git a/content/common/webplugin_geometry.h b/content/common/webplugin_geometry.h index 7ac99f0..3745590 100644 --- a/content/common/webplugin_geometry.h +++ b/content/common/webplugin_geometry.h @@ -20,19 +20,6 @@ struct WebPluginGeometry { bool Equals(const WebPluginGeometry& rhs) const; - // On Windows, this is the plugin window in the plugin process. - // On X11, this is the XID of the plugin-side GtkPlug containing the - // GtkSocket hosting the actual plugin window. - // - // On Mac OS X, all of the plugin types are currently "windowless" - // (window == 0) except for the special case of the GPU plugin, - // which currently performs rendering on behalf of the Pepper 3D API - // and WebGL. The GPU plugin uses a simple integer for the - // PluginWindowHandle which is used to map to a side data structure - // containing information about the plugin. Soon this plugin will be - // generalized, at which point this mechanism will be rethought or - // removed. - gfx::PluginWindowHandle window; gfx::Rect window_rect; // Clip rect (include) and cutouts (excludes), relative to // window_rect origin. diff --git a/content/plugin/webplugin_proxy.cc b/content/plugin/webplugin_proxy.cc index 15b9a2f..8744d22 100644 --- a/content/plugin/webplugin_proxy.cc +++ b/content/plugin/webplugin_proxy.cc @@ -76,24 +76,6 @@ bool WebPluginProxy::Send(IPC::Message* msg) { return channel_->Send(msg); } -void WebPluginProxy::SetWindow(gfx::PluginWindowHandle window) { - Send(new PluginHostMsg_SetWindow(route_id_, window)); -} - -void WebPluginProxy::SetAcceptsInputEvents(bool accepts) { - NOTREACHED(); -} - -void WebPluginProxy::WillDestroyWindow(gfx::PluginWindowHandle window) { -#if defined(OS_WIN) - PluginThread::current()->Send( - new PluginProcessHostMsg_PluginWindowDestroyed( - window, ::GetParent(window))); -#else - NOTIMPLEMENTED(); -#endif -} - #if defined(OS_WIN) void WebPluginProxy::SetWindowlessData( HANDLE pump_messages_event, gfx::NativeViewId dummy_activation_window) { @@ -341,8 +323,7 @@ void WebPluginProxy::UpdateGeometry( // Send over any pending invalidates which occured when the plugin was // off screen. - if (delegate_->IsWindowless() && !clip_rect.IsEmpty() && - !damaged_rect_.IsEmpty()) { + if (!clip_rect.IsEmpty() && !damaged_rect_.IsEmpty()) { InvalidateRect(damaged_rect_); } } diff --git a/content/plugin/webplugin_proxy.h b/content/plugin/webplugin_proxy.h index 78814a7..3703056 100644 --- a/content/plugin/webplugin_proxy.h +++ b/content/plugin/webplugin_proxy.h @@ -53,9 +53,6 @@ class WebPluginProxy : public WebPlugin, void set_delegate(WebPluginDelegateImpl* d) { delegate_ = d; } // WebPlugin overrides - void SetWindow(gfx::PluginWindowHandle window) override; - void SetAcceptsInputEvents(bool accepts) override; - void WillDestroyWindow(gfx::PluginWindowHandle window) override; void Invalidate() override; void InvalidateRect(const gfx::Rect& rect) override; NPObject* GetWindowScriptNPObject() override; diff --git a/content/public/browser/plugin_service.h b/content/public/browser/plugin_service.h index 3fa7623..bf19804 100644 --- a/content/public/browser/plugin_service.h +++ b/content/public/browser/plugin_service.h @@ -152,13 +152,6 @@ class PluginService { // Called when the application is made active so that modal plugin windows can // be made forward too. virtual void AppActivated() = 0; -#elif defined(OS_WIN) - // Returns the name and version of a plugin HWND. If the HWND isn't a valid - // plugin, returns false. - // This can be called from any thread. - virtual bool GetPluginInfoFromWindow(HWND window, - base::string16* plugin_name, - base::string16* plugin_version) = 0; #endif // Returns true iff PPAPI "dev channel" methods are supported. diff --git a/content/renderer/npapi/webplugin_delegate_proxy.cc b/content/renderer/npapi/webplugin_delegate_proxy.cc index 942dc71..2e80b85 100644 --- a/content/renderer/npapi/webplugin_delegate_proxy.cc +++ b/content/renderer/npapi/webplugin_delegate_proxy.cc @@ -105,13 +105,12 @@ WebPluginDelegateProxy::WebPluginDelegateProxy( : render_view_(render_view), render_frame_(render_frame), plugin_(plugin), - uses_shared_bitmaps_(false), + uses_shared_bitmaps_(true), #if defined(OS_MACOSX) uses_compositor_(false), #elif defined(OS_WIN) dummy_activation_window_(NULL), #endif - window_(gfx::kNullPluginWindow), mime_type_(mime_type), instance_id_(MSG_ROUTING_NONE), npobject_(NULL), @@ -147,9 +146,6 @@ void WebPluginDelegateProxy::PluginDestroyed() { dummy_activation_window_ = NULL; #endif - if (window_) - WillDestroyWindow(); - if (render_view_.get()) render_view_->UnregisterPluginDelegate(this); @@ -298,7 +294,6 @@ bool WebPluginDelegateProxy::OnMessageReceived(const IPC::Message& msg) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(WebPluginDelegateProxy, msg) - IPC_MESSAGE_HANDLER(PluginHostMsg_SetWindow, OnSetWindow) IPC_MESSAGE_HANDLER(PluginHostMsg_InvalidateRect, OnInvalidateRect) IPC_MESSAGE_HANDLER(PluginHostMsg_GetWindowScriptNPObject, OnGetWindowScriptNPObject) @@ -333,11 +328,6 @@ bool WebPluginDelegateProxy::OnMessageReceived(const IPC::Message& msg) { void WebPluginDelegateProxy::OnChannelError() { if (plugin_) { - if (window_) { - // The actual WebPluginDelegate never got a chance to tell the WebPlugin - // its window was going away. Do it on its behalf. - WillDestroyWindow(); - } plugin_->Invalidate(); } if (channel_host_.get() && !channel_host_->expecting_shutdown()) { @@ -716,23 +706,6 @@ void WebPluginDelegateProxy::ImeCompositionCompleted(const base::string16& text, } #endif // OS_MACOSX -void WebPluginDelegateProxy::OnSetWindow(gfx::PluginWindowHandle window) { -#if defined(OS_MACOSX) - uses_shared_bitmaps_ = !window && !uses_compositor_; -#else - uses_shared_bitmaps_ = !window; -#endif - window_ = window; - if (plugin_) - plugin_->SetWindow(window); -} - -void WebPluginDelegateProxy::WillDestroyWindow() { - DCHECK(window_); - plugin_->WillDestroyWindow(window_); - window_ = gfx::kNullPluginWindow; -} - #if defined(OS_WIN) void WebPluginDelegateProxy::OnSetWindowlessData( HANDLE modal_loop_pump_messages_event_handle, @@ -916,10 +889,6 @@ void WebPluginDelegateProxy::OnStartIme() { } #endif -gfx::PluginWindowHandle WebPluginDelegateProxy::GetPluginWindowHandle() { - return window_; -} - void WebPluginDelegateProxy::OnCancelDocumentLoad() { plugin_->CancelDocumentLoad(); } @@ -935,7 +904,7 @@ void WebPluginDelegateProxy::OnDidStopLoading() { #if defined(OS_MACOSX) void WebPluginDelegateProxy::OnAcceleratedPluginEnabledRendering() { uses_compositor_ = true; - OnSetWindow(gfx::kNullPluginWindow); + uses_shared_bitmaps_ = false; } void WebPluginDelegateProxy::OnAcceleratedPluginAllocatedIOSurface( diff --git a/content/renderer/npapi/webplugin_delegate_proxy.h b/content/renderer/npapi/webplugin_delegate_proxy.h index c32aa1c..9e3643e 100644 --- a/content/renderer/npapi/webplugin_delegate_proxy.h +++ b/content/renderer/npapi/webplugin_delegate_proxy.h @@ -113,8 +113,6 @@ class WebPluginDelegateProxy // IPC::Sender implementation: bool Send(IPC::Message* msg) override; - gfx::PluginWindowHandle GetPluginWindowHandle(); - protected: friend class base::DeleteHelper<WebPluginDelegateProxy>; ~WebPluginDelegateProxy() override; @@ -130,7 +128,6 @@ class WebPluginDelegateProxy // Message handlers for messages that proxy WebPlugin methods, which // we translate into calls to the real WebPlugin. - void OnSetWindow(gfx::PluginWindowHandle window); void OnCompleteURL(const std::string& url_in, std::string* url_out, bool* result); void OnHandleURLRequest(const PluginHostMsg_URLRequest_Params& params); @@ -233,7 +230,6 @@ class WebPluginDelegateProxy // Used for windowless plugins so that keyboard activation works. gfx::NativeViewId dummy_activation_window_; #endif - gfx::PluginWindowHandle window_; scoped_refptr<PluginChannelHost> channel_host_; std::string mime_type_; int instance_id_; diff --git a/content/renderer/npapi/webplugin_impl.cc b/content/renderer/npapi/webplugin_impl.cc index f9d6a23..12ce896 100644 --- a/content/renderer/npapi/webplugin_impl.cc +++ b/content/renderer/npapi/webplugin_impl.cc @@ -190,7 +190,6 @@ void WebPluginImpl::updateGeometry(const WebRect& window_rect, const WebVector<WebRect>& cut_outs_rects, bool is_visible) { WebPluginGeometry new_geometry; - new_geometry.window = window_; new_geometry.window_rect = window_rect; new_geometry.clip_rect = clip_rect; new_geometry.visible = is_visible; @@ -198,18 +197,6 @@ void WebPluginImpl::updateGeometry(const WebRect& window_rect, for (size_t i = 0; i < cut_outs_rects.size(); ++i) new_geometry.cutout_rects.push_back(cut_outs_rects[i]); - // Only send DidMovePlugin if the geometry changed in some way. - if (window_ && (first_geometry_update_ || !new_geometry.Equals(geometry_))) { - render_frame_->GetRenderWidget()->SchedulePluginMove(new_geometry); - // We invalidate windowed plugins during the first geometry update to - // ensure that they get reparented to the wrapper window in the browser. - // This ensures that they become visible and are painted by the OS. This is - // required as some pages don't invalidate when the plugin is added. - if (first_geometry_update_ && window_) { - InvalidateRect(window_rect); - } - } - // Only UpdateGeometry if either the window or clip rects have changed. if (delegate_ && (first_geometry_update_ || new_geometry.window_rect != geometry_.window_rect || @@ -236,26 +223,14 @@ void WebPluginImpl::updateGeometry(const WebRect& window_rect, } void WebPluginImpl::updateFocus(bool focused, blink::WebFocusType focus_type) { - if (accepts_input_events_) - delegate_->SetFocus(focused); + delegate_->SetFocus(focused); } void WebPluginImpl::updateVisibility(bool visible) { - if (!window_) - return; - - WebPluginGeometry move; - move.window = window_; - move.window_rect = gfx::Rect(); - move.clip_rect = gfx::Rect(); - move.rects_valid = false; - move.visible = visible; - - render_frame_->GetRenderWidget()->SchedulePluginMove(move); } bool WebPluginImpl::acceptsInputEvents() { - return accepts_input_events_; + return true; } WebInputEventResult WebPluginImpl::handleInputEvent( @@ -290,10 +265,7 @@ WebPluginImpl::WebPluginImpl( const base::FilePath& file_path, const base::WeakPtr<RenderViewImpl>& render_view, RenderFrameImpl* render_frame) - : windowless_(false), - window_(gfx::kNullPluginWindow), - accepts_input_events_(false), - render_frame_(render_frame), + : render_frame_(render_frame), render_view_(render_view), webframe_(webframe), delegate_(NULL), @@ -320,41 +292,6 @@ WebPluginImpl::WebPluginImpl( WebPluginImpl::~WebPluginImpl() { } -void WebPluginImpl::SetWindow(gfx::PluginWindowHandle window) { - if (window) { - DCHECK(!windowless_); - window_ = window; -#if defined(OS_MACOSX) - // TODO(kbr): remove. http://crbug.com/105344 - - // Lie to ourselves about being windowless even if we got a fake - // plugin window handle, so we continue to get input events. - windowless_ = true; - accepts_input_events_ = true; - // We do not really need to notify the page delegate that a plugin - // window was created -- so don't. -#else - accepts_input_events_ = false; - -#endif // OS_MACOSX - } else { - DCHECK(!window_); // Make sure not called twice. - windowless_ = true; - accepts_input_events_ = true; - } -} - -void WebPluginImpl::SetAcceptsInputEvents(bool accepts) { - accepts_input_events_ = accepts; -} - -void WebPluginImpl::WillDestroyWindow(gfx::PluginWindowHandle window) { - DCHECK_EQ(window, window_); - window_ = gfx::kNullPluginWindow; - if (render_view_.get()) - render_frame_->GetRenderWidget()->CleanupWindowInPluginMoves(window); -} - GURL WebPluginImpl::CompleteURL(const char* url) { if (!webframe_) { NOTREACHED(); diff --git a/content/renderer/npapi/webplugin_impl.h b/content/renderer/npapi/webplugin_impl.h index 45ec06f..3e695e6 100644 --- a/content/renderer/npapi/webplugin_impl.h +++ b/content/renderer/npapi/webplugin_impl.h @@ -96,9 +96,6 @@ class WebPluginImpl : public WebPlugin, bool isPlaceholder() override; // WebPlugin implementation: - void SetWindow(gfx::PluginWindowHandle window) override; - void SetAcceptsInputEvents(bool accepts) override; - void WillDestroyWindow(gfx::PluginWindowHandle window) override; void Invalidate() override; void InvalidateRect(const gfx::Rect& rect) override; NPObject* GetWindowScriptNPObject() override; @@ -185,8 +182,6 @@ class WebPluginImpl : public WebPlugin, // Check for invalid chars like @, ;, \ before the first / (in path). bool IsValidUrl(const GURL& url, ReferrerValue referrer_flag); - bool windowless_; - gfx::PluginWindowHandle window_; #if defined(OS_MACOSX) bool next_io_surface_allocated_; int32_t next_io_surface_width_; @@ -195,7 +190,6 @@ class WebPluginImpl : public WebPlugin, scoped_refptr<cc::IOSurfaceLayer> io_surface_layer_; scoped_ptr<blink::WebLayer> web_layer_; #endif - bool accepts_input_events_; RenderFrameImpl* render_frame_; base::WeakPtr<RenderViewImpl> render_view_; blink::WebFrame* webframe_; diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc index 944d109..a4b9d63 100644 --- a/content/renderer/render_widget.cc +++ b/content/renderer/render_widget.cc @@ -824,14 +824,12 @@ void RenderWidget::DidCompleteSwapBuffers() { // Notify subclasses threaded composited rendering was flushed to the screen. DidFlushPaint(); - if (!next_paint_flags_ && !need_update_rect_for_auto_resize_ && - !plugin_window_moves_.size()) { + if (!next_paint_flags_ && !need_update_rect_for_auto_resize_) { return; } ViewHostMsg_UpdateRect_Params params; params.view_size = size_; - params.plugin_window_moves.swap(plugin_window_moves_); params.flags = next_paint_flags_; Send(new ViewHostMsg_UpdateRect(routing_id_, params)); @@ -2003,34 +2001,6 @@ void RenderWidget::StartCompositor() { compositor_->setVisible(true); } -void RenderWidget::SchedulePluginMove(const WebPluginGeometry& move) { - size_t i = 0; - for (; i < plugin_window_moves_.size(); ++i) { - if (plugin_window_moves_[i].window == move.window) { - if (move.rects_valid) { - plugin_window_moves_[i] = move; - } else { - plugin_window_moves_[i].visible = move.visible; - } - break; - } - } - - if (i == plugin_window_moves_.size()) - plugin_window_moves_.push_back(move); -} - -void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) { - for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin(); - i != plugin_window_moves_.end(); ++i) { - if (i->window == window) { - plugin_window_moves_.erase(i); - break; - } - } -} - - RenderWidgetCompositor* RenderWidget::compositor() const { return compositor_.get(); } diff --git a/content/renderer/render_widget.h b/content/renderer/render_widget.h index 732a196..3e0668a 100644 --- a/content/renderer/render_widget.h +++ b/content/renderer/render_widget.h @@ -92,7 +92,6 @@ class ResizingModeSelector; struct ContextMenuParams; struct DidOverscrollParams; struct ResizeParams; -struct WebPluginGeometry; // RenderWidget provides a communication bridge between a WebWidget and // a RenderWidgetHost, the latter of which lives in a different process. @@ -285,14 +284,6 @@ class CONTENT_EXPORT RenderWidget // Stop compositing. void WillCloseLayerTreeView(); - // Called when a plugin is moved. These events are queued up and sent with - // the next paint or scroll message to the host. - void SchedulePluginMove(const WebPluginGeometry& move); - - // Called when a plugin window has been destroyed, to make sure the currently - // pending moves don't try to reference it. - void CleanupWindowInPluginMoves(gfx::PluginWindowHandle window); - RenderWidgetCompositor* compositor() const; const RenderWidgetInputHandler& input_handler() const { @@ -703,10 +694,6 @@ class CONTENT_EXPORT RenderWidget // The kind of popup this widget represents, NONE if not a popup. blink::WebPopupType popup_type_; - // Holds all the needed plugin window moves for a scroll. - typedef std::vector<WebPluginGeometry> WebPluginGeometryVector; - WebPluginGeometryVector plugin_window_moves_; - // While we are waiting for the browser to update window sizes, we track the // pending size temporarily. int pending_window_rect_count_; diff --git a/content/shell/tools/plugin/main.cpp b/content/shell/tools/plugin/main.cpp index 2a6cba7..ea969d4 100644 --- a/content/shell/tools/plugin/main.cpp +++ b/content/shell/tools/plugin/main.cpp @@ -268,8 +268,6 @@ NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc obj->alwaysFilterEvents = true; } } - void* windowed = 0; - browser->setvalue(instance, NPPVpluginWindowBool, windowed); #ifdef XP_MACOSX browser->setvalue(instance, NPPVpluginDrawingModel, (void *)NPDrawingModelCoreGraphics); diff --git a/content/test/fake_plugin_service.cc b/content/test/fake_plugin_service.cc index f34345d..e279c1a 100644 --- a/content/test/fake_plugin_service.cc +++ b/content/test/fake_plugin_service.cc @@ -108,13 +108,6 @@ void FakePluginService::DisablePluginsDiscoveryForTesting() { #if defined(OS_MACOSX) void FakePluginService::AppActivated() { } -#elif defined(OS_WIN) -bool FakePluginService::GetPluginInfoFromWindow( - HWND window, - base::string16* plugin_name, - base::string16* plugin_version) { - return false; -} #endif bool FakePluginService::PpapiDevChannelSupported( diff --git a/content/test/fake_plugin_service.h b/content/test/fake_plugin_service.h index 41460ff..7ccab2c 100644 --- a/content/test/fake_plugin_service.h +++ b/content/test/fake_plugin_service.h @@ -56,10 +56,6 @@ class FakePluginService : public PluginService { void DisablePluginsDiscoveryForTesting() override; #if defined(OS_MACOSX) void AppActivated() override; -#elif defined(OS_WIN) - bool GetPluginInfoFromWindow(HWND window, - base::string16* plugin_name, - base::string16* plugin_version) override; #endif bool PpapiDevChannelSupported(BrowserContext* browser_context, const GURL& document_url) override; diff --git a/content/test/test_render_view_host.h b/content/test/test_render_view_host.h index 80e1e58..5dbcd3e 100644 --- a/content/test/test_render_view_host.h +++ b/content/test/test_render_view_host.h @@ -98,8 +98,6 @@ class TestRenderWidgetHostView : public RenderWidgetHostViewBase { void InitAsPopup(RenderWidgetHostView* parent_host_view, const gfx::Rect& bounds) override {} void InitAsFullscreen(RenderWidgetHostView* reference_host_view) override {} - void MovePluginWindows(const std::vector<WebPluginGeometry>& moves) override { - } void Focus() override {} void SetIsLoading(bool is_loading) override {} void UpdateCursor(const WebCursor& cursor) override {} |