Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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_COMMON_EXTENSIONS_PERMISSIONS_MEDIA_GALLERIES_PERMISSION_DATA_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SESSIONS_SESSION_ID_H__ |
| 6 #define CHROME_COMMON_EXTENSIONS_PERMISSIONS_MEDIA_GALLERIES_PERMISSION_DATA_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_SESSIONS_SESSION_ID_H__ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "chrome/common/extensions/permissions/api_permission.h" | |
| 13 | |
| 14 namespace base { | |
| 15 class Value; | |
| 16 } | |
| 17 | 12 |
| 18 namespace extensions { | 13 namespace extensions { |
| 19 | 14 |
| 20 // A MediaGalleriesPermissionData instance represents a single part of the | 15 class SessionId { |
| 21 // MediaGalleriesPermission. e.g. "read" or "allAutoDetected". | |
| 22 class MediaGalleriesPermissionData { | |
| 23 public: | 16 public: |
| 24 MediaGalleriesPermissionData(); | 17 // Constructs a SessionId object for the given session information. |
|
not at google - send to devlin
2013/08/15 20:16:24
wow. git. weird. damn.
can worry about fixing thi
| |
| 18 // |session_tag| is the string used to uniquely identify a synced foreign | |
| 19 // session from the SessionModelAssociator. In the case that SessionId | |
| 20 // represents a local session, |session_tag_| will be the empty string. |id| | |
| 21 // uniquely identifies either a window or tab object in the local or the | |
| 22 // |session_tag| session. | |
| 23 SessionId(const std::string& session_tag, int id); | |
| 25 | 24 |
| 26 // Check if |param| (which must be a MediaGalleriesPermission::CheckParam) | 25 // Returns a SessionId, representing either a local or a foreign session. |
| 27 // matches the encapsulated attribute. | 26 // In the case that the session is local, |session_tag_| will be empty string. |
| 28 bool Check(const APIPermission::CheckParam* param) const; | 27 static scoped_ptr<SessionId> Parse(const std::string& session_string); |
|
not at google - send to devlin
2013/08/15 20:16:24
put static methods first. You should also mention
Kristen Dwan
2013/08/16 22:03:06
Done.
| |
| 29 | 28 |
| 30 // Convert |this| into a base::Value. | 29 // Returns true if the SessionId represents a foreign session. |
| 31 scoped_ptr<base::Value> ToValue() const; | 30 bool IsForeign() const; |
| 32 | 31 |
| 33 // Populate |this| from a base::Value. | 32 // Returns the compressed std::string representation of a SessionId. |
| 34 bool FromValue(const base::Value* value); | 33 std::string ToString() const; |
| 35 | 34 |
| 36 bool operator<(const MediaGalleriesPermissionData& rhs) const; | 35 const std::string& session_tag() const { return session_tag_; } |
| 37 bool operator==(const MediaGalleriesPermissionData& rhs) const; | 36 int id() const { return id_; } |
| 38 | |
| 39 std::string permission() const { return permission_; } | |
| 40 | |
| 41 // This accessor is provided for IPC_STRUCT_TRAITS_MEMBER. Please think | |
| 42 // twice before using it for anything else. | |
| 43 std::string& permission() { return permission_; } | |
| 44 | 37 |
| 45 private: | 38 private: |
| 46 std::string permission_; | 39 // The unique identifier for a foreign session, given by the |
| 40 // SessionModelAssociator. | |
| 41 std::string session_tag_; | |
| 42 | |
| 43 // ID corresponding to a window or tab object. | |
| 44 int id_; | |
| 45 | |
| 46 DISALLOW_COPY_AND_ASSIGN(SessionId); | |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 } // namespace extensions | 49 } // namespace extensions |
| 50 | 50 |
| 51 #endif // CHROME_COMMON_EXTENSIONS_PERMISSIONS_MEDIA_GALLERIES_PERMISSION_DATA_ H_ | 51 #endif // CHROME_BROWSER_EXTENSIONS_API_SESSIONS_SESSION_ID_H__ |
| OLD | NEW |