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" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 // destroyed asynchronously and the shown state will be checked before then. | 118 // destroyed asynchronously and the shown state will be checked before then. |
119 DCHECK_EQ(bookmark_bubble_, this); | 119 DCHECK_EQ(bookmark_bubble_, this); |
120 bookmark_bubble_ = NULL; | 120 bookmark_bubble_ = NULL; |
121 | 121 |
122 if (observer_) | 122 if (observer_) |
123 observer_->OnBookmarkBubbleHidden(); | 123 observer_->OnBookmarkBubbleHidden(); |
124 } | 124 } |
125 | 125 |
126 bool BookmarkBubbleView::AcceleratorPressed( | 126 bool BookmarkBubbleView::AcceleratorPressed( |
127 const ui::Accelerator& accelerator) { | 127 const ui::Accelerator& accelerator) { |
128 if (accelerator.key_code() == ui::VKEY_RETURN) { | 128 ui::KeyboardCode key_code = accelerator.key_code(); |
129 if (edit_button_->HasFocus()) | 129 if (key_code == ui::VKEY_RETURN) { |
130 HandleButtonPressed(edit_button_); | 130 HandleButtonPressed(close_button_); |
131 else | 131 return true; |
132 HandleButtonPressed(close_button_); | 132 } |
133 return true; | 133 if (key_code == ui::VKEY_E && accelerator.IsAltDown()) { |
134 } else if (accelerator.key_code() == ui::VKEY_ESCAPE) { | 134 HandleButtonPressed(edit_button_); |
| 135 return true; |
| 136 } |
| 137 if (key_code == ui::VKEY_R && accelerator.IsAltDown()) { |
| 138 HandleButtonPressed(remove_button_); |
| 139 return true; |
| 140 } |
| 141 if (key_code == ui::VKEY_ESCAPE) { |
135 remove_bookmark_ = newly_bookmarked_; | 142 remove_bookmark_ = newly_bookmarked_; |
136 apply_edits_ = false; | 143 apply_edits_ = false; |
137 } | 144 } |
138 | 145 |
139 return BubbleDelegateView::AcceleratorPressed(accelerator); | 146 return BubbleDelegateView::AcceleratorPressed(accelerator); |
140 } | 147 } |
141 | 148 |
142 void BookmarkBubbleView::Init() { | 149 void BookmarkBubbleView::Init() { |
143 views::Label* title_label = new views::Label( | 150 views::Label* title_label = new views::Label( |
144 l10n_util::GetStringUTF16( | 151 l10n_util::GetStringUTF16( |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 GridLayout::USE_PREF, | 251 GridLayout::USE_PREF, |
245 0, | 252 0, |
246 0); | 253 0); |
247 layout->StartRow(0, SYNC_PROMO_COLUMN_SET_ID); | 254 layout->StartRow(0, SYNC_PROMO_COLUMN_SET_ID); |
248 | 255 |
249 sync_promo_view_ = new BookmarkSyncPromoView(delegate_.get()); | 256 sync_promo_view_ = new BookmarkSyncPromoView(delegate_.get()); |
250 layout->AddView(sync_promo_view_); | 257 layout->AddView(sync_promo_view_); |
251 } | 258 } |
252 | 259 |
253 AddAccelerator(ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE)); | 260 AddAccelerator(ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE)); |
| 261 AddAccelerator(ui::Accelerator(ui::VKEY_E, ui::EF_ALT_DOWN)); |
| 262 AddAccelerator(ui::Accelerator(ui::VKEY_R, ui::EF_ALT_DOWN)); |
254 } | 263 } |
255 | 264 |
256 BookmarkBubbleView::BookmarkBubbleView( | 265 BookmarkBubbleView::BookmarkBubbleView( |
257 views::View* anchor_view, | 266 views::View* anchor_view, |
258 BookmarkBubbleViewObserver* observer, | 267 BookmarkBubbleViewObserver* observer, |
259 scoped_ptr<BookmarkBubbleDelegate> delegate, | 268 scoped_ptr<BookmarkBubbleDelegate> delegate, |
260 Profile* profile, | 269 Profile* profile, |
261 const GURL& url, | 270 const GURL& url, |
262 bool newly_bookmarked) | 271 bool newly_bookmarked) |
263 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), | 272 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 if (node) { | 365 if (node) { |
357 const base::string16 new_title = title_tf_->text(); | 366 const base::string16 new_title = title_tf_->text(); |
358 if (new_title != node->GetTitle()) { | 367 if (new_title != node->GetTitle()) { |
359 model->SetTitle(node, new_title); | 368 model->SetTitle(node, new_title); |
360 content::RecordAction( | 369 content::RecordAction( |
361 UserMetricsAction("BookmarkBubble_ChangeTitleInBubble")); | 370 UserMetricsAction("BookmarkBubble_ChangeTitleInBubble")); |
362 } | 371 } |
363 parent_model_.MaybeChangeParent(node, parent_combobox_->selected_index()); | 372 parent_model_.MaybeChangeParent(node, parent_combobox_->selected_index()); |
364 } | 373 } |
365 } | 374 } |
OLD | NEW |