diff options
-rw-r--r-- | chrome/app/nibs/BookmarkBubble.xib | 38 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_bubble_view.h | 11 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_bubble_window_unittest.mm | 25 | ||||
-rw-r--r-- | chrome/browser/cocoa/info_bubble_view.h | 21 | ||||
-rw-r--r-- | chrome/browser/cocoa/info_bubble_view.mm (renamed from chrome/browser/cocoa/bookmark_bubble_view.mm) | 35 | ||||
-rw-r--r-- | chrome/browser/cocoa/info_bubble_view_unittest.mm (renamed from chrome/browser/cocoa/bookmark_bubble_view_unittest.mm) | 14 | ||||
-rw-r--r-- | chrome/browser/cocoa/info_bubble_window.h (renamed from chrome/browser/cocoa/bookmark_bubble_window.h) | 5 | ||||
-rw-r--r-- | chrome/browser/cocoa/info_bubble_window.mm (renamed from chrome/browser/cocoa/bookmark_bubble_window.mm) | 10 | ||||
-rw-r--r-- | chrome/browser/cocoa/info_bubble_window_unittest.mm | 22 | ||||
-rwxr-xr-x | chrome/chrome.gyp | 12 |
10 files changed, 112 insertions, 81 deletions
diff --git a/chrome/app/nibs/BookmarkBubble.xib b/chrome/app/nibs/BookmarkBubble.xib index fab9030..e3f6c3c 100644 --- a/chrome/app/nibs/BookmarkBubble.xib +++ b/chrome/app/nibs/BookmarkBubble.xib @@ -12,7 +12,7 @@ </object> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="39"/> + <integer value="51"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -50,7 +50,7 @@ <string key="NSWindowRect">{{196, 365}, {374, 145}}</string> <int key="NSWTFlags">603979776</int> <string key="NSWindowTitle">Window</string> - <string key="NSWindowClass">BookmarkBubbleWindow</string> + <string key="NSWindowClass">InfoBubbleWindow</string> <nil key="NSViewClass"/> <string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string> <object class="NSView" key="NSWindowView" id="45997296"> @@ -347,7 +347,7 @@ </object> <string key="NSFrameSize">{374, 145}</string> <reference key="NSSuperview" ref="45997296"/> - <string key="NSClassName">BookmarkBubbleView</string> + <string key="NSClassName">InfoBubbleView</string> </object> </object> <string key="NSFrameSize">{374, 145}</string> @@ -854,22 +854,6 @@ </object> </object> <object class="IBPartialClassDescription"> - <string key="className">BookmarkBubbleView</string> - <string key="superclassName">NSView</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBProjectSource</string> - <string key="minorKey">browser/cocoa/bookmark_bubble_view.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">BookmarkBubbleWindow</string> - <string key="superclassName">NSWindow</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBProjectSource</string> - <string key="minorKey">browser/cocoa/bookmark_bubble_window.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> <string key="className">ChromeUILocalizer</string> <string key="superclassName">GTMUILocalizer</string> <object class="IBClassDescriptionSource" key="sourceIdentifier"> @@ -944,6 +928,22 @@ <reference key="sourceIdentifier" ref="1009161267"/> </object> <object class="IBPartialClassDescription"> + <string key="className">InfoBubbleView</string> + <string key="superclassName">NSView</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">browser/cocoa/info_bubble_view.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">InfoBubbleWindow</string> + <string key="superclassName">NSWindow</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">browser/cocoa/info_bubble_window.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> <string key="className">NSObject</string> <object class="IBClassDescriptionSource" key="sourceIdentifier"> <string key="majorKey">IBProjectSource</string> diff --git a/chrome/browser/cocoa/bookmark_bubble_view.h b/chrome/browser/cocoa/bookmark_bubble_view.h deleted file mode 100644 index 1e811a8..0000000 --- a/chrome/browser/cocoa/bookmark_bubble_view.h +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) 2009 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> - -// Content view for a Bookmark Bubble opened by clicking on the star -// toolbar button. This is where nonrectangular drawing happens. -@interface BookmarkBubbleView : NSView -@end - diff --git a/chrome/browser/cocoa/bookmark_bubble_window_unittest.mm b/chrome/browser/cocoa/bookmark_bubble_window_unittest.mm deleted file mode 100644 index bae4697..0000000 --- a/chrome/browser/cocoa/bookmark_bubble_window_unittest.mm +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2009 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 "base/scoped_ptr.h" -#include "chrome/browser/cocoa/cocoa_test_helper.h" -#include "chrome/browser/cocoa/bookmark_bubble_window.h" - -class BookmarkBubbleWindowTest : public CocoaTest { -}; - -TEST_F(BookmarkBubbleWindowTest, Basics) { - BookmarkBubbleWindow* window = - [[BookmarkBubbleWindow alloc] initWithContentRect:NSMakeRect(0, 0, 10, 10) - styleMask:NSBorderlessWindowMask - backing:NSBackingStoreBuffered - defer:NO]; - EXPECT_TRUE([window canBecomeKeyWindow]); - EXPECT_FALSE([window canBecomeMainWindow]); - - EXPECT_TRUE([window isExcludedFromWindowsMenu]); - [window close]; -} - - diff --git a/chrome/browser/cocoa/info_bubble_view.h b/chrome/browser/cocoa/info_bubble_view.h new file mode 100644 index 0000000..fc95bc9 --- /dev/null +++ b/chrome/browser/cocoa/info_bubble_view.h @@ -0,0 +1,21 @@ +// Copyright (c) 2009 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> + +enum BubbleArrowLocation { + kTopLeft, + kTopRight, +}; + +// Content view for a bubble with an arrow showing arbitrary content. +// This is where nonrectangular drawing happens. +@interface InfoBubbleView : NSView { + @private + BubbleArrowLocation arrowLocation_; +} + +@property (assign, nonatomic) BubbleArrowLocation arrowLocation; + +@end diff --git a/chrome/browser/cocoa/bookmark_bubble_view.mm b/chrome/browser/cocoa/info_bubble_view.mm index 18f589c..e8c288d 100644 --- a/chrome/browser/cocoa/bookmark_bubble_view.mm +++ b/chrome/browser/cocoa/info_bubble_view.mm @@ -2,18 +2,30 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#import "chrome/browser/cocoa/bookmark_bubble_view.h" +#import "chrome/browser/cocoa/info_bubble_view.h" + +#include "base/logging.h" #import "third_party/GTM/AppKit/GTMTheme.h" namespace { -// TODO(jrg): confirm constants with UI dudes +// TODO(andybons): confirm constants with UI dudes const CGFloat kBubbleCornerRadius = 8.0; const CGFloat kBubbleArrowXOffset = 10.0; const CGFloat kBubbleArrowWidth = 15.0; const CGFloat kBubbleArrowHeight = 8.0; } -@implementation BookmarkBubbleView +@implementation InfoBubbleView + +@synthesize arrowLocation = arrowLocation_; + +- (id)initWithFrame:(NSRect)frameRect { + if ((self = [super initWithFrame:frameRect])) { + arrowLocation_ = kTopLeft; + } + + return self; +} - (void)drawRect:(NSRect)rect { // Make room for the border to be seen. @@ -27,9 +39,21 @@ const CGFloat kBubbleArrowHeight = 8.0; xRadius:kBubbleCornerRadius yRadius:kBubbleCornerRadius]; - // Add the bubble arrow (pointed at the star). + // Add the bubble arrow. + CGFloat dX; + switch (arrowLocation_) { + case kTopLeft: + dX = kBubbleArrowXOffset; + break; + case kTopRight: + dX = NSWidth(bounds) - kBubbleArrowXOffset - kBubbleArrowWidth; + break; + default: + NOTREACHED(); + break; + } NSPoint arrowStart = NSMakePoint(NSMinX(bounds), NSMaxY(bounds)); - arrowStart.x += kBubbleArrowXOffset; + arrowStart.x += dX; [bezier moveToPoint:NSMakePoint(arrowStart.x, arrowStart.y)]; [bezier lineToPoint:NSMakePoint(arrowStart.x + kBubbleArrowWidth/2.0, arrowStart.y + kBubbleArrowHeight)]; @@ -45,4 +69,3 @@ const CGFloat kBubbleArrowHeight = 8.0; } @end - diff --git a/chrome/browser/cocoa/bookmark_bubble_view_unittest.mm b/chrome/browser/cocoa/info_bubble_view_unittest.mm index f9083f7..2f07c8b 100644 --- a/chrome/browser/cocoa/bookmark_bubble_view_unittest.mm +++ b/chrome/browser/cocoa/info_bubble_view_unittest.mm @@ -3,24 +3,24 @@ // found in the LICENSE file. #include "base/scoped_nsobject.h" -#import "chrome/browser/cocoa/bookmark_bubble_view.h" +#import "chrome/browser/cocoa/info_bubble_view.h" #import "chrome/browser/cocoa/cocoa_test_helper.h" namespace { -class BookmarkBubbleViewTest : public CocoaTest { +class InfoBubbleViewTest : public CocoaTest { public: - BookmarkBubbleViewTest() { + InfoBubbleViewTest() { NSRect frame = NSMakeRect(0, 0, 100, 30); - scoped_nsobject<BookmarkBubbleView> view( - [[BookmarkBubbleView alloc] initWithFrame:frame]); + scoped_nsobject<InfoBubbleView> view( + [[InfoBubbleView alloc] initWithFrame:frame]); view_ = view.get(); [[test_window() contentView] addSubview:view_]; } - BookmarkBubbleView* view_; + InfoBubbleView* view_; }; -TEST_VIEW(BookmarkBubbleViewTest, view_); +TEST_VIEW(InfoBubbleViewTest, view_); } // namespace diff --git a/chrome/browser/cocoa/bookmark_bubble_window.h b/chrome/browser/cocoa/info_bubble_window.h index 5e667ad..bd549d1 100644 --- a/chrome/browser/cocoa/bookmark_bubble_window.h +++ b/chrome/browser/cocoa/info_bubble_window.h @@ -4,6 +4,7 @@ #import <Cocoa/Cocoa.h> -// Window for the bookmark bubble that comes up when you click on "STAR". -@interface BookmarkBubbleWindow : NSWindow +// A rounded window with an arrow used for example when you click on the STAR +// button or that pops up within our first-run UI. +@interface InfoBubbleWindow : NSWindow @end diff --git a/chrome/browser/cocoa/bookmark_bubble_window.mm b/chrome/browser/cocoa/info_bubble_window.mm index 4b2e372..9941c62 100644 --- a/chrome/browser/cocoa/bookmark_bubble_window.mm +++ b/chrome/browser/cocoa/info_bubble_window.mm @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#import "chrome/browser/cocoa/bookmark_bubble_window.h" +#import "chrome/browser/cocoa/info_bubble_window.h" -@implementation BookmarkBubbleWindow +@implementation InfoBubbleWindow - (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle @@ -25,9 +25,9 @@ // According to // http://www.cocoabuilder.com/archive/message/cocoa/2006/6/19/165953, -// NSBorderlessWindowMask windows cannot become key or main. In our -// case, however, we don't want all of that behavior. (As an example, -// our bubble has buttons!) +// NSBorderlessWindowMask windows cannot become key or main. In our +// case, however, we don't want all of that behavior. As an example, +// our bubble could have buttons. - (BOOL)canBecomeKeyWindow { return YES; diff --git a/chrome/browser/cocoa/info_bubble_window_unittest.mm b/chrome/browser/cocoa/info_bubble_window_unittest.mm new file mode 100644 index 0000000..11a07fe --- /dev/null +++ b/chrome/browser/cocoa/info_bubble_window_unittest.mm @@ -0,0 +1,22 @@ +// Copyright (c) 2009 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 "base/scoped_ptr.h" +#include "chrome/browser/cocoa/cocoa_test_helper.h" +#include "chrome/browser/cocoa/info_bubble_window.h" + +class InfoBubbleWindowTest : public CocoaTest {}; + +TEST_F(InfoBubbleWindowTest, Basics) { + InfoBubbleWindow* window = + [[InfoBubbleWindow alloc] initWithContentRect:NSMakeRect(0, 0, 10, 10) + styleMask:NSBorderlessWindowMask + backing:NSBackingStoreBuffered + defer:NO]; + EXPECT_TRUE([window canBecomeKeyWindow]); + EXPECT_FALSE([window canBecomeMainWindow]); + + EXPECT_TRUE([window isExcludedFromWindowsMenu]); + [window close]; +} diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 938aec3..17fb8db 100755 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -1073,10 +1073,6 @@ 'browser/cocoa/bookmark_bar_toolbar_view.mm', 'browser/cocoa/bookmark_bubble_controller.h', 'browser/cocoa/bookmark_bubble_controller.mm', - 'browser/cocoa/bookmark_bubble_view.h', - 'browser/cocoa/bookmark_bubble_view.mm', - 'browser/cocoa/bookmark_bubble_window.h', - 'browser/cocoa/bookmark_bubble_window.mm', 'browser/cocoa/bookmark_button_cell.h', 'browser/cocoa/bookmark_button_cell.mm', 'browser/cocoa/bookmark_editor_base_controller.h', @@ -1185,6 +1181,10 @@ 'browser/cocoa/import_progress_dialog.mm', 'browser/cocoa/importer_lock_dialog.h', 'browser/cocoa/importer_lock_dialog.mm', + 'browser/cocoa/info_bubble_view.h', + 'browser/cocoa/info_bubble_view.mm', + 'browser/cocoa/info_bubble_window.h', + 'browser/cocoa/info_bubble_window.mm', 'browser/cocoa/infobar.h', 'browser/cocoa/infobar_container_controller.h', 'browser/cocoa/infobar_container_controller.mm', @@ -4558,8 +4558,6 @@ 'browser/cocoa/bookmark_bar_toolbar_view_unittest.mm', 'browser/cocoa/bookmark_bar_view_unittest.mm', 'browser/cocoa/bookmark_bubble_controller_unittest.mm', - 'browser/cocoa/bookmark_bubble_view_unittest.mm', - 'browser/cocoa/bookmark_bubble_window_unittest.mm', 'browser/cocoa/bookmark_button_cell_unittest.mm', 'browser/cocoa/bookmark_editor_base_controller_unittest.mm', 'browser/cocoa/bookmark_editor_controller_unittest.mm', @@ -4598,6 +4596,8 @@ 'browser/cocoa/fullscreen_window_unittest.mm', 'browser/cocoa/html_dialog_window_controller_unittest.mm', 'browser/cocoa/hung_renderer_controller_unittest.mm', + 'browser/cocoa/info_bubble_view_unittest.mm', + 'browser/cocoa/info_bubble_window_unittest.mm', 'browser/cocoa/infobar_container_controller_unittest.mm', 'browser/cocoa/infobar_controller_unittest.mm', 'browser/cocoa/infobar_gradient_view_unittest.mm', |