| 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" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "chrome/app/chrome_command_ids.h" | 13 #include "chrome/app/chrome_command_ids.h" |
| 14 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 14 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 15 #include "chrome/browser/platform_util.h" | |
| 16 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/ui/bookmarks/bookmark_bubble_observer.h" | 16 #include "chrome/browser/ui/bookmarks/bookmark_bubble_observer.h" |
| 18 #include "chrome/browser/ui/bookmarks/bookmark_editor.h" | 17 #include "chrome/browser/ui/bookmarks/bookmark_editor.h" |
| 19 #include "chrome/browser/ui/browser_dialogs.h" | 18 #include "chrome/browser/ui/browser_dialogs.h" |
| 20 #include "chrome/browser/ui/sync/sync_promo_ui.h" | 19 #include "chrome/browser/ui/sync/sync_promo_ui.h" |
| 21 #include "chrome/browser/ui/views/harmony/layout_delegate.h" | 20 #include "chrome/browser/ui/views/harmony/layout_delegate.h" |
| 22 #include "chrome/browser/ui/views/sync/bubble_sync_promo_view.h" | 21 #include "chrome/browser/ui/views/sync/bubble_sync_promo_view.h" |
| 23 #include "chrome/grit/chromium_strings.h" | 22 #include "chrome/grit/chromium_strings.h" |
| 24 #include "chrome/grit/generated_resources.h" | 23 #include "chrome/grit/generated_resources.h" |
| 25 #include "components/bookmarks/browser/bookmark_model.h" | 24 #include "components/bookmarks/browser/bookmark_model.h" |
| 26 #include "components/bookmarks/browser/bookmark_utils.h" | 25 #include "components/bookmarks/browser/bookmark_utils.h" |
| 27 #include "components/strings/grit/components_strings.h" | 26 #include "components/strings/grit/components_strings.h" |
| 28 #include "content/public/browser/user_metrics.h" | 27 #include "content/public/browser/user_metrics.h" |
| 29 #include "ui/accessibility/ax_node_data.h" | 28 #include "ui/accessibility/ax_node_data.h" |
| 30 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
| 31 #include "ui/events/keycodes/keyboard_codes.h" | 30 #include "ui/events/keycodes/keyboard_codes.h" |
| 31 #include "ui/gfx/view_util.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" |
| 39 #include "ui/views/layout/layout_constants.h" | 39 #include "ui/views/layout/layout_constants.h" |
| 40 #include "ui/views/widget/widget.h" | 40 #include "ui/views/widget/widget.h" |
| 41 | 41 |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_) |
| 324 ->GetMostRecentlyAddedUserNodeForURL(url_); | 324 ->GetMostRecentlyAddedUserNodeForURL(url_); |
| 325 gfx::NativeWindow native_parent = | 325 gfx::NativeWindow native_parent = anchor_widget() |
| 326 anchor_widget() ? anchor_widget()->GetNativeWindow() | 326 ? anchor_widget()->GetNativeWindow() |
| 327 : platform_util::GetTopLevel(parent_window()); | 327 : gfx::GetTopLevel(parent_window()); |
| 328 DCHECK(native_parent); | 328 DCHECK(native_parent); |
| 329 | 329 |
| 330 Profile* profile = profile_; | 330 Profile* profile = profile_; |
| 331 ApplyEdits(); | 331 ApplyEdits(); |
| 332 GetWidget()->Close(); | 332 GetWidget()->Close(); |
| 333 | 333 |
| 334 if (node && native_parent) | 334 if (node && native_parent) |
| 335 BookmarkEditor::Show(native_parent, profile, | 335 BookmarkEditor::Show(native_parent, profile, |
| 336 BookmarkEditor::EditDetails::EditNode(node), | 336 BookmarkEditor::EditDetails::EditNode(node), |
| 337 BookmarkEditor::SHOW_TREE); | 337 BookmarkEditor::SHOW_TREE); |
| 338 } | 338 } |
| 339 | 339 |
| 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 content::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 |