OLD | NEW |
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/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 "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 12 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
13 #include "chrome/browser/chromeos/options/network_property_ui_data.h" | 13 #include "chrome/browser/chromeos/options/network_property_ui_data.h" |
14 #include "chrome/browser/chromeos/options/vpn_config_view.h" | 14 #include "chrome/browser/chromeos/options/vpn_config_view.h" |
15 #include "chrome/browser/chromeos/options/wifi_config_view.h" | 15 #include "chrome/browser/chromeos/options/wifi_config_view.h" |
16 #include "chrome/browser/chromeos/options/wimax_config_view.h" | 16 #include "chrome/browser/chromeos/options/wimax_config_view.h" |
17 #include "chrome/browser/profiles/profile_manager.h" | 17 #include "chrome/browser/profiles/profile_manager.h" |
18 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
19 #include "chrome/browser/ui/browser_finder.h" | 19 #include "chrome/browser/ui/browser_finder.h" |
20 #include "chrome/browser/ui/browser_window.h" | 20 #include "chrome/browser/ui/browser_window.h" |
21 #include "chrome/grit/generated_resources.h" | 21 #include "chrome/grit/generated_resources.h" |
22 #include "chrome/grit/locale_settings.h" | 22 #include "chrome/grit/locale_settings.h" |
| 23 #include "chrome/grit/theme_resources.h" |
23 #include "chromeos/login/login_state.h" | 24 #include "chromeos/login/login_state.h" |
24 #include "chromeos/network/network_state.h" | 25 #include "chromeos/network/network_state.h" |
25 #include "chromeos/network/network_state_handler.h" | 26 #include "chromeos/network/network_state_handler.h" |
26 #include "components/device_event_log/device_event_log.h" | 27 #include "components/device_event_log/device_event_log.h" |
| 28 #include "components/grit/components_scaled_resources.h" |
27 #include "components/user_manager/user.h" | 29 #include "components/user_manager/user.h" |
28 #include "ui/accessibility/ax_view_state.h" | 30 #include "ui/accessibility/ax_view_state.h" |
29 #include "ui/aura/window_event_dispatcher.h" | 31 #include "ui/aura/window_event_dispatcher.h" |
30 #include "ui/base/l10n/l10n_util.h" | 32 #include "ui/base/l10n/l10n_util.h" |
31 #include "ui/gfx/color_palette.h" | 33 #include "ui/base/resource/resource_bundle.h" |
32 #include "ui/gfx/geometry/rect.h" | 34 #include "ui/gfx/geometry/rect.h" |
33 #include "ui/gfx/image/image.h" | 35 #include "ui/gfx/image/image.h" |
34 #include "ui/gfx/paint_vector_icon.h" | |
35 #include "ui/gfx/vector_icons_public.h" | |
36 #include "ui/views/controls/button/md_text_button.h" | 36 #include "ui/views/controls/button/md_text_button.h" |
37 #include "ui/views/controls/image_view.h" | 37 #include "ui/views/controls/image_view.h" |
38 #include "ui/views/layout/fill_layout.h" | |
39 #include "ui/views/layout/layout_constants.h" | 38 #include "ui/views/layout/layout_constants.h" |
40 #include "ui/views/widget/widget.h" | 39 #include "ui/views/widget/widget.h" |
41 | 40 |
42 using views::Widget; | 41 using views::Widget; |
43 | 42 |
44 namespace chromeos { | 43 namespace chromeos { |
45 | 44 |
46 namespace { | 45 namespace { |
47 | 46 |
48 gfx::NativeWindow GetParentForUnhostedDialog() { | 47 gfx::NativeWindow GetParentForUnhostedDialog() { |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 // static | 305 // static |
307 void ChildNetworkConfigView::GetShareStateForLoginState(bool* default_value, | 306 void ChildNetworkConfigView::GetShareStateForLoginState(bool* default_value, |
308 bool* modifiable) { | 307 bool* modifiable) { |
309 *default_value = !LoginState::Get()->UserHasNetworkProfile(); | 308 *default_value = !LoginState::Get()->UserHasNetworkProfile(); |
310 // Allow only authenticated user to change the share state. | 309 // Allow only authenticated user to change the share state. |
311 *modifiable = LoginState::Get()->IsUserAuthenticated(); | 310 *modifiable = LoginState::Get()->IsUserAuthenticated(); |
312 } | 311 } |
313 | 312 |
314 // ControlledSettingIndicatorView | 313 // ControlledSettingIndicatorView |
315 | 314 |
| 315 ControlledSettingIndicatorView::ControlledSettingIndicatorView() |
| 316 : managed_(false), image_view_(nullptr) { |
| 317 Init(); |
| 318 } |
| 319 |
316 ControlledSettingIndicatorView::ControlledSettingIndicatorView( | 320 ControlledSettingIndicatorView::ControlledSettingIndicatorView( |
317 const NetworkPropertyUIData& ui_data) | 321 const NetworkPropertyUIData& ui_data) |
318 : managed_(ui_data.IsManaged()), image_view_(nullptr) { | 322 : managed_(false), image_view_(nullptr) { |
319 image_view_ = new views::ImageView(); | 323 Init(); |
320 // Disable |image_view_| so mouse events propagate to the parent. | 324 Update(ui_data); |
321 image_view_->SetEnabled(false); | |
322 image_view_->SetImage(gfx::CreateVectorIcon(gfx::VectorIconId::BUSINESS, 16, | |
323 gfx::kChromeIconGrey)); | |
324 image_view_->SetTooltipText( | |
325 l10n_util::GetStringUTF16(IDS_OPTIONS_CONTROLLED_SETTING_POLICY)); | |
326 AddChildView(image_view_); | |
327 SetLayoutManager(new views::FillLayout()); | |
328 } | 325 } |
329 | 326 |
330 ControlledSettingIndicatorView::~ControlledSettingIndicatorView() {} | 327 ControlledSettingIndicatorView::~ControlledSettingIndicatorView() {} |
331 | 328 |
| 329 void ControlledSettingIndicatorView::Update( |
| 330 const NetworkPropertyUIData& ui_data) { |
| 331 if (managed_ == ui_data.IsManaged()) |
| 332 return; |
| 333 |
| 334 managed_ = ui_data.IsManaged(); |
| 335 PreferredSizeChanged(); |
| 336 } |
| 337 |
332 gfx::Size ControlledSettingIndicatorView::GetPreferredSize() const { | 338 gfx::Size ControlledSettingIndicatorView::GetPreferredSize() const { |
333 return (managed_ && visible()) ? image_view_->GetPreferredSize() | 339 return (managed_ && visible()) ? image_view_->GetPreferredSize() |
334 : gfx::Size(); | 340 : gfx::Size(); |
335 } | 341 } |
336 | 342 |
| 343 void ControlledSettingIndicatorView::Layout() { |
| 344 image_view_->SetBounds(0, 0, width(), height()); |
| 345 } |
| 346 |
| 347 void ControlledSettingIndicatorView::Init() { |
| 348 image_ = ResourceBundle::GetSharedInstance() |
| 349 .GetImageNamed(IDR_OMNIBOX_HTTPS_POLICY_WARNING) |
| 350 .ToImageSkia(); |
| 351 image_view_ = new views::ImageView(); |
| 352 // Disable |image_view_| so mouse events propagate to the parent. |
| 353 image_view_->SetEnabled(false); |
| 354 image_view_->SetImage(image_); |
| 355 image_view_->SetTooltipText( |
| 356 l10n_util::GetStringUTF16(IDS_OPTIONS_CONTROLLED_SETTING_POLICY)); |
| 357 AddChildView(image_view_); |
| 358 } |
| 359 |
337 } // namespace chromeos | 360 } // namespace chromeos |
OLD | NEW |