Commit cd358850 authored by Nico Weber's avatar Nico Weber

Reland "mac: Remove unused TabDialogsMac/TabDialogsCocoa."

This reverts commit 8e5ef240.

Reason for revert: Relanding with HungRendererController removed as well.

Original change's description:
> Revert "mac: Remove unused TabDialogsMac/TabDialogsCocoa."
>
> This reverts commit 50439b88.
>
> Reason for revert:
> Mac bots start failing after this CL on HungRendererControllerTest.
> The error logs are below.
> https://ci.chromium.org/p/chromium/builders/luci.chromium.ci/Mac10.11%20Tests/29038
> https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket.appspot.com/8934838111834185888/+/steps/unit_tests_on__none__GPU_on_Mac_on_Mac-10.11/0/logs/HungRendererControllerTest.TestKillButton/0
>
> Original change's description:
> > mac: Remove unused TabDialogsMac/TabDialogsCocoa.
> >
> > Bug: 832676
> > Change-Id: I0fb8d4b1f0197dab0b988a52741724f63a18ee9f
> > Reviewed-on: https://chromium-review.googlesource.com/1236178
> > Commit-Queue: Nico Weber <thakis@chromium.org>
> > Reviewed-by: Elly Fong-Jones <ellyjones@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#592819}
>
> TBR=ellyjones@chromium.org,thakis@chromium.org
>
> Change-Id: I6554e741ef31bc99da0c90e3c4fd2bb8826a741f
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: 832676
> Reviewed-on: https://chromium-review.googlesource.com/1237797
> Reviewed-by: Taiju Tsuiki <tzik@chromium.org>
> Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#593085}

TBR=ellyjones@chromium.org,thakis@chromium.org,tzik@chromium.org

Change-Id: I5e076b202734c727608279952fad9d1b5657636b
Bug: 832676
Reviewed-on: https://chromium-review.googlesource.com/1238595Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593278}
parent a8d5a670
...@@ -9,7 +9,6 @@ assert(is_mac) ...@@ -9,7 +9,6 @@ assert(is_mac)
translated_xibs = [ translated_xibs = [
"AppMenu.xib", "AppMenu.xib",
"HungRendererDialog.xib",
"OneClickSigninDialog.xib", "OneClickSigninDialog.xib",
"SaveAccessoryView.xib", "SaveAccessoryView.xib",
"TaskManager.xib", "TaskManager.xib",
......
This diff is collapsed.
...@@ -210,8 +210,6 @@ jumbo_split_static_library("ui") { ...@@ -210,8 +210,6 @@ jumbo_split_static_library("ui") {
"cocoa/has_weak_browser_pointer.h", "cocoa/has_weak_browser_pointer.h",
"cocoa/hover_close_button.h", "cocoa/hover_close_button.h",
"cocoa/hover_close_button.mm", "cocoa/hover_close_button.mm",
"cocoa/hung_renderer_controller.h",
"cocoa/hung_renderer_controller.mm",
"cocoa/image_button_cell.h", "cocoa/image_button_cell.h",
"cocoa/image_button_cell.mm", "cocoa/image_button_cell.mm",
"cocoa/info_bubble_view.h", "cocoa/info_bubble_view.h",
...@@ -351,10 +349,6 @@ jumbo_split_static_library("ui") { ...@@ -351,10 +349,6 @@ jumbo_split_static_library("ui") {
"cocoa/tab_contents/sad_tab_view_cocoa.mm", "cocoa/tab_contents/sad_tab_view_cocoa.mm",
"cocoa/tab_contents/tab_contents_controller.h", "cocoa/tab_contents/tab_contents_controller.h",
"cocoa/tab_contents/tab_contents_controller.mm", "cocoa/tab_contents/tab_contents_controller.mm",
"cocoa/tab_dialogs_cocoa.h",
"cocoa/tab_dialogs_cocoa.mm",
"cocoa/tab_dialogs_views_mac.h",
"cocoa/tab_dialogs_views_mac.mm",
"cocoa/tab_modal_confirm_dialog_mac.h", "cocoa/tab_modal_confirm_dialog_mac.h",
"cocoa/tab_modal_confirm_dialog_mac.mm", "cocoa/tab_modal_confirm_dialog_mac.mm",
"cocoa/tabbed_browser_window.h", "cocoa/tabbed_browser_window.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_HUNG_RENDERER_CONTROLLER_H_
#define CHROME_BROWSER_UI_COCOA_HUNG_RENDERER_CONTROLLER_H_
// A controller for the Mac hung renderer dialog window. Only one
// instance of this controller can exist at any time, although a given
// controller is destroyed when its window is closed.
//
// The dialog itself displays a list of frozen tabs, all of which
// share a render process. Since there can only be a single dialog
// open at a time, if showForWebContents is called for a different
// tab, the dialog is repurposed to show a warning for the new tab.
//
// The caller is required to call endForWebContents before deleting
// any WebContents object.
#import <Cocoa/Cocoa.h>
#include <memory>
#include "base/callback.h"
#import "base/mac/scoped_nsobject.h"
@class MultiKeyEquivalentButton;
class HungRendererObserverBridge;
namespace content {
class RenderWidgetHost;
class WebContents;
}
@interface HungRendererController : NSWindowController<NSTableViewDataSource> {
@private
IBOutlet MultiKeyEquivalentButton* waitButton_;
IBOutlet NSButton* killButton_;
IBOutlet NSTableView* tableView_;
IBOutlet NSImageView* imageView_;
IBOutlet NSTextField* messageView_;
// The WebContents and RenderWidgetHost for which this dialog is open.
// Should never be null while this dialog is open.
content::WebContents* hungContents_;
content::RenderWidgetHost* hungWidget_;
// Callback that restarts the hang timeout (e.g. if the user wants to wait
// some more until the renderer process responds).
base::RepeatingClosure hangMonitorRestarter_;
// Observes |hungContents_| in case it closes while the panel is up.
std::unique_ptr<HungRendererObserverBridge> hungContentsObserver_;
// Backing data for |tableView_|. Titles of each WebContents that
// shares a renderer process with |hungContents_|.
base::scoped_nsobject<NSArray> hungTitles_;
// Favicons of each WebContents that shares a renderer process with
// |hungContents_|.
base::scoped_nsobject<NSArray> hungFavicons_;
}
// Shows or hides the hung renderer dialog for the given WebContents.
+ (void)showForWebContents:(content::WebContents*)contents
renderWidgetHost:(content::RenderWidgetHost*)renderWidget
timeoutRestarter:(base::RepeatingClosure)timeoutRestarter;
+ (void)endForWebContents:(content::WebContents*)contents
renderWidgetHost:(content::RenderWidgetHost*)renderWidget;
+ (bool)isShowing;
// Kills the hung render process.
- (IBAction)kill:(id)sender;
// Waits longer for the render process to respond.
- (IBAction)wait:(id)sender;
@end // HungRendererController
@interface HungRendererController (JustForTesting)
- (NSButton*)killButton;
- (MultiKeyEquivalentButton*)waitButton;
@end
#endif // CHROME_BROWSER_UI_COCOA_HUNG_RENDERER_CONTROLLER_H_
This diff is collapsed.
// Copyright (c) 2011 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 <Cocoa/Cocoa.h>
#import "chrome/browser/ui/cocoa/hung_renderer_controller.h"
#include "chrome/browser/ui/cocoa/test/cocoa_test_helper.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
namespace {
class HungRendererControllerTest : public CocoaTest {
public:
void SetUp() override {
CocoaTest::SetUp();
hung_renderer_controller_ = [[HungRendererController alloc]
initWithWindowNibName:@"HungRendererDialog"];
}
HungRendererController* hung_renderer_controller_; // owned by its window
};
TEST_F(HungRendererControllerTest, TestShowAndClose) {
// Doesn't test much functionality-wise, but makes sure we can
// display and tear down a window.
[hung_renderer_controller_ showWindow:nil];
// Cannot call performClose:, because the close button is disabled.
[hung_renderer_controller_ close];
}
TEST_F(HungRendererControllerTest, TestKillButton) {
// We can't test killing a process because we have no running
// process to kill, but we can make sure that pressing the kill
// button closes the window.
[hung_renderer_controller_ showWindow:nil];
[[hung_renderer_controller_ killButton] performClick:nil];
}
TEST_F(HungRendererControllerTest, TestWaitButton) {
// We can't test waiting because we have no running process to wait
// for, but we can make sure that pressing the wait button closes
// the window.
[hung_renderer_controller_ showWindow:nil];
[[hung_renderer_controller_ waitButton] performClick:nil];
}
} // namespace
// Copyright 2014 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_TAB_DIALOGS_COCOA_H_
#define CHROME_BROWSER_UI_COCOA_TAB_DIALOGS_COCOA_H_
#include "base/macros.h"
#include "chrome/browser/ui/tab_dialogs.h"
// Cocoa implementation of TabDialogs interface.
class TabDialogsCocoa : public TabDialogs {
public:
explicit TabDialogsCocoa(content::WebContents* contents);
~TabDialogsCocoa() override;
// TabDialogs:
gfx::NativeView GetDialogParentView() const override;
void ShowCollectedCookies() override;
void ShowHungRendererDialog(
content::RenderWidgetHost* render_widget_host,
base::RepeatingClosure hang_monitor_restarter) override;
void HideHungRendererDialog(
content::RenderWidgetHost* render_widget_host) override;
bool IsShowingHungRendererDialog() override;
void ShowProfileSigninConfirmation(
Browser* browser,
Profile* profile,
const std::string& username,
std::unique_ptr<ui::ProfileSigninConfirmationDelegate> delegate) override;
void ShowManagePasswordsBubble(bool user_action) override;
void HideManagePasswordsBubble() override;
protected:
content::WebContents* web_contents() const { return web_contents_; }
private:
content::WebContents* web_contents_; // Weak. Owns this.
DISALLOW_COPY_AND_ASSIGN(TabDialogsCocoa);
};
#endif // CHROME_BROWSER_UI_COCOA_TAB_DIALOGS_COCOA_H_
// Copyright 2014 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/tab_dialogs_cocoa.h"
#include <memory>
#import "chrome/browser/ui/cocoa/hung_renderer_controller.h"
#import "chrome/browser/ui/cocoa/profiles/profile_signin_confirmation_dialog_cocoa.h"
#include "chrome/browser/ui/cocoa/tab_dialogs_views_mac.h"
#include "chrome/browser/ui/sync/profile_signin_confirmation_helper.h"
#include "content/public/browser/web_contents.h"
#include "ui/base/ui_features.h"
TabDialogsCocoa::TabDialogsCocoa(content::WebContents* contents)
: web_contents_(contents) {
DCHECK(contents);
}
TabDialogsCocoa::~TabDialogsCocoa() {
}
gfx::NativeView TabDialogsCocoa::GetDialogParentView() const {
// View hierarchy of the contents view:
// NSView -- switchView, same for all tabs
// +- TabContentsContainerView -- TabContentsController's view
// +- WebContentsViewCocoa
//
// Changing it? Do not forget to modify
// -[TabStripControllerCocoa swapInTabAtIndex:] too.
return [web_contents_->GetNativeView() superview];
}
void TabDialogsCocoa::ShowCollectedCookies() {
NOTREACHED() << "MacViewsBrowser builds can't use Cocoa dialogs";
}
void TabDialogsCocoa::ShowHungRendererDialog(
content::RenderWidgetHost* render_widget_host,
base::RepeatingClosure hang_monitor_restarter) {
[HungRendererController showForWebContents:web_contents_
renderWidgetHost:render_widget_host
timeoutRestarter:hang_monitor_restarter];
}
void TabDialogsCocoa::HideHungRendererDialog(
content::RenderWidgetHost* render_widget_host) {
[HungRendererController endForWebContents:web_contents_
renderWidgetHost:render_widget_host];
}
bool TabDialogsCocoa::IsShowingHungRendererDialog() {
return [HungRendererController isShowing];
}
void TabDialogsCocoa::ShowProfileSigninConfirmation(
Browser* browser,
Profile* profile,
const std::string& username,
std::unique_ptr<ui::ProfileSigninConfirmationDelegate> delegate) {
ProfileSigninConfirmationDialogCocoa::Show(browser, web_contents_, profile,
username, std::move(delegate));
}
void TabDialogsCocoa::ShowManagePasswordsBubble(bool user_action) {
// The method is implemented by TabDialogsViewsMac and only that one is to be
// called due to MacViews release.
NOTREACHED();
}
void TabDialogsCocoa::HideManagePasswordsBubble() {
// The method is implemented by TabDialogsViewsMac and only that one is to be
// called due to MacViews release.
NOTREACHED();
}
// Copyright 2017 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_TAB_DIALOGS_VIEWS_MAC_H_
#define CHROME_BROWSER_UI_COCOA_TAB_DIALOGS_VIEWS_MAC_H_
#include "chrome/browser/ui/cocoa/tab_dialogs_cocoa.h"
// Implementation of TabDialogs interface for toolkit-views dialogs on Mac.
class TabDialogsViewsMac : public TabDialogsCocoa {
public:
explicit TabDialogsViewsMac(content::WebContents* contents);
~TabDialogsViewsMac() override;
// TabDialogs:
void ShowCollectedCookies() override;
void ShowProfileSigninConfirmation(
Browser* browser,
Profile* profile,
const std::string& username,
std::unique_ptr<ui::ProfileSigninConfirmationDelegate> delegate) override;
void ShowManagePasswordsBubble(bool user_action) override;
void HideManagePasswordsBubble() override;
private:
DISALLOW_COPY_AND_ASSIGN(TabDialogsViewsMac);
};
#endif // CHROME_BROWSER_UI_COCOA_TAB_DIALOGS_VIEWS_MAC_H_
// Copyright 2017 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/tab_dialogs_views_mac.h"
#include "chrome/browser/platform_util.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_window.h"
#import "chrome/browser/ui/cocoa/browser_window_controller.h"
#import "chrome/browser/ui/cocoa/bubble_anchor_helper_views.h"
#include "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
#include "chrome/browser/ui/cocoa/location_bar/manage_passwords_decoration.h"
#include "chrome/browser/ui/views/collected_cookies_views.h"
#include "chrome/browser/ui/views/passwords/password_bubble_view_base.h"
#include "chrome/browser/ui/views/sync/profile_signin_confirmation_dialog_views.h"
#include "chrome/browser/ui/views/tab_dialogs_views.h"
#include "chrome/browser/ui/views_mode_controller.h"
#include "content/public/browser/web_contents.h"
#import "ui/base/cocoa/cocoa_base_utils.h"
#include "ui/base/ui_features.h"
#import "ui/gfx/mac/coordinate_conversion.h"
namespace {
gfx::Point ScreenPointFromBrowser(Browser* browser, NSPoint ns_point) {
return gfx::ScreenPointFromNSPoint(ui::ConvertPointFromWindowToScreen(
browser->window()->GetNativeWindow(), ns_point));
}
}
// static
void TabDialogs::CreateForWebContents(content::WebContents* contents) {
DCHECK(contents);
if (!FromWebContents(contents)) {
// This is a bit subtle: if IsViewsBrowserCocoa(), that means this is a
// mac_views_browser build using a Cocoa browser window, in which case
// TabDialogsViewsMac is the right implementation; mostly it inherits
// behavior from TabDialogsCocoa, which will only work with a Cocoa browser
// window. If !IsViewsBrowserCocoa(), there is a Views browser window, so
// TabDialogsViews (which is the only implementation that works with a Views
// browser window) is the right implementation.
//
// Note that the ternary below can't use std::make_unique<> because
// TabDialogsViewsMac and TabDialogsViews are not compatible types (neither
// is an ancestor of the other).
std::unique_ptr<TabDialogs> tab_dialogs(
views_mode_controller::IsViewsBrowserCocoa()
? static_cast<TabDialogs*>(new TabDialogsViewsMac(contents))
: static_cast<TabDialogs*>(new TabDialogsViews(contents)));
contents->SetUserData(UserDataKey(), std::move(tab_dialogs));
}
}
TabDialogsViewsMac::TabDialogsViewsMac(content::WebContents* contents)
: TabDialogsCocoa(contents) {}
TabDialogsViewsMac::~TabDialogsViewsMac() {}
void TabDialogsViewsMac::ShowCollectedCookies() {
// Deletes itself on close.
new CollectedCookiesViews(web_contents());
}
void TabDialogsViewsMac::ShowProfileSigninConfirmation(
Browser* browser,
Profile* profile,
const std::string& username,
std::unique_ptr<ui::ProfileSigninConfirmationDelegate> delegate) {
ProfileSigninConfirmationDialogViews::ShowDialog(browser, profile, username,
std::move(delegate));
}
void TabDialogsViewsMac::ShowManagePasswordsBubble(bool user_action) {
NSWindow* window = [web_contents()->GetNativeView() window];
if (!window) {
// The tab isn't active right now.
return;
}
// Don't show the bubble again if it's already showing. A second click on the
// location icon in the omnibox will dismiss an open bubble. This behaviour is
// consistent with the non-Mac views implementation.
// Note that when the browser is toolkit-views, IsBubbleShown() is checked
// earlier because the bubble is shown on mouse release (but dismissed on
// mouse pressed). A Cocoa browser does both on mouse pressed, so a check
// when showing is sufficient.
if (PasswordBubbleViewBase::manage_password_bubble() &&
PasswordBubbleViewBase::manage_password_bubble()
->GetWidget()
->IsVisible())
return;
Browser* browser = chrome::FindBrowserWithWebContents(web_contents());
bool has_location_bar =
browser && browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR);
NSPoint ns_anchor_point;
views::BubbleBorder::Arrow arrow = views::BubbleBorder::TOP_RIGHT;
if (has_location_bar) {
BrowserWindowController* bwc =
[BrowserWindowController browserWindowControllerForWindow:window];
LocationBarViewMac* location_bar = [bwc locationBarBridge];
ns_anchor_point = location_bar->GetBubblePointForDecoration(
location_bar->manage_passwords_decoration());
} else {
// Center the bubble if there's no location bar.
NSRect content_frame = [[window contentView] frame];
ns_anchor_point = NSMakePoint(NSMidX(content_frame), NSMaxY(content_frame));
arrow = views::BubbleBorder::TOP_CENTER;
}
gfx::Point anchor_point = ScreenPointFromBrowser(browser, ns_anchor_point);
gfx::NativeView parent =
platform_util::GetViewForWindow(browser->window()->GetNativeWindow());
DCHECK(parent);
LocationBarBubbleDelegateView::DisplayReason reason =
user_action ? LocationBarBubbleDelegateView::USER_GESTURE
: LocationBarBubbleDelegateView::AUTOMATIC;
PasswordBubbleViewBase* bubble_view = PasswordBubbleViewBase::CreateBubble(
web_contents(), nullptr, anchor_point, reason);
bubble_view->SetArrow(arrow);
bubble_view->set_parent_window(parent);
views::BubbleDialogDelegateView::CreateBubble(bubble_view);
bubble_view->ShowForReason(reason);
KeepBubbleAnchored(bubble_view, GetManagePasswordDecoration(window));
}
void TabDialogsViewsMac::HideManagePasswordsBubble() {
// Close toolkit-views bubble.
if (!PasswordBubbleViewBase::manage_password_bubble())
return;
const content::WebContents* bubble_web_contents =
PasswordBubbleViewBase::manage_password_bubble()->GetWebContents();
if (web_contents() == bubble_web_contents)
PasswordBubbleViewBase::CloseCurrentBubble();
}
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include "chrome/browser/ui/views/sync/profile_signin_confirmation_dialog_views.h" #include "chrome/browser/ui/views/sync/profile_signin_confirmation_dialog_views.h"
#endif #endif
#if !defined(OS_MACOSX)
// static // static
void TabDialogs::CreateForWebContents(content::WebContents* contents) { void TabDialogs::CreateForWebContents(content::WebContents* contents) {
DCHECK(contents); DCHECK(contents);
...@@ -27,7 +26,6 @@ void TabDialogs::CreateForWebContents(content::WebContents* contents) { ...@@ -27,7 +26,6 @@ void TabDialogs::CreateForWebContents(content::WebContents* contents) {
std::make_unique<TabDialogsViews>(contents)); std::make_unique<TabDialogsViews>(contents));
} }
} }
#endif
TabDialogsViews::TabDialogsViews(content::WebContents* contents) TabDialogsViews::TabDialogsViews(content::WebContents* contents)
: web_contents_(contents) { : web_contents_(contents) {
......
...@@ -4172,7 +4172,6 @@ test("unit_tests") { ...@@ -4172,7 +4172,6 @@ test("unit_tests") {
"../browser/ui/cocoa/history_menu_cocoa_controller_unittest.mm", "../browser/ui/cocoa/history_menu_cocoa_controller_unittest.mm",
"../browser/ui/cocoa/history_overlay_controller_unittest.mm", "../browser/ui/cocoa/history_overlay_controller_unittest.mm",
"../browser/ui/cocoa/hover_close_button_unittest.mm", "../browser/ui/cocoa/hover_close_button_unittest.mm",
"../browser/ui/cocoa/hung_renderer_controller_unittest.mm",
"../browser/ui/cocoa/image_button_cell_unittest.mm", "../browser/ui/cocoa/image_button_cell_unittest.mm",
"../browser/ui/cocoa/info_bubble_view_unittest.mm", "../browser/ui/cocoa/info_bubble_view_unittest.mm",
"../browser/ui/cocoa/info_bubble_window_unittest.mm", "../browser/ui/cocoa/info_bubble_window_unittest.mm",
......
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