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

Side by Side Diff: chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_connection_manager.h

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header Created 4 years, 8 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_EXTENSIONS_API_EASY_UNLOCK_PRIVATE_EASY_UNLOCK_PRIVATE_CO NNECTION_MANAGER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_EASY_UNLOCK_PRIVATE_EASY_UNLOCK_PRIVATE_CO NNECTION_MANAGER_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_EASY_UNLOCK_PRIVATE_EASY_UNLOCK_PRIVATE_CO NNECTION_MANAGER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_EASY_UNLOCK_PRIVATE_EASY_UNLOCK_PRIVATE_CO NNECTION_MANAGER_H_
7 7
8 #include <memory>
8 #include <set> 9 #include <set>
9 #include <string> 10 #include <string>
10 11
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_ connection.h" 13 #include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_ connection.h"
14 #include "chrome/common/extensions/api/easy_unlock_private.h" 14 #include "chrome/common/extensions/api/easy_unlock_private.h"
15 #include "components/proximity_auth/connection.h" 15 #include "components/proximity_auth/connection.h"
16 #include "components/proximity_auth/connection_observer.h" 16 #include "components/proximity_auth/connection_observer.h"
17 #include "components/proximity_auth/wire_message.h" 17 #include "components/proximity_auth/wire_message.h"
18 18
19 namespace content { 19 namespace content {
20 class BrowserContext; 20 class BrowserContext;
21 } // namespace content 21 } // namespace content
22 22
23 namespace extensions { 23 namespace extensions {
24 24
25 class Extension; 25 class Extension;
26 26
27 // EasyUnlockPrivateConnectionManager is used by the EasyUnlockPrivateAPI to 27 // EasyUnlockPrivateConnectionManager is used by the EasyUnlockPrivateAPI to
28 // interface with proximity_auth::Connection. 28 // interface with proximity_auth::Connection.
29 class EasyUnlockPrivateConnectionManager 29 class EasyUnlockPrivateConnectionManager
30 : public proximity_auth::ConnectionObserver { 30 : public proximity_auth::ConnectionObserver {
31 public: 31 public:
32 explicit EasyUnlockPrivateConnectionManager(content::BrowserContext* context); 32 explicit EasyUnlockPrivateConnectionManager(content::BrowserContext* context);
33 ~EasyUnlockPrivateConnectionManager() override; 33 ~EasyUnlockPrivateConnectionManager() override;
34 34
35 // Stores |connection| in the API connection manager. Returns the 35 // Stores |connection| in the API connection manager. Returns the
36 // |connection_id|. 36 // |connection_id|.
37 int AddConnection(const Extension* extension, 37 int AddConnection(const Extension* extension,
38 scoped_ptr<proximity_auth::Connection> connection, 38 std::unique_ptr<proximity_auth::Connection> connection,
39 bool persistent); 39 bool persistent);
40 40
41 // Returns the status of the connection with |connection_id|. 41 // Returns the status of the connection with |connection_id|.
42 api::easy_unlock_private::ConnectionStatus ConnectionStatus( 42 api::easy_unlock_private::ConnectionStatus ConnectionStatus(
43 const Extension* extension, 43 const Extension* extension,
44 int connection_id) const; 44 int connection_id) const;
45 45
46 // Disconnects the connection with |connection_id|. Returns true if 46 // Disconnects the connection with |connection_id|. Returns true if
47 // |connection_id| is valid. 47 // |connection_id| is valid.
48 bool Disconnect(const Extension* extension, int connection_id); 48 bool Disconnect(const Extension* extension, int connection_id);
(...skipping 20 matching lines...) Expand all
69 const proximity_auth::WireMessage& message, 69 const proximity_auth::WireMessage& message,
70 bool success) override; 70 bool success) override;
71 71
72 private: 72 private:
73 // Dispatches |event_name| with |args| to all listeners. Retrieves the 73 // Dispatches |event_name| with |args| to all listeners. Retrieves the
74 // |connection_id| corresponding to the event and rewrite the first argument 74 // |connection_id| corresponding to the event and rewrite the first argument
75 // in |args| with it. 75 // in |args| with it.
76 void DispatchConnectionEvent(const std::string& event_name, 76 void DispatchConnectionEvent(const std::string& event_name,
77 events::HistogramValue histogram_value, 77 events::HistogramValue histogram_value,
78 const proximity_auth::Connection* connection, 78 const proximity_auth::Connection* connection,
79 scoped_ptr<base::ListValue> args); 79 std::unique_ptr<base::ListValue> args);
80 80
81 // Convenience method to get the API resource manager. 81 // Convenience method to get the API resource manager.
82 ApiResourceManager<EasyUnlockPrivateConnection>* GetResourceManager() const; 82 ApiResourceManager<EasyUnlockPrivateConnection>* GetResourceManager() const;
83 83
84 // Convenience method to get the connection with |connection_id| created by 84 // Convenience method to get the connection with |connection_id| created by
85 // extension with |extension_id| from the API resource manager. 85 // extension with |extension_id| from the API resource manager.
86 proximity_auth::Connection* GetConnection(const std::string& extension_id, 86 proximity_auth::Connection* GetConnection(const std::string& extension_id,
87 int connection_id) const; 87 int connection_id) const;
88 88
89 // Find the connection_id for |connection| owned by |extension_id| from the 89 // Find the connection_id for |connection| owned by |extension_id| from the
90 // API resource manager. 90 // API resource manager.
91 int FindConnectionId(const std::string& extension_id, 91 int FindConnectionId(const std::string& extension_id,
92 const proximity_auth::Connection* connection); 92 const proximity_auth::Connection* connection);
93 93
94 // BrowserContext passed during initialization. 94 // BrowserContext passed during initialization.
95 content::BrowserContext* browser_context_; 95 content::BrowserContext* browser_context_;
96 96
97 // The set of extensions that have at least one connection. 97 // The set of extensions that have at least one connection.
98 std::set<std::string> extensions_; 98 std::set<std::string> extensions_;
99 99
100 DISALLOW_COPY_AND_ASSIGN(EasyUnlockPrivateConnectionManager); 100 DISALLOW_COPY_AND_ASSIGN(EasyUnlockPrivateConnectionManager);
101 }; 101 };
102 102
103 } // namespace extensions 103 } // namespace extensions
104 104
105 #endif // CHROME_BROWSER_EXTENSIONS_API_EASY_UNLOCK_PRIVATE_EASY_UNLOCK_PRIVATE _CONNECTION_MANAGER_H_ 105 #endif // CHROME_BROWSER_EXTENSIONS_API_EASY_UNLOCK_PRIVATE_EASY_UNLOCK_PRIVATE _CONNECTION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698