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

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

Issue 9456031: Remove PSS::ShowLoginDialog() and obsolete IDC_SYNC_BOOKMARKS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed review feedback. Created 8 years, 10 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) 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/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
15 #include "base/stringprintf.h" 15 #include "base/stringprintf.h"
16 #include "chrome/browser/prefs/pref_service.h" 16 #include "chrome/browser/prefs/pref_service.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/signin/signin_manager.h"
19 #include "chrome/browser/signin/signin_manager_factory.h"
18 #include "chrome/browser/signin/token_service.h" 20 #include "chrome/browser/signin/token_service.h"
19 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
20 #include "chrome/common/net/gaia/gaia_constants.h" 22 #include "chrome/common/net/gaia/gaia_constants.h"
21 #include "chrome/common/net/gaia/gaia_urls.h" 23 #include "chrome/common/net/gaia/gaia_urls.h"
22 #include "chrome/common/net/http_return.h" 24 #include "chrome/common/net/http_return.h"
23 #include "chrome/common/pref_names.h" 25 #include "chrome/common/pref_names.h"
24 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
25 #include "content/public/common/url_fetcher.h" 27 #include "content/public/common/url_fetcher.h"
26 #include "net/base/escape.h" 28 #include "net/base/escape.h"
27 #include "net/base/load_flags.h" 29 #include "net/base/load_flags.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 fetcher->SetLoadFlags( 142 fetcher->SetLoadFlags(
141 net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES); 143 net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES);
142 fetcher->SetExtraRequestHeaders(MakeAuthorizationHeader(auth_token)); 144 fetcher->SetExtraRequestHeaders(MakeAuthorizationHeader(auth_token));
143 if (!body.empty()) { 145 if (!body.empty()) {
144 fetcher->SetUploadData("application/x-www-form-urlencoded", body); 146 fetcher->SetUploadData("application/x-www-form-urlencoded", body);
145 } 147 }
146 return fetcher; 148 return fetcher;
147 } 149 }
148 150
149 bool AppNotifyChannelSetup::ShouldPromptForLogin() const { 151 bool AppNotifyChannelSetup::ShouldPromptForLogin() const {
150 std::string username = profile_->GetPrefs()->GetString( 152 std::string username =
151 prefs::kGoogleServicesUsername); 153 SigninManagerFactory::GetForProfile(profile_)->GetAuthenticatedUsername();
152 // Prompt for login if either: 154 // Prompt for login if either:
153 // 1. the user has not logged in at all or 155 // 1. the user has not logged in at all or
154 // 2. if the user is logged in but there is no OAuth2 login token. 156 // 2. if the user is logged in but there is no OAuth2 login token.
155 // The latter happens for users who are already logged in before the 157 // The latter happens for users who are already logged in before the
156 // code to generate OAuth2 login token is released. 158 // code to generate OAuth2 login token is released.
157 // 3. If the OAuth2 login token does not work anymore. 159 // 3. If the OAuth2 login token does not work anymore.
158 // This can happen if the user explicitly revoked access to Google Chrome 160 // This can happen if the user explicitly revoked access to Google Chrome
159 // from Google Accounts page. 161 // from Google Accounts page.
160 return username.empty() || 162 return username.empty() ||
161 !profile_->GetTokenService()->HasOAuthLoginToken() || 163 !profile_->GetTokenService()->HasOAuthLoginToken() ||
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 DictionaryValue* dict = static_cast<DictionaryValue*>(value.get()); 399 DictionaryValue* dict = static_cast<DictionaryValue*>(value.get());
398 if (!dict->Get("id", &channel_id_value)) 400 if (!dict->Get("id", &channel_id_value))
399 return false; 401 return false;
400 if (channel_id_value->GetType() != base::Value::TYPE_STRING) 402 if (channel_id_value->GetType() != base::Value::TYPE_STRING)
401 return false; 403 return false;
402 404
403 StringValue* channel_id = static_cast<StringValue*>(channel_id_value); 405 StringValue* channel_id = static_cast<StringValue*>(channel_id_value);
404 channel_id->GetAsString(result); 406 channel_id->GetAsString(result);
405 return true; 407 return true;
406 } 408 }
OLDNEW
« no previous file with comments | « chrome/browser/app_controller_mac.mm ('k') | chrome/browser/extensions/app_notify_channel_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698