Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(383)

Side by Side Diff: chrome/browser/chromeos/net/tether_notification_presenter.h

Issue 2861583002: [CrOS Tether] Open the Tether settings page when a tether notification body is clicked. (Closed)
Patch Set: stevenjb@ comments. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/chromeos/net/tether_notification_presenter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_CHROMEOS_NET_TETHER_NOTIFICATION_PRESENTER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_NET_TETHER_NOTIFICATION_PRESENTER_H_
6 #define CHROME_BROWSER_CHROMEOS_NET_TETHER_NOTIFICATION_PRESENTER_H_ 6 #define CHROME_BROWSER_CHROMEOS_NET_TETHER_NOTIFICATION_PRESENTER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/strings/string16.h" 14 #include "base/strings/string16.h"
15 #include "chromeos/components/tether/notification_presenter.h" 15 #include "chromeos/components/tether/notification_presenter.h"
16 #include "chromeos/network/network_connect.h" 16 #include "chromeos/network/network_connect.h"
17 #include "components/cryptauth/remote_device.h" 17 #include "components/cryptauth/remote_device.h"
18 #include "ui/message_center/message_center_observer.h" 18 #include "ui/message_center/message_center_observer.h"
19 #include "ui/message_center/notification.h" 19 #include "ui/message_center/notification.h"
20 20
21 class Profile;
22
21 namespace message_center { 23 namespace message_center {
22 class MessageCenter; 24 class MessageCenter;
23 class Notification; 25 class Notification;
24 } // namespace message_center 26 } // namespace message_center
25 27
26 namespace chromeos { 28 namespace chromeos {
27 29
28 namespace tether { 30 namespace tether {
29 31
30 // Produces notifications associated with CrOS tether network events and alerts 32 // Produces notifications associated with CrOS tether network events and alerts
31 // observers about interactions with those notifications. 33 // observers about interactions with those notifications.
32 class TetherNotificationPresenter 34 class TetherNotificationPresenter
33 : public NotificationPresenter, 35 : public NotificationPresenter,
34 public message_center::MessageCenterObserver { 36 public message_center::MessageCenterObserver {
35 public: 37 public:
36 // Caller must ensure that |message_center| amd |network_connect| outlive 38 // Caller must ensure that |profile|, |message_center|, and |network_connect|
37 // this instance. 39 // outlive this instance.
38 TetherNotificationPresenter(message_center::MessageCenter* message_center, 40 TetherNotificationPresenter(Profile* profile,
41 message_center::MessageCenter* message_center,
39 NetworkConnect* network_connect); 42 NetworkConnect* network_connect);
40 ~TetherNotificationPresenter() override; 43 ~TetherNotificationPresenter() override;
41 44
42 // NotificationPresenter: 45 // NotificationPresenter:
43 void NotifyPotentialHotspotNearby( 46 void NotifyPotentialHotspotNearby(
44 const cryptauth::RemoteDevice& remote_device) override; 47 const cryptauth::RemoteDevice& remote_device) override;
45 void NotifyMultiplePotentialHotspotsNearby() override; 48 void NotifyMultiplePotentialHotspotsNearby() override;
46 void RemovePotentialHotspotNotification() override; 49 void RemovePotentialHotspotNotification() override;
47 void NotifyConnectionToHostFailed() override; 50 void NotifyConnectionToHostFailed() override;
48 void RemoveConnectionToHostFailedNotification() override; 51 void RemoveConnectionToHostFailedNotification() override;
49 52
50 // message_center::MessageCenterObserver: 53 // message_center::MessageCenterObserver:
51 void OnNotificationClicked(const std::string& notification_id) override; 54 void OnNotificationClicked(const std::string& notification_id) override;
52 void OnNotificationButtonClicked(const std::string& notification_id, 55 void OnNotificationButtonClicked(const std::string& notification_id,
53 int button_index) override; 56 int button_index) override;
54 57
58 class SettingsUiDelegate {
59 public:
60 virtual ~SettingsUiDelegate() {}
61
62 // Displays the settings page (opening a new window if necessary) at the
63 // provided subpage for the user with the Profile |profile|.
64 virtual void ShowSettingsSubPageForProfile(Profile* profile,
65 const std::string& sub_page) = 0;
66 };
67
55 private: 68 private:
56 friend class TetherNotificationPresenterTest;
57
58 static const char kTetherNotifierId[]; 69 static const char kTetherNotifierId[];
59 static const char kPotentialHotspotNotificationId[]; 70 static const char kPotentialHotspotNotificationId[];
60 static const char kActiveHostNotificationId[]; 71 static const char kActiveHostNotificationId[];
61 72
62 static std::unique_ptr<message_center::Notification> CreateNotification( 73 static std::unique_ptr<message_center::Notification> CreateNotification(
63 const std::string& id, 74 const std::string& id,
64 const base::string16& title, 75 const base::string16& title,
65 const base::string16& message); 76 const base::string16& message);
66 static std::unique_ptr<message_center::Notification> CreateNotification( 77 static std::unique_ptr<message_center::Notification> CreateNotification(
67 const std::string& id, 78 const std::string& id,
68 const base::string16& title, 79 const base::string16& title,
69 const base::string16& message, 80 const base::string16& message,
70 const message_center::RichNotificationData rich_notification_data); 81 const message_center::RichNotificationData rich_notification_data);
71 82
83 friend class TetherNotificationPresenterTest;
84
85 void SetSettingsUiDelegateForTesting(
86 std::unique_ptr<SettingsUiDelegate> settings_ui_delegate);
87
72 void ShowNotification( 88 void ShowNotification(
73 std::unique_ptr<message_center::Notification> notification); 89 std::unique_ptr<message_center::Notification> notification);
74 90
91 Profile* profile_;
75 message_center::MessageCenter* message_center_; 92 message_center::MessageCenter* message_center_;
76 NetworkConnect* network_connect_; 93 NetworkConnect* network_connect_;
77 94
95 std::unique_ptr<SettingsUiDelegate> settings_ui_delegate_;
96
78 cryptauth::RemoteDevice hotspot_nearby_device_; 97 cryptauth::RemoteDevice hotspot_nearby_device_;
79 base::WeakPtrFactory<TetherNotificationPresenter> weak_ptr_factory_; 98 base::WeakPtrFactory<TetherNotificationPresenter> weak_ptr_factory_;
80 99
81 DISALLOW_COPY_AND_ASSIGN(TetherNotificationPresenter); 100 DISALLOW_COPY_AND_ASSIGN(TetherNotificationPresenter);
82 }; 101 };
83 102
84 } // namespace tether 103 } // namespace tether
85 104
86 } // namespace chromeos 105 } // namespace chromeos
87 106
88 #endif // CHROME_BROWSER_CHROMEOS_NET_TETHER_NOTIFICATION_PRESENTER_H_ 107 #endif // CHROME_BROWSER_CHROMEOS_NET_TETHER_NOTIFICATION_PRESENTER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/net/tether_notification_presenter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698