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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 } // namespace | 63 } // namespace |
64 | 64 |
65 BookmarkBubbleView* BookmarkBubbleView::bookmark_bubble_ = NULL; | 65 BookmarkBubbleView* BookmarkBubbleView::bookmark_bubble_ = NULL; |
66 | 66 |
67 // static | 67 // static |
68 views::Widget* BookmarkBubbleView::ShowBubble( | 68 views::Widget* BookmarkBubbleView::ShowBubble( |
69 views::View* anchor_view, | 69 views::View* anchor_view, |
70 const gfx::Rect& anchor_rect, | 70 const gfx::Rect& anchor_rect, |
71 gfx::NativeView parent_window, | 71 gfx::NativeView parent_window, |
72 bookmarks::BookmarkBubbleObserver* observer, | 72 bookmarks::BookmarkBubbleObserver* observer, |
73 scoped_ptr<BubbleSyncPromoDelegate> delegate, | 73 std::unique_ptr<BubbleSyncPromoDelegate> delegate, |
74 Profile* profile, | 74 Profile* profile, |
75 const GURL& url, | 75 const GURL& url, |
76 bool already_bookmarked) { | 76 bool already_bookmarked) { |
77 if (bookmark_bubble_) | 77 if (bookmark_bubble_) |
78 return nullptr; | 78 return nullptr; |
79 | 79 |
80 bookmark_bubble_ = | 80 bookmark_bubble_ = |
81 new BookmarkBubbleView(anchor_view, observer, std::move(delegate), | 81 new BookmarkBubbleView(anchor_view, observer, std::move(delegate), |
82 profile, url, !already_bookmarked); | 82 profile, url, !already_bookmarked); |
83 if (!anchor_view) { | 83 if (!anchor_view) { |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 content::RecordAction( | 246 content::RecordAction( |
247 base::UserMetricsAction("Signin_Impression_FromBookmarkBubble")); | 247 base::UserMetricsAction("Signin_Impression_FromBookmarkBubble")); |
248 | 248 |
249 return new BubbleSyncPromoView(delegate_.get(), IDS_BOOKMARK_SYNC_PROMO_LINK, | 249 return new BubbleSyncPromoView(delegate_.get(), IDS_BOOKMARK_SYNC_PROMO_LINK, |
250 IDS_BOOKMARK_SYNC_PROMO_MESSAGE); | 250 IDS_BOOKMARK_SYNC_PROMO_MESSAGE); |
251 } | 251 } |
252 | 252 |
253 BookmarkBubbleView::BookmarkBubbleView( | 253 BookmarkBubbleView::BookmarkBubbleView( |
254 views::View* anchor_view, | 254 views::View* anchor_view, |
255 bookmarks::BookmarkBubbleObserver* observer, | 255 bookmarks::BookmarkBubbleObserver* observer, |
256 scoped_ptr<BubbleSyncPromoDelegate> delegate, | 256 std::unique_ptr<BubbleSyncPromoDelegate> delegate, |
257 Profile* profile, | 257 Profile* profile, |
258 const GURL& url, | 258 const GURL& url, |
259 bool newly_bookmarked) | 259 bool newly_bookmarked) |
260 : LocationBarBubbleDelegateView(anchor_view, nullptr), | 260 : LocationBarBubbleDelegateView(anchor_view, nullptr), |
261 observer_(observer), | 261 observer_(observer), |
262 delegate_(std::move(delegate)), | 262 delegate_(std::move(delegate)), |
263 profile_(profile), | 263 profile_(profile), |
264 url_(url), | 264 url_(url), |
265 newly_bookmarked_(newly_bookmarked), | 265 newly_bookmarked_(newly_bookmarked), |
266 parent_model_(BookmarkModelFactory::GetForProfile(profile_), | 266 parent_model_(BookmarkModelFactory::GetForProfile(profile_), |
267 BookmarkModelFactory::GetForProfile(profile_) | 267 BookmarkModelFactory::GetForProfile(profile_) |
268 ->GetMostRecentlyAddedUserNodeForURL(url)), | 268 ->GetMostRecentlyAddedUserNodeForURL(url)), |
269 remove_button_(NULL), | 269 remove_button_(NULL), |
270 edit_button_(NULL), | 270 edit_button_(NULL), |
271 close_button_(NULL), | 271 close_button_(NULL), |
272 title_tf_(NULL), | 272 title_tf_(NULL), |
273 parent_combobox_(NULL), | 273 parent_combobox_(NULL), |
274 remove_bookmark_(false), | 274 remove_bookmark_(false), |
275 apply_edits_(true) { | 275 apply_edits_(true) {} |
276 } | |
277 | 276 |
278 base::string16 BookmarkBubbleView::GetTitle() { | 277 base::string16 BookmarkBubbleView::GetTitle() { |
279 BookmarkModel* bookmark_model = | 278 BookmarkModel* bookmark_model = |
280 BookmarkModelFactory::GetForProfile(profile_); | 279 BookmarkModelFactory::GetForProfile(profile_); |
281 const BookmarkNode* node = | 280 const BookmarkNode* node = |
282 bookmark_model->GetMostRecentlyAddedUserNodeForURL(url_); | 281 bookmark_model->GetMostRecentlyAddedUserNodeForURL(url_); |
283 if (node) | 282 if (node) |
284 return node->GetTitle(); | 283 return node->GetTitle(); |
285 else | 284 else |
286 NOTREACHED(); | 285 NOTREACHED(); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 if (node) { | 349 if (node) { |
351 const base::string16 new_title = title_tf_->text(); | 350 const base::string16 new_title = title_tf_->text(); |
352 if (new_title != node->GetTitle()) { | 351 if (new_title != node->GetTitle()) { |
353 model->SetTitle(node, new_title); | 352 model->SetTitle(node, new_title); |
354 content::RecordAction( | 353 content::RecordAction( |
355 UserMetricsAction("BookmarkBubble_ChangeTitleInBubble")); | 354 UserMetricsAction("BookmarkBubble_ChangeTitleInBubble")); |
356 } | 355 } |
357 parent_model_.MaybeChangeParent(node, parent_combobox_->selected_index()); | 356 parent_model_.MaybeChangeParent(node, parent_combobox_->selected_index()); |
358 } | 357 } |
359 } | 358 } |
OLD | NEW |