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

Side by Side Diff: remoting/client/client_util.cc

Issue 3064009: Initial scriptable object implementation. (Closed)
Patch Set: Fix alpha's style nits. Created 10 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
« no previous file with comments | « remoting/client/client_util.h ('k') | remoting/client/client_util_unittest.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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "remoting/client/client_util.h" 5 #include "remoting/client/client_util.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 if (!found_auth_token) { 71 if (!found_auth_token) {
72 return false; 72 return false;
73 } 73 }
74 74
75 config->host_jid = host_jid; 75 config->host_jid = host_jid;
76 config->username = username; 76 config->username = username;
77 config->auth_token = auth_token; 77 config->auth_token = auth_token;
78 return true; 78 return true;
79 } 79 }
80 80
81 // Get host JID from command line arguments, or stdin if not specified.
82 bool GetLoginInfoFromUrlParams(const std::string& url, ClientConfig* config) {
83 // TODO(ajwong): We should use GURL or something. Don't parse this by hand!
84
85 // The Url should be of the form:
86 //
87 // chrome://remoting?user=<userid>&auth=<authtoken>&jid=<hostjid>
88 //
89 vector<string> parts;
90 SplitString(url, '&', &parts);
91 if (parts.size() != 3) {
92 return false;
93 }
94
95 size_t pos = parts[0].rfind('=');
96 if (pos == string::npos && (pos + 1) != string::npos) {
97 return false;
98 }
99 std::string username = parts[0].substr(pos + 1);
100
101 pos = parts[1].rfind('=');
102 if (pos == string::npos && (pos + 1) != string::npos) {
103 return false;
104 }
105 std::string auth_token = parts[1].substr(pos + 1);
106
107 pos = parts[2].rfind('=');
108 if (pos == string::npos && (pos + 1) != string::npos) {
109 return false;
110 }
111 std::string host_jid = parts[2].substr(pos + 1);
112
113 config->host_jid = host_jid;
114 config->username = username;
115 config->auth_token = auth_token;
116 return true;
117 }
118
119 } // namespace remoting 81 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/client_util.h ('k') | remoting/client/client_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698