Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(866)

Side by Side Diff: chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc

Issue 1953943003: In dialogs & dialog-like bubbles, make the escape button just close (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: self review Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 return true; 136 return true;
137 } 137 }
138 if (key_code == ui::VKEY_E && accelerator.IsAltDown()) { 138 if (key_code == ui::VKEY_E && accelerator.IsAltDown()) {
139 HandleButtonPressed(edit_button_); 139 HandleButtonPressed(edit_button_);
140 return true; 140 return true;
141 } 141 }
142 if (key_code == ui::VKEY_R && accelerator.IsAltDown()) { 142 if (key_code == ui::VKEY_R && accelerator.IsAltDown()) {
143 HandleButtonPressed(remove_button_); 143 HandleButtonPressed(remove_button_);
144 return true; 144 return true;
145 } 145 }
146 if (key_code == ui::VKEY_ESCAPE) {
msw 2016/05/10 18:23:32 This is the one case that I use myself and appreci
147 remove_bookmark_ = newly_bookmarked_;
148 apply_edits_ = false;
149 }
150 146
151 return LocationBarBubbleDelegateView::AcceleratorPressed(accelerator); 147 return LocationBarBubbleDelegateView::AcceleratorPressed(accelerator);
152 } 148 }
153 149
154 void BookmarkBubbleView::Init() { 150 void BookmarkBubbleView::Init() {
155 remove_button_ = views::MdTextButton::CreateSecondaryUiButton( 151 remove_button_ = views::MdTextButton::CreateSecondaryUiButton(
156 this, l10n_util::GetStringUTF16(IDS_BOOKMARK_BUBBLE_REMOVE_BOOKMARK)); 152 this, l10n_util::GetStringUTF16(IDS_BOOKMARK_BUBBLE_REMOVE_BOOKMARK));
157 153
158 edit_button_ = views::MdTextButton::CreateSecondaryUiButton( 154 edit_button_ = views::MdTextButton::CreateSecondaryUiButton(
159 this, l10n_util::GetStringUTF16(IDS_BOOKMARK_BUBBLE_OPTIONS)); 155 this, l10n_util::GetStringUTF16(IDS_BOOKMARK_BUBBLE_OPTIONS));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 208
213 layout->StartRow(0, cs_id); 209 layout->StartRow(0, cs_id);
214 layout->SkipColumns(2); 210 layout->SkipColumns(2);
215 layout->AddView(remove_button_); 211 layout->AddView(remove_button_);
216 layout->AddView(edit_button_); 212 layout->AddView(edit_button_);
217 layout->AddView(close_button_); 213 layout->AddView(close_button_);
218 214
219 AddAccelerator(ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE)); 215 AddAccelerator(ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE));
220 AddAccelerator(ui::Accelerator(ui::VKEY_E, ui::EF_ALT_DOWN)); 216 AddAccelerator(ui::Accelerator(ui::VKEY_E, ui::EF_ALT_DOWN));
221 AddAccelerator(ui::Accelerator(ui::VKEY_R, ui::EF_ALT_DOWN)); 217 AddAccelerator(ui::Accelerator(ui::VKEY_R, ui::EF_ALT_DOWN));
222 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE));
223 } 218 }
224 219
225 base::string16 BookmarkBubbleView::GetWindowTitle() const { 220 base::string16 BookmarkBubbleView::GetWindowTitle() const {
226 return l10n_util::GetStringUTF16(newly_bookmarked_ 221 return l10n_util::GetStringUTF16(newly_bookmarked_
227 ? IDS_BOOKMARK_BUBBLE_PAGE_BOOKMARKED 222 ? IDS_BOOKMARK_BUBBLE_PAGE_BOOKMARKED
228 : IDS_BOOKMARK_BUBBLE_PAGE_BOOKMARK); 223 : IDS_BOOKMARK_BUBBLE_PAGE_BOOKMARK);
229 } 224 }
230 225
231 const char* BookmarkBubbleView::GetClassName() const { 226 const char* BookmarkBubbleView::GetClassName() const {
232 return "BookmarkBubbleView"; 227 return "BookmarkBubbleView";
(...skipping 23 matching lines...) Expand all
256 bool newly_bookmarked) 251 bool newly_bookmarked)
257 : LocationBarBubbleDelegateView(anchor_view, nullptr), 252 : LocationBarBubbleDelegateView(anchor_view, nullptr),
258 observer_(observer), 253 observer_(observer),
259 delegate_(std::move(delegate)), 254 delegate_(std::move(delegate)),
260 profile_(profile), 255 profile_(profile),
261 url_(url), 256 url_(url),
262 newly_bookmarked_(newly_bookmarked), 257 newly_bookmarked_(newly_bookmarked),
263 parent_model_(BookmarkModelFactory::GetForProfile(profile_), 258 parent_model_(BookmarkModelFactory::GetForProfile(profile_),
264 BookmarkModelFactory::GetForProfile(profile_) 259 BookmarkModelFactory::GetForProfile(profile_)
265 ->GetMostRecentlyAddedUserNodeForURL(url)), 260 ->GetMostRecentlyAddedUserNodeForURL(url)),
266 remove_button_(NULL), 261 remove_button_(nullptr),
267 edit_button_(NULL), 262 edit_button_(nullptr),
268 close_button_(NULL), 263 close_button_(nullptr),
269 title_tf_(NULL), 264 title_tf_(nullptr),
270 parent_combobox_(NULL), 265 parent_combobox_(nullptr),
271 remove_bookmark_(false), 266 remove_bookmark_(false),
272 apply_edits_(true) {} 267 apply_edits_(true) {}
273 268
274 base::string16 BookmarkBubbleView::GetTitle() { 269 base::string16 BookmarkBubbleView::GetTitle() {
275 BookmarkModel* bookmark_model = 270 BookmarkModel* bookmark_model =
276 BookmarkModelFactory::GetForProfile(profile_); 271 BookmarkModelFactory::GetForProfile(profile_);
277 const BookmarkNode* node = 272 const BookmarkNode* node =
278 bookmark_model->GetMostRecentlyAddedUserNodeForURL(url_); 273 bookmark_model->GetMostRecentlyAddedUserNodeForURL(url_);
279 if (node) 274 if (node)
280 return node->GetTitle(); 275 return node->GetTitle();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 if (node) { 341 if (node) {
347 const base::string16 new_title = title_tf_->text(); 342 const base::string16 new_title = title_tf_->text();
348 if (new_title != node->GetTitle()) { 343 if (new_title != node->GetTitle()) {
349 model->SetTitle(node, new_title); 344 model->SetTitle(node, new_title);
350 content::RecordAction( 345 content::RecordAction(
351 UserMetricsAction("BookmarkBubble_ChangeTitleInBubble")); 346 UserMetricsAction("BookmarkBubble_ChangeTitleInBubble"));
352 } 347 }
353 parent_model_.MaybeChangeParent(node, parent_combobox_->selected_index()); 348 parent_model_.MaybeChangeParent(node, parent_combobox_->selected_index());
354 } 349 }
355 } 350 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698