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

Side by Side Diff: chrome/browser/chromeos/options/network_config_view.cc

Issue 8726008: Disable network "Connect" dialog UI in case of policy-managed networks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Split out UI data handling into separate CL. Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/chromeos/options/network_config_view.h" 5 #include "chrome/browser/chromeos/options/network_config_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/chromeos/options/vpn_config_view.h" 11 #include "chrome/browser/chromeos/options/vpn_config_view.h"
12 #include "chrome/browser/chromeos/options/wifi_config_view.h" 12 #include "chrome/browser/chromeos/options/wifi_config_view.h"
13 #include "grit/chromium_strings.h" 13 #include "grit/chromium_strings.h"
14 #include "grit/generated_resources.h" 14 #include "grit/generated_resources.h"
15 #include "grit/locale_settings.h" 15 #include "grit/locale_settings.h"
16 #include "grit/theme_resources.h"
16 #include "ui/base/accessibility/accessible_view_state.h" 17 #include "ui/base/accessibility/accessible_view_state.h"
17 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
19 #include "ui/base/resource/resource_bundle.h"
20 #include "ui/gfx/image/image.h"
18 #include "ui/gfx/rect.h" 21 #include "ui/gfx/rect.h"
19 #include "ui/views/controls/button/text_button.h" 22 #include "ui/views/controls/button/text_button.h"
20 #include "ui/views/layout/grid_layout.h" 23 #include "ui/views/layout/grid_layout.h"
21 #include "ui/views/layout/layout_constants.h" 24 #include "ui/views/layout/layout_constants.h"
22 #include "ui/views/widget/widget.h" 25 #include "ui/views/widget/widget.h"
26 #include "views/controls/image_view.h"
23 27
24 namespace chromeos { 28 namespace chromeos {
25 29
26 // static 30 // static
27 const int ChildNetworkConfigView::kInputFieldMinWidth = 270; 31 const int ChildNetworkConfigView::kInputFieldMinWidth = 270;
28 32
29 NetworkConfigView::NetworkConfigView(Network* network) 33 NetworkConfigView::NetworkConfigView(Network* network)
30 : delegate_(NULL), 34 : delegate_(NULL),
31 advanced_button_(NULL), 35 advanced_button_(NULL),
32 advanced_button_container_(NULL) { 36 advanced_button_container_(NULL) {
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 advanced_button_container_->SetLayoutManager(layout); 184 advanced_button_container_->SetLayoutManager(layout);
181 185
182 int column_set_id = 0; 186 int column_set_id = 0;
183 views::ColumnSet* column_set = layout->AddColumnSet(column_set_id); 187 views::ColumnSet* column_set = layout->AddColumnSet(column_set_id);
184 column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::LEADING, 188 column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::LEADING,
185 0, views::GridLayout::USE_PREF, 0, 0); 189 0, views::GridLayout::USE_PREF, 0, 0);
186 layout->StartRow(0, column_set_id); 190 layout->StartRow(0, column_set_id);
187 layout->AddView(advanced_button_); 191 layout->AddView(advanced_button_);
188 } 192 }
189 193
194 ControlledSettingIndicatorView::ControlledSettingIndicatorView()
195 : controller_(NetworkPropertyUIData::CONTROLLER_USER),
196 image_view_(NULL) {
197 Init();
198 }
199
200 ControlledSettingIndicatorView::ControlledSettingIndicatorView(
201 const NetworkPropertyUIData& ui_data)
202 : controller_(NetworkPropertyUIData::CONTROLLER_USER),
203 image_view_(NULL) {
204 Init();
205 Update(ui_data);
206 }
207
208 ControlledSettingIndicatorView::~ControlledSettingIndicatorView() {}
209
210 void ControlledSettingIndicatorView::Update(
211 const NetworkPropertyUIData& ui_data) {
212 if (controller_ == ui_data.controller())
213 return;
stevenjb 2011/11/29 17:58:28 See my comments in 8728030, but I think we should
Mattias Nissler (ping if slow) 2011/11/29 21:29:39 Done.
214
215 controller_ = ui_data.controller();
216 PreferredSizeChanged();
217 }
218
219 gfx::Size ControlledSettingIndicatorView::GetPreferredSize() {
220 if (!IsVisible())
221 return gfx::Size();
222
223 return image_view_->GetPreferredSize();
224 }
225
226 bool ControlledSettingIndicatorView::IsVisible() const {
227 return controller_ == NetworkPropertyUIData::CONTROLLER_POLICY &&
228 views::View::IsVisible();
229 }
230
231 void ControlledSettingIndicatorView::Layout() {
232 image_view_->SetBounds(0, 0, width(), height());
233 }
234
235 void ControlledSettingIndicatorView::OnMouseEntered(
236 const views::MouseEvent& event) {
237 image_view_->SetImage(color_image_);
238 }
239
240 void ControlledSettingIndicatorView::OnMouseExited(
241 const views::MouseEvent& event) {
242 image_view_->SetImage(gray_image_);
243 }
244
245 void ControlledSettingIndicatorView::Init() {
246 color_image_ = ResourceBundle::GetSharedInstance().GetImageNamed(
247 IDR_CONTROLLED_SETTING_MANDATORY).ToSkBitmap();
248 gray_image_ = ResourceBundle::GetSharedInstance().GetImageNamed(
249 IDR_CONTROLLED_SETTING_MANDATORY_GRAY).ToSkBitmap();
250 image_view_ = new views::ImageView();
251 // Disable |image_view_|, so mouse events bubble up.
stevenjb 2011/11/29 17:58:28 nit: "bubble up" may not be well understood :) Per
Mattias Nissler (ping if slow) 2011/11/29 21:29:39 Done.
252 image_view_->SetEnabled(false);
253 image_view_->SetImage(gray_image_);
254 image_view_->SetTooltipText(
255 l10n_util::GetStringUTF16(IDS_OPTIONS_CONTROLLED_SETTING_POLICY));
256 AddChildView(image_view_);
257 }
258
190 } // namespace chromeos 259 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698