| 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 "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
| 11 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 11 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/ui/bookmarks/bookmark_bubble_observer.h" |
| 13 #include "chrome/browser/ui/bookmarks/bookmark_editor.h" | 14 #include "chrome/browser/ui/bookmarks/bookmark_editor.h" |
| 14 #include "chrome/browser/ui/sync/sync_promo_ui.h" | 15 #include "chrome/browser/ui/sync/sync_promo_ui.h" |
| 15 #include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view_observer.h" | |
| 16 #include "chrome/browser/ui/views/bookmarks/bookmark_sync_promo_view.h" | 16 #include "chrome/browser/ui/views/bookmarks/bookmark_sync_promo_view.h" |
| 17 #include "chrome/grit/generated_resources.h" | 17 #include "chrome/grit/generated_resources.h" |
| 18 #include "components/bookmarks/browser/bookmark_model.h" | 18 #include "components/bookmarks/browser/bookmark_model.h" |
| 19 #include "components/bookmarks/browser/bookmark_utils.h" | 19 #include "components/bookmarks/browser/bookmark_utils.h" |
| 20 #include "content/public/browser/user_metrics.h" | 20 #include "content/public/browser/user_metrics.h" |
| 21 #include "ui/accessibility/ax_view_state.h" | 21 #include "ui/accessibility/ax_view_state.h" |
| 22 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
| 23 #include "ui/base/resource/resource_bundle.h" | 23 #include "ui/base/resource/resource_bundle.h" |
| 24 #include "ui/events/keycodes/keyboard_codes.h" | 24 #include "ui/events/keycodes/keyboard_codes.h" |
| 25 #include "ui/views/bubble/bubble_frame_view.h" | 25 #include "ui/views/bubble/bubble_frame_view.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 56 private: | 56 private: |
| 57 DISALLOW_COPY_AND_ASSIGN(UnsizedCombobox); | 57 DISALLOW_COPY_AND_ASSIGN(UnsizedCombobox); |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 } // namespace | 60 } // namespace |
| 61 | 61 |
| 62 BookmarkBubbleView* BookmarkBubbleView::bookmark_bubble_ = NULL; | 62 BookmarkBubbleView* BookmarkBubbleView::bookmark_bubble_ = NULL; |
| 63 | 63 |
| 64 // static | 64 // static |
| 65 void BookmarkBubbleView::ShowBubble(views::View* anchor_view, | 65 void BookmarkBubbleView::ShowBubble(views::View* anchor_view, |
| 66 BookmarkBubbleViewObserver* observer, | 66 bookmarks::BookmarkBubbleObserver* observer, |
| 67 scoped_ptr<BookmarkBubbleDelegate> delegate, | 67 scoped_ptr<BookmarkBubbleDelegate> delegate, |
| 68 Profile* profile, | 68 Profile* profile, |
| 69 const GURL& url, | 69 const GURL& url, |
| 70 bool newly_bookmarked) { | 70 bool newly_bookmarked) { |
| 71 if (bookmark_bubble_) | 71 if (bookmark_bubble_) |
| 72 return; | 72 return; |
| 73 | 73 |
| 74 bookmark_bubble_ = new BookmarkBubbleView(anchor_view, | 74 bookmark_bubble_ = new BookmarkBubbleView(anchor_view, |
| 75 observer, | 75 observer, |
| 76 delegate.Pass(), | 76 delegate.Pass(), |
| 77 profile, | 77 profile, |
| 78 url, | 78 url, |
| 79 newly_bookmarked); | 79 newly_bookmarked); |
| 80 views::BubbleDelegateView::CreateBubble(bookmark_bubble_)->Show(); | 80 views::BubbleDelegateView::CreateBubble(bookmark_bubble_)->Show(); |
| 81 // Select the entire title textfield contents when the bubble is first shown. | 81 // Select the entire title textfield contents when the bubble is first shown. |
| 82 bookmark_bubble_->title_tf_->SelectAll(true); | 82 bookmark_bubble_->title_tf_->SelectAll(true); |
| 83 bookmark_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); | 83 bookmark_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); |
| 84 | 84 |
| 85 if (bookmark_bubble_->observer_) | 85 if (bookmark_bubble_->observer_) { |
| 86 bookmark_bubble_->observer_->OnBookmarkBubbleShown(url); | 86 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile); |
| 87 const BookmarkNode* node = model->GetMostRecentlyAddedUserNodeForURL(url); |
| 88 bookmark_bubble_->observer_->OnBookmarkBubbleShown(node); |
| 89 } |
| 87 } | 90 } |
| 88 | 91 |
| 89 void BookmarkBubbleView::Hide() { | 92 void BookmarkBubbleView::Hide() { |
| 90 if (bookmark_bubble_) | 93 if (bookmark_bubble_) |
| 91 bookmark_bubble_->GetWidget()->Close(); | 94 bookmark_bubble_->GetWidget()->Close(); |
| 92 } | 95 } |
| 93 | 96 |
| 94 BookmarkBubbleView::~BookmarkBubbleView() { | 97 BookmarkBubbleView::~BookmarkBubbleView() { |
| 95 if (apply_edits_) { | 98 if (apply_edits_) { |
| 96 ApplyEdits(); | 99 ApplyEdits(); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 const char* BookmarkBubbleView::GetClassName() const { | 260 const char* BookmarkBubbleView::GetClassName() const { |
| 258 return "BookmarkBubbleView"; | 261 return "BookmarkBubbleView"; |
| 259 } | 262 } |
| 260 | 263 |
| 261 views::View* BookmarkBubbleView::GetInitiallyFocusedView() { | 264 views::View* BookmarkBubbleView::GetInitiallyFocusedView() { |
| 262 return title_tf_; | 265 return title_tf_; |
| 263 } | 266 } |
| 264 | 267 |
| 265 BookmarkBubbleView::BookmarkBubbleView( | 268 BookmarkBubbleView::BookmarkBubbleView( |
| 266 views::View* anchor_view, | 269 views::View* anchor_view, |
| 267 BookmarkBubbleViewObserver* observer, | 270 bookmarks::BookmarkBubbleObserver* observer, |
| 268 scoped_ptr<BookmarkBubbleDelegate> delegate, | 271 scoped_ptr<BookmarkBubbleDelegate> delegate, |
| 269 Profile* profile, | 272 Profile* profile, |
| 270 const GURL& url, | 273 const GURL& url, |
| 271 bool newly_bookmarked) | 274 bool newly_bookmarked) |
| 272 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), | 275 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), |
| 273 observer_(observer), | 276 observer_(observer), |
| 274 delegate_(delegate.Pass()), | 277 delegate_(delegate.Pass()), |
| 275 profile_(profile), | 278 profile_(profile), |
| 276 url_(url), | 279 url_(url), |
| 277 newly_bookmarked_(newly_bookmarked), | 280 newly_bookmarked_(newly_bookmarked), |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 if (node) { | 368 if (node) { |
| 366 const base::string16 new_title = title_tf_->text(); | 369 const base::string16 new_title = title_tf_->text(); |
| 367 if (new_title != node->GetTitle()) { | 370 if (new_title != node->GetTitle()) { |
| 368 model->SetTitle(node, new_title); | 371 model->SetTitle(node, new_title); |
| 369 content::RecordAction( | 372 content::RecordAction( |
| 370 UserMetricsAction("BookmarkBubble_ChangeTitleInBubble")); | 373 UserMetricsAction("BookmarkBubble_ChangeTitleInBubble")); |
| 371 } | 374 } |
| 372 parent_model_.MaybeChangeParent(node, parent_combobox_->selected_index()); | 375 parent_model_.MaybeChangeParent(node, parent_combobox_->selected_index()); |
| 373 } | 376 } |
| 374 } | 377 } |
| OLD | NEW |