| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 profile, url, !already_bookmarked); | 82 profile, url, !already_bookmarked); |
| 83 if (!anchor_view) { | 83 if (!anchor_view) { |
| 84 bookmark_bubble_->SetAnchorRect(anchor_rect); | 84 bookmark_bubble_->SetAnchorRect(anchor_rect); |
| 85 bookmark_bubble_->set_parent_window(parent_window); | 85 bookmark_bubble_->set_parent_window(parent_window); |
| 86 } | 86 } |
| 87 views::Widget* bubble_widget = | 87 views::Widget* bubble_widget = |
| 88 views::BubbleDialogDelegateView::CreateBubble(bookmark_bubble_); | 88 views::BubbleDialogDelegateView::CreateBubble(bookmark_bubble_); |
| 89 bubble_widget->Show(); | 89 bubble_widget->Show(); |
| 90 // Select the entire title textfield contents when the bubble is first shown. | 90 // Select the entire title textfield contents when the bubble is first shown. |
| 91 bookmark_bubble_->title_tf_->SelectAll(true); | 91 bookmark_bubble_->title_tf_->SelectAll(true); |
| 92 bookmark_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); | 92 bookmark_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_TRANSPARENT); |
| 93 | 93 |
| 94 if (bookmark_bubble_->observer_) { | 94 if (bookmark_bubble_->observer_) { |
| 95 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile); | 95 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile); |
| 96 const BookmarkNode* node = model->GetMostRecentlyAddedUserNodeForURL(url); | 96 const BookmarkNode* node = model->GetMostRecentlyAddedUserNodeForURL(url); |
| 97 bookmark_bubble_->observer_->OnBookmarkBubbleShown(node); | 97 bookmark_bubble_->observer_->OnBookmarkBubbleShown(node); |
| 98 } | 98 } |
| 99 return bubble_widget; | 99 return bubble_widget; |
| 100 } | 100 } |
| 101 | 101 |
| 102 void BookmarkBubbleView::Hide() { | 102 void BookmarkBubbleView::Hide() { |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 // Compensate for built-in vertical padding in the anchor view's image. | |
| 277 set_anchor_view_insets(gfx::Insets(2, 0, 2, 0)); | |
| 278 } | 276 } |
| 279 | 277 |
| 280 base::string16 BookmarkBubbleView::GetTitle() { | 278 base::string16 BookmarkBubbleView::GetTitle() { |
| 281 BookmarkModel* bookmark_model = | 279 BookmarkModel* bookmark_model = |
| 282 BookmarkModelFactory::GetForProfile(profile_); | 280 BookmarkModelFactory::GetForProfile(profile_); |
| 283 const BookmarkNode* node = | 281 const BookmarkNode* node = |
| 284 bookmark_model->GetMostRecentlyAddedUserNodeForURL(url_); | 282 bookmark_model->GetMostRecentlyAddedUserNodeForURL(url_); |
| 285 if (node) | 283 if (node) |
| 286 return node->GetTitle(); | 284 return node->GetTitle(); |
| 287 else | 285 else |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 if (node) { | 350 if (node) { |
| 353 const base::string16 new_title = title_tf_->text(); | 351 const base::string16 new_title = title_tf_->text(); |
| 354 if (new_title != node->GetTitle()) { | 352 if (new_title != node->GetTitle()) { |
| 355 model->SetTitle(node, new_title); | 353 model->SetTitle(node, new_title); |
| 356 content::RecordAction( | 354 content::RecordAction( |
| 357 UserMetricsAction("BookmarkBubble_ChangeTitleInBubble")); | 355 UserMetricsAction("BookmarkBubble_ChangeTitleInBubble")); |
| 358 } | 356 } |
| 359 parent_model_.MaybeChangeParent(node, parent_combobox_->selected_index()); | 357 parent_model_.MaybeChangeParent(node, parent_combobox_->selected_index()); |
| 360 } | 358 } |
| 361 } | 359 } |
| OLD | NEW |