Commit 50439b88 authored by Nico Weber's avatar Nico Weber Committed by Commit Bot

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: default avatarElly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592819}
parent fbe67a95
...@@ -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.
...@@ -388,10 +388,6 @@ jumbo_split_static_library("ui") { ...@@ -388,10 +388,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 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) {
......
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