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

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

Issue 1759453002: Convert location bar bubble delegates to bubble dialog delegates (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix ImmersiveFullscreenController Created 4 years, 9 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 return nullptr; 78 return nullptr;
79 79
80 bookmark_bubble_ = 80 bookmark_bubble_ =
81 new BookmarkBubbleView(anchor_view, observer, std::move(delegate), 81 new BookmarkBubbleView(anchor_view, observer, std::move(delegate),
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::BubbleDelegateView::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_NONE);
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 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) { 146 if (key_code == ui::VKEY_ESCAPE) {
147 remove_bookmark_ = newly_bookmarked_; 147 remove_bookmark_ = newly_bookmarked_;
148 apply_edits_ = false; 148 apply_edits_ = false;
149 } 149 }
150 150
151 return BubbleDelegateView::AcceleratorPressed(accelerator); 151 return LocationBarBubbleDelegateView::AcceleratorPressed(accelerator);
152 } 152 }
153 153
154 void BookmarkBubbleView::Init() { 154 void BookmarkBubbleView::Init() {
155 remove_button_ = new views::LabelButton(this, l10n_util::GetStringUTF16( 155 remove_button_ = new views::LabelButton(this, l10n_util::GetStringUTF16(
156 IDS_BOOKMARK_BUBBLE_REMOVE_BOOKMARK)); 156 IDS_BOOKMARK_BUBBLE_REMOVE_BOOKMARK));
157 remove_button_->SetStyle(views::Button::STYLE_BUTTON); 157 remove_button_->SetStyle(views::Button::STYLE_BUTTON);
158 158
159 edit_button_ = new views::LabelButton( 159 edit_button_ = new views::LabelButton(
160 this, l10n_util::GetStringUTF16(IDS_BOOKMARK_BUBBLE_OPTIONS)); 160 this, l10n_util::GetStringUTF16(IDS_BOOKMARK_BUBBLE_OPTIONS));
161 edit_button_->SetStyle(views::Button::STYLE_BUTTON); 161 edit_button_->SetStyle(views::Button::STYLE_BUTTON);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 215
216 layout->StartRow(0, cs_id); 216 layout->StartRow(0, cs_id);
217 layout->SkipColumns(2); 217 layout->SkipColumns(2);
218 layout->AddView(remove_button_); 218 layout->AddView(remove_button_);
219 layout->AddView(edit_button_); 219 layout->AddView(edit_button_);
220 layout->AddView(close_button_); 220 layout->AddView(close_button_);
221 221
222 AddAccelerator(ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE)); 222 AddAccelerator(ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE));
223 AddAccelerator(ui::Accelerator(ui::VKEY_E, ui::EF_ALT_DOWN)); 223 AddAccelerator(ui::Accelerator(ui::VKEY_E, ui::EF_ALT_DOWN));
224 AddAccelerator(ui::Accelerator(ui::VKEY_R, ui::EF_ALT_DOWN)); 224 AddAccelerator(ui::Accelerator(ui::VKEY_R, ui::EF_ALT_DOWN));
225 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE));
225 } 226 }
226 227
227 base::string16 BookmarkBubbleView::GetWindowTitle() const { 228 base::string16 BookmarkBubbleView::GetWindowTitle() const {
228 return l10n_util::GetStringUTF16(newly_bookmarked_ 229 return l10n_util::GetStringUTF16(newly_bookmarked_
229 ? IDS_BOOKMARK_BUBBLE_PAGE_BOOKMARKED 230 ? IDS_BOOKMARK_BUBBLE_PAGE_BOOKMARKED
230 : IDS_BOOKMARK_BUBBLE_PAGE_BOOKMARK); 231 : IDS_BOOKMARK_BUBBLE_PAGE_BOOKMARK);
231 } 232 }
232 233
233 const char* BookmarkBubbleView::GetClassName() const { 234 const char* BookmarkBubbleView::GetClassName() const {
234 return "BookmarkBubbleView"; 235 return "BookmarkBubbleView";
(...skipping 14 matching lines...) Expand all
249 IDS_BOOKMARK_SYNC_PROMO_MESSAGE); 250 IDS_BOOKMARK_SYNC_PROMO_MESSAGE);
250 } 251 }
251 252
252 BookmarkBubbleView::BookmarkBubbleView( 253 BookmarkBubbleView::BookmarkBubbleView(
253 views::View* anchor_view, 254 views::View* anchor_view,
254 bookmarks::BookmarkBubbleObserver* observer, 255 bookmarks::BookmarkBubbleObserver* observer,
255 scoped_ptr<BubbleSyncPromoDelegate> delegate, 256 scoped_ptr<BubbleSyncPromoDelegate> delegate,
256 Profile* profile, 257 Profile* profile,
257 const GURL& url, 258 const GURL& url,
258 bool newly_bookmarked) 259 bool newly_bookmarked)
259 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), 260 : LocationBarBubbleDelegateView(anchor_view, nullptr),
260 observer_(observer), 261 observer_(observer),
261 delegate_(std::move(delegate)), 262 delegate_(std::move(delegate)),
262 profile_(profile), 263 profile_(profile),
263 url_(url), 264 url_(url),
264 newly_bookmarked_(newly_bookmarked), 265 newly_bookmarked_(newly_bookmarked),
265 parent_model_(BookmarkModelFactory::GetForProfile(profile_), 266 parent_model_(BookmarkModelFactory::GetForProfile(profile_),
266 BookmarkModelFactory::GetForProfile(profile_) 267 BookmarkModelFactory::GetForProfile(profile_)
267 ->GetMostRecentlyAddedUserNodeForURL(url)), 268 ->GetMostRecentlyAddedUserNodeForURL(url)),
268 remove_button_(NULL), 269 remove_button_(NULL),
269 edit_button_(NULL), 270 edit_button_(NULL),
(...skipping 12 matching lines...) Expand all
282 const BookmarkNode* node = 283 const BookmarkNode* node =
283 bookmark_model->GetMostRecentlyAddedUserNodeForURL(url_); 284 bookmark_model->GetMostRecentlyAddedUserNodeForURL(url_);
284 if (node) 285 if (node)
285 return node->GetTitle(); 286 return node->GetTitle();
286 else 287 else
287 NOTREACHED(); 288 NOTREACHED();
288 return base::string16(); 289 return base::string16();
289 } 290 }
290 291
291 void BookmarkBubbleView::GetAccessibleState(ui::AXViewState* state) { 292 void BookmarkBubbleView::GetAccessibleState(ui::AXViewState* state) {
292 BubbleDelegateView::GetAccessibleState(state); 293 LocationBarBubbleDelegateView::GetAccessibleState(state);
293 state->name = 294 state->name =
294 l10n_util::GetStringUTF16( 295 l10n_util::GetStringUTF16(
295 newly_bookmarked_ ? IDS_BOOKMARK_BUBBLE_PAGE_BOOKMARKED : 296 newly_bookmarked_ ? IDS_BOOKMARK_BUBBLE_PAGE_BOOKMARKED :
296 IDS_BOOKMARK_AX_BUBBLE_PAGE_BOOKMARK); 297 IDS_BOOKMARK_AX_BUBBLE_PAGE_BOOKMARK);
297 } 298 }
298 299
299 void BookmarkBubbleView::ButtonPressed(views::Button* sender, 300 void BookmarkBubbleView::ButtonPressed(views::Button* sender,
300 const ui::Event& event) { 301 const ui::Event& event) {
301 HandleButtonPressed(sender); 302 HandleButtonPressed(sender);
302 } 303 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 if (node) { 352 if (node) {
352 const base::string16 new_title = title_tf_->text(); 353 const base::string16 new_title = title_tf_->text();
353 if (new_title != node->GetTitle()) { 354 if (new_title != node->GetTitle()) {
354 model->SetTitle(node, new_title); 355 model->SetTitle(node, new_title);
355 content::RecordAction( 356 content::RecordAction(
356 UserMetricsAction("BookmarkBubble_ChangeTitleInBubble")); 357 UserMetricsAction("BookmarkBubble_ChangeTitleInBubble"));
357 } 358 }
358 parent_model_.MaybeChangeParent(node, parent_combobox_->selected_index()); 359 parent_model_.MaybeChangeParent(node, parent_combobox_->selected_index());
359 } 360 }
360 } 361 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698