Commit 6ffc06bf authored by Elly Fong-Jones's avatar Elly Fong-Jones Committed by Commit Bot

cocoa: remove cocoa extension popup support

Bug: 832676
Change-Id: I6b4358838170781d13f54c76b4d34715471757e6
Reviewed-on: https://chromium-review.googlesource.com/1185202Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586656}
parent 5553ca2e
......@@ -117,13 +117,6 @@ class ExtensionViewHost
static std::unique_ptr<ExtensionView> CreateExtensionView(
ExtensionViewHost* host,
Browser* browser);
#if defined(OS_MACOSX)
// Temporary shim for Polychrome. See bottom of first comment in
// https://crbug.com/80495 for details.
static std::unique_ptr<ExtensionView> CreateExtensionViewCocoa(
ExtensionViewHost* host,
Browser* browser);
#endif
// Optional view that shows the rendered content in the UI.
std::unique_ptr<ExtensionView> view_;
......
......@@ -231,13 +231,9 @@ jumbo_split_static_library("ui") {
"cocoa/extensions/extension_action_platform_delegate_cocoa.mm",
"cocoa/extensions/extension_keybinding_registry_cocoa.h",
"cocoa/extensions/extension_keybinding_registry_cocoa.mm",
"cocoa/extensions/extension_popup_controller.h",
"cocoa/extensions/extension_popup_controller.mm",
"cocoa/extensions/extension_popup_views_mac.h",
"cocoa/extensions/extension_popup_views_mac.mm",
"cocoa/extensions/extension_uninstall_dialog_cocoa.mm",
"cocoa/extensions/extension_view_mac.h",
"cocoa/extensions/extension_view_mac.mm",
"cocoa/extensions/media_galleries_dialog_cocoa.h",
"cocoa/extensions/media_galleries_dialog_cocoa.mm",
"cocoa/extensions/media_gallery_list_entry_view.h",
......
......@@ -15,7 +15,6 @@
#include "chrome/browser/ui/cocoa/browser_window_utils.h"
#import "chrome/browser/ui/cocoa/chrome_event_processing_window.h"
#include "chrome/browser/ui/cocoa/extensions/extension_keybinding_registry_cocoa.h"
#include "chrome/browser/ui/cocoa/extensions/extension_view_mac.h"
#include "chrome/common/chrome_switches.h"
#include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/browser/web_contents.h"
......
......@@ -20,7 +20,6 @@
#import "chrome/browser/ui/cocoa/extensions/browser_action_button.h"
#import "chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h"
#import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h"
#import "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h"
#include "chrome/browser/ui/cocoa/extensions/extension_popup_views_mac.h"
#import "chrome/browser/ui/cocoa/info_bubble_window.h"
#import "chrome/browser/ui/cocoa/test/cocoa_test_helper.h"
......@@ -117,37 +116,6 @@ class ExtensionPopupTestManager {
DISALLOW_COPY_AND_ASSIGN(ExtensionPopupTestManager);
};
class ExtensionPopupTestManagerCocoa : public ExtensionPopupTestManager {
public:
ExtensionPopupTestManagerCocoa() = default;
~ExtensionPopupTestManagerCocoa() override = default;
void DisableAnimations() override {
[ExtensionPopupController setAnimationsEnabledForTesting:NO];
}
gfx::Size GetPopupSize(BrowserActionTestUtil* test_util) override {
NSRect bounds = [[[ExtensionPopupController popup] view] bounds];
return gfx::Size(NSSizeToCGSize(bounds.size));
}
void HidePopup(BrowserActionTestUtil* test_util) override {
ExtensionPopupController* controller = [ExtensionPopupController popup];
[controller close];
}
gfx::Size GetMinPopupSize() override {
return gfx::Size(NSSizeToCGSize([ExtensionPopupController minPopupSize]));
}
gfx::Size GetMaxPopupSize() override {
return gfx::Size(NSSizeToCGSize([ExtensionPopupController maxPopupSize]));
}
private:
DISALLOW_COPY_AND_ASSIGN(ExtensionPopupTestManagerCocoa);
};
class ExtensionPopupTestManagerViews : public ExtensionPopupTestManager {
public:
ExtensionPopupTestManagerViews() = default;
......@@ -181,9 +149,6 @@ class ExtensionPopupTestManagerViews : public ExtensionPopupTestManager {
};
std::unique_ptr<ExtensionPopupTestManager> GetExtensionPopupTestManager() {
if (!chrome::ShowAllDialogsWithViewsToolkit()) {
return std::make_unique<ExtensionPopupTestManagerCocoa>();
}
return std::make_unique<ExtensionPopupTestManagerViews>();
}
......
......@@ -12,8 +12,6 @@
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
@class ExtensionPopupController;
// The Cocoa-specific implementation for ExtensionActionPlatformDelegate.
class ExtensionActionPlatformDelegateCocoa
: public ExtensionActionPlatformDelegate,
......
......@@ -18,7 +18,6 @@
#import "chrome/browser/ui/cocoa/browser_window_controller.h"
#import "chrome/browser/ui/cocoa/extensions/browser_action_button.h"
#import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h"
#import "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h"
#import "chrome/browser/ui/cocoa/extensions/extension_popup_views_mac.h"
#import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
#import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
......@@ -87,15 +86,6 @@ void ExtensionActionPlatformDelegateCocoa::ShowPopup(
std::unique_ptr<extensions::ExtensionViewHost> host,
bool grant_tab_permissions,
ExtensionActionViewController::PopupShowAction show_action) {
if (!chrome::ShowAllDialogsWithViewsToolkit()) {
BOOL devMode =
show_action == ExtensionActionViewController::SHOW_POPUP_AND_INSPECT;
[ExtensionPopupController host:std::move(host)
inBrowser:controller_->browser()
anchoredAt:GetPopupPoint()
devMode:devMode];
return;
}
ExtensionPopup::ShowAction popupShowAction =
show_action == ExtensionActionViewController::SHOW_POPUP
......
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_POPUP_CONTROLLER_H_
#define CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_POPUP_CONTROLLER_H_
#import <Cocoa/Cocoa.h>
#include <memory>
#include <string>
#import "chrome/browser/ui/cocoa/base_bubble_controller.h"
#import "chrome/browser/ui/cocoa/info_bubble_view.h"
#include "content/public/browser/notification_registrar.h"
class Browser;
class ExtensionPopupNotificationBridge;
class ExtensionPopupContainer;
namespace extensions {
class ExtensionViewHost;
}
// This controller manages a single browser action popup that can appear once a
// user has clicked on a browser action button. It instantiates the extension
// popup view showing the content and resizes the window to accomodate any size
// changes as they occur.
//
// There can only be one browser action popup open at a time, so a static
// variable holds a reference to the current popup.
@interface ExtensionPopupController : BaseBubbleController {
@private
// The native extension view retrieved from the extension host. Weak.
NSView* extensionView_;
// The current frame of the extension view. Cached to prevent setting the
// frame if the size hasn't changed.
NSRect extensionFrame_;
// The extension host object.
std::unique_ptr<extensions::ExtensionViewHost> host_;
content::NotificationRegistrar registrar_;
std::unique_ptr<ExtensionPopupNotificationBridge> notificationBridge_;
std::unique_ptr<ExtensionPopupContainer> container_;
std::string extensionId_;
// Whether the popup has a devtools window attached to it.
BOOL beingInspected_;
// There's an extra windowDidResignKey: notification right after a
// ConstrainedWindow closes that should be ignored.
BOOL ignoreWindowDidResignKey_;
// The size once the ExtensionView has loaded.
NSSize pendingSize_;
}
// Starts the process of showing the given popup URL. Instantiates an
// ExtensionPopupController with the parent window retrieved from |browser|, a
// host for the popup created by the extension process manager specific to the
// browser profile and the remaining arguments |anchoredAt| and with an
// appropriate arrow. |anchoredAt| is expected to be in the window's coordinates
// along the bottom edge of the browser action button.
// The actual display of the popup is delayed until the page contents finish
// loading in order to minimize UI flashing and resizing.
// Passing YES to |devMode| will launch the webkit inspector for the popup,
// and prevent the popup from closing when focus is lost. It will be closed
// after the inspector is closed, or another popup is opened.
+ (ExtensionPopupController*)
host:(std::unique_ptr<extensions::ExtensionViewHost>)host
inBrowser:(Browser*)browser
anchoredAt:(NSPoint)anchoredAt
devMode:(BOOL)devMode;
// Returns the controller used to display the popup being shown. If no popup is
// currently open, then nil is returned. Static because only one extension popup
// window can be open at a time.
+ (ExtensionPopupController*)popup;
// Whether the popup is in the process of closing (via Core Animation).
- (BOOL)isClosing;
// Show the dev tools attached to the popup.
- (void)showDevTools;
// Set whether the popup is being inspected or not. If it is being inspected
// it will not be hidden when it loses focus.
- (void)setBeingInspected:(BOOL)beingInspected;
@property(readonly, nonatomic) std::string extensionId;
@end
@interface ExtensionPopupController(TestingAPI)
// Sets whether or not animations are enabled.
+ (void)setAnimationsEnabledForTesting:(BOOL)enabled;
// Returns a weak pointer to the current popup's view.
- (NSView*)view;
// Returns the minimum allowed size for an extension popup.
+ (NSSize)minPopupSize;
// Returns the maximum allowed size for an extension popup.
+ (NSSize)maxPopupSize;
@end
#endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_POPUP_CONTROLLER_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_VIEW_MAC_H_
#define CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_VIEW_MAC_H_
#include <ApplicationServices/ApplicationServices.h>
#include "base/macros.h"
#include "chrome/browser/extensions/extension_view.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/native_widget_types.h"
class Browser;
namespace content {
class RenderViewHost;
}
namespace extensions {
class ExtensionHost;
}
// This class represents extension views. An extension view internally contains
// a bridge to an extension process, which draws to the extension view's
// native view object through IPC.
class ExtensionViewMac : public extensions::ExtensionView {
public:
class Container {
public:
virtual ~Container() {}
virtual void OnExtensionSizeChanged(ExtensionViewMac* view,
const gfx::Size& new_size) {}
virtual void OnExtensionViewDidShow(ExtensionViewMac* view) {};
};
// The minimum/maximum dimensions of the popup.
// The minimum is just a little larger than the size of the button itself.
// The maximum is an arbitrary number that should be smaller than most
// screens.
static const CGFloat kMinWidth;
static const CGFloat kMinHeight;
static const CGFloat kMaxWidth;
static const CGFloat kMaxHeight;
ExtensionViewMac(extensions::ExtensionHost* extension_host, Browser* browser);
~ExtensionViewMac() override;
// Sets the container for this view.
void set_container(Container* container) { container_ = container; }
// Create the host view, adding it as a subview of |superview|.
void CreateWidgetHostViewIn(gfx::NativeView superview);
// extensions::ExtensionView:
Browser* GetBrowser() override;
gfx::NativeView GetNativeView() override;
void ResizeDueToAutoResize(content::WebContents* web_contents,
const gfx::Size& new_size) override;
void RenderViewCreated(content::RenderViewHost* render_view_host) override;
void HandleKeyboardEvent(
content::WebContents* source,
const content::NativeWebKeyboardEvent& event) override;
void OnLoaded() override;
private:
content::RenderViewHost* render_view_host() const;
// We wait to show the ExtensionView until several things have loaded.
void ShowIfCompletelyLoaded();
Browser* browser_; // weak
extensions::ExtensionHost* extension_host_; // weak
// What we should set the preferred width to once the ExtensionView has
// loaded.
gfx::Size pending_preferred_size_;
Container* container_;
DISALLOW_COPY_AND_ASSIGN(ExtensionViewMac);
};
#endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_VIEW_MAC_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/cocoa/extensions/extension_view_mac.h"
#import <Cocoa/Cocoa.h>
#include <memory>
#include "base/mac/foundation_util.h"
#include "chrome/browser/extensions/extension_view_host.h"
#import "chrome/browser/ui/cocoa/chrome_event_processing_window.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/extension_host.h"
#include "extensions/common/view_type.h"
#include "ui/base/ui_features.h"
// The minimum/maximum dimensions of the popup.
const CGFloat ExtensionViewMac::kMinWidth = 25.0;
const CGFloat ExtensionViewMac::kMinHeight = 25.0;
const CGFloat ExtensionViewMac::kMaxWidth = 800.0;
const CGFloat ExtensionViewMac::kMaxHeight = 600.0;
ExtensionViewMac::ExtensionViewMac(extensions::ExtensionHost* extension_host,
Browser* browser)
: browser_(browser),
extension_host_(extension_host),
container_(NULL) {
DCHECK(extension_host_);
[GetNativeView() setHidden:YES];
}
ExtensionViewMac::~ExtensionViewMac() {
}
void ExtensionViewMac::CreateWidgetHostViewIn(gfx::NativeView superview) {
[superview addSubview:GetNativeView()];
extension_host_->CreateRenderViewSoon();
}
Browser* ExtensionViewMac::GetBrowser() {
return browser_;
}
gfx::NativeView ExtensionViewMac::GetNativeView() {
return extension_host_->host_contents()->GetNativeView();
}
void ExtensionViewMac::ResizeDueToAutoResize(content::WebContents* web_contents,
const gfx::Size& new_size) {
if (container_)
container_->OnExtensionSizeChanged(this, new_size);
}
void ExtensionViewMac::RenderViewCreated(content::RenderViewHost* host) {
extensions::ViewType host_type = extension_host_->extension_host_type();
if (host_type == extensions::VIEW_TYPE_EXTENSION_POPUP) {
gfx::Size min_size(ExtensionViewMac::kMinWidth,
ExtensionViewMac::kMinHeight);
gfx::Size max_size(ExtensionViewMac::kMaxWidth,
ExtensionViewMac::kMaxHeight);
extension_host_->host_contents()
->GetRenderWidgetHostView()
->EnableAutoResize(min_size, max_size);
}
}
void ExtensionViewMac::HandleKeyboardEvent(
content::WebContents* source,
const content::NativeWebKeyboardEvent& event) {
if (event.skip_in_browser ||
event.GetType() == content::NativeWebKeyboardEvent::kChar ||
extension_host_->extension_host_type() !=
extensions::VIEW_TYPE_EXTENSION_POPUP)
return;
ChromeEventProcessingWindow* event_window =
base::mac::ObjCCastStrict<ChromeEventProcessingWindow>(
[GetNativeView() window]);
[[event_window commandDispatcher] redispatchKeyEvent:event.os_event];
}
void ExtensionViewMac::OnLoaded() {
ShowIfCompletelyLoaded();
}
content::RenderViewHost* ExtensionViewMac::render_view_host() const {
return extension_host_->render_view_host();
}
void ExtensionViewMac::ShowIfCompletelyLoaded() {
// We wait to show the ExtensionView until it has loaded, and the view has
// actually been created. These can happen in different orders.
if (extension_host_->has_loaded_once()) {
[GetNativeView() setHidden:NO];
if (container_)
container_->OnExtensionViewDidShow(this);
}
}
namespace extensions {
// static
std::unique_ptr<ExtensionView> ExtensionViewHost::CreateExtensionViewCocoa(
ExtensionViewHost* host,
Browser* browser) {
return std::make_unique<ExtensionViewMac>(host, browser);
}
} // namespace extensions
......@@ -139,11 +139,6 @@ namespace extensions {
std::unique_ptr<ExtensionView> ExtensionViewHost::CreateExtensionView(
ExtensionViewHost* host,
Browser* browser) {
#if defined(OS_MACOSX)
if (!chrome::ShowAllDialogsWithViewsToolkit()) {
return CreateExtensionViewCocoa(host, browser);
}
#endif
std::unique_ptr<ExtensionViewViews> view(
new ExtensionViewViews(host, browser));
// We own |view_|, so don't auto delete when it's removed from the view
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment