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

Side by Side Diff: chrome/browser/ui/views/chooser_content_view.cc

Issue 2478863003: Fix the Web Bluetooth chooser when it is used on Chrome apps on non-Mac (Closed)
Patch Set: added code to handle the footnote link pointer ownership Created 4 years, 1 month 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/chooser_content_view.h" 5 #include "chrome/browser/ui/views/chooser_content_view.h"
6 6
7 #include "base/numerics/safe_conversions.h" 7 #include "base/numerics/safe_conversions.h"
8 #include "chrome/grit/generated_resources.h" 8 #include "chrome/grit/generated_resources.h"
9 #include "ui/base/l10n/l10n_util.h" 9 #include "ui/base/l10n/l10n_util.h"
10 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 IDS_BLUETOOTH_DEVICE_CHOOSER_TURN_ON_BLUETOOTH_LINK_TEXT); 79 IDS_BLUETOOTH_DEVICE_CHOOSER_TURN_ON_BLUETOOTH_LINK_TEXT);
80 size_t offset = 0; 80 size_t offset = 0;
81 base::string16 text = l10n_util::GetStringFUTF16( 81 base::string16 text = l10n_util::GetStringFUTF16(
82 IDS_BLUETOOTH_DEVICE_CHOOSER_TURN_ADAPTER_OFF, link_text, &offset); 82 IDS_BLUETOOTH_DEVICE_CHOOSER_TURN_ADAPTER_OFF, link_text, &offset);
83 turn_adapter_off_help_ = new views::StyledLabel(text, this); 83 turn_adapter_off_help_ = new views::StyledLabel(text, this);
84 turn_adapter_off_help_->AddStyleRange( 84 turn_adapter_off_help_->AddStyleRange(
85 gfx::Range(0, link_text.size()), 85 gfx::Range(0, link_text.size()),
86 views::StyledLabel::RangeStyleInfo::CreateForLink()); 86 views::StyledLabel::RangeStyleInfo::CreateForLink());
87 turn_adapter_off_help_->SetVisible(false); 87 turn_adapter_off_help_->SetVisible(false);
88 AddChildView(turn_adapter_off_help_); 88 AddChildView(turn_adapter_off_help_);
89 footnote_link_ptr_.reset(new views::StyledLabel(help_text_, this));
90 footnote_link_ = footnote_link_ptr_.get();
91 footnote_link_->AddStyleRange(
92 help_text_range_, views::StyledLabel::RangeStyleInfo::CreateForLink());
89 } 93 }
90 94
91 ChooserContentView::~ChooserContentView() { 95 ChooserContentView::~ChooserContentView() {
92 chooser_controller_->set_view(nullptr); 96 chooser_controller_->set_view(nullptr);
93 table_view_->SetObserver(nullptr); 97 table_view_->SetObserver(nullptr);
94 table_view_->SetModel(nullptr); 98 table_view_->SetModel(nullptr);
95 } 99 }
96 100
97 gfx::Size ChooserContentView::GetPreferredSize() const { 101 gfx::Size ChooserContentView::GetPreferredSize() const {
98 return gfx::Size(kChooserWidth, kChooserHeight); 102 return gfx::Size(kChooserWidth, kChooserHeight);
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 return button == ui::DIALOG_BUTTON_OK 276 return button == ui::DIALOG_BUTTON_OK
273 ? chooser_controller_->GetOkButtonLabel() 277 ? chooser_controller_->GetOkButtonLabel()
274 : l10n_util::GetStringUTF16(IDS_DEVICE_CHOOSER_CANCEL_BUTTON_TEXT); 278 : l10n_util::GetStringUTF16(IDS_DEVICE_CHOOSER_CANCEL_BUTTON_TEXT);
275 } 279 }
276 280
277 bool ChooserContentView::IsDialogButtonEnabled(ui::DialogButton button) const { 281 bool ChooserContentView::IsDialogButtonEnabled(ui::DialogButton button) const {
278 return button != ui::DIALOG_BUTTON_OK || 282 return button != ui::DIALOG_BUTTON_OK ||
279 !table_view_->selection_model().empty(); 283 !table_view_->selection_model().empty();
280 } 284 }
281 285
282 views::StyledLabel* ChooserContentView::CreateFootnoteView() { 286 views::StyledLabel* ChooserContentView::CreateFootnoteView() {
sky 2016/11/08 05:04:19 I find the usage of footnote_link_ and footnote_li
juncai 2016/11/08 19:43:26 That sounds better. I modified the ChooserContents
283 footnote_link_ = new views::StyledLabel(help_text_, this); 287 return footnote_link_ptr_.release();
284 footnote_link_->AddStyleRange(
285 help_text_range_, views::StyledLabel::RangeStyleInfo::CreateForLink());
286 return footnote_link_;
287 } 288 }
288 289
289 void ChooserContentView::Accept() { 290 void ChooserContentView::Accept() {
290 chooser_controller_->Select(table_view_->selection_model().active()); 291 chooser_controller_->Select(table_view_->selection_model().active());
291 } 292 }
292 293
293 void ChooserContentView::Cancel() { 294 void ChooserContentView::Cancel() {
294 chooser_controller_->Cancel(); 295 chooser_controller_->Cancel();
295 } 296 }
296 297
(...skipping 10 matching lines...) Expand all
307 } 308 }
308 } 309 }
309 310
310 void ChooserContentView::SetGetHelpAndReScanLink() { 311 void ChooserContentView::SetGetHelpAndReScanLink() {
311 footnote_link_->SetText(help_and_re_scan_text_); 312 footnote_link_->SetText(help_and_re_scan_text_);
312 footnote_link_->AddStyleRange( 313 footnote_link_->AddStyleRange(
313 help_text_range_, views::StyledLabel::RangeStyleInfo::CreateForLink()); 314 help_text_range_, views::StyledLabel::RangeStyleInfo::CreateForLink());
314 footnote_link_->AddStyleRange( 315 footnote_link_->AddStyleRange(
315 re_scan_text_range_, views::StyledLabel::RangeStyleInfo::CreateForLink()); 316 re_scan_text_range_, views::StyledLabel::RangeStyleInfo::CreateForLink());
316 } 317 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/chooser_content_view.h ('k') | chrome/browser/ui/views/constrained_web_dialog_delegate_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698