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

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

Issue 2192953002: Chooser spinner should disappear as soon as one device shows up (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 4 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 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 "chrome/grit/generated_resources.h" 7 #include "chrome/grit/generated_resources.h"
8 #include "ui/base/l10n/l10n_util.h" 8 #include "ui/base/l10n/l10n_util.h"
9 #include "ui/views/controls/link.h" 9 #include "ui/views/controls/link.h"
10 #include "ui/views/controls/styled_label.h" 10 #include "ui/views/controls/styled_label.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 void ChooserContentView::SetObserver(ui::TableModelObserver* observer) {} 81 void ChooserContentView::SetObserver(ui::TableModelObserver* observer) {}
82 82
83 void ChooserContentView::OnOptionsInitialized() { 83 void ChooserContentView::OnOptionsInitialized() {
84 table_view_->OnModelChanged(); 84 table_view_->OnModelChanged();
85 UpdateTableView(); 85 UpdateTableView();
86 } 86 }
87 87
88 void ChooserContentView::OnOptionAdded(size_t index) { 88 void ChooserContentView::OnOptionAdded(size_t index) {
89 table_view_->OnItemsAdded(static_cast<int>(index), 1); 89 table_view_->OnItemsAdded(static_cast<int>(index), 1);
90 UpdateTableView(); 90 UpdateTableView();
91 table_view_->SetVisible(true);
92 throbber_->SetVisible(false);
93 throbber_->Stop();
91 } 94 }
92 95
93 void ChooserContentView::OnOptionRemoved(size_t index) { 96 void ChooserContentView::OnOptionRemoved(size_t index) {
94 table_view_->OnItemsRemoved(static_cast<int>(index), 1); 97 table_view_->OnItemsRemoved(static_cast<int>(index), 1);
95 UpdateTableView(); 98 UpdateTableView();
96 } 99 }
97 100
98 void ChooserContentView::OnAdapterEnabledChanged(bool enabled) { 101 void ChooserContentView::OnAdapterEnabledChanged(bool enabled) {
99 // No row is selected since the adapter status has changed. 102 // No row is selected since the adapter status has changed.
100 // This will also disable the OK button if it was enabled because 103 // This will also disable the OK button if it was enabled because
101 // of a previously selected row. 104 // of a previously selected row.
102 table_view_->Select(-1); 105 table_view_->Select(-1);
103 UpdateTableView(); 106 UpdateTableView();
104 table_view_->SetVisible(true); 107 table_view_->SetVisible(true);
105 108
106 throbber_->Stop(); 109 throbber_->Stop();
107 throbber_->SetVisible(false); 110 throbber_->SetVisible(false);
108 111
109 discovery_state_->SetText(chooser_controller_->GetStatus()); 112 discovery_state_->SetText(chooser_controller_->GetStatus());
110 discovery_state_->SetEnabled(enabled); 113 discovery_state_->SetEnabled(enabled);
111 } 114 }
112 115
113 void ChooserContentView::OnRefreshStateChanged(bool refreshing) { 116 void ChooserContentView::OnRefreshStateChanged(bool refreshing) {
114 // No row is selected since the chooser is refreshing or just refreshed. 117 if (refreshing) {
115 // This will also disable the OK button if it was enabled because 118 // No row is selected since the chooser is refreshing. This will also
116 // of a previously selected row. 119 // disable the OK button if it was enabled because of a previously
117 table_view_->Select(-1); 120 // selected row.
118 UpdateTableView(); 121 table_view_->Select(-1);
119 // When refreshing, hide |table_view_|. When complete, show |table_view_|. 122 UpdateTableView();
120 table_view_->SetVisible(!refreshing); 123 }
121 124
122 if (refreshing) 125 // When refreshing and no option available yet, hide |table_view_| and show
126 // |throbber_|. Otherwise show |table_view_| and hide |throbber_|.
127 bool throbber_visible =
128 refreshing && (chooser_controller_->NumOptions() == 0);
129 table_view_->SetVisible(!throbber_visible);
130 throbber_->SetVisible(throbber_visible);
131 if (throbber_visible)
123 throbber_->Start(); 132 throbber_->Start();
124 else 133 else
125 throbber_->Stop(); 134 throbber_->Stop();
126 // When refreshing, show |throbber_|. When complete, hide |throbber_|.
127 throbber_->SetVisible(refreshing);
128 135
129 discovery_state_->SetText(chooser_controller_->GetStatus()); 136 discovery_state_->SetText(chooser_controller_->GetStatus());
130 // When refreshing, disable |discovery_state_| to show it as a text label. 137 // When refreshing, disable |discovery_state_| to show it as a text label.
131 // When complete, enable |discovery_state_| to show it as a link. 138 // When complete, enable |discovery_state_| to show it as a link.
132 discovery_state_->SetEnabled(!refreshing); 139 discovery_state_->SetEnabled(!refreshing);
133 } 140 }
134 141
135 void ChooserContentView::LinkClicked(views::Link* source, int event_flags) { 142 void ChooserContentView::LinkClicked(views::Link* source, int event_flags) {
136 chooser_controller_->RefreshOptions(); 143 chooser_controller_->RefreshOptions();
137 } 144 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 } 199 }
193 200
194 void ChooserContentView::UpdateTableView() { 201 void ChooserContentView::UpdateTableView() {
195 if (chooser_controller_->NumOptions() == 0) { 202 if (chooser_controller_->NumOptions() == 0) {
196 table_view_->OnModelChanged(); 203 table_view_->OnModelChanged();
197 table_view_->SetEnabled(false); 204 table_view_->SetEnabled(false);
198 } else { 205 } else {
199 table_view_->SetEnabled(true); 206 table_view_->SetEnabled(true);
200 } 207 }
201 } 208 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698