notifier_settings.h revision c2e0dbddbe15c98d52c4786dac06cb8952a8ae6d
1// Copyright (c) 2013 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef UI_MESSAGE_CENTER_NOTIFIER_SETTINGS_H_ 6#define UI_MESSAGE_CENTER_NOTIFIER_SETTINGS_H_ 7 8#include <string> 9 10#include "base/string16.h" 11#include "googleurl/src/gurl.h" 12#include "ui/gfx/image/image.h" 13#include "ui/message_center/message_center_export.h" 14 15namespace message_center { 16 17class NotifierSettingsDelegate; 18class NotifierSettingsProvider; 19 20// Brings up the settings dialog and returns a weak reference to the delegate, 21// which is typically the view. If the dialog already exists, it is brought to 22// the front, otherwise it is created. 23MESSAGE_CENTER_EXPORT NotifierSettingsDelegate* ShowSettings( 24 NotifierSettingsProvider* provider, 25 gfx::NativeView context); 26 27// The struct to hold the information of notifiers. The information will be 28// used by NotifierSettingsView. 29struct MESSAGE_CENTER_EXPORT Notifier { 30 enum NotifierType { 31 APPLICATION, 32 WEB_PAGE, 33 SYSTEM_COMPONENT, 34 }; 35 36 enum SystemComponentNotifierType { 37 NONE, 38 SCREENSHOT, 39 }; 40 41 // Constructor for APPLICATION type. 42 Notifier(const std::string& id, const string16& name, bool enabled); 43 44 // Constructor for WEB_PAGE type. 45 Notifier(const GURL& url, const string16& name, bool enabled); 46 47 // Constructor for SYSTEM_COMPONENT type. 48 Notifier(SystemComponentNotifierType type, 49 const string16& name, bool enabled); 50 51 ~Notifier(); 52 53 // The identifier of the app notifier. Empty if it's URL_PATTERN. 54 std::string id; 55 56 // The URL pattern of the notifer. 57 GURL url; 58 59 // The type of system component notifier. 60 SystemComponentNotifierType system_component_type; 61 62 // The human-readable name of the notifier such like the extension name. 63 // It can be empty. 64 string16 name; 65 66 // True if the source is allowed to send notifications. True is default. 67 bool enabled; 68 69 // The type of notifier: Chrome app, URL pattern, or System component. 70 NotifierType type; 71 72 // The icon image of the notifier. The extension icon or favicon. 73 gfx::Image icon; 74 75 private: 76 DISALLOW_COPY_AND_ASSIGN(Notifier); 77}; 78 79MESSAGE_CENTER_EXPORT std::string ToString( 80 Notifier::SystemComponentNotifierType type); 81MESSAGE_CENTER_EXPORT Notifier::SystemComponentNotifierType 82 ParseSystemComponentName(const std::string& name); 83 84// A class used by NotifierSettingsView to integrate with a setting system 85// for the clients of this module. 86class MESSAGE_CENTER_EXPORT NotifierSettingsProvider { 87 public: 88 // Collects the current notifier list and fills to |notifiers|. Caller takes 89 // the ownership of the elements of |notifiers|. 90 virtual void GetNotifierList(std::vector<Notifier*>* notifiers) = 0; 91 92 // Called when the |enabled| for the |notifier| has been changed by user 93 // operation. 94 virtual void SetNotifierEnabled(const Notifier& notifier, bool enabled) = 0; 95 96 // Called when the settings window is closed. 97 virtual void OnNotifierSettingsClosing() = 0; 98}; 99 100// A delegate class implemented by the view of the NotifierSettings to get 101// notified when the controller has changed data. 102class MESSAGE_CENTER_EXPORT NotifierSettingsDelegate { 103 public: 104 // Called when an icon in the controller has been updated. 105 virtual void UpdateIconImage(const std::string& id, 106 const gfx::Image& icon) = 0; 107 108 // Called when the controller detects that a favicon has changed. 109 virtual void UpdateFavicon(const GURL& url, const gfx::Image& icon) = 0; 110}; 111 112} // namespace message_center 113 114#endif // UI_MESSAGE_CENTER_NOTIFIER_SETTINGS_H_ 115