diff options
author | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-23 04:10:49 +0000 |
---|---|---|
committer | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-23 04:10:49 +0000 |
commit | ca1bb9300e48706fde29065dd685f8d32da60106 (patch) | |
tree | a1ab97c819185331210e4e1e03fd534dbac65247 /ui/message_center/notifier_settings.h | |
parent | e01dddb11b56d56beeaeadc1fdb300419f50c2e3 (diff) | |
download | chromium_src-ca1bb9300e48706fde29065dd685f8d32da60106.zip chromium_src-ca1bb9300e48706fde29065dd685f8d32da60106.tar.gz chromium_src-ca1bb9300e48706fde29065dd685f8d32da60106.tar.bz2 |
Introduces the UI for the settings of notifiers.
Although this adds the UI, it's still unavailable because there remain
two large TODOs:
- icon loader
- integration with preferences
They'll be done in other CLs.
BUG=161094
Review URL: https://chromiumcodereview.appspot.com/12018006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178240 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/message_center/notifier_settings.h')
-rw-r--r-- | ui/message_center/notifier_settings.h | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/ui/message_center/notifier_settings.h b/ui/message_center/notifier_settings.h new file mode 100644 index 0000000..a8f3bb0 --- /dev/null +++ b/ui/message_center/notifier_settings.h @@ -0,0 +1,95 @@ +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_MESSAGE_CENTER_NOTIFIER_SETTINGS_H_ +#define UI_MESSAGE_CENTER_NOTIFIER_SETTINGS_H_ + +#include <map> +#include <string> +#include <vector> + +#include "base/string16.h" +#include "ui/gfx/image/image_skia.h" +#include "ui/message_center/message_center_export.h" +#include "ui/views/controls/button/button.h" +#include "ui/views/widget/widget_delegate.h" + +namespace message_center { + +// A class to show the list of notifier extensions / URL patterns and allow +// users to customize the settings. +class MESSAGE_CENTER_EXPORT NotifierSettingsView + : public views::WidgetDelegateView, + public views::ButtonListener { + public: + struct MESSAGE_CENTER_EXPORT Notifier { + enum NotifierType { + APPLICATION, + URL_PATTERN, + }; + + Notifier(const std::string& id, NotifierType type, const string16& name); + + // The identifier of the notifier. The extension id or URL pattern itself. + std::string id; + + // The human-readable name of the notifier such like the extension name. + // It can be empty. + string16 name; + + // True if the source is allowed to send notifications. True is default. + bool enabled; + + // The type of notifier: Chrome app or URL pattern. + NotifierType type; + + // The icon image of the notifier. The extension icon or favicon. + gfx::ImageSkia icon; + }; + + class MESSAGE_CENTER_EXPORT Delegate { + public: + // Collects the current notifier list and fills to |notifiers|. + virtual void GetNotifierList(std::vector<Notifier>* notifiers) = 0; + + // Called when the |enabled| for the |id| has been changed by user + // operation. + virtual void SetNotifierEnabled(const std::string& id, bool enabled) = 0; + + // Called when the settings window is closed. + virtual void OnNotifierSettingsClosing(NotifierSettingsView* view) = 0; + }; + + // Create a new widget of the notifier settings and returns it. Note that + // the widget and the view is self-owned. It'll be deleted when it's closed + // or the chrome's shutdown. + static NotifierSettingsView* Create(Delegate* delegate); + + void UpdateIconImage(const std::string& id, const gfx::ImageSkia& icon); + + private: + class NotifierButton; + + NotifierSettingsView(Delegate* delegate); + virtual ~NotifierSettingsView(); + + // views::WidgetDelegate overrides: + virtual bool CanResize() const OVERRIDE; + virtual string16 GetWindowTitle() const OVERRIDE; + virtual void WindowClosing() OVERRIDE; + virtual views::View* GetContentsView() OVERRIDE; + + // views::ButtonListener overrides: + virtual void ButtonPressed(views::Button* sender, + const ui::Event& event) OVERRIDE; + + Delegate* delegate_; + std::set<NotifierButton*> buttons_; + + DISALLOW_COPY_AND_ASSIGN(NotifierSettingsView); +}; + +} // namespace message_center + +#endif // UI_MESSAGE_CENTER_NOTIFIER_SETTINGS_H_ |