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

Side by Side Diff: chrome/browser/extensions/api/sessions/session_id.h

Issue 21022018: Sessions API - previously Session Restore API. Supports restoring currently open foreign windows an… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
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_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGING_HOST_MANIFEST_H _ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SESSIONS_SESSION_ID_H__
6 #define CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGING_HOST_MANIFEST_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/files/file_path.h"
12 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
13 #include "extensions/common/url_pattern_set.h"
14
15 namespace base {
16 class DictionaryValue;
17 }
18 12
19 namespace extensions { 13 namespace extensions {
20 14
21 class NativeMessagingHostManifest { 15 class SessionId {
22 public: 16 public:
23 enum HostInterface { 17 // Returns a SessionId, representing either a local or a foreign session.
24 HOST_INTERFACE_STDIO, 18 // In the case that the session is local, |session_tag_| will be empty string.
25 }; 19 // |session_string| should be in the format that ToString() would produce.
20 static scoped_ptr<SessionId> Parse(const std::string& session_string);
26 21
27 ~NativeMessagingHostManifest(); 22 // Constructs a SessionId object for the given session information.
23 // |session_tag| is the string used to uniquely identify a synced foreign
24 // session from the SessionModelAssociator. In the case that SessionId
25 // represents a local session, |session_tag_| will be the empty string. |id|
26 // uniquely identifies either a window or tab object in the local or the
27 // |session_tag| session.
28 SessionId(const std::string& session_tag, int id);
28 29
29 // Verifies that the name is valid. Valid names must match regular expression 30 // Returns true if the SessionId represents a foreign session.
30 // "([a-z0-9_]+.)*[a-z0-9_]+". 31 bool IsForeign() const;
31 static bool IsValidName(const std::string& name);
32 32
33 // Load manifest file from |file_path|. 33 // Returns the compressed std::string representation of a SessionId in the
34 static scoped_ptr<NativeMessagingHostManifest> Load( 34 // same format that Parse() accepts as its |session_string| parameter.
35 const base::FilePath& file_path, 35 std::string ToString() const;
36 std::string* error_message);
37 36
38 const std::string& name() const { return name_; } 37 const std::string& session_tag() const { return session_tag_; }
39 const std::string& description() const { return description_; } 38 int id() const { return id_; }
40 HostInterface interface() const { return interface_; }
41 const base::FilePath& path() const { return path_; }
42 const URLPatternSet& allowed_origins() const { return allowed_origins_; }
43 39
44 private: 40 private:
45 NativeMessagingHostManifest(); 41 // The unique identifier for a foreign session, given by the
42 // SessionModelAssociator.
43 std::string session_tag_;
46 44
47 // Parses manifest |dictionary|. In case of an error sets |error_message| and 45 // ID corresponding to a window or tab object.
48 // returns false. 46 int id_;
49 bool Parse(base::DictionaryValue* dictionary, std::string* error_message);
50 47
51 std::string name_; 48 DISALLOW_COPY_AND_ASSIGN(SessionId);
52 std::string description_;
53 HostInterface interface_;
54 base::FilePath path_;
55 URLPatternSet allowed_origins_;
56
57 DISALLOW_COPY_AND_ASSIGN(NativeMessagingHostManifest);
58 }; 49 };
59 50
60 } // namespace extensions 51 } // namespace extensions
61 52
62 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGING_HOST_MANIFES T_H_ 53 #endif // CHROME_BROWSER_EXTENSIONS_API_SESSIONS_SESSION_ID_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698