Commit 14f33a9d authored by Nico Weber's avatar Nico Weber Committed by Commit Bot

mac: Remove GetAppMenuAnchorRectCocoa() and TrackBubbleState().

Bug: 832676
Change-Id: If227bcc8b17bb5bcd8563c921c41794d4c7e9dc0
Reviewed-on: https://chromium-review.googlesource.com/1241497
Commit-Queue: Nico Weber <thakis@chromium.org>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593760}
parent c7340785
......@@ -77,7 +77,6 @@ jumbo_split_static_library("ui") {
"cocoa/bubble_anchor_helper.mm",
"cocoa/bubble_anchor_helper_views.h",
"cocoa/bubble_anchor_helper_views.mm",
"cocoa/bubble_anchor_util_views_mac.mm",
"cocoa/bubble_combobox.h",
"cocoa/bubble_combobox.mm",
"cocoa/bubble_view.h",
......
......@@ -35,13 +35,6 @@ constexpr int kNoToolbarLeftOffset = 40;
// based browsers. The anchor rect is in screen coordinates.
gfx::Rect GetPageInfoAnchorRect(Browser* browser);
#if defined(OS_MACOSX)
// Returns the app menu anchor rect for |browser|, which is assumed to have a
// Cocoa browser window.
gfx::Rect GetAppMenuAnchorRectCocoa(Browser* browser);
#endif
} // namespace bubble_anchor_util
#endif // CHROME_BROWSER_UI_BUBBLE_ANCHOR_UTIL_H_
......@@ -20,9 +20,4 @@ class LocationBarDecoration;
void KeepBubbleAnchored(views::BubbleDialogDelegateView* bubble,
LocationBarDecoration* decoration = nullptr);
// Simplified version of KeepBubbleAnchored() for bubbles that manage their own
// anchoring. Causes |decoration| to be set active until |bubble| is closed.
void TrackBubbleState(views::BubbleDialogDelegateView* bubble,
LocationBarDecoration* decoration);
#endif // CHROME_BROWSER_UI_COCOA_BUBBLE_ANCHOR_HELPER_VIEWS_H_
......@@ -17,17 +17,13 @@
namespace {
// Whether frame changes on the parent window are observed or ignored.
enum AnchorType { OBSERVE_PARENT, IGNORE_PARENT };
// Self-deleting object that hosts Objective-C observers watching for parent
// window resizes to reposition a bubble Widget. Deletes itself when the bubble
// Widget closes.
class BubbleAnchorHelper final : public views::WidgetObserver {
public:
BubbleAnchorHelper(views::BubbleDialogDelegateView* bubble,
LocationBarDecoration* decoration,
AnchorType type);
LocationBarDecoration* decoration);
private:
// Observe |notification| on the bubble parent window with a block to call
......@@ -76,17 +72,11 @@ class BubbleAnchorHelper final : public views::WidgetObserver {
void KeepBubbleAnchored(views::BubbleDialogDelegateView* bubble,
LocationBarDecoration* decoration) {
new BubbleAnchorHelper(bubble, decoration, OBSERVE_PARENT);
}
void TrackBubbleState(views::BubbleDialogDelegateView* bubble,
LocationBarDecoration* decoration) {
new BubbleAnchorHelper(bubble, decoration, IGNORE_PARENT);
new BubbleAnchorHelper(bubble, decoration);
}
BubbleAnchorHelper::BubbleAnchorHelper(views::BubbleDialogDelegateView* bubble,
LocationBarDecoration* decoration,
AnchorType type)
LocationBarDecoration* decoration)
: observer_tokens_([[NSMutableArray alloc] init]),
bubble_(bubble),
decoration_(decoration) {
......@@ -97,9 +87,6 @@ BubbleAnchorHelper::BubbleAnchorHelper(views::BubbleDialogDelegateView* bubble,
if (decoration_)
decoration_->SetActive(true);
if (type == IGNORE_PARENT)
return;
RecalculateAnchor();
ObserveParentWindow(NSWindowDidEnterFullScreenNotification);
......
// 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/views/bubble_anchor_util_views.h"
#import <Cocoa/Cocoa.h>
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#import "chrome/browser/ui/cocoa/browser_window_controller.h"
#include "chrome/browser/ui/cocoa/browser_window_views_mac.h"
#import "chrome/browser/ui/cocoa/bubble_anchor_helper.h"
#import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
#import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
#include "chrome/browser/ui/extensions/extension_installed_bubble.h"
#import "ui/base/cocoa/cocoa_base_utils.h"
#include "ui/base/ui_features.h"
#include "ui/gfx/geometry/rect.h"
#import "ui/gfx/mac/coordinate_conversion.h"
// This file contains the bubble_anchor_util implementation for
// BrowserWindowCocoa.
namespace bubble_anchor_util {
gfx::Rect GetAppMenuAnchorRectCocoa(Browser* browser) {
NSWindow* window = browser->window()->GetNativeWindow();
BrowserWindowController* bwc = BrowserWindowControllerForWindow(window);
NSPoint point = [[bwc toolbarController] appMenuBubblePoint];
return gfx::Rect(gfx::ScreenPointFromNSPoint(
ui::ConvertPointFromWindowToScreen(window, point)),
gfx::Size());
}
} // namespace bubble_anchor_util
......@@ -23,7 +23,6 @@
#include "chrome/browser/ui/views/frame/app_menu_button.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
#include "chrome/browser/ui/views_mode_controller.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_features.h"
#include "ui/gfx/image/image.h"
......@@ -36,28 +35,16 @@
#include "ui/views/layout/grid_layout.h"
#include "ui/views/window/dialog_client_view.h"
#if defined(OS_MACOSX)
#include "chrome/browser/ui/cocoa/bubble_anchor_helper_views.h"
#endif
namespace {
const int kMaxBubbleViewWidth = 362;
views::View* GetGlobalErrorBubbleAnchorView(Browser* browser) {
#if defined(OS_MACOSX)
if (views_mode_controller::IsViewsBrowserCocoa())
return nullptr;
#endif
BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser);
return browser_view->toolbar_button_provider()->GetAppMenuButton();
}
gfx::Rect GetGlobalErrorBubbleAnchorRect(Browser* browser) {
#if defined(OS_MACOSX)
if (views_mode_controller::IsViewsBrowserCocoa())
return bubble_anchor_util::GetAppMenuAnchorRectCocoa(browser);
#endif
return gfx::Rect();
}
......@@ -77,10 +64,6 @@ GlobalErrorBubbleViewBase* GlobalErrorBubbleViewBase::ShowStandardBubbleView(
anchor_view, anchor_rect, views::BubbleBorder::TOP_RIGHT, browser, error);
views::BubbleDialogDelegateView::CreateBubble(bubble_view);
bubble_view->GetWidget()->Show();
#if defined(OS_MACOSX)
if (views_mode_controller::IsViewsBrowserCocoa())
KeepBubbleAnchored(bubble_view);
#endif
return bubble_view;
}
......
......@@ -29,7 +29,6 @@
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/toolbar_button_provider.h"
#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
#include "chrome/browser/ui/views_mode_controller.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/installer/util/google_update_settings.h"
......@@ -48,12 +47,6 @@
#include "ui/views/layout/grid_layout.h"
#include "ui/views/widget/widget.h"
#if defined(OS_MACOSX)
#include "chrome/browser/platform_util.h"
#include "chrome/browser/ui/cocoa/browser_dialogs_views_mac.h"
#include "chrome/browser/ui/cocoa/bubble_anchor_helper_views.h"
#endif
namespace {
enum SessionCrashedBubbleHistogramValue {
......@@ -86,20 +79,12 @@ bool DoesSupportConsentCheck() {
// browser windows always have a null anchor view and use
// GetSessionCrashedBubbleAnchorRect() instead.
views::View* GetSessionCrashedBubbleAnchorView(Browser* browser) {
#if BUILDFLAG(MAC_VIEWS_BROWSER)
if (views_mode_controller::IsViewsBrowserCocoa())
return nullptr;
#endif
return BrowserView::GetBrowserViewForBrowser(browser)
->toolbar_button_provider()
->GetAppMenuButton();
}
gfx::Rect GetSessionCrashedBubbleAnchorRect(Browser* browser) {
#if defined(OS_MACOSX)
if (views_mode_controller::IsViewsBrowserCocoa())
return bubble_anchor_util::GetAppMenuAnchorRectCocoa(browser);
#endif
return gfx::Rect();
}
......@@ -176,10 +161,6 @@ void SessionCrashedBubbleView::ShowForReal(
GetSessionCrashedBubbleAnchorView(browser),
GetSessionCrashedBubbleAnchorRect(browser), browser, offer_uma_optin);
views::BubbleDialogDelegateView::CreateBubble(crash_bubble)->Show();
#if defined(OS_MACOSX)
if (views_mode_controller::IsViewsBrowserCocoa())
KeepBubbleAnchored(crash_bubble);
#endif
RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_SHOWN);
if (uma_opted_in_already)
......
......@@ -12,7 +12,6 @@
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/toolbar/browser_app_menu_button.h"
#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
#include "chrome/browser/ui/views_mode_controller.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "ui/base/ui_features.h"
#include "ui/views/view.h"
......@@ -25,10 +24,6 @@ class SessionCrashedBubbleViewTest : public DialogBrowserTest {
void ShowUi(const std::string& name) override {
gfx::Rect anchor_rect = gfx::Rect();
views::View* anchor_view = nullptr;
#if BUILDFLAG(MAC_VIEWS_BROWSER)
if (views_mode_controller::IsViewsBrowserCocoa())
anchor_rect = bubble_anchor_util::GetAppMenuAnchorRectCocoa(browser());
#endif
if (anchor_rect == gfx::Rect()) {
anchor_view = BrowserView::GetBrowserViewForBrowser(browser())
->toolbar()
......
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