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

Side by Side Diff: chrome/browser/extensions/app_notify_channel_setup.cc

Issue 11618024: [signin] Support for CrOS and OAuth2AccessTokenConsumer services. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Minor fixes Created 8 years 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 | « chrome/browser/chromeos/login/online_attempt.cc ('k') | chrome/browser/google_apis/DEPS » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/extensions/app_notify_channel_setup.h" 5 #include "chrome/browser/extensions/app_notify_channel_setup.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/json/json_reader.h" 13 #include "base/json/json_reader.h"
14 #include "base/message_loop.h" 14 #include "base/message_loop.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/stringprintf.h" 16 #include "base/stringprintf.h"
17 #include "chrome/browser/prefs/pref_service.h" 17 #include "chrome/browser/prefs/pref_service.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/signin/about_signin_internals.h"
20 #include "chrome/browser/signin/about_signin_internals_factory.h"
19 #include "chrome/browser/signin/signin_manager.h" 21 #include "chrome/browser/signin/signin_manager.h"
20 #include "chrome/browser/signin/signin_manager_factory.h" 22 #include "chrome/browser/signin/signin_manager_factory.h"
21 #include "chrome/browser/signin/token_service.h" 23 #include "chrome/browser/signin/token_service.h"
22 #include "chrome/browser/signin/token_service_factory.h" 24 #include "chrome/browser/signin/token_service_factory.h"
23 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
24 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
25 #include "content/public/browser/browser_thread.h" 27 #include "content/public/browser/browser_thread.h"
26 #include "google_apis/gaia/gaia_constants.h" 28 #include "google_apis/gaia/gaia_constants.h"
27 #include "google_apis/gaia/gaia_urls.h" 29 #include "google_apis/gaia/gaia_urls.h"
28 #include "net/base/escape.h" 30 #include "net/base/escape.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 return; 113 return;
112 } 114 }
113 115
114 BeginLogin(); 116 BeginLogin();
115 } 117 }
116 118
117 void AppNotifyChannelSetup::OnGetTokenSuccess( 119 void AppNotifyChannelSetup::OnGetTokenSuccess(
118 const std::string& access_token, 120 const std::string& access_token,
119 const base::Time& expiration_time) { 121 const base::Time& expiration_time) {
120 oauth2_access_token_ = access_token; 122 oauth2_access_token_ = access_token;
123
124 // Let SigninInternals know about the token fetch.
125 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
126 DCHECK(profile_);
127 // TODO(vishwath): This can be removed when refactoring this to use
128 // OAuth2TokenService instead.
129 AboutSigninInternalsFactory::GetForProfile(profile_)->
130 NotifyTokenReceivedSuccess(
131 signin_internals_util::kAppNotifyChannelSetupToken,
132 access_token,
133 true);
134
121 EndGetAccessToken(true); 135 EndGetAccessToken(true);
122 } 136 }
123 void AppNotifyChannelSetup::OnGetTokenFailure( 137 void AppNotifyChannelSetup::OnGetTokenFailure(
124 const GoogleServiceAuthError& error) { 138 const GoogleServiceAuthError& error) {
139 // Let SigninInternals know about the failed token fetch.
140 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
141 DCHECK(profile_);
142 // TODO(vishwath): This can be removed when refactoring this to use
143 // OAuth2TokenService instead.
144 AboutSigninInternalsFactory::GetForProfile(profile_)->
145 NotifyTokenReceivedFailure(
146 signin_internals_util::kAppNotifyChannelSetupToken, error.ToString());
147
125 EndGetAccessToken(false); 148 EndGetAccessToken(false);
126 } 149 }
127 150
128 void AppNotifyChannelSetup::OnSyncSetupResult(bool enabled) { 151 void AppNotifyChannelSetup::OnSyncSetupResult(bool enabled) {
129 EndLogin(enabled); 152 EndLogin(enabled);
130 } 153 }
131 154
132 void AppNotifyChannelSetup::OnURLFetchComplete(const net::URLFetcher* source) { 155 void AppNotifyChannelSetup::OnURLFetchComplete(const net::URLFetcher* source) {
133 CHECK(source); 156 CHECK(source);
134 switch (state_) { 157 switch (state_) {
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 const std::string& data, std::string* result) { 430 const std::string& data, std::string* result) {
408 scoped_ptr<base::Value> value(base::JSONReader::Read(data)); 431 scoped_ptr<base::Value> value(base::JSONReader::Read(data));
409 if (!value.get() || value->GetType() != base::Value::TYPE_DICTIONARY) 432 if (!value.get() || value->GetType() != base::Value::TYPE_DICTIONARY)
410 return false; 433 return false;
411 434
412 DictionaryValue* dict = static_cast<DictionaryValue*>(value.get()); 435 DictionaryValue* dict = static_cast<DictionaryValue*>(value.get());
413 return dict->GetString("id", result); 436 return dict->GetString("id", result);
414 } 437 }
415 438
416 } // namespace extensions 439 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/online_attempt.cc ('k') | chrome/browser/google_apis/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698