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

Side by Side Diff: chrome/browser/sync/notifier/communicator/auth_task.cc

Issue 194065: Initial commit of sync engine code to browser/sync.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Fixes to gtest include path, reverted syncapi. Created 11 years, 3 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/sync/notifier/communicator/auth_task.h"
6
7 #include "chrome/browser/sync/notifier/gaia_auth/gaiaauth.h"
8 #include "chrome/browser/sync/notifier/communicator/login.h"
9 #include "chrome/browser/sync/notifier/communicator/login_settings.h"
10 #include "chrome/browser/sync/notifier/communicator/product_info.h"
11 #include "talk/base/common.h"
12 #include "talk/base/urlencode.h"
13 #include "talk/xmpp/xmppclient.h"
14
15 namespace notifier {
16 const char kTalkGadgetAuthPath[] = "/auth";
17
18 AuthTask::AuthTask(talk_base::Task* parent, Login* login, const char* url)
19 : talk_base::Task(parent),
20 login_(login),
21 url_(url),
22 use_gaia_redirect_(true) {
23 ASSERT(login && !url_.empty());
24 }
25
26 int AuthTask::ProcessStart() {
27 auth_.reset(new buzz::GaiaAuth(GetUserAgentString(),
28 GetProductSignature()));
29 auth_->SignalAuthDone.connect(this, &AuthTask::OnAuthDone);
30 auth_->StartTokenAuth(login_->xmpp_client()->jid().BareJid(),
31 login_->login_settings().user_settings().pass(),
32 use_gaia_redirect_ ? "gaia" : service_);
33 return STATE_RESPONSE;
34 }
35
36 int AuthTask::ProcessResponse() {
37 ASSERT(auth_.get());
38 if (!auth_->IsAuthDone()) {
39 return STATE_BLOCKED;
40 }
41 if (!auth_->IsAuthorized()) {
42 SignalAuthError(!auth_->HadError());
43 return STATE_ERROR;
44 }
45
46 std::string uber_url;
47 if (use_gaia_redirect_) {
48 uber_url = auth_->CreateAuthenticatedUrl(url_, service_);
49 } else {
50 uber_url = redir_auth_prefix_ + auth_->GetAuthCookie();
51 uber_url += redir_continue_;
52 uber_url += UrlEncodeString(url_);
53 }
54
55 if (uber_url == "") {
56 SignalAuthError(true);
57 return STATE_ERROR;
58 }
59
60 SignalAuthDone(uber_url);
61 return STATE_DONE;
62 }
63
64
65 void AuthTask::OnAuthDone() {
66 Wake();
67 }
68
69 } // namespace notifier
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698