| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h" | 5 #include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 DISALLOW_COPY_AND_ASSIGN(UnsizedCombobox); | 64 DISALLOW_COPY_AND_ASSIGN(UnsizedCombobox); |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 } // namespace | 67 } // namespace |
| 68 | 68 |
| 69 BookmarkBubbleView* BookmarkBubbleView::bookmark_bubble_ = NULL; | 69 BookmarkBubbleView* BookmarkBubbleView::bookmark_bubble_ = NULL; |
| 70 | 70 |
| 71 // static | 71 // static |
| 72 void BookmarkBubbleView::ShowBubble( | 72 views::Widget* BookmarkBubbleView::ShowBubble( |
| 73 views::View* anchor_view, | 73 views::View* anchor_view, |
| 74 const gfx::Rect& anchor_rect, | 74 const gfx::Rect& anchor_rect, |
| 75 gfx::NativeView parent_window, | 75 gfx::NativeView parent_window, |
| 76 bookmarks::BookmarkBubbleObserver* observer, | 76 bookmarks::BookmarkBubbleObserver* observer, |
| 77 scoped_ptr<BubbleSyncPromoDelegate> delegate, | 77 scoped_ptr<BubbleSyncPromoDelegate> delegate, |
| 78 Profile* profile, | 78 Profile* profile, |
| 79 const GURL& url, | 79 const GURL& url, |
| 80 bool already_bookmarked) { | 80 bool already_bookmarked) { |
| 81 if (bookmark_bubble_) | 81 if (bookmark_bubble_) |
| 82 return; | 82 return nullptr; |
| 83 | 83 |
| 84 bookmark_bubble_ = | 84 bookmark_bubble_ = |
| 85 new BookmarkBubbleView(anchor_view, observer, std::move(delegate), | 85 new BookmarkBubbleView(anchor_view, observer, std::move(delegate), |
| 86 profile, url, !already_bookmarked); | 86 profile, url, !already_bookmarked); |
| 87 if (!anchor_view) { | 87 if (!anchor_view) { |
| 88 bookmark_bubble_->SetAnchorRect(anchor_rect); | 88 bookmark_bubble_->SetAnchorRect(anchor_rect); |
| 89 bookmark_bubble_->set_parent_window(parent_window); | 89 bookmark_bubble_->set_parent_window(parent_window); |
| 90 } | 90 } |
| 91 views::BubbleDelegateView::CreateBubble(bookmark_bubble_)->Show(); | 91 views::Widget* bubble_widget = |
| 92 views::BubbleDelegateView::CreateBubble(bookmark_bubble_); |
| 93 bubble_widget->Show(); |
| 92 // Select the entire title textfield contents when the bubble is first shown. | 94 // Select the entire title textfield contents when the bubble is first shown. |
| 93 bookmark_bubble_->title_tf_->SelectAll(true); | 95 bookmark_bubble_->title_tf_->SelectAll(true); |
| 94 bookmark_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); | 96 bookmark_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); |
| 95 | 97 |
| 96 if (bookmark_bubble_->observer_) { | 98 if (bookmark_bubble_->observer_) { |
| 97 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile); | 99 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile); |
| 98 const BookmarkNode* node = model->GetMostRecentlyAddedUserNodeForURL(url); | 100 const BookmarkNode* node = model->GetMostRecentlyAddedUserNodeForURL(url); |
| 99 bookmark_bubble_->observer_->OnBookmarkBubbleShown(node); | 101 bookmark_bubble_->observer_->OnBookmarkBubbleShown(node); |
| 100 } | 102 } |
| 103 return bubble_widget; |
| 101 } | 104 } |
| 102 | 105 |
| 103 void BookmarkBubbleView::Hide() { | 106 void BookmarkBubbleView::Hide() { |
| 104 if (bookmark_bubble_) | 107 if (bookmark_bubble_) |
| 105 bookmark_bubble_->GetWidget()->Close(); | 108 bookmark_bubble_->GetWidget()->Close(); |
| 106 } | 109 } |
| 107 | 110 |
| 108 BookmarkBubbleView::~BookmarkBubbleView() { | 111 BookmarkBubbleView::~BookmarkBubbleView() { |
| 109 if (apply_edits_) { | 112 if (apply_edits_) { |
| 110 ApplyEdits(); | 113 ApplyEdits(); |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 if (node) { | 389 if (node) { |
| 387 const base::string16 new_title = title_tf_->text(); | 390 const base::string16 new_title = title_tf_->text(); |
| 388 if (new_title != node->GetTitle()) { | 391 if (new_title != node->GetTitle()) { |
| 389 model->SetTitle(node, new_title); | 392 model->SetTitle(node, new_title); |
| 390 content::RecordAction( | 393 content::RecordAction( |
| 391 UserMetricsAction("BookmarkBubble_ChangeTitleInBubble")); | 394 UserMetricsAction("BookmarkBubble_ChangeTitleInBubble")); |
| 392 } | 395 } |
| 393 parent_model_.MaybeChangeParent(node, parent_combobox_->selected_index()); | 396 parent_model_.MaybeChangeParent(node, parent_combobox_->selected_index()); |
| 394 } | 397 } |
| 395 } | 398 } |
| OLD | NEW |