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

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: Removed file which did not belong in this CL. 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
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
55 private: 58 private:
56 friend class TetherNotificationPresenterTest;
57
58 static const char kTetherNotifierId[]; 59 static const char kTetherNotifierId[];
59 static const char kPotentialHotspotNotificationId[]; 60 static const char kPotentialHotspotNotificationId[];
60 static const char kActiveHostNotificationId[]; 61 static const char kActiveHostNotificationId[];
61 62
62 static std::unique_ptr<message_center::Notification> CreateNotification( 63 static std::unique_ptr<message_center::Notification> CreateNotification(
63 const std::string& id, 64 const std::string& id,
64 const base::string16& title, 65 const base::string16& title,
65 const base::string16& message); 66 const base::string16& message);
66 static std::unique_ptr<message_center::Notification> CreateNotification( 67 static std::unique_ptr<message_center::Notification> CreateNotification(
67 const std::string& id, 68 const std::string& id,
68 const base::string16& title, 69 const base::string16& title,
69 const base::string16& message, 70 const base::string16& message,
70 const message_center::RichNotificationData rich_notification_data); 71 const message_center::RichNotificationData rich_notification_data);
71 72
73 friend class TetherNotificationPresenterTest;
74
75 class SettingsUiDelegate {
76 public:
77 SettingsUiDelegate();
78 virtual ~SettingsUiDelegate();
stevenjb 2017/05/03 23:07:44 blank line and comment for ShowSettingsSubPageForP
Kyle Horimoto 2017/05/03 23:25:48 Done.
79 virtual void ShowSettingsSubPageForProfile(Profile* profile,
80 const std::string& sub_page);
stevenjb 2017/05/03 23:07:44 This should be a pure virtual. Create a local Impl
Kyle Horimoto 2017/05/03 23:25:48 Done, but I made the destructor public. Otherwise,
stevenjb 2017/05/03 23:42:37 Acknowledged.
81 };
82
83 void SetSettingsUiDelegateForTesting(
84 std::unique_ptr<SettingsUiDelegate> settings_ui_delegate);
stevenjb 2017/05/03 23:07:44 blank line
Kyle Horimoto 2017/05/03 23:25:48 Done.
72 void ShowNotification( 85 void ShowNotification(
73 std::unique_ptr<message_center::Notification> notification); 86 std::unique_ptr<message_center::Notification> notification);
74 87
88 Profile* profile_;
75 message_center::MessageCenter* message_center_; 89 message_center::MessageCenter* message_center_;
76 NetworkConnect* network_connect_; 90 NetworkConnect* network_connect_;
77 91
92 std::unique_ptr<SettingsUiDelegate> settings_ui_delegate_;
93
78 cryptauth::RemoteDevice hotspot_nearby_device_; 94 cryptauth::RemoteDevice hotspot_nearby_device_;
79 base::WeakPtrFactory<TetherNotificationPresenter> weak_ptr_factory_; 95 base::WeakPtrFactory<TetherNotificationPresenter> weak_ptr_factory_;
80 96
81 DISALLOW_COPY_AND_ASSIGN(TetherNotificationPresenter); 97 DISALLOW_COPY_AND_ASSIGN(TetherNotificationPresenter);
82 }; 98 };
83 99
84 } // namespace tether 100 } // namespace tether
85 101
86 } // namespace chromeos 102 } // namespace chromeos
87 103
88 #endif // CHROME_BROWSER_CHROMEOS_NET_TETHER_NOTIFICATION_PRESENTER_H_ 104 #endif // CHROME_BROWSER_CHROMEOS_NET_TETHER_NOTIFICATION_PRESENTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698