Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / ui / message_center / views / notifier_settings_view.cc
index 719addf..856546b 100644 (file)
@@ -9,8 +9,6 @@
 
 #include "base/strings/string16.h"
 #include "base/strings/utf_string_conversions.h"
-#include "grit/ui_resources.h"
-#include "grit/ui_strings.h"
 #include "skia/ext/image_operations.h"
 #include "third_party/skia/include/core/SkColor.h"
 #include "ui/base/l10n/l10n_util.h"
 #include "ui/gfx/size.h"
 #include "ui/message_center/message_center_style.h"
 #include "ui/message_center/views/message_center_view.h"
+#include "ui/resources/grit/ui_resources.h"
+#include "ui/strings/grit/ui_strings.h"
 #include "ui/views/background.h"
 #include "ui/views/border.h"
 #include "ui/views/controls/button/checkbox.h"
-#include "ui/views/controls/button/custom_button.h"
 #include "ui/views/controls/button/label_button_border.h"
 #include "ui/views/controls/button/menu_button.h"
 #include "ui/views/controls/image_view.h"
 #include "ui/views/painter.h"
 #include "ui/views/widget/widget.h"
 
-#if defined(USE_AURA)
-#include "ui/aura/window.h"
-#endif
-
 namespace message_center {
 namespace settings {
 
@@ -73,14 +68,8 @@ const int kTitleMargin = 10;
 
 namespace {
 
-// The amount of built-in padding for the notifier group switcher.
-const int kButtonPainterInsets = 5;
-
 // Menu button metrics to make the text line up.
 const int kMenuButtonInnateMargin = 2;
-const int kMenuButtonLeftPadding = 12;
-const int kMenuButtonRightPadding = 13;
-const int kMenuButtonVerticalPadding = 9;
 
 // Used to place the context menu correctly.
 const int kMenuWhitespaceOffset = 2;
@@ -122,7 +111,7 @@ const int kComputedTitleTopMargin =
 // The switcher has a lot of blank space built in so we should include that when
 // spacing the title area vertically.
 const int kComputedTitleElementSpacing =
-    settings::kDescriptionToSwitcherSpace - kButtonPainterInsets - 1;
+    settings::kDescriptionToSwitcherSpace - 6;
 
 // A function to create a focus border.
 scoped_ptr<views::Painter> CreateFocusPainter() {
@@ -137,17 +126,17 @@ scoped_ptr<views::Painter> CreateFocusPainter() {
 class EntryView : public views::View {
  public:
   explicit EntryView(views::View* contents);
-  virtual ~EntryView();
+  ~EntryView() override;
 
   // views::View:
-  virtual void Layout() OVERRIDE;
-  virtual gfx::Size GetPreferredSize() OVERRIDE;
-  virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE;
-  virtual void OnFocus() OVERRIDE;
-  virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE;
-  virtual bool OnKeyReleased(const ui::KeyEvent& event) OVERRIDE;
-  virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
-  virtual void OnBlur() OVERRIDE;
+  void Layout() override;
+  gfx::Size GetPreferredSize() const override;
+  void GetAccessibleState(ui::AXViewState* state) override;
+  void OnFocus() override;
+  bool OnKeyPressed(const ui::KeyEvent& event) override;
+  bool OnKeyReleased(const ui::KeyEvent& event) override;
+  void OnPaint(gfx::Canvas* canvas) override;
+  void OnBlur() override;
 
  private:
   scoped_ptr<views::Painter> focus_painter_;
@@ -171,7 +160,7 @@ void EntryView::Layout() {
   content->SetBounds(0, y, content_width, content_height);
 }
 
-gfx::Size EntryView::GetPreferredSize() {
+gfx::Size EntryView::GetPreferredSize() const {
   DCHECK_EQ(1, child_count());
   gfx::Size size = child_at(0)->GetPreferredSize();
   size.SetToMax(gfx::Size(settings::kWidth, settings::kEntryHeight));
@@ -218,15 +207,14 @@ class NotifierGroupMenuModel : public ui::SimpleMenuModel,
                                public ui::SimpleMenuModel::Delegate {
  public:
   NotifierGroupMenuModel(NotifierSettingsProvider* notifier_settings_provider);
-  virtual ~NotifierGroupMenuModel();
+  ~NotifierGroupMenuModel() override;
 
   // ui::SimpleMenuModel::Delegate:
-  virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
-  virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE;
-  virtual bool GetAcceleratorForCommandId(
-      int command_id,
-      ui::Accelerator* accelerator) OVERRIDE;
-  virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE;
+  bool IsCommandIdChecked(int command_id) const override;
+  bool IsCommandIdEnabled(int command_id) const override;
+  bool GetAcceleratorForCommandId(int command_id,
+                                  ui::Accelerator* accelerator) override;
+  void ExecuteCommand(int command_id, int event_flags) override;
 
  private:
   NotifierSettingsProvider* notifier_settings_provider_;
@@ -544,6 +532,9 @@ void NotifierSettingsView::NotifierGroupChanged() {
   UpdateContentsView(notifiers);
 }
 
+void NotifierSettingsView::NotifierEnabledChanged(const NotifierId& notifier_id,
+                                                  bool enabled) {}
+
 void NotifierSettingsView::UpdateContentsView(
     const std::vector<Notifier*>& notifiers) {
   buttons_.clear();
@@ -583,22 +574,8 @@ void NotifierSettingsView::UpdateContentsView(
         active_group.name : active_group.login_info;
     notifier_group_selector_ =
         new views::MenuButton(NULL, notifier_group_text, this, true);
-    scoped_ptr<views::TextButtonDefaultBorder> selector_border(
-        new views::TextButtonDefaultBorder());
-    ui::ResourceBundle* rb = &ResourceBundle::GetSharedInstance();
-    gfx::Insets painter_insets(kButtonPainterInsets, kButtonPainterInsets,
-                               kButtonPainterInsets, kButtonPainterInsets);
-    selector_border->set_normal_painter(views::Painter::CreateImagePainter(
-        *rb->GetImageSkiaNamed(IDR_BUTTON_NORMAL), painter_insets));
-    selector_border->set_hot_painter(views::Painter::CreateImagePainter(
-        *rb->GetImageSkiaNamed(IDR_BUTTON_HOVER), painter_insets));
-    selector_border->set_pushed_painter(views::Painter::CreateImagePainter(
-        *rb->GetImageSkiaNamed(IDR_BUTTON_PRESSED), painter_insets));
-    selector_border->SetInsets(gfx::Insets(
-        kMenuButtonVerticalPadding, kMenuButtonLeftPadding,
-        kMenuButtonVerticalPadding, kMenuButtonRightPadding));
-    notifier_group_selector_->SetBorder(
-        selector_border.PassAs<views::Border>());
+    notifier_group_selector_->SetBorder(scoped_ptr<views::Border>(
+        new views::LabelButtonBorder(views::Button::STYLE_BUTTON)).Pass());
     notifier_group_selector_->SetFocusPainter(scoped_ptr<views::Painter>());
     notifier_group_selector_->set_animate_on_state_change(false);
     notifier_group_selector_->SetFocusable(true);
@@ -656,7 +633,7 @@ void NotifierSettingsView::Layout() {
   scroller_->SetBounds(0, title_height, width(), height() - title_height);
 }
 
-gfx::Size NotifierSettingsView::GetMinimumSize() {
+gfx::Size NotifierSettingsView::GetMinimumSize() const {
   gfx::Size size(settings::kWidth, settings::kMinimumHeight);
   int total_height = title_label_->GetPreferredSize().height() +
                      scroller_->contents()->GetPreferredSize().height();
@@ -665,7 +642,7 @@ gfx::Size NotifierSettingsView::GetMinimumSize() {
   return size;
 }
 
-gfx::Size NotifierSettingsView::GetPreferredSize() {
+gfx::Size NotifierSettingsView::GetPreferredSize() const {
   gfx::Size preferred_size;
   gfx::Size title_size = title_label_->GetPreferredSize();
   gfx::Size content_size = scroller_->contents()->GetPreferredSize();
@@ -708,8 +685,8 @@ void NotifierSettingsView::ButtonPressed(views::Button* sender,
 void NotifierSettingsView::OnMenuButtonClicked(views::View* source,
                                                const gfx::Point& point) {
   notifier_group_menu_model_.reset(new NotifierGroupMenuModel(provider_));
-  notifier_group_menu_runner_.reset(
-      new views::MenuRunner(notifier_group_menu_model_.get()));
+  notifier_group_menu_runner_.reset(new views::MenuRunner(
+      notifier_group_menu_model_.get(), views::MenuRunner::CONTEXT_MENU));
   gfx::Rect menu_anchor = source->GetBoundsInScreen();
   menu_anchor.Inset(
       gfx::Insets(0, kMenuWhitespaceOffset, 0, kMenuWhitespaceOffset));
@@ -717,9 +694,8 @@ void NotifierSettingsView::OnMenuButtonClicked(views::View* source,
       notifier_group_menu_runner_->RunMenuAt(GetWidget(),
                                              notifier_group_selector_,
                                              menu_anchor,
-                                             views::MenuItemView::BUBBLE_ABOVE,
-                                             ui::MENU_SOURCE_MOUSE,
-                                             views::MenuRunner::CONTEXT_MENU))
+                                             views::MENU_ANCHOR_BUBBLE_ABOVE,
+                                             ui::MENU_SOURCE_MOUSE))
     return;
   MessageCenterView* center_view = static_cast<MessageCenterView*>(parent());
   center_view->OnSettingsChanged();