Chromium Code Reviews| Index: chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc |
| diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc |
| index 66aef8123fa940e9339716ccd73d747f37be0e05..40205b7fb705f7ce50ef327e071c804b4ea4323e 100644 |
| --- a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc |
| +++ b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc |
| @@ -9,10 +9,12 @@ |
| #include "base/strings/utf_string_conversions.h" |
| #include "chrome/app/chrome_command_ids.h" |
| #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| +#include "chrome/browser/platform_util.h" |
| #include "chrome/browser/profiles/profile.h" |
| +#include "chrome/browser/ui/bookmarks/bookmark_bubble_observer.h" |
| #include "chrome/browser/ui/bookmarks/bookmark_editor.h" |
| +#include "chrome/browser/ui/browser_dialogs.h" |
| #include "chrome/browser/ui/sync/sync_promo_ui.h" |
| -#include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view_observer.h" |
| #include "chrome/browser/ui/views/bookmarks/bookmark_sync_promo_view.h" |
| #include "chrome/grit/generated_resources.h" |
| #include "components/bookmarks/browser/bookmark_model.h" |
| @@ -63,7 +65,9 @@ BookmarkBubbleView* BookmarkBubbleView::bookmark_bubble_ = NULL; |
| // static |
| void BookmarkBubbleView::ShowBubble(views::View* anchor_view, |
| - BookmarkBubbleViewObserver* observer, |
| + const gfx::Rect& anchor_rect, |
| + gfx::NativeView parent_window, |
| + bookmarks::BookmarkBubbleObserver* observer, |
| scoped_ptr<BookmarkBubbleDelegate> delegate, |
| Profile* profile, |
| const GURL& url, |
| @@ -77,13 +81,20 @@ void BookmarkBubbleView::ShowBubble(views::View* anchor_view, |
| profile, |
| url, |
| newly_bookmarked); |
| + if (!anchor_view) { |
| + bookmark_bubble_->SetAnchorRect(anchor_rect); |
| + bookmark_bubble_->set_parent_window(parent_window); |
| + } |
| views::BubbleDelegateView::CreateBubble(bookmark_bubble_)->Show(); |
| // Select the entire title textfield contents when the bubble is first shown. |
| bookmark_bubble_->title_tf_->SelectAll(true); |
| bookmark_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); |
| - if (bookmark_bubble_->observer_) |
| - bookmark_bubble_->observer_->OnBookmarkBubbleShown(url); |
| + if (bookmark_bubble_->observer_) { |
| + BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile); |
| + const BookmarkNode* node = model->GetMostRecentlyAddedUserNodeForURL(url); |
| + bookmark_bubble_->observer_->OnBookmarkBubbleShown(node); |
| + } |
| } |
| void BookmarkBubbleView::Hide() { |
| @@ -264,7 +275,7 @@ views::View* BookmarkBubbleView::GetInitiallyFocusedView() { |
| BookmarkBubbleView::BookmarkBubbleView( |
| views::View* anchor_view, |
| - BookmarkBubbleViewObserver* observer, |
| + bookmarks::BookmarkBubbleObserver* observer, |
| scoped_ptr<BookmarkBubbleDelegate> delegate, |
| Profile* profile, |
| const GURL& url, |
| @@ -343,17 +354,19 @@ void BookmarkBubbleView::HandleButtonPressed(views::Button* sender) { |
| void BookmarkBubbleView::ShowEditor() { |
| const BookmarkNode* node = BookmarkModelFactory::GetForProfile( |
| profile_)->GetMostRecentlyAddedUserNodeForURL(url_); |
| - views::Widget* parent = anchor_widget(); |
| - DCHECK(parent); |
| + gfx::NativeWindow native_window = |
| + anchor_widget() ? anchor_widget()->GetNativeWindow() |
| + : platform_util::GetTopLevel(parent_window()); |
| + DCHECK(native_window); |
| Profile* profile = profile_; |
| ApplyEdits(); |
| GetWidget()->Close(); |
| - if (node && parent) |
| - BookmarkEditor::Show(parent->GetNativeWindow(), profile, |
| - BookmarkEditor::EditDetails::EditNode(node), |
| - BookmarkEditor::SHOW_TREE); |
| + if (node && native_window) |
| + chrome::ShowBookmarkEditorViews(native_window, profile, |
|
tapted
2015/08/21 07:19:18
leave this as BookmarkEditor::Show?
jackhou1
2015/08/24 08:22:04
Done.
|
| + BookmarkEditor::EditDetails::EditNode(node), |
| + BookmarkEditor::SHOW_TREE); |
| } |
| void BookmarkBubbleView::ApplyEdits() { |