Commit 76b43718 authored by Nico Weber's avatar Nico Weber Committed by Commit Bot

mac: Remove StatusBubbleMac.

Bug: 832676
Change-Id: I4eebf5172371c2e69feef32d9fed265716992020
Reviewed-on: https://chromium-review.googlesource.com/1242136Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593934}
parent 9152d53f
...@@ -188,8 +188,6 @@ jumbo_split_static_library("ui") { ...@@ -188,8 +188,6 @@ jumbo_split_static_library("ui") {
"cocoa/ssl_client_certificate_selector_cocoa.h", "cocoa/ssl_client_certificate_selector_cocoa.h",
"cocoa/ssl_client_certificate_selector_cocoa.mm", "cocoa/ssl_client_certificate_selector_cocoa.mm",
"cocoa/spinner_util.h", "cocoa/spinner_util.h",
"cocoa/status_bubble_mac.h",
"cocoa/status_bubble_mac.mm",
"cocoa/styled_text_field.h", "cocoa/styled_text_field.h",
"cocoa/styled_text_field.mm", "cocoa/styled_text_field.mm",
"cocoa/styled_text_field_cell.h", "cocoa/styled_text_field_cell.h",
......
...@@ -39,7 +39,6 @@ ...@@ -39,7 +39,6 @@
#import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
#import "chrome/browser/ui/cocoa/nsmenuitem_additions.h" #import "chrome/browser/ui/cocoa/nsmenuitem_additions.h"
#include "chrome/browser/ui/cocoa/restart_browser.h" #include "chrome/browser/ui/cocoa/restart_browser.h"
#include "chrome/browser/ui/cocoa/status_bubble_mac.h"
#include "chrome/browser/ui/cocoa/task_manager_mac.h" #include "chrome/browser/ui/cocoa/task_manager_mac.h"
#import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
#include "chrome/browser/ui/exclusive_access/exclusive_access_context.h" #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h"
...@@ -258,7 +257,7 @@ void BrowserWindowCocoa::SetTopControlsGestureScrollInProgress( ...@@ -258,7 +257,7 @@ void BrowserWindowCocoa::SetTopControlsGestureScrollInProgress(
} }
StatusBubble* BrowserWindowCocoa::GetStatusBubble() { StatusBubble* BrowserWindowCocoa::GetStatusBubble() {
return [controller_ statusBubble]; return nullptr;
} }
void BrowserWindowCocoa::UpdateTitleBar() { void BrowserWindowCocoa::UpdateTitleBar() {
......
...@@ -46,7 +46,6 @@ class ExclusiveAccessContext; ...@@ -46,7 +46,6 @@ class ExclusiveAccessContext;
@class FullscreenWindow; @class FullscreenWindow;
class LocationBarViewMac; class LocationBarViewMac;
@class OverlayableContentsController; @class OverlayableContentsController;
class StatusBubbleMac;
@class TabStripControllerCocoa; @class TabStripControllerCocoa;
@class TabStripView; @class TabStripView;
@class ToolbarController; @class ToolbarController;
...@@ -84,12 +83,6 @@ constexpr const gfx::Size kMinCocoaPopupWindowSize(100, 122); ...@@ -84,12 +83,6 @@ constexpr const gfx::Size kMinCocoaPopupWindowSize(100, 122);
fullscreenTransition_; fullscreenTransition_;
base::scoped_nsobject<BrowserWindowTouchBarController> touchBarController_; base::scoped_nsobject<BrowserWindowTouchBarController> touchBarController_;
// Strong. StatusBubble is a special case of a strong reference that
// we don't wrap in a scoped_ptr because it is acting the same
// as an NSWindowController in that it wraps a window that must
// be shut down before our destructors are called.
StatusBubbleMac* statusBubble_;
BOOL initializing_; // YES while we are currently in initWithBrowser: BOOL initializing_; // YES while we are currently in initWithBrowser:
BOOL ownsBrowser_; // Only ever NO when testing BOOL ownsBrowser_; // Only ever NO when testing
...@@ -203,9 +196,6 @@ constexpr const gfx::Size kMinCocoaPopupWindowSize(100, 122); ...@@ -203,9 +196,6 @@ constexpr const gfx::Size kMinCocoaPopupWindowSize(100, 122);
// Return a weak pointer to the tab strip controller. // Return a weak pointer to the tab strip controller.
- (TabStripControllerCocoa*)tabStripController; - (TabStripControllerCocoa*)tabStripController;
// Access the C++ bridge object representing the status bubble for the window.
- (StatusBubbleMac*)statusBubble;
// Access the C++ bridge object representing the location bar. // Access the C++ bridge object representing the location bar.
- (LocationBarViewMac*)locationBarBridge; - (LocationBarViewMac*)locationBarBridge;
...@@ -284,9 +274,6 @@ constexpr const gfx::Size kMinCocoaPopupWindowSize(100, 122); ...@@ -284,9 +274,6 @@ constexpr const gfx::Size kMinCocoaPopupWindowSize(100, 122);
- (BOOL)handledByExtensionCommand:(NSEvent*)event - (BOOL)handledByExtensionCommand:(NSEvent*)event
priority:(ui::AcceleratorManager::HandlerPriority)priority; priority:(ui::AcceleratorManager::HandlerPriority)priority;
// Delegate method for the status bubble to query its base frame.
- (NSRect)statusBubbleBaseFrame;
// Dismiss the permission bubble // Dismiss the permission bubble
- (void)dismissPermissionBubble; - (void)dismissPermissionBubble;
......
...@@ -58,7 +58,6 @@ ...@@ -58,7 +58,6 @@
#include "chrome/browser/ui/cocoa/l10n_util.h" #include "chrome/browser/ui/cocoa/l10n_util.h"
#import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h" #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h"
#import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
#import "chrome/browser/ui/cocoa/status_bubble_mac.h"
#import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h" #import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h"
#import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h"
#import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h"
...@@ -347,9 +346,6 @@ bool IsTabDetachingInFullscreenEnabled() { ...@@ -347,9 +346,6 @@ bool IsTabDetachingInFullscreenEnabled() {
} }
} }
// Create the bridge for the status bubble.
statusBubble_ = new StatusBubbleMac([self window], self);
extensionKeybindingRegistry_.reset( extensionKeybindingRegistry_.reset(
new ExtensionKeybindingRegistryCocoa(browser_->profile(), new ExtensionKeybindingRegistryCocoa(browser_->profile(),
[self window], [self window],
...@@ -445,10 +441,6 @@ bool IsTabDetachingInFullscreenEnabled() { ...@@ -445,10 +441,6 @@ bool IsTabDetachingInFullscreenEnabled() {
return tabStripController_.get(); return tabStripController_.get();
} }
- (StatusBubbleMac*)statusBubble {
return statusBubble_;
}
- (LocationBarViewMac*)locationBarBridge { - (LocationBarViewMac*)locationBarBridge {
return [toolbarController_ locationBarBridge]; return [toolbarController_ locationBarBridge];
} }
...@@ -495,11 +487,6 @@ bool IsTabDetachingInFullscreenEnabled() { ...@@ -495,11 +487,6 @@ bool IsTabDetachingInFullscreenEnabled() {
DCHECK(browser_->tab_strip_model()->empty()); DCHECK(browser_->tab_strip_model()->empty());
[savedRegularWindow_ close]; [savedRegularWindow_ close];
// We delete statusBubble here because we need to kill off the dependency
// that its window has on our window before our window goes away.
delete statusBubble_;
statusBubble_ = NULL;
// We can't actually use |-autorelease| here because there's an embedded // We can't actually use |-autorelease| here because there's an embedded
// run loop in the |-performClose:| which contains its own autorelease pool. // run loop in the |-performClose:| which contains its own autorelease pool.
// Instead call it after a zero-length delay, which gets us back to the main // Instead call it after a zero-length delay, which gets us back to the main
...@@ -905,13 +892,6 @@ bool IsTabDetachingInFullscreenEnabled() { ...@@ -905,13 +892,6 @@ bool IsTabDetachingInFullscreenEnabled() {
content::NativeWebKeyboardEvent(event), priority); content::NativeWebKeyboardEvent(event), priority);
} }
// StatusBubble delegate method: tell the status bubble the frame it should
// position itself in.
- (NSRect)statusBubbleBaseFrame {
NSView* view = [overlayableContentsController_ view];
return [view convertRect:[view bounds] toView:nil];
}
- (void)updateToolbarWithContents:(WebContents*)tab { - (void)updateToolbarWithContents:(WebContents*)tab {
[toolbarController_ updateToolbarWithContents:tab]; [toolbarController_ updateToolbarWithContents:tab];
} }
...@@ -1404,13 +1384,6 @@ bool IsTabDetachingInFullscreenEnabled() { ...@@ -1404,13 +1384,6 @@ bool IsTabDetachingInFullscreenEnabled() {
// Delegate method called when window is resized. // Delegate method called when window is resized.
- (void)windowDidResize:(NSNotification*)notification { - (void)windowDidResize:(NSNotification*)notification {
[self saveWindowPositionIfNeeded]; [self saveWindowPositionIfNeeded];
// Resize (and possibly move) the status bubble. Note that we may get called
// when the status bubble does not exist.
if (statusBubble_) {
statusBubble_->UpdateSizeAndPosition();
}
[self updatePermissionBubbleAnchor]; [self updatePermissionBubbleAnchor];
} }
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#import "chrome/browser/ui/cocoa/fullscreen_window.h" #import "chrome/browser/ui/cocoa/fullscreen_window.h"
#include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h" #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h"
#include "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" #include "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
#import "chrome/browser/ui/cocoa/status_bubble_mac.h"
#import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h" #import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h"
#import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h"
#import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h"
...@@ -345,10 +344,6 @@ willPositionSheet:(NSWindow*)sheet ...@@ -345,10 +344,6 @@ willPositionSheet:(NSWindow*)sheet
[self setWindow:destWindow]; [self setWindow:destWindow];
[destWindow setWindowController:[self nsWindowController]]; [destWindow setWindowController:[self nsWindowController]];
// Move the status bubble over, if we have one.
if (statusBubble_)
statusBubble_->SwitchParentWindow(destWindow);
[self updatePermissionBubbleAnchor]; [self updatePermissionBubbleAnchor];
// Move the title over. // Move the title over.
......
// 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.
#ifndef CHROME_BROWSER_UI_COCOA_STATUS_BUBBLE_MAC_H_
#define CHROME_BROWSER_UI_COCOA_STATUS_BUBBLE_MAC_H_
#include <string>
#import <Cocoa/Cocoa.h>
#import <QuartzCore/QuartzCore.h>
#include <stdint.h>
#include "base/compiler_specific.h"
#include "base/mac/scoped_nsobject.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/string16.h"
#include "chrome/browser/ui/status_bubble.h"
#include "url/gurl.h"
namespace gfx {
class Point;
}
class StatusBubbleMacTest;
@class StatusBubbleWindow;
class StatusBubbleMac : public StatusBubble {
public:
// The various states that a status bubble may be in. Public for delegate
// access (for testing).
enum StatusBubbleState {
kBubbleHidden, // Fully hidden
kBubbleShowingTimer, // Waiting to fade in
kBubbleShowingFadeIn, // In a fade-in transition
kBubbleShown, // Fully visible
kBubbleHidingTimer, // Waiting to fade out
kBubbleHidingFadeOut // In a fade-out transition
};
StatusBubbleMac(NSWindow* parent, id delegate);
~StatusBubbleMac() override;
// StatusBubble implementation.
void SetStatus(const base::string16& status) override;
void SetURL(const GURL& url) override;
void Hide() override;
void MouseMoved(bool left_content) override;
void UpdateDownloadShelfVisibility(bool visible) override;
// Mac-specific method: Update the size and position of the status bubble to
// match the parent window. Safe to call even when the status bubble does not
// exist.
void UpdateSizeAndPosition();
// Mac-specific method: Change the parent window of the status bubble. Safe to
// call even when the status bubble does not exist.
void SwitchParentWindow(NSWindow* parent);
// Expand the bubble to fit a URL too long for the standard bubble size.
void ExpandBubble();
protected:
// Get the current location of the mouse. Protected so that it can be
// stubbed out for testing.
virtual gfx::Point GetMouseLocation();
// Notify mouse events with current mouse location. The location is (0,0) when
// mouse is at the bottom-left of the screen.
void MouseMovedAt(const gfx::Point& location, bool left_content);
private:
friend class StatusBubbleMacTest;
// Setter for state_. Use this instead of writing to state_ directly so
// that state changes can be observed by unit tests.
void SetState(StatusBubbleState state);
// Sets the bubble text for SetStatus and SetURL.
void SetText(const base::string16& text, bool is_url);
// Construct the window/widget if it does not already exist. (Safe to call if
// it does.)
void Create();
// Attaches the status bubble window to its parent window. Safe to call even
// when already attached.
void Attach();
// Detaches the status bubble window from its parent window.
void Detach();
// Is the status bubble attached to the browser window? It should be attached
// when shown and during any fades, but should be detached when hidden.
bool is_attached();
// Begins fading the status bubble window in or out depending on the value
// of |show|. This must be called from the appropriate fade state,
// kBubbleShowingFadeIn or kBubbleHidingFadeOut, or from the appropriate
// fully-shown/hidden state, kBubbleShown or kBubbleHidden. This may be
// called at any point during a fade-in or fade-out; it is even possible to
// reverse a transition before it has completed.
void Fade(bool show);
// Starts an animation of the bubble window to a specific alpha value over a
// specific period of time.
void AnimateWindowAlpha(CGFloat alpha, NSTimeInterval duration);
// Method called from the completion callbacks when a fade-in or fade-out
// transition has completed.
void AnimationDidStop();
// One-shot timer operations to manage the delays associated with the
// kBubbleShowingTimer and kBubbleHidingTimer states. StartTimer and
// TimerFired must be called from one of these states. StartTimer may be
// called while the timer is still running; in that case, the timer will be
// reset. CancelTimer may be called from any state.
void StartTimer(int64_t time_ms);
void CancelTimer();
void TimerFired();
// Begin the process of showing or hiding the status bubble. These may be
// called from any state, and will take the appropriate action to initiate
// any state changes that may be needed.
void StartShowing();
void StartHiding();
// Cancel the expansion timer.
void CancelExpandTimer();
// Sets the frame of the status bubble window to |window_frame|, adjusting
// for the given mouse position if necessary. Protected for use in tests.
void SetFrameAvoidingMouse(NSRect window_frame, const gfx::Point& mouse_pos);
// Calculate the appropriate frame for the status bubble window. If
// |expanded_width|, use entire width of parent frame.
NSRect CalculateWindowFrame(bool expanded_width);
// Returns the flags to be used to round the corners of the status bubble.
// Before 10.7, windows have square bottom corners, but in 10.7, the bottom
// corners are rounded. This method considers the bubble's placement (as
// proposed in window_frame) relative to its parent window in determining
// which flags to return. This function may choose to round any corner,
// including top corners. Note that there may be other reasons that a
// status bubble's corner may be rounded in addition to those dependent on
// OS version, and flags will be set or unset elsewhere to address these
// concerns.
unsigned long OSDependentCornerFlags(NSRect window_frame);
// Returns the status bubble window as an NSWindow. For use in tests.
NSWindow* GetWindow();
// The window we attach ourselves to.
NSWindow* parent_; // WEAK
// The object that we query about our vertical offset for positioning.
id delegate_; // WEAK
// The window we own.
base::scoped_nsobject<StatusBubbleWindow> window_;
// The status text we want to display when there are no URLs to display.
NSString* status_text_;
// The url we want to display when there is no status text to display.
NSString* url_text_;
// The status bubble's current state. Do not write to this field directly;
// use SetState().
StatusBubbleState state_;
// True if operations are to be performed immediately rather than waiting
// for delays and transitions. Normally false, this should only be set to
// true for testing.
bool immediate_;
// True if the status bubble has been expanded. If the bubble is in the
// expanded state and encounters a new URL, change size immediately,
// with no hover delay.
bool is_expanded_;
// The original, non-elided URL.
GURL url_;
// The factory used to generate weak pointers for the show and hide delay
// timers.
base::WeakPtrFactory<StatusBubbleMac> timer_factory_;
// The factory used to generate weak pointers for the expansion delay timer.
base::WeakPtrFactory<StatusBubbleMac> expand_timer_factory_;
// The factory used to generate weak pointers for the CAAnimation completion
// handlers.
base::WeakPtrFactory<StatusBubbleMac> completion_handler_factory_;
DISALLOW_COPY_AND_ASSIGN(StatusBubbleMac);
};
// Delegate interface
@interface NSObject(StatusBubbleDelegate)
// Called to query the delegate about the frame StatusBubble should position
// itself in. Frame is returned in the parent window coordinates.
- (NSRect)statusBubbleBaseFrame;
// Called from SetState to notify the delegate of state changes.
- (void)statusBubbleWillEnterState:(StatusBubbleMac::StatusBubbleState)state;
@end
#endif // CHROME_BROWSER_UI_COCOA_STATUS_BUBBLE_MAC_H_
This diff is collapsed.
This diff is collapsed.
...@@ -4169,7 +4169,6 @@ test("unit_tests") { ...@@ -4169,7 +4169,6 @@ test("unit_tests") {
"../browser/ui/cocoa/profiles/profile_menu_controller_unittest.mm", "../browser/ui/cocoa/profiles/profile_menu_controller_unittest.mm",
"../browser/ui/cocoa/scoped_menu_bar_lock_unittest.mm", "../browser/ui/cocoa/scoped_menu_bar_lock_unittest.mm",
"../browser/ui/cocoa/spinner_view_unittest.mm", "../browser/ui/cocoa/spinner_view_unittest.mm",
"../browser/ui/cocoa/status_bubble_mac_unittest.mm",
"../browser/ui/cocoa/status_icons/status_icon_mac_unittest.mm", "../browser/ui/cocoa/status_icons/status_icon_mac_unittest.mm",
"../browser/ui/cocoa/styled_text_field_cell_unittest.mm", "../browser/ui/cocoa/styled_text_field_cell_unittest.mm",
"../browser/ui/cocoa/styled_text_field_unittest.mm", "../browser/ui/cocoa/styled_text_field_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