| Index: chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_controller.mm
|
| diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_controller.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_controller.mm
|
| index 2fed9b9645ee72677b6a86613e97b982fb1a75a1..bb5ad282e06ccb1add4d0245581aa169e29272c7 100644
|
| --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_controller.mm
|
| +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_controller.mm
|
| @@ -6,7 +6,9 @@
|
|
|
| #include "base/mac/bundle_locations.h"
|
| #include "base/strings/sys_string_conversions.h"
|
| +#include "chrome/browser/ui/bookmarks/bookmark_bubble_observer.h"
|
| #include "chrome/browser/ui/browser.h"
|
| +#include "chrome/browser/ui/browser_dialogs.h"
|
| #include "chrome/browser/ui/browser_finder.h"
|
| #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h"
|
| #import "chrome/browser/ui/cocoa/bookmarks/bookmark_sync_promo_controller.h"
|
| @@ -22,11 +24,35 @@
|
| #include "content/public/browser/notification_service.h"
|
| #include "content/public/browser/user_metrics.h"
|
| #include "ui/base/l10n/l10n_util_mac.h"
|
| +#import "ui/gfx/mac/coordinate_conversion.h"
|
|
|
| using base::UserMetricsAction;
|
| using bookmarks::BookmarkModel;
|
| using bookmarks::BookmarkNode;
|
|
|
| +namespace {
|
| +
|
| +// Closes the BookmarkBubbleController when the toolkit-views bubble closes.
|
| +class CocoaViewsBookmarkBubbleObserver
|
| + : public bookmarks::BookmarkBubbleObserver {
|
| + public:
|
| + explicit CocoaViewsBookmarkBubbleObserver(
|
| + BookmarkBubbleController* controller)
|
| + : controller_(controller) {}
|
| + ~CocoaViewsBookmarkBubbleObserver() override {}
|
| +
|
| + // bookmarks::BookmarkBubbleObserver.
|
| + void OnBookmarkBubbleShown(const GURL& url) override {}
|
| + void OnBookmarkBubbleHidden() override { [controller_ close]; }
|
| +
|
| + private:
|
| + BookmarkBubbleController* controller_; // Weak, owns us.
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(CocoaViewsBookmarkBubbleObserver);
|
| +};
|
| +
|
| +} // namespace
|
| +
|
| // An object to represent the ChooseAnotherFolder item in the pop up.
|
| @interface ChooseAnotherFolder : NSObject
|
| @end
|
| @@ -184,9 +210,8 @@ using bookmarks::BookmarkNode;
|
| arrowTip = [parentWindow convertBaseToScreen:arrowTip];
|
| NSPoint bubbleArrowTip = [bubble arrowTip];
|
| bubbleArrowTip = [bubble convertPoint:bubbleArrowTip toView:nil];
|
| - arrowTip.y -= bubbleArrowTip.y;
|
| - arrowTip.x -= bubbleArrowTip.x;
|
| - [window setFrameOrigin:arrowTip];
|
| + [window setFrameOrigin:NSMakePoint(arrowTip.x - bubbleArrowTip.x,
|
| + arrowTip.y - bubbleArrowTip.y)];
|
|
|
| // Default is IDS_BOOKMARK_BUBBLE_PAGE_BOOKMARK; "Bookmark".
|
| // If adding for the 1st time the string becomes "Bookmark Added!"
|
| @@ -215,6 +240,17 @@ using bookmarks::BookmarkNode;
|
| // Pulse something interesting on the bookmark bar.
|
| [self startPulsingBookmarkButton:node_];
|
|
|
| + if (chrome::ToolkitViewsDialogsEnabled()) {
|
| + if (!bookmarkBubbleObserver_.get())
|
| + bookmarkBubbleObserver_.reset(new CocoaViewsBookmarkBubbleObserver(self));
|
| + chrome::ShowBookmarkBubbleViewsAtPoint(
|
| + gfx::ScreenPointFromNSPoint(arrowTip), [parentWindow contentView],
|
| + bookmarkBubbleObserver_.get(),
|
| + chrome::FindBrowserWithWindow(parentWindow), node_->url(),
|
| + alreadyBookmarked_);
|
| + return;
|
| + }
|
| +
|
| [parentWindow addChildWindow:window ordered:NSWindowAbove];
|
| [window makeKeyAndOrderFront:self];
|
| [self registerKeyStateEventTap];
|
|
|