Commit d87b7836 authored by Daniel Xie's avatar Daniel Xie

Revert "MacViews: Unify web contents modal dialog types"

speculatively reverting this to solve browser CPM

BUG=463776

This reverts commit 5f1263bb.

Merge branch 'master' of https://chromium.googlesource.com/a/chromium/src

Revert "Handle unsucessful JsonPrefStore initialization in SupervisedUserSettingsService."

this may be casuing an increase in rendererexit code.

BUG=463646

This reverts commit 0197d5df.

Merge branch 'master' of https://chromium.googlesource.com/a/chromium/src

This is causing a huge amounts of renderer crashes because of RESULT_CODE_KILLED_BAD_MESSAGE.  Reverting this from master.

Revert "<webview>: Removed ResolveURL"

This reverts commit c2fc6144.

Cr-Commit-Position: refs/heads/master@{#319017}
parent 0ee1586a
......@@ -197,10 +197,6 @@ void ShowCertificateViewer(content::WebContents* web_contents,
// NOOP
}
- (NSWindow*)sheetWindow {
return panel_;
}
- (void)onConstrainedWindowClosed {
panel_.reset();
constrainedWindow_.reset();
......
......@@ -72,7 +72,9 @@ class ConstrainedWebDialogDelegateViewMac :
void ReleaseWebContentsOnDialogClose() override {
return impl_->ReleaseWebContentsOnDialogClose();
}
NativeWebContentsModalDialog GetNativeDialog() override { return window_; }
NativeWebContentsModalDialog GetNativeDialog() override {
return constrained_window_->GetNativeDialog();
}
WebContents* GetWebContents() override { return impl_->GetWebContents(); }
gfx::Size GetMinimumSize() const override {
NOTIMPLEMENTED();
......
......@@ -73,8 +73,4 @@
[customWindow_ setFrameOrigin:origin];
}
- (NSWindow*)sheetWindow {
return customWindow_;
}
@end
......@@ -7,11 +7,13 @@
#import <Cocoa/Cocoa.h>
#include "base/mac/scoped_nsobject.h"
#include "components/web_modal/native_web_contents_modal_dialog.h"
namespace content {
class WebContents;
}
class ConstrainedWindowMac;
class SingleWebContentsDialogManagerCocoa;
@protocol ConstrainedWindowSheet;
// A delegate for a constrained window. The delegate is notified when the
......@@ -26,25 +28,29 @@ class ConstrainedWindowMacDelegate {
// should delete the instance when the window is closed.
class ConstrainedWindowMac {
public:
ConstrainedWindowMac(ConstrainedWindowMacDelegate* delegate,
content::WebContents* web_contents,
id<ConstrainedWindowSheet> sheet);
~ConstrainedWindowMac();
// Closes the constrained window.
ConstrainedWindowMac(
ConstrainedWindowMacDelegate* delegate,
content::WebContents* web_contents,
id<ConstrainedWindowSheet> sheet);
virtual ~ConstrainedWindowMac();
void ShowWebContentsModalDialog();
// Closes the constrained window and deletes this instance.
void CloseWebContentsModalDialog();
SingleWebContentsDialogManagerCocoa* manager() const { return manager_; }
void set_manager(SingleWebContentsDialogManagerCocoa* manager) {
manager_ = manager;
}
// Called by |manager_| when the dialog is closing.
void OnDialogClosing();
void FocusWebContentsModalDialog();
void PulseWebContentsModalDialog();
web_modal::NativeWebContentsModalDialog GetNativeDialog();
private:
ConstrainedWindowMacDelegate* delegate_; // weak, owns us.
SingleWebContentsDialogManagerCocoa* manager_; // weak, owned by WCMDM.
// The WebContents that owns and constrains this ConstrainedWindowMac. Weak.
content::WebContents* web_contents_;
base::scoped_nsprotocol<id<ConstrainedWindowSheet>> sheet_;
// This is true if the constrained window has been shown.
bool shown_;
};
#endif // CHROME_BROWSER_UI_COCOA_CONSTRAINED_WINDOW_CONSTRAINED_WINDOW_MAC_
......@@ -4,46 +4,89 @@
#include "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h"
#include "base/memory/scoped_ptr.h"
#include "base/logging.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_window.h"
#import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet.h"
#import "chrome/browser/ui/cocoa/single_web_contents_dialog_manager_cocoa.h"
#import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_controller.h"
#import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h"
#include "components/web_modal/popup_manager.h"
#include "components/web_modal/web_contents_modal_dialog_manager.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/guest_view/guest_view_base.h"
using web_modal::WebContentsModalDialogManager;
using web_modal::NativeWebContentsModalDialog;
ConstrainedWindowMac::ConstrainedWindowMac(
ConstrainedWindowMacDelegate* delegate,
content::WebContents* web_contents,
id<ConstrainedWindowSheet> sheet)
: delegate_(delegate) {
DCHECK(sheet);
: delegate_(delegate),
web_contents_(NULL),
sheet_([sheet retain]),
shown_(false) {
DCHECK(web_contents);
extensions::GuestViewBase* guest_view =
extensions::GuestViewBase::FromWebContents(web_contents);
// For embedded WebContents, use the embedder's WebContents for constrained
// window.
web_contents = guest_view && guest_view->embedder_web_contents() ?
guest_view->embedder_web_contents() : web_contents;
auto manager = WebContentsModalDialogManager::FromWebContents(web_contents);
scoped_ptr<SingleWebContentsDialogManagerCocoa> native_manager(
new SingleWebContentsDialogManagerCocoa(this, sheet, manager));
manager->ShowDialogWithManager([sheet sheetWindow], native_manager.Pass());
web_contents_ = guest_view && guest_view->embedder_web_contents() ?
guest_view->embedder_web_contents() : web_contents;
DCHECK(sheet_.get());
web_modal::PopupManager* popup_manager =
web_modal::PopupManager::FromWebContents(web_contents_);
if (popup_manager)
popup_manager->ShowModalDialog(this, web_contents_);
}
ConstrainedWindowMac::~ConstrainedWindowMac() {
CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
DCHECK(!manager_);
}
void ConstrainedWindowMac::CloseWebContentsModalDialog() {
if (manager_)
manager_->Close();
void ConstrainedWindowMac::ShowWebContentsModalDialog() {
if (shown_)
return;
NSWindow* parent_window = web_contents_->GetTopLevelNativeWindow();
NSView* parent_view = GetSheetParentViewForWebContents(web_contents_);
if (!parent_window || !parent_view)
return;
shown_ = true;
ConstrainedWindowSheetController* controller =
[ConstrainedWindowSheetController
controllerForParentWindow:parent_window];
[controller showSheet:sheet_ forParentView:parent_view];
}
void ConstrainedWindowMac::OnDialogClosing() {
void ConstrainedWindowMac::CloseWebContentsModalDialog() {
[[ConstrainedWindowSheetController controllerForSheet:sheet_]
closeSheet:sheet_];
// TODO(gbillock): get this object in config, not from a global.
WebContentsModalDialogManager* web_contents_modal_dialog_manager =
WebContentsModalDialogManager::FromWebContents(web_contents_);
// Will result in the delegate being deleted.
if (delegate_)
delegate_->OnConstrainedWindowClosed(this);
// Will cause this object to be deleted.
web_contents_modal_dialog_manager->WillClose(this);
}
void ConstrainedWindowMac::FocusWebContentsModalDialog() {
}
void ConstrainedWindowMac::PulseWebContentsModalDialog() {
[[ConstrainedWindowSheetController controllerForSheet:sheet_]
pulseSheet:sheet_];
}
NativeWebContentsModalDialog ConstrainedWindowMac::GetNativeDialog() {
// TODO(wittman): Ultimately this should be changed to the
// ConstrainedWindowSheet pointer, in conjunction with the corresponding
// changes to NativeWebContentsModalDialogManagerCocoa.
return this;
}
......@@ -24,8 +24,6 @@
- (void)updateSheetPosition;
@property(readonly, nonatomic) NSWindow* sheetWindow;
@end
#endif // CHROME_BROWSER_UI_COCOA_CONSTRAINED_WINDOW_CONSTRAINED_WINDOW_SHEET_H_
......@@ -56,10 +56,6 @@ const int kSystemSheetReturnCode = 77;
- (void)updateSheetPosition {
}
- (NSWindow*)sheetWindow {
return [alert_ window];
}
- (void)alertDidEnd:(NSAlert *)alert
returnCode:(NSInteger)returnCode
ctxInfo:(void *)contextInfo {
......
// Copyright 2015 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_SINGLE_WEB_CONTENTS_DIALOG_MANAGER_COCOA_H_
#define CHROME_BROWSER_UI_COCOA_SINGLE_WEB_CONTENTS_DIALOG_MANAGER_COCOA_H_
#import "base/mac/scoped_nsobject.h"
#include "components/web_modal/single_web_contents_dialog_manager.h"
class ConstrainedWindowMac;
@protocol ConstrainedWindowSheet;
// Cocoa implementation of web_modal::SingleWebContentsDialogManager.
class SingleWebContentsDialogManagerCocoa
: public web_modal::SingleWebContentsDialogManager {
public:
SingleWebContentsDialogManagerCocoa(
ConstrainedWindowMac* client,
id<ConstrainedWindowSheet> sheet,
web_modal::SingleWebContentsDialogManagerDelegate* delegate);
~SingleWebContentsDialogManagerCocoa() override;
// SingleWebContentsDialogManager overrides.
void Show() override;
void Hide() override;
void Close() override;
void Focus() override;
void Pulse() override;
void HostChanged(web_modal::WebContentsModalDialogHost* new_host) override;
web_modal::NativeWebContentsModalDialog dialog() override;
private:
ConstrainedWindowMac* client_; // Weak. Can be null.
base::scoped_nsprotocol<id<ConstrainedWindowSheet>> sheet_;
// Weak. Owns this.
web_modal::SingleWebContentsDialogManagerDelegate* delegate_;
bool shown_;
DISALLOW_COPY_AND_ASSIGN(SingleWebContentsDialogManagerCocoa);
};
#endif // CHROME_BROWSER_UI_COCOA_SINGLE_WEB_CONTENTS_DIALOG_MANAGER_COCOA_H_
// Copyright 2015 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.
#import "chrome/browser/ui/cocoa/single_web_contents_dialog_manager_cocoa.h"
#import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sheet.h"
#import "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h"
#import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_controller.h"
#import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h"
#include "components/web_modal/web_contents_modal_dialog_manager.h"
using web_modal::NativeWebContentsModalDialog;
using web_modal::SingleWebContentsDialogManagerDelegate;
SingleWebContentsDialogManagerCocoa::SingleWebContentsDialogManagerCocoa(
ConstrainedWindowMac* client,
id<ConstrainedWindowSheet> sheet,
web_modal::SingleWebContentsDialogManagerDelegate* delegate)
: client_(client),
sheet_([sheet retain]),
delegate_(delegate),
shown_(false) {
if (client)
client->set_manager(this);
}
SingleWebContentsDialogManagerCocoa::~SingleWebContentsDialogManagerCocoa() {
}
void SingleWebContentsDialogManagerCocoa::Show() {
if (shown_)
return;
content::WebContents* web_contents = delegate_->GetWebContents();
NSWindow* parent_window = web_contents->GetTopLevelNativeWindow();
NSView* parent_view = GetSheetParentViewForWebContents(web_contents);
if (!parent_window || !parent_view)
return;
shown_ = true;
[[ConstrainedWindowSheetController controllerForParentWindow:parent_window]
showSheet:sheet_ forParentView:parent_view];
}
void SingleWebContentsDialogManagerCocoa::Hide() {
}
void SingleWebContentsDialogManagerCocoa::Close() {
[[ConstrainedWindowSheetController controllerForSheet:sheet_]
closeSheet:sheet_];
if (client_) {
client_->set_manager(nullptr);
client_->OnDialogClosing(); // |client_| might delete itself here.
client_ = nullptr;
}
delegate_->WillClose(dialog());
}
void SingleWebContentsDialogManagerCocoa::Focus() {
}
void SingleWebContentsDialogManagerCocoa::Pulse() {
[[ConstrainedWindowSheetController controllerForSheet:sheet_]
pulseSheet:sheet_];
}
void SingleWebContentsDialogManagerCocoa::HostChanged(
web_modal::WebContentsModalDialogHost* new_host) {
}
NativeWebContentsModalDialog SingleWebContentsDialogManagerCocoa::dialog() {
return [sheet_ sheetWindow];
}
namespace web_modal {
SingleWebContentsDialogManager*
WebContentsModalDialogManager::CreateNativeWebModalManager(
NativeWebContentsModalDialog dialog,
SingleWebContentsDialogManagerDelegate* delegate) {
base::scoped_nsobject<CustomConstrainedWindowSheet> sheet(
[[CustomConstrainedWindowSheet alloc] initWithCustomWindow:dialog]);
return new SingleWebContentsDialogManagerCocoa(nullptr, sheet, delegate);
}
} // namespace web_modal
......@@ -227,10 +227,6 @@ void ShowSSLClientCertificateSelector(
// NOOP
}
- (NSWindow*)sheetWindow {
return panel_;
}
- (void)onConstrainedWindowClosed {
observer_->StopObserving();
panel_.reset();
......
......@@ -7,7 +7,6 @@
#import <Cocoa/Cocoa.h>
#import "base/mac/scoped_nsobject.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h"
#include "chrome/browser/ui/tab_modal_confirm_dialog.h"
......
// Copyright (c) 2013 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 "components/web_modal/web_contents_modal_dialog_manager.h"
#include "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h"
#include "components/web_modal/single_web_contents_dialog_manager.h"
using web_modal::NativeWebContentsModalDialog;
namespace {
class NativeWebContentsModalDialogManagerCocoa
: public web_modal::SingleWebContentsDialogManager {
public:
NativeWebContentsModalDialogManagerCocoa(
NativeWebContentsModalDialog dialog)
: dialog_(dialog) {
}
~NativeWebContentsModalDialogManagerCocoa() override {}
// SingleWebContentsDialogManager overrides
void Show() override {
GetConstrainedWindowMac(dialog())->ShowWebContentsModalDialog();
}
void Hide() override {}
void Close() override {
GetConstrainedWindowMac(dialog())->CloseWebContentsModalDialog();
}
void Focus() override {
GetConstrainedWindowMac(dialog())->FocusWebContentsModalDialog();
}
void Pulse() override {
GetConstrainedWindowMac(dialog())->PulseWebContentsModalDialog();
}
void HostChanged(web_modal::WebContentsModalDialogHost* new_host) override {}
NativeWebContentsModalDialog dialog() override { return dialog_; }
private:
static ConstrainedWindowMac* GetConstrainedWindowMac(
NativeWebContentsModalDialog dialog) {
return static_cast<ConstrainedWindowMac*>(dialog);
}
// In mac this is a pointer to a ConstrainedWindowMac.
// TODO(gbillock): Replace this casting system with a more typesafe call path.
NativeWebContentsModalDialog dialog_;
DISALLOW_COPY_AND_ASSIGN(NativeWebContentsModalDialogManagerCocoa);
};
} // namespace
namespace web_modal {
SingleWebContentsDialogManager*
WebContentsModalDialogManager::CreateNativeWebModalManager(
NativeWebContentsModalDialog dialog,
SingleWebContentsDialogManagerDelegate* native_delegate) {
return new NativeWebContentsModalDialogManagerCocoa(dialog);
}
} // namespace web_modal
......@@ -125,7 +125,7 @@ class ConstrainedWebDialogDelegateViews
// ConstrainedWebDialogDelegate:
web_modal::NativeWebContentsModalDialog GetNativeDialog() override {
return view_->GetWidget()->GetNativeWindow();
return view_->GetWidget()->GetNativeView();
}
private:
......@@ -246,7 +246,7 @@ class ConstrainedWebDialogDelegateViewViews
web_modal::PopupManager* popup_manager =
web_modal::PopupManager::FromWebContents(
initiator_observer_.web_contents());
popup_manager->ShowModalDialog(GetWidget()->GetNativeWindow(),
popup_manager->ShowModalDialog(GetWidget()->GetNativeView(),
initiator_observer_.web_contents());
}
}
......
......@@ -220,7 +220,7 @@ class NativeWebContentsModalDialogManagerViews
#endif
// Will cause this object to be deleted.
native_delegate_->WillClose(widget->GetNativeWindow());
native_delegate_->WillClose(widget->GetNativeView());
}
SingleWebContentsDialogManagerDelegate* native_delegate_;
......
......@@ -651,8 +651,6 @@
'browser/ui/cocoa/screen_capture_notification_ui_cocoa.h',
'browser/ui/cocoa/screen_capture_notification_ui_cocoa.mm',
'browser/ui/cocoa/simple_message_box_mac.mm',
'browser/ui/cocoa/single_web_contents_dialog_manager_cocoa.h',
'browser/ui/cocoa/single_web_contents_dialog_manager_cocoa.mm',
'browser/ui/cocoa/sprite_view.h',
'browser/ui/cocoa/sprite_view.mm',
'browser/ui/cocoa/ssl_client_certificate_selector_cocoa.h',
......@@ -733,6 +731,7 @@
'browser/ui/cocoa/view_id_util.h',
'browser/ui/cocoa/view_id_util.mm',
'browser/ui/cocoa/view_resizer.h',
'browser/ui/cocoa/web_contents_modal_dialog_manager_cocoa.mm',
'browser/ui/cocoa/web_dialog_window_controller.h',
'browser/ui/cocoa/web_dialog_window_controller.mm',
'browser/ui/cocoa/website_settings/permission_bubble_cocoa.h',
......
......@@ -11,8 +11,21 @@ namespace web_modal {
// TODO(gbillock): rename this file
using NativeWebContentsModalDialog = gfx::NativeWindow;
using NativePopup = gfx::NativeWindow;
#if defined(OS_MACOSX)
// Use a void* since none of the gfx::Native* types are suitable for
// representing the web contents modal dialog under Cocoa.
typedef void* NativeWebContentsModalDialog;
#else
typedef gfx::NativeView NativeWebContentsModalDialog;
#endif
#if defined(OS_MACOSX)
// Use a void* since none of the gfx::Native* types are suitable for
// representing a popup window under Cocoa.
typedef void* NativePopup;
#else
typedef gfx::NativeView NativePopup;
#endif
} // namespace web_modal
......
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