summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpaul@chromium.org <paul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-21 17:34:23 +0000
committerpaul@chromium.org <paul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-21 17:34:23 +0000
commit9b032bfa866097c14d7dcd3a6552795ee4ea2b0f (patch)
tree2ad6260c64ef8730fc69952cde4d632ed9e363df
parent6a7374568948adc4a24c64539411b3b272e01231 (diff)
downloadchromium_src-9b032bfa866097c14d7dcd3a6552795ee4ea2b0f.zip
chromium_src-9b032bfa866097c14d7dcd3a6552795ee4ea2b0f.tar.gz
chromium_src-9b032bfa866097c14d7dcd3a6552795ee4ea2b0f.tar.bz2
Fix for the URL status bubble overlapping the download shelf.
BUG=14662 (http://crbug.com/14662) TEST=Download something so that the shelf is visible and make sure that hovering over links on the page produce a status bubble above the download shelf. Review URL: http://codereview.chromium.org/155706 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21185 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser.cc5
-rw-r--r--chrome/browser/cocoa/browser_window_controller.h3
-rw-r--r--chrome/browser/cocoa/browser_window_controller.mm14
-rw-r--r--chrome/browser/cocoa/download_shelf_controller.h7
-rw-r--r--chrome/browser/cocoa/download_shelf_controller.mm12
-rw-r--r--chrome/browser/cocoa/download_shelf_mac.h2
-rw-r--r--chrome/browser/cocoa/download_shelf_mac.mm3
-rw-r--r--chrome/browser/cocoa/status_bubble_mac.h15
-rw-r--r--chrome/browser/cocoa/status_bubble_mac.mm18
-rw-r--r--chrome/browser/cocoa/status_bubble_mac_unittest.mm6
10 files changed, 70 insertions, 15 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 533be3f..e248920 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -1875,7 +1875,8 @@ void Browser::UpdateTargetURL(TabContents* source, const GURL& url) {
}
void Browser::UpdateDownloadShelfVisibility(bool visible) {
- GetStatusBubble()->UpdateDownloadShelfVisibility(visible);
+ if (GetStatusBubble())
+ GetStatusBubble()->UpdateDownloadShelfVisibility(visible);
}
void Browser::ContentsZoomChange(bool zoom_in) {
@@ -2410,7 +2411,7 @@ void Browser::RemoveScheduledUpdatesFor(TabContents* contents) {
// Browser, Getters for UI (private):
StatusBubble* Browser::GetStatusBubble() {
- return window_->GetStatusBubble();
+ return window_ ? window_->GetStatusBubble() : NULL;
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/cocoa/browser_window_controller.h b/chrome/browser/cocoa/browser_window_controller.h
index 104742c..39fee3a 100644
--- a/chrome/browser/cocoa/browser_window_controller.h
+++ b/chrome/browser/cocoa/browser_window_controller.h
@@ -136,6 +136,9 @@ class TabStripModelObserverBridge;
// "chrome/app/chrome_dll_resource.h" file.
- (void)executeCommand:(int)command;
+// Delegate method for the status bubble to query about its vertical offset.
+- (float)verticalOffsetForStatusBubble;
+
@end
diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm
index c2c88f9..f016420 100644
--- a/chrome/browser/cocoa/browser_window_controller.mm
+++ b/chrome/browser/cocoa/browser_window_controller.mm
@@ -204,7 +204,7 @@ willPositionSheet:(NSWindow*)sheet
object:[self tabContentArea]];
// Create the bridge for the status bubble.
- statusBubble_.reset(new StatusBubbleMac([self window]));
+ statusBubble_.reset(new StatusBubbleMac([self window], self));
#if 0
// Move all buttons down two pixels for visual balance.
@@ -440,6 +440,18 @@ willPositionSheet:(NSWindow*)sheet
browser_->ExecuteCommand(command);
}
+// StatusBubble delegate method: tell the status bubble how far above the bottom
+// of the window it should position itself.
+- (float)verticalOffsetForStatusBubble {
+ float offset = 0.0;
+
+ // Don't create a download shelf if there isn't one.
+ if (downloadShelfController_.get() && [[self downloadShelf] isVisible])
+ offset += [[self downloadShelf] height];
+
+ return offset;
+}
+
- (LocationBar*)locationBar {
return [toolbarController_ locationBar];
}
diff --git a/chrome/browser/cocoa/download_shelf_controller.h b/chrome/browser/cocoa/download_shelf_controller.h
index ff4cedc..f598d5c 100644
--- a/chrome/browser/cocoa/download_shelf_controller.h
+++ b/chrome/browser/cocoa/download_shelf_controller.h
@@ -28,7 +28,7 @@ class DownloadShelf;
scoped_ptr<DownloadShelf> bridge_;
NSView* contentArea_;
- int shelfHeight_;
+ float shelfHeight_;
// The download items we have added to our shelf.
scoped_nsobject<NSMutableArray> downloadItemControllers_;
@@ -40,6 +40,8 @@ class DownloadShelf;
- (BOOL)isVisible;
- (IBAction)show:(id)sender;
+
+// Run when the user clicks the close button on the right side of the shelf.
- (IBAction)hide:(id)sender;
- (void)addDownloadItem:(BaseDownloadItemModel*)model;
@@ -53,4 +55,7 @@ class DownloadShelf;
// Notification that we are closing and should release our downloads.
- (void)exiting;
+// Return the height of the download shelf.
+- (float)height;
+
@end
diff --git a/chrome/browser/cocoa/download_shelf_controller.mm b/chrome/browser/cocoa/download_shelf_controller.mm
index 0256ccd..896b72e 100644
--- a/chrome/browser/cocoa/download_shelf_controller.mm
+++ b/chrome/browser/cocoa/download_shelf_controller.mm
@@ -177,7 +177,17 @@ const int kDownloadItemPadding = 10;
}
- (void)hide:(id)sender {
- [self showDownloadShelf:NO];
+ // If |sender| isn't nil, then we're being closed from the UI by the user and
+ // we need to tell our shelf implementation to close. Otherwise, we're being
+ // closed programmatically by our shelf implementation.
+ if (sender)
+ bridge_->Close();
+ else
+ [self showDownloadShelf:NO];
+}
+
+- (float)height {
+ return shelfHeight_;
}
- (void)addDownloadItem:(BaseDownloadItemModel*)model {
diff --git a/chrome/browser/cocoa/download_shelf_mac.h b/chrome/browser/cocoa/download_shelf_mac.h
index 5b45e37..2e09988 100644
--- a/chrome/browser/cocoa/download_shelf_mac.h
+++ b/chrome/browser/cocoa/download_shelf_mac.h
@@ -25,7 +25,7 @@ class DownloadItemMac;
class DownloadShelfMac : public DownloadShelf {
public:
explicit DownloadShelfMac(Browser* browser,
- DownloadShelfController* controller);
+ DownloadShelfController* controller);
// DownloadShelf implementation.
virtual void AddDownload(BaseDownloadItemModel* download_model);
diff --git a/chrome/browser/cocoa/download_shelf_mac.mm b/chrome/browser/cocoa/download_shelf_mac.mm
index 0323ff1..c415dc3 100644
--- a/chrome/browser/cocoa/download_shelf_mac.mm
+++ b/chrome/browser/cocoa/download_shelf_mac.mm
@@ -4,6 +4,7 @@
#include "chrome/browser/cocoa/download_shelf_mac.h"
+#include "chrome/browser/browser.h"
#import "chrome/browser/cocoa/download_shelf_controller.h"
#include "chrome/browser/cocoa/download_item_mac.h"
#include "chrome/browser/download/download_item_model.h"
@@ -31,8 +32,10 @@ bool DownloadShelfMac::IsClosing() const {
void DownloadShelfMac::Show() {
[shelf_controller_ show:nil];
+ browser_->UpdateDownloadShelfVisibility(true);
}
void DownloadShelfMac::Close() {
[shelf_controller_ hide:nil];
+ browser_->UpdateDownloadShelfVisibility(false);
}
diff --git a/chrome/browser/cocoa/status_bubble_mac.h b/chrome/browser/cocoa/status_bubble_mac.h
index b6843c0..54899c2 100644
--- a/chrome/browser/cocoa/status_bubble_mac.h
+++ b/chrome/browser/cocoa/status_bubble_mac.h
@@ -16,7 +16,7 @@ class StatusBubbleMacTest;
class StatusBubbleMac : public StatusBubble {
public:
- StatusBubbleMac(NSWindow* parent);
+ StatusBubbleMac(NSWindow* parent, id delegate);
virtual ~StatusBubbleMac();
// StatusBubble implementation.
@@ -41,6 +41,9 @@ class StatusBubbleMac : public StatusBubble {
// 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.
NSWindow* window_;
@@ -52,6 +55,16 @@ class StatusBubbleMac : public StatusBubble {
// How vertically offset the bubble is from its root position.
int offset_;
+
+ // Is the download shelf visible.
+ bool is_download_shelf_visible_;
};
+// Delegate interface that allows the StatusBubble to query its delegate about
+// the vertical offset (if any) that should be applied to the StatusBubble's
+// position.
+@interface NSObject(StatusBubbleDelegate)
+- (float)verticalOffsetForStatusBubble;
+@end
+
#endif // #ifndef CHROME_BROWSER_COCOA_STATUS_BUBBLE_MAC_H_
diff --git a/chrome/browser/cocoa/status_bubble_mac.mm b/chrome/browser/cocoa/status_bubble_mac.mm
index 160b086..67b920b 100644
--- a/chrome/browser/cocoa/status_bubble_mac.mm
+++ b/chrome/browser/cocoa/status_bubble_mac.mm
@@ -56,11 +56,13 @@ enum BubbleStyle {
- (NSFont*)font;
@end
-StatusBubbleMac::StatusBubbleMac(NSWindow* parent)
+StatusBubbleMac::StatusBubbleMac(NSWindow* parent, id delegate)
: parent_(parent),
+ delegate_(delegate),
window_(nil),
status_text_(nil),
- url_text_(nil) {
+ url_text_(nil),
+ is_download_shelf_visible_(false) {
}
StatusBubbleMac::~StatusBubbleMac() {
@@ -180,16 +182,22 @@ void StatusBubbleMac::MouseMoved() {
offset_ = offset;
window_frame.origin.y -= offset;
- [window_ setFrame:window_frame display:YES];
} else {
offset_ = 0;
[[window_ contentView] setStyle:STYLE_STANDARD];
- [window_ setFrame:window_frame display:YES];
}
+
+ // |delegate_| can be nil during unit tests.
+ if (is_download_shelf_visible_) {
+ if ([delegate_ respondsToSelector:@selector(verticalOffsetForStatusBubble)])
+ window_frame.origin.y += [delegate_ verticalOffsetForStatusBubble];
+ }
+
+ [window_ setFrame:window_frame display:YES];
}
void StatusBubbleMac::UpdateDownloadShelfVisibility(bool visible) {
- NOTIMPLEMENTED();
+ is_download_shelf_visible_ = visible;
}
void StatusBubbleMac::Create() {
diff --git a/chrome/browser/cocoa/status_bubble_mac_unittest.mm b/chrome/browser/cocoa/status_bubble_mac_unittest.mm
index 9f59148..b0fa87b 100644
--- a/chrome/browser/cocoa/status_bubble_mac_unittest.mm
+++ b/chrome/browser/cocoa/status_bubble_mac_unittest.mm
@@ -15,7 +15,7 @@ class StatusBubbleMacTest : public testing::Test {
public:
StatusBubbleMacTest() {
NSWindow* window = cocoa_helper_.window();
- bubble_.reset(new StatusBubbleMac(window));
+ bubble_.reset(new StatusBubbleMac(window, nil));
EXPECT_TRUE(bubble_.get());
EXPECT_FALSE(bubble_->window_); // lazily creates window
}
@@ -87,11 +87,11 @@ TEST_F(StatusBubbleMacTest, MouseMove) {
TEST_F(StatusBubbleMacTest, Delete) {
NSWindow* window = cocoa_helper_.window();
// Create and delete immediately.
- StatusBubbleMac* bubble = new StatusBubbleMac(window);
+ StatusBubbleMac* bubble = new StatusBubbleMac(window, nil);
delete bubble;
// Create then delete while visible.
- bubble = new StatusBubbleMac(window);
+ bubble = new StatusBubbleMac(window, nil);
bubble->SetStatus(L"showing");
delete bubble;
}