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

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

Issue 2390823005: Update device permissions dialog ui for Chrome apps and extensions (Closed)
Patch Set: address more comments Created 4 years 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/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/numerics/safe_conversions.h" 8 #include "base/numerics/safe_conversions.h"
9 #include "chrome/grit/generated_resources.h" 9 #include "chrome/grit/generated_resources.h"
10 #include "ui/base/l10n/l10n_util.h" 10 #include "ui/base/l10n/l10n_util.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 IDS_BLUETOOTH_DEVICE_CHOOSER_TURN_ON_BLUETOOTH_LINK_TEXT); 80 IDS_BLUETOOTH_DEVICE_CHOOSER_TURN_ON_BLUETOOTH_LINK_TEXT);
81 size_t offset = 0; 81 size_t offset = 0;
82 base::string16 text = l10n_util::GetStringFUTF16( 82 base::string16 text = l10n_util::GetStringFUTF16(
83 IDS_BLUETOOTH_DEVICE_CHOOSER_TURN_ADAPTER_OFF, link_text, &offset); 83 IDS_BLUETOOTH_DEVICE_CHOOSER_TURN_ADAPTER_OFF, link_text, &offset);
84 turn_adapter_off_help_ = new views::StyledLabel(text, this); 84 turn_adapter_off_help_ = new views::StyledLabel(text, this);
85 turn_adapter_off_help_->AddStyleRange( 85 turn_adapter_off_help_->AddStyleRange(
86 gfx::Range(0, link_text.size()), 86 gfx::Range(0, link_text.size()),
87 views::StyledLabel::RangeStyleInfo::CreateForLink()); 87 views::StyledLabel::RangeStyleInfo::CreateForLink());
88 turn_adapter_off_help_->SetVisible(false); 88 turn_adapter_off_help_->SetVisible(false);
89 AddChildView(turn_adapter_off_help_); 89 AddChildView(turn_adapter_off_help_);
90 footnote_link_ = base::MakeUnique<views::StyledLabel>(help_text_, this);
91 footnote_link_->set_owned_by_client();
92 footnote_link_->AddStyleRange(
93 help_text_range_, views::StyledLabel::RangeStyleInfo::CreateForLink());
94 } 90 }
95 91
96 ChooserContentView::~ChooserContentView() { 92 ChooserContentView::~ChooserContentView() {
97 chooser_controller_->set_view(nullptr); 93 chooser_controller_->set_view(nullptr);
98 table_view_->SetObserver(nullptr); 94 table_view_->SetObserver(nullptr);
99 table_view_->SetModel(nullptr); 95 table_view_->SetModel(nullptr);
100 } 96 }
101 97
102 gfx::Size ChooserContentView::GetPreferredSize() const { 98 gfx::Size ChooserContentView::GetPreferredSize() const {
103 return gfx::Size(kChooserWidth, kChooserHeight); 99 return gfx::Size(kChooserWidth, kChooserHeight);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 UpdateTableView(); 199 UpdateTableView();
204 table_view_->SetVisible(enabled); 200 table_view_->SetVisible(enabled);
205 turn_adapter_off_help_->SetVisible(!enabled); 201 turn_adapter_off_help_->SetVisible(!enabled);
206 202
207 throbber_->Stop(); 203 throbber_->Stop();
208 throbber_->SetVisible(false); 204 throbber_->SetVisible(false);
209 205
210 if (enabled) { 206 if (enabled) {
211 SetGetHelpAndReScanLink(); 207 SetGetHelpAndReScanLink();
212 } else { 208 } else {
209 DCHECK(footnote_link_);
213 footnote_link_->SetText(help_text_); 210 footnote_link_->SetText(help_text_);
214 footnote_link_->AddStyleRange( 211 footnote_link_->AddStyleRange(
215 help_text_range_, views::StyledLabel::RangeStyleInfo::CreateForLink()); 212 help_text_range_, views::StyledLabel::RangeStyleInfo::CreateForLink());
216 } 213 }
217 214
218 if (GetWidget() && GetWidget()->GetRootView()) 215 if (GetWidget() && GetWidget()->GetRootView())
219 GetWidget()->GetRootView()->Layout(); 216 GetWidget()->GetRootView()->Layout();
220 } 217 }
221 218
222 void ChooserContentView::OnRefreshStateChanged(bool refreshing) { 219 void ChooserContentView::OnRefreshStateChanged(bool refreshing) {
(...skipping 10 matching lines...) Expand all
233 bool throbber_visible = 230 bool throbber_visible =
234 refreshing && (chooser_controller_->NumOptions() == 0); 231 refreshing && (chooser_controller_->NumOptions() == 0);
235 table_view_->SetVisible(!throbber_visible); 232 table_view_->SetVisible(!throbber_visible);
236 throbber_->SetVisible(throbber_visible); 233 throbber_->SetVisible(throbber_visible);
237 if (throbber_visible) 234 if (throbber_visible)
238 throbber_->Start(); 235 throbber_->Start();
239 else 236 else
240 throbber_->Stop(); 237 throbber_->Stop();
241 238
242 if (refreshing) { 239 if (refreshing) {
240 DCHECK(footnote_link_);
243 footnote_link_->SetText(help_and_scanning_text_); 241 footnote_link_->SetText(help_and_scanning_text_);
244 footnote_link_->AddStyleRange( 242 footnote_link_->AddStyleRange(
245 help_text_range_, views::StyledLabel::RangeStyleInfo::CreateForLink()); 243 help_text_range_, views::StyledLabel::RangeStyleInfo::CreateForLink());
246 } else { 244 } else {
247 SetGetHelpAndReScanLink(); 245 SetGetHelpAndReScanLink();
248 } 246 }
249 247
250 if (GetWidget() && GetWidget()->GetRootView()) 248 if (GetWidget() && GetWidget()->GetRootView())
251 GetWidget()->GetRootView()->Layout(); 249 GetWidget()->GetRootView()->Layout();
252 } 250 }
(...skipping 24 matching lines...) Expand all
277 return button == ui::DIALOG_BUTTON_OK 275 return button == ui::DIALOG_BUTTON_OK
278 ? chooser_controller_->GetOkButtonLabel() 276 ? chooser_controller_->GetOkButtonLabel()
279 : l10n_util::GetStringUTF16(IDS_DEVICE_CHOOSER_CANCEL_BUTTON_TEXT); 277 : l10n_util::GetStringUTF16(IDS_DEVICE_CHOOSER_CANCEL_BUTTON_TEXT);
280 } 278 }
281 279
282 bool ChooserContentView::IsDialogButtonEnabled(ui::DialogButton button) const { 280 bool ChooserContentView::IsDialogButtonEnabled(ui::DialogButton button) const {
283 return button != ui::DIALOG_BUTTON_OK || 281 return button != ui::DIALOG_BUTTON_OK ||
284 !table_view_->selection_model().empty(); 282 !table_view_->selection_model().empty();
285 } 283 }
286 284
285 views::StyledLabel* ChooserContentView::footnote_link() {
286 if (chooser_controller_->ShouldShowFootnoteView()) {
287 footnote_link_ = base::MakeUnique<views::StyledLabel>(help_text_, this);
288 footnote_link_->set_owned_by_client();
289 footnote_link_->AddStyleRange(
290 help_text_range_, views::StyledLabel::RangeStyleInfo::CreateForLink());
291 }
292
293 return footnote_link_.get();
294 }
295
287 void ChooserContentView::Accept() { 296 void ChooserContentView::Accept() {
288 std::vector<size_t> indices( 297 std::vector<size_t> indices(
289 table_view_->selection_model().selected_indices().begin(), 298 table_view_->selection_model().selected_indices().begin(),
290 table_view_->selection_model().selected_indices().end()); 299 table_view_->selection_model().selected_indices().end());
291 chooser_controller_->Select(indices); 300 chooser_controller_->Select(indices);
292 } 301 }
293 302
294 void ChooserContentView::Cancel() { 303 void ChooserContentView::Cancel() {
295 chooser_controller_->Cancel(); 304 chooser_controller_->Cancel();
296 } 305 }
297 306
298 void ChooserContentView::Close() { 307 void ChooserContentView::Close() {
299 chooser_controller_->Close(); 308 chooser_controller_->Close();
300 } 309 }
301 310
302 void ChooserContentView::UpdateTableView() { 311 void ChooserContentView::UpdateTableView() {
303 if (chooser_controller_->NumOptions() == 0) { 312 if (chooser_controller_->NumOptions() == 0) {
304 table_view_->OnModelChanged(); 313 table_view_->OnModelChanged();
305 table_view_->SetEnabled(false); 314 table_view_->SetEnabled(false);
306 } else { 315 } else {
307 table_view_->SetEnabled(true); 316 table_view_->SetEnabled(true);
308 } 317 }
309 } 318 }
310 319
311 void ChooserContentView::SetGetHelpAndReScanLink() { 320 void ChooserContentView::SetGetHelpAndReScanLink() {
321 DCHECK(footnote_link_);
312 footnote_link_->SetText(help_and_re_scan_text_); 322 footnote_link_->SetText(help_and_re_scan_text_);
313 footnote_link_->AddStyleRange( 323 footnote_link_->AddStyleRange(
314 help_text_range_, views::StyledLabel::RangeStyleInfo::CreateForLink()); 324 help_text_range_, views::StyledLabel::RangeStyleInfo::CreateForLink());
315 footnote_link_->AddStyleRange( 325 footnote_link_->AddStyleRange(
316 re_scan_text_range_, views::StyledLabel::RangeStyleInfo::CreateForLink()); 326 re_scan_text_range_, views::StyledLabel::RangeStyleInfo::CreateForLink());
317 } 327 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/chooser_content_view.h ('k') | chrome/browser/ui/views/extensions/chooser_dialog_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698