Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / notifications / sync_notifier / chrome_notifier_delegate.h
blob4bf75fedf9f45c130c1946a40147b6c97065ba58
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.
5 #ifndef CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_CHROME_NOTIFIER_DELEGATE_H_
6 #define CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_CHROME_NOTIFIER_DELEGATE_H_
8 #include <map>
9 #include <string>
11 #include "chrome/browser/notifications/notification_delegate.h"
12 #include "url/gurl.h"
14 namespace notifier {
16 enum SyncedNotificationActionType {
17 SYNCED_NOTIFICATION_ACTION_UNKNOWN,
18 SYNCED_NOTIFICATION_ACTION_CLICK,
19 SYNCED_NOTIFICATION_ACTION_BUTTON_CLICK,
20 SYNCED_NOTIFICATION_ACTION_CLOSE_BY_USER,
21 SYNCED_NOTIFICATION_ACTION_CLOSE_BY_SYSTEM,
22 SYNCED_NOTIFICATION_ACTION_TOAST_TIMEOUT,
23 // NOTE: Add new action types only immediately above this line. Also,
24 // make sure the enum list in tools/histogram/histograms.xml is
25 // updated with any change in here.
26 SYNCED_NOTIFICATION_ACTION_COUNT
29 class ChromeNotifierService;
31 // ChromeNotifierDelegate is a NotificationDelegate which catches
32 // responses from the NotificationUIManager when a notification
33 // has been closed.
35 class ChromeNotifierDelegate : public NotificationDelegate {
36 public:
37 // We use an id instead of a notification so we can check to see if the
38 // notification still exists before acting on it instead of using a ref count.
39 explicit ChromeNotifierDelegate(const std::string& notification_id,
40 ChromeNotifierService* notifier);
42 // NotificationDelegate interface.
43 virtual void Display() OVERRIDE {}
44 virtual void Error() OVERRIDE {}
45 virtual void Close(bool by_user) OVERRIDE;
46 virtual void Click() OVERRIDE;
47 virtual void ButtonClick(int button_index) OVERRIDE;
48 virtual std::string id() const OVERRIDE;
50 virtual content::RenderViewHost* GetRenderViewHost() const OVERRIDE;
52 void CollectAction(SyncedNotificationActionType type);
54 private:
55 virtual ~ChromeNotifierDelegate();
56 void NavigateToUrl(const GURL& destination) const;
58 const std::string notification_id_;
59 ChromeNotifierService* const chrome_notifier_;
61 DISALLOW_COPY_AND_ASSIGN(ChromeNotifierDelegate);
64 } // namespace notifier
66 #endif // CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_CHROME_NOTIFIER_DELEGATE_H_