| 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/metrics/user_metrics.h" |
| 10 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 11 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 13 #include "chrome/app/chrome_command_ids.h" | 14 #include "chrome/app/chrome_command_ids.h" |
| 14 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 15 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 15 #include "chrome/browser/platform_util.h" | 16 #include "chrome/browser/platform_util.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/ui/bookmarks/bookmark_bubble_observer.h" | 18 #include "chrome/browser/ui/bookmarks/bookmark_bubble_observer.h" |
| 18 #include "chrome/browser/ui/bookmarks/bookmark_editor.h" | 19 #include "chrome/browser/ui/bookmarks/bookmark_editor.h" |
| 19 #include "chrome/browser/ui/browser_dialogs.h" | 20 #include "chrome/browser/ui/browser_dialogs.h" |
| 20 #include "chrome/browser/ui/sync/sync_promo_ui.h" | 21 #include "chrome/browser/ui/sync/sync_promo_ui.h" |
| 21 #include "chrome/browser/ui/views/harmony/layout_delegate.h" | 22 #include "chrome/browser/ui/views/harmony/layout_delegate.h" |
| 22 #include "chrome/browser/ui/views/sync/bubble_sync_promo_view.h" | 23 #include "chrome/browser/ui/views/sync/bubble_sync_promo_view.h" |
| 23 #include "chrome/grit/chromium_strings.h" | 24 #include "chrome/grit/chromium_strings.h" |
| 24 #include "chrome/grit/generated_resources.h" | 25 #include "chrome/grit/generated_resources.h" |
| 25 #include "components/bookmarks/browser/bookmark_model.h" | 26 #include "components/bookmarks/browser/bookmark_model.h" |
| 26 #include "components/bookmarks/browser/bookmark_utils.h" | 27 #include "components/bookmarks/browser/bookmark_utils.h" |
| 27 #include "components/strings/grit/components_strings.h" | 28 #include "components/strings/grit/components_strings.h" |
| 28 #include "content/public/browser/user_metrics.h" | |
| 29 #include "ui/accessibility/ax_node_data.h" | 29 #include "ui/accessibility/ax_node_data.h" |
| 30 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
| 31 #include "ui/events/keycodes/keyboard_codes.h" | 31 #include "ui/events/keycodes/keyboard_codes.h" |
| 32 #include "ui/views/bubble/bubble_frame_view.h" | 32 #include "ui/views/bubble/bubble_frame_view.h" |
| 33 #include "ui/views/controls/button/md_text_button.h" | 33 #include "ui/views/controls/button/md_text_button.h" |
| 34 #include "ui/views/controls/combobox/combobox.h" | 34 #include "ui/views/controls/combobox/combobox.h" |
| 35 #include "ui/views/controls/label.h" | 35 #include "ui/views/controls/label.h" |
| 36 #include "ui/views/controls/link.h" | 36 #include "ui/views/controls/link.h" |
| 37 #include "ui/views/controls/textfield/textfield.h" | 37 #include "ui/views/controls/textfield/textfield.h" |
| 38 #include "ui/views/layout/grid_layout.h" | 38 #include "ui/views/layout/grid_layout.h" |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 } | 233 } |
| 234 | 234 |
| 235 views::View* BookmarkBubbleView::GetInitiallyFocusedView() { | 235 views::View* BookmarkBubbleView::GetInitiallyFocusedView() { |
| 236 return title_tf_; | 236 return title_tf_; |
| 237 } | 237 } |
| 238 | 238 |
| 239 views::View* BookmarkBubbleView::CreateFootnoteView() { | 239 views::View* BookmarkBubbleView::CreateFootnoteView() { |
| 240 if (!SyncPromoUI::ShouldShowSyncPromo(profile_)) | 240 if (!SyncPromoUI::ShouldShowSyncPromo(profile_)) |
| 241 return nullptr; | 241 return nullptr; |
| 242 | 242 |
| 243 content::RecordAction( | 243 base::RecordAction( |
| 244 base::UserMetricsAction("Signin_Impression_FromBookmarkBubble")); | 244 base::UserMetricsAction("Signin_Impression_FromBookmarkBubble")); |
| 245 | 245 |
| 246 return new BubbleSyncPromoView(delegate_.get(), IDS_BOOKMARK_SYNC_PROMO_LINK, | 246 return new BubbleSyncPromoView(delegate_.get(), IDS_BOOKMARK_SYNC_PROMO_LINK, |
| 247 IDS_BOOKMARK_SYNC_PROMO_MESSAGE); | 247 IDS_BOOKMARK_SYNC_PROMO_MESSAGE); |
| 248 } | 248 } |
| 249 | 249 |
| 250 BookmarkBubbleView::BookmarkBubbleView( | 250 BookmarkBubbleView::BookmarkBubbleView( |
| 251 views::View* anchor_view, | 251 views::View* anchor_view, |
| 252 bookmarks::BookmarkBubbleObserver* observer, | 252 bookmarks::BookmarkBubbleObserver* observer, |
| 253 std::unique_ptr<BubbleSyncPromoDelegate> delegate, | 253 std::unique_ptr<BubbleSyncPromoDelegate> delegate, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 : IDS_BOOKMARK_AX_BUBBLE_PAGE_BOOKMARK)); | 290 : IDS_BOOKMARK_AX_BUBBLE_PAGE_BOOKMARK)); |
| 291 } | 291 } |
| 292 | 292 |
| 293 void BookmarkBubbleView::ButtonPressed(views::Button* sender, | 293 void BookmarkBubbleView::ButtonPressed(views::Button* sender, |
| 294 const ui::Event& event) { | 294 const ui::Event& event) { |
| 295 HandleButtonPressed(sender); | 295 HandleButtonPressed(sender); |
| 296 } | 296 } |
| 297 | 297 |
| 298 void BookmarkBubbleView::OnPerformAction(views::Combobox* combobox) { | 298 void BookmarkBubbleView::OnPerformAction(views::Combobox* combobox) { |
| 299 if (combobox->selected_index() + 1 == parent_model_.GetItemCount()) { | 299 if (combobox->selected_index() + 1 == parent_model_.GetItemCount()) { |
| 300 content::RecordAction(UserMetricsAction("BookmarkBubble_EditFromCombobox")); | 300 base::RecordAction(UserMetricsAction("BookmarkBubble_EditFromCombobox")); |
| 301 ShowEditor(); | 301 ShowEditor(); |
| 302 } | 302 } |
| 303 } | 303 } |
| 304 | 304 |
| 305 void BookmarkBubbleView::HandleButtonPressed(views::Button* sender) { | 305 void BookmarkBubbleView::HandleButtonPressed(views::Button* sender) { |
| 306 if (sender == remove_button_) { | 306 if (sender == remove_button_) { |
| 307 content::RecordAction(UserMetricsAction("BookmarkBubble_Unstar")); | 307 base::RecordAction(UserMetricsAction("BookmarkBubble_Unstar")); |
| 308 // Set this so we remove the bookmark after the window closes. | 308 // Set this so we remove the bookmark after the window closes. |
| 309 remove_bookmark_ = true; | 309 remove_bookmark_ = true; |
| 310 apply_edits_ = false; | 310 apply_edits_ = false; |
| 311 GetWidget()->Close(); | 311 GetWidget()->Close(); |
| 312 } else if (sender == edit_button_) { | 312 } else if (sender == edit_button_) { |
| 313 content::RecordAction(UserMetricsAction("BookmarkBubble_Edit")); | 313 base::RecordAction(UserMetricsAction("BookmarkBubble_Edit")); |
| 314 ShowEditor(); | 314 ShowEditor(); |
| 315 } else { | 315 } else { |
| 316 DCHECK_EQ(close_button_, sender); | 316 DCHECK_EQ(close_button_, sender); |
| 317 GetWidget()->Close(); | 317 GetWidget()->Close(); |
| 318 } | 318 } |
| 319 } | 319 } |
| 320 | 320 |
| 321 void BookmarkBubbleView::ShowEditor() { | 321 void BookmarkBubbleView::ShowEditor() { |
| 322 const BookmarkNode* node = | 322 const BookmarkNode* node = |
| 323 BookmarkModelFactory::GetForBrowserContext(profile_) | 323 BookmarkModelFactory::GetForBrowserContext(profile_) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 340 void BookmarkBubbleView::ApplyEdits() { | 340 void BookmarkBubbleView::ApplyEdits() { |
| 341 // Set this to make sure we don't attempt to apply edits again. | 341 // Set this to make sure we don't attempt to apply edits again. |
| 342 apply_edits_ = false; | 342 apply_edits_ = false; |
| 343 | 343 |
| 344 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile_); | 344 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile_); |
| 345 const BookmarkNode* node = model->GetMostRecentlyAddedUserNodeForURL(url_); | 345 const BookmarkNode* node = model->GetMostRecentlyAddedUserNodeForURL(url_); |
| 346 if (node) { | 346 if (node) { |
| 347 const base::string16 new_title = title_tf_->text(); | 347 const base::string16 new_title = title_tf_->text(); |
| 348 if (new_title != node->GetTitle()) { | 348 if (new_title != node->GetTitle()) { |
| 349 model->SetTitle(node, new_title); | 349 model->SetTitle(node, new_title); |
| 350 content::RecordAction( | 350 base::RecordAction( |
| 351 UserMetricsAction("BookmarkBubble_ChangeTitleInBubble")); | 351 UserMetricsAction("BookmarkBubble_ChangeTitleInBubble")); |
| 352 } | 352 } |
| 353 parent_model_.MaybeChangeParent(node, parent_combobox_->selected_index()); | 353 parent_model_.MaybeChangeParent(node, parent_combobox_->selected_index()); |
| 354 } | 354 } |
| 355 } | 355 } |
| OLD | NEW |