Index: chrome/browser/chromeos/options/network_config_view.cc |
diff --git a/chrome/browser/chromeos/options/network_config_view.cc b/chrome/browser/chromeos/options/network_config_view.cc |
index 595253450540c73b2ef9d9cc911d070131ecb9f3..a413966d9df2f16fdc522628e3e066fc7b8b7e90 100644 |
--- a/chrome/browser/chromeos/options/network_config_view.cc |
+++ b/chrome/browser/chromeos/options/network_config_view.cc |
@@ -13,13 +13,17 @@ |
#include "grit/chromium_strings.h" |
#include "grit/generated_resources.h" |
#include "grit/locale_settings.h" |
+#include "grit/theme_resources.h" |
#include "ui/base/accessibility/accessible_view_state.h" |
#include "ui/base/l10n/l10n_util.h" |
+#include "ui/base/resource/resource_bundle.h" |
+#include "ui/gfx/image/image.h" |
#include "ui/gfx/rect.h" |
#include "ui/views/controls/button/text_button.h" |
#include "ui/views/layout/grid_layout.h" |
#include "ui/views/layout/layout_constants.h" |
#include "ui/views/widget/widget.h" |
+#include "views/controls/image_view.h" |
namespace chromeos { |
@@ -187,4 +191,69 @@ void NetworkConfigView::CreateAdvancedButton() { |
layout->AddView(advanced_button_); |
} |
+ControlledSettingIndicatorView::ControlledSettingIndicatorView() |
+ : controller_(NetworkPropertyUIData::CONTROLLER_USER), |
+ image_view_(NULL) { |
+ Init(); |
+} |
+ |
+ControlledSettingIndicatorView::ControlledSettingIndicatorView( |
+ const NetworkPropertyUIData& ui_data) |
+ : controller_(NetworkPropertyUIData::CONTROLLER_USER), |
+ image_view_(NULL) { |
+ Init(); |
+ Update(ui_data); |
+} |
+ |
+ControlledSettingIndicatorView::~ControlledSettingIndicatorView() {} |
+ |
+void ControlledSettingIndicatorView::Update( |
+ const NetworkPropertyUIData& ui_data) { |
+ if (controller_ == ui_data.controller()) |
+ 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.
|
+ |
+ controller_ = ui_data.controller(); |
+ PreferredSizeChanged(); |
+} |
+ |
+gfx::Size ControlledSettingIndicatorView::GetPreferredSize() { |
+ if (!IsVisible()) |
+ return gfx::Size(); |
+ |
+ return image_view_->GetPreferredSize(); |
+} |
+ |
+bool ControlledSettingIndicatorView::IsVisible() const { |
+ return controller_ == NetworkPropertyUIData::CONTROLLER_POLICY && |
+ views::View::IsVisible(); |
+} |
+ |
+void ControlledSettingIndicatorView::Layout() { |
+ image_view_->SetBounds(0, 0, width(), height()); |
+} |
+ |
+void ControlledSettingIndicatorView::OnMouseEntered( |
+ const views::MouseEvent& event) { |
+ image_view_->SetImage(color_image_); |
+} |
+ |
+void ControlledSettingIndicatorView::OnMouseExited( |
+ const views::MouseEvent& event) { |
+ image_view_->SetImage(gray_image_); |
+} |
+ |
+void ControlledSettingIndicatorView::Init() { |
+ color_image_ = ResourceBundle::GetSharedInstance().GetImageNamed( |
+ IDR_CONTROLLED_SETTING_MANDATORY).ToSkBitmap(); |
+ gray_image_ = ResourceBundle::GetSharedInstance().GetImageNamed( |
+ IDR_CONTROLLED_SETTING_MANDATORY_GRAY).ToSkBitmap(); |
+ image_view_ = new views::ImageView(); |
+ // 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.
|
+ image_view_->SetEnabled(false); |
+ image_view_->SetImage(gray_image_); |
+ image_view_->SetTooltipText( |
+ l10n_util::GetStringUTF16(IDS_OPTIONS_CONTROLLED_SETTING_POLICY)); |
+ AddChildView(image_view_); |
+} |
+ |
} // namespace chromeos |