summaryrefslogtreecommitdiff
path: root/chromium/components/signin
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-04-05 14:08:31 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2017-04-11 07:46:53 +0000
commit6a4cabb866f66d4128a97cdc6d9d08ce074f1247 (patch)
treeab00f70a5e89278d6a0d16ff0c42578dc4d84a2d /chromium/components/signin
parente733310db58160074f574c429d48f8308c0afe17 (diff)
downloadqtwebengine-chromium-6a4cabb866f66d4128a97cdc6d9d08ce074f1247.tar.gz
BASELINE: Update Chromium to 57.0.2987.144
Change-Id: I29db402ff696c71a04c4dbaec822c2e53efe0267 Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
Diffstat (limited to 'chromium/components/signin')
-rw-r--r--chromium/components/signin/DEPS1
-rw-r--r--chromium/components/signin/OWNERS2
-rw-r--r--chromium/components/signin/core/account_id/account_id.cc243
-rw-r--r--chromium/components/signin/core/account_id/account_id.h46
-rw-r--r--chromium/components/signin/core/browser/BUILD.gn3
-rw-r--r--chromium/components/signin/core/browser/about_signin_internals.h2
-rw-r--r--chromium/components/signin/core/browser/account_fetcher_service.cc18
-rw-r--r--chromium/components/signin/core/browser/account_fetcher_service.h8
-rw-r--r--chromium/components/signin/core/browser/account_investigator_unittest.cc4
-rw-r--r--chromium/components/signin/core/browser/account_reconcilor.h4
-rw-r--r--chromium/components/signin/core/browser/android/BUILD.gn1
-rw-r--r--chromium/components/signin/core/browser/fake_account_fetcher_service.h4
-rw-r--r--chromium/components/signin/core/browser/fake_gaia_cookie_manager_service.cc10
-rw-r--r--chromium/components/signin/core/browser/fake_gaia_cookie_manager_service.h8
-rw-r--r--chromium/components/signin/core/browser/gaia_cookie_manager_service.cc53
-rw-r--r--chromium/components/signin/core/browser/gaia_cookie_manager_service.h7
-rw-r--r--chromium/components/signin/core/browser/signin_client.cc4
-rw-r--r--chromium/components/signin/core/browser/signin_client.h5
-rw-r--r--chromium/components/signin/core/browser/signin_header_helper_unittest.cc4
-rw-r--r--chromium/components/signin/core/browser/signin_manager.cc2
-rw-r--r--chromium/components/signin/core/browser/signin_status_metrics_provider.cc7
-rw-r--r--chromium/components/signin/core/browser/signin_status_metrics_provider.h2
-rw-r--r--chromium/components/signin/core/browser/webdata/token_web_data.cc9
-rw-r--r--chromium/components/signin/ios/browser/BUILD.gn2
-rw-r--r--chromium/components/signin/ios/browser/account_consistency_service.h2
-rw-r--r--chromium/components/signin/ios/browser/account_consistency_service.mm8
-rw-r--r--chromium/components/signin/ios/browser/account_consistency_service_unittest.mm20
-rw-r--r--chromium/components/signin/ios/browser/fake_profile_oauth2_token_service_ios_provider.mm2
-rw-r--r--chromium/components/signin/ios/browser/profile_oauth2_token_service_ios_delegate.h1
-rw-r--r--chromium/components/signin/ios/browser/profile_oauth2_token_service_ios_delegate.mm2
-rw-r--r--chromium/components/signin/public/interfaces/BUILD.gn11
-rw-r--r--chromium/components/signin/public/interfaces/OWNERS2
-rw-r--r--chromium/components/signin/public/interfaces/account_id.mojom19
-rw-r--r--chromium/components/signin/public/interfaces/account_id.typemap14
-rw-r--r--chromium/components/signin/public/interfaces/account_id_traits.h107
35 files changed, 501 insertions, 136 deletions
diff --git a/chromium/components/signin/DEPS b/chromium/components/signin/DEPS
index 89ffc6df341..20e335b0eba 100644
--- a/chromium/components/signin/DEPS
+++ b/chromium/components/signin/DEPS
@@ -5,6 +5,7 @@ include_rules = [
"+components/os_crypt",
"+components/pref_registry",
"+components/prefs",
+ "+components/sync_preferences",
"+components/webdata/common",
"+crypto",
"+google_apis/gaia",
diff --git a/chromium/components/signin/OWNERS b/chromium/components/signin/OWNERS
index b8a8f4aa83a..b3c82866293 100644
--- a/chromium/components/signin/OWNERS
+++ b/chromium/components/signin/OWNERS
@@ -1,2 +1,2 @@
-atwilson@chromium.org
+msarda@chromium.org
rogerta@chromium.org
diff --git a/chromium/components/signin/core/account_id/account_id.cc b/chromium/components/signin/core/account_id/account_id.cc
index 00ceb2e2f52..1ffac80db1e 100644
--- a/chromium/components/signin/core/account_id/account_id.cc
+++ b/chromium/components/signin/core/account_id/account_id.cc
@@ -16,25 +16,20 @@
namespace {
-// Known account types.
-const char kGoogle[] = "google";
-
// Serialization keys
const char kGaiaIdKey[] = "gaia_id";
const char kEmailKey[] = "email";
+const char kObjGuid[] = "obj_guid";
+const char kAccountTypeKey[] = "account_type";
+
+// Serialization values for account type.
+const char kGoogle[] = "google";
+const char kAd[] = "ad";
+const char kUnknown[] = "unknown";
// Prefix for GetAccountIdKey().
const char kKeyGaiaIdPrefix[] = "g-";
-
-struct GoogleStringSingleton {
- GoogleStringSingleton() : google(kGoogle) {}
-
- static GoogleStringSingleton* GetInstance() {
- return base::Singleton<GoogleStringSingleton>::get();
- }
-
- const std::string google;
-};
+const char kKeyAdIdPrefix[] = "a-";
} // anonymous namespace
@@ -49,26 +44,46 @@ struct AccountId::EmptyAccountId {
AccountId::AccountId() {}
-AccountId::AccountId(const std::string& gaia_id, const std::string& user_email)
- : gaia_id_(gaia_id), user_email_(user_email) {
+AccountId::AccountId(const std::string& id,
+ const std::string& user_email,
+ const AccountType& account_type)
+ : id_(id), user_email_(user_email), account_type_(account_type) {
+ DCHECK(account_type != AccountType::UNKNOWN || id.empty());
+ DCHECK(account_type != AccountType::ACTIVE_DIRECTORY || !id.empty());
// Fail if e-mail looks similar to GaiaIdKey.
LOG_ASSERT(!base::StartsWith(user_email, kKeyGaiaIdPrefix,
base::CompareCase::SENSITIVE) ||
user_email.find('@') != std::string::npos)
- << "Bad e-mail: '" << user_email << "' with gaia_id='" << gaia_id << "'";
+ << "Bad e-mail: '" << user_email << "' with gaia_id='" << id << "'";
// TODO(alemate): DCHECK(!email.empty());
// TODO(alemate): check gaia_id is not empty once it is required.
}
AccountId::AccountId(const AccountId& other)
- : gaia_id_(other.gaia_id_), user_email_(other.user_email_) {}
+ : id_(other.id_),
+ user_email_(other.user_email_),
+ account_type_(other.account_type_) {}
bool AccountId::operator==(const AccountId& other) const {
- return (this == &other) ||
- (gaia_id_ == other.gaia_id_ && user_email_ == other.user_email_) ||
- (!gaia_id_.empty() && gaia_id_ == other.gaia_id_) ||
- (!user_email_.empty() && user_email_ == other.user_email_);
+ if (this == &other)
+ return true;
+ if (account_type_ == AccountType::UNKNOWN ||
+ other.account_type_ == AccountType::UNKNOWN)
+ return user_email_ == other.user_email_;
+ if (account_type_ != other.account_type_)
+ return false;
+ switch (account_type_) {
+ case AccountType::GOOGLE:
+ return (id_ == other.id_ && user_email_ == other.user_email_) ||
+ (!id_.empty() && id_ == other.id_) ||
+ (!user_email_.empty() && user_email_ == other.user_email_);
+ case AccountType::ACTIVE_DIRECTORY:
+ return id_ == other.id_ && user_email_ == other.user_email_;
+ default:
+ NOTREACHED() << "Unknown account type";
+ }
+ return false;
}
bool AccountId::operator!=(const AccountId& other) const {
@@ -81,45 +96,70 @@ bool AccountId::operator<(const AccountId& right) const {
}
bool AccountId::empty() const {
- return gaia_id_.empty() && user_email_.empty();
+ return id_.empty() && user_email_.empty() &&
+ account_type_ == AccountType::UNKNOWN;
}
bool AccountId::is_valid() const {
- return /* !gaia_id_.empty() && */ !user_email_.empty();
+ switch (account_type_) {
+ case AccountType::GOOGLE:
+ return /* !id_.empty() && */ !user_email_.empty();
+ case AccountType::ACTIVE_DIRECTORY:
+ return !id_.empty() && !user_email_.empty();
+ case AccountType::UNKNOWN:
+ return id_.empty() && !user_email_.empty();
+ }
+ NOTREACHED();
+ return false;
}
void AccountId::clear() {
- gaia_id_.clear();
+ id_.clear();
user_email_.clear();
+ account_type_ = AccountType::UNKNOWN;
}
-const std::string& AccountId::GetAccountType() const {
- return GoogleStringSingleton::GetInstance()->google;
+AccountType AccountId::GetAccountType() const {
+ return account_type_;
}
const std::string& AccountId::GetGaiaId() const {
- return gaia_id_;
+ if (account_type_ != AccountType::GOOGLE)
+ NOTIMPLEMENTED() << "Failed to get gaia_id for non-Google account.";
+ return id_;
+}
+
+const std::string& AccountId::GetObjGuid() const {
+ if (account_type_ != AccountType::ACTIVE_DIRECTORY)
+ NOTIMPLEMENTED()
+ << "Failed to get obj_guid for non-Active Directory account.";
+ return id_;
}
const std::string& AccountId::GetUserEmail() const {
return user_email_;
}
+bool AccountId::HasAccountIdKey() const {
+ return account_type_ != AccountType::UNKNOWN && !id_.empty();
+}
+
const std::string AccountId::GetAccountIdKey() const {
#ifdef NDEBUG
- if (gaia_id_.empty())
- LOG(FATAL) << "GetAccountIdKey(): no gaia id for " << Serialize();
-
+ if (id_.empty())
+ LOG(FATAL) << "GetAccountIdKey(): no id for " << Serialize();
#else
- CHECK(!gaia_id_.empty());
+ CHECK(!id_.empty());
#endif
-
- return std::string(kKeyGaiaIdPrefix) + gaia_id_;
-}
-
-void AccountId::SetGaiaId(const std::string& gaia_id) {
- DCHECK(!gaia_id.empty());
- gaia_id_ = gaia_id;
+ switch (GetAccountType()) {
+ case AccountType::GOOGLE:
+ return std::string(kKeyGaiaIdPrefix) + id_;
+ case AccountType::ACTIVE_DIRECTORY:
+ return std::string(kKeyAdIdPrefix) + id_;
+ default:
+ NOTREACHED() << "Unknown account type";
+ }
+ return std::string();
}
void AccountId::SetUserEmail(const std::string& email) {
@@ -130,24 +170,75 @@ void AccountId::SetUserEmail(const std::string& email) {
// static
AccountId AccountId::FromUserEmail(const std::string& email) {
// TODO(alemate): DCHECK(!email.empty());
- return AccountId(std::string() /* gaia_id */, email);
+ return AccountId(std::string() /* id */, email, AccountType::UNKNOWN);
}
+// static
AccountId AccountId::FromGaiaId(const std::string& gaia_id) {
DCHECK(!gaia_id.empty());
- return AccountId(gaia_id, std::string() /* email */);
+ return AccountId(gaia_id, std::string() /* email */, AccountType::GOOGLE);
}
// static
AccountId AccountId::FromUserEmailGaiaId(const std::string& email,
const std::string& gaia_id) {
DCHECK(!(email.empty() && gaia_id.empty()));
- return AccountId(gaia_id, email);
+ return AccountId(gaia_id, email, AccountType::GOOGLE);
+}
+
+// static
+AccountId AccountId::AdFromUserEmailObjGuid(const std::string& email,
+ const std::string& obj_guid) {
+ DCHECK(!email.empty() && !obj_guid.empty());
+ return AccountId(obj_guid, email, AccountType::ACTIVE_DIRECTORY);
+}
+
+// static
+AccountId AccountId::AdFromObjGuid(const std::string& obj_guid) {
+ DCHECK(!obj_guid.empty());
+ return AccountId(obj_guid, std::string() /* email */,
+ AccountType::ACTIVE_DIRECTORY);
+}
+
+// static
+AccountType AccountId::StringToAccountType(
+ const std::string& account_type_string) {
+ if (account_type_string == kGoogle)
+ return AccountType::GOOGLE;
+ if (account_type_string == kAd)
+ return AccountType::ACTIVE_DIRECTORY;
+ if (account_type_string == kUnknown)
+ return AccountType::UNKNOWN;
+ NOTREACHED() << "Unknown account type " << account_type_string;
+ return AccountType::UNKNOWN;
+}
+
+// static
+std::string AccountId::AccountTypeToString(const AccountType& account_type) {
+ switch (account_type) {
+ case AccountType::GOOGLE:
+ return kGoogle;
+ case AccountType::ACTIVE_DIRECTORY:
+ return kAd;
+ case AccountType::UNKNOWN:
+ return kUnknown;
+ }
+ return std::string();
}
std::string AccountId::Serialize() const {
base::DictionaryValue value;
- value.SetString(kGaiaIdKey, gaia_id_);
+ switch (GetAccountType()) {
+ case AccountType::GOOGLE:
+ value.SetString(kGaiaIdKey, id_);
+ break;
+ case AccountType::ACTIVE_DIRECTORY:
+ value.SetString(kObjGuid, id_);
+ break;
+ case AccountType::UNKNOWN:
+ break;
+ }
+ value.SetString(kAccountTypeKey, AccountTypeToString(GetAccountType()));
value.SetString(kEmailKey, user_email_);
std::string serialized;
@@ -167,23 +258,65 @@ bool AccountId::Deserialize(const std::string& serialized,
std::string gaia_id;
std::string user_email;
+ std::string obj_guid;
+ std::string account_type_string;
+ AccountType account_type = AccountType::GOOGLE;
const bool found_gaia_id = dictionary_value->GetString(kGaiaIdKey, &gaia_id);
const bool found_user_email =
dictionary_value->GetString(kEmailKey, &user_email);
-
- if (!found_gaia_id)
- LOG(ERROR) << "gaia_id is not found in '" << serialized << "'";
-
- if (!found_user_email)
- LOG(ERROR) << "user_email is not found in '" << serialized << "'";
-
- if (!found_gaia_id && !found_user_email)
- return false;
-
- *account_id = FromUserEmailGaiaId(user_email, gaia_id);
-
- return true;
+ const bool found_obj_guid = dictionary_value->GetString(kObjGuid, &obj_guid);
+ const bool found_account_type =
+ dictionary_value->GetString(kAccountTypeKey, &account_type_string);
+ if (found_account_type)
+ account_type = StringToAccountType(account_type_string);
+
+ switch (account_type) {
+ case AccountType::GOOGLE:
+ if (found_obj_guid)
+ DLOG(ERROR) << "AccountType is 'google' but obj_guid is found in '"
+ << serialized << "'";
+
+ if (!found_gaia_id)
+ DLOG(ERROR) << "gaia_id is not found in '" << serialized << "'";
+
+ if (!found_user_email)
+ DLOG(ERROR) << "user_email is not found in '" << serialized << "'";
+
+ if (!found_gaia_id && !found_user_email)
+ return false;
+
+ *account_id = FromUserEmailGaiaId(user_email, gaia_id);
+ return true;
+
+ case AccountType::ACTIVE_DIRECTORY:
+ if (found_gaia_id)
+ DLOG(ERROR)
+ << "AccountType is 'active directory' but gaia_id is found in '"
+ << serialized << "'";
+
+ if (!found_obj_guid) {
+ DLOG(ERROR) << "obj_guid is not found in '" << serialized << "'";
+ return false;
+ }
+
+ if (!found_user_email) {
+ DLOG(ERROR) << "user_email is not found in '" << serialized << "'";
+ }
+
+ if (!found_obj_guid || !found_user_email)
+ return false;
+
+ *account_id = AdFromUserEmailObjGuid(user_email, obj_guid);
+ return true;
+
+ case AccountType::UNKNOWN:
+ if (!found_user_email)
+ return false;
+ *account_id = FromUserEmail(user_email);
+ return true;
+ }
+ return false;
}
const AccountId& EmptyAccountId() {
diff --git a/chromium/components/signin/core/account_id/account_id.h b/chromium/components/signin/core/account_id/account_id.h
index 7cba697805d..81082b5fe04 100644
--- a/chromium/components/signin/core/account_id/account_id.h
+++ b/chromium/components/signin/core/account_id/account_id.h
@@ -10,18 +10,35 @@
#include <string>
#include "base/containers/hash_tables.h"
+enum class AccountType { UNKNOWN, GOOGLE, ACTIVE_DIRECTORY };
+
// Type that contains enough information to identify user.
//
// TODO(alemate): we are in the process of moving away from std::string as a
// type for storing user identifier to AccountId. At this time GaiaId is mostly
// empty, so this type is used as a replacement for e-mail string.
// But in near future AccountId will become full feature user identifier.
+// TODO(alemate): Rename functions and fields to reflect different types of
+// accounts. (see crbug.com/672253)
class AccountId {
public:
struct EmptyAccountId;
+ // Creates an empty account id.
+ //
+ // Note: This constructor is public as it is required for mojo serialization
+ // To create an AccountId object, prefer using the static FromXXXX methods or
+ // the EmptyAccountId method when creating an empty account id.
+ AccountId();
+
AccountId(const AccountId& other);
+ // If any of the comparable AccountIds has AccountType == UNKNOWN then it
+ // compares emails.
+ // If both are not UNKNOWN and not equal then it returns false.
+ // If AccountType == GOOGLE then it checks if either ids or emails are equal.
+ // If AccountType == ACTIVE_DIRECTORY then it checks if ids and emails are
+ // equal.
bool operator==(const AccountId& other) const;
bool operator!=(const AccountId& other) const;
bool operator<(const AccountId& right) const;
@@ -31,28 +48,45 @@ class AccountId {
bool is_valid() const;
void clear();
- const std::string& GetAccountType() const;
+ AccountType GetAccountType() const;
const std::string& GetGaiaId() const;
+ const std::string& GetObjGuid() const;
// Users of AccountId should make no assumptions on the format of email.
// I.e. it cannot be used as account identifier, because it is (in general)
// non-comparable.
const std::string& GetUserEmail() const;
+ // Returns true if |GetAccountIdKey| would return valid key.
+ bool HasAccountIdKey() const;
// This returns prefixed some string that can be used as a storage key.
// You should make no assumptions on the format of this string.
const std::string GetAccountIdKey() const;
- void SetGaiaId(const std::string& gaia_id);
void SetUserEmail(const std::string& email);
// This method is to be used during transition period only.
+ // AccountId with UNKNOWN AccountType;
static AccountId FromUserEmail(const std::string& user_email);
+ // AccountId with GOOGLE AccountType;
// This method is to be used during transition period only.
static AccountId FromGaiaId(const std::string& gaia_id);
// This method is the preferred way to construct AccountId if you have
// full account information.
+ // AccountId with GOOGLE AccountType;
static AccountId FromUserEmailGaiaId(const std::string& user_email,
const std::string& gaia_id);
+ // These methods are used to construct Active Directory AccountIds.
+ // AccountId with ACTIVE_DIRECTORY AccountType;
+ static AccountId AdFromUserEmailObjGuid(const std::string& email,
+ const std::string& obj_guid);
+ // AccountId with ACTIVE_DIRECTORY AccountType;
+ static AccountId AdFromObjGuid(const std::string& obj_guid);
+
+ // Translation functions between AccountType and std::string. Used for
+ // serialization.
+ static AccountType StringToAccountType(
+ const std::string& account_type_string);
+ static std::string AccountTypeToString(const AccountType& account_type);
// These are (for now) unstable and cannot be used to store serialized data to
// persistent storage. Only in-memory storage is safe.
@@ -63,11 +97,13 @@ class AccountId {
AccountId* out_account_id);
private:
- AccountId();
- AccountId(const std::string& gaia_id, const std::string& user_email);
+ AccountId(const std::string& id,
+ const std::string& user_email,
+ const AccountType& account_type);
- std::string gaia_id_;
+ std::string id_;
std::string user_email_;
+ AccountType account_type_ = AccountType::UNKNOWN;
};
// Returns a reference to a singleton.
diff --git a/chromium/components/signin/core/browser/BUILD.gn b/chromium/components/signin/core/browser/BUILD.gn
index 602802d96fe..a381719d0ba 100644
--- a/chromium/components/signin/core/browser/BUILD.gn
+++ b/chromium/components/signin/core/browser/BUILD.gn
@@ -162,8 +162,9 @@ source_set("unit_tests") {
":test_support",
"//components/content_settings/core/browser",
"//components/os_crypt:test_support",
- "//components/pref_registry:test_support",
+ "//components/pref_registry:pref_registry",
"//components/signin/core/common",
+ "//components/sync_preferences:test_support",
"//testing/gmock",
]
diff --git a/chromium/components/signin/core/browser/about_signin_internals.h b/chromium/components/signin/core/browser/about_signin_internals.h
index 0e32b0eb345..3caeb6ebd3e 100644
--- a/chromium/components/signin/core/browser/about_signin_internals.h
+++ b/chromium/components/signin/core/browser/about_signin_internals.h
@@ -10,7 +10,6 @@
#include <string>
#include "base/macros.h"
-#include "base/memory/linked_ptr.h"
#include "base/observer_list.h"
#include "base/values.h"
#include "components/keyed_service/core/keyed_service.h"
@@ -26,7 +25,6 @@ class PrefRegistrySyncable;
}
class AccountTrackerService;
-class GaiaAuthFetcher;
class ProfileOAuth2TokenService;
class SigninClient;
diff --git a/chromium/components/signin/core/browser/account_fetcher_service.cc b/chromium/components/signin/core/browser/account_fetcher_service.cc
index 2cd588b94d3..7f25b2d377c 100644
--- a/chromium/components/signin/core/browser/account_fetcher_service.cc
+++ b/chromium/components/signin/core/browser/account_fetcher_service.cc
@@ -7,6 +7,7 @@
#include <utility>
#include "base/command_line.h"
+#include "base/memory/ptr_util.h"
#include "base/metrics/field_trial.h"
#include "base/profiler/scoped_tracker.h"
#include "base/trace_event/trace_event.h"
@@ -201,13 +202,16 @@ void AccountFetcherService::StartFetchingUserInfo(
DCHECK(CalledOnValidThread());
DCHECK(network_fetches_enabled_);
- if (!ContainsKey(user_info_requests_, account_id)) {
+ std::unique_ptr<AccountInfoFetcher>& request =
+ user_info_requests_[account_id];
+ if (!request) {
DVLOG(1) << "StartFetching " << account_id;
- std::unique_ptr<AccountInfoFetcher> fetcher(new AccountInfoFetcher(
- token_service_, signin_client_->GetURLRequestContext(), this,
- account_id));
- user_info_requests_.set(account_id, std::move(fetcher));
- user_info_requests_.get(account_id)->Start();
+ std::unique_ptr<AccountInfoFetcher> fetcher =
+ base::MakeUnique<AccountInfoFetcher>(
+ token_service_, signin_client_->GetURLRequestContext(), this,
+ account_id);
+ request = std::move(fetcher);
+ request->Start();
}
}
@@ -271,7 +275,7 @@ void AccountFetcherService::SendRefreshTokenAnnotationRequest(
// If request was sent AccountFetcherService needs to own request till it
// finishes.
if (request)
- refresh_token_annotation_requests_.set(account_id, std::move(request));
+ refresh_token_annotation_requests_[account_id] = std::move(request);
}
#endif
}
diff --git a/chromium/components/signin/core/browser/account_fetcher_service.h b/chromium/components/signin/core/browser/account_fetcher_service.h
index 0f3e57515e8..5ca34f1fc8a 100644
--- a/chromium/components/signin/core/browser/account_fetcher_service.h
+++ b/chromium/components/signin/core/browser/account_fetcher_service.h
@@ -8,8 +8,8 @@
#include <stdint.h>
#include <memory>
+#include <unordered_map>
-#include "base/containers/scoped_ptr_hash_map.h"
#include "base/macros.h"
#include "base/threading/non_thread_safe.h"
#include "base/timer/timer.h"
@@ -132,11 +132,11 @@ class AccountFetcherService : public KeyedService,
std::unique_ptr<ChildAccountInfoFetcher> child_info_request_;
// Holds references to account info fetchers keyed by account_id.
- base::ScopedPtrHashMap<std::string, std::unique_ptr<AccountInfoFetcher>>
+ std::unordered_map<std::string, std::unique_ptr<AccountInfoFetcher>>
user_info_requests_;
// Holds references to refresh token annotation requests keyed by account_id.
- base::ScopedPtrHashMap<std::string,
- std::unique_ptr<RefreshTokenAnnotationRequest>>
+ std::unordered_map<std::string,
+ std::unique_ptr<RefreshTokenAnnotationRequest>>
refresh_token_annotation_requests_;
DISALLOW_COPY_AND_ASSIGN(AccountFetcherService);
diff --git a/chromium/components/signin/core/browser/account_investigator_unittest.cc b/chromium/components/signin/core/browser/account_investigator_unittest.cc
index d70acac2036..11050b6f45c 100644
--- a/chromium/components/signin/core/browser/account_investigator_unittest.cc
+++ b/chromium/components/signin/core/browser/account_investigator_unittest.cc
@@ -13,13 +13,13 @@
#include "base/test/histogram_tester.h"
#include "base/timer/timer.h"
#include "components/pref_registry/pref_registry_syncable.h"
-#include "components/pref_registry/testing_pref_service_syncable.h"
#include "components/signin/core/browser/account_tracker_service.h"
#include "components/signin/core/browser/fake_gaia_cookie_manager_service.h"
#include "components/signin/core/browser/fake_signin_manager.h"
#include "components/signin/core/browser/signin_metrics.h"
#include "components/signin/core/browser/test_signin_client.h"
#include "components/signin/core/common/signin_pref_names.h"
+#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "google_apis/gaia/gaia_auth_util.h"
#include "google_apis/gaia/gaia_constants.h"
#include "google_apis/gaia/google_service_auth_error.h"
@@ -155,7 +155,7 @@ class AccountInvestigatorTest : public testing::Test {
private:
// Timer needs a message loop.
base::MessageLoop message_loop_;
- user_prefs::TestingPrefServiceSyncable prefs_;
+ sync_preferences::TestingPrefServiceSyncable prefs_;
AccountTrackerService account_tracker_service_;
TestSigninClient signin_client_;
FakeSigninManager signin_manager_;
diff --git a/chromium/components/signin/core/browser/account_reconcilor.h b/chromium/components/signin/core/browser/account_reconcilor.h
index 68ad603880c..6217588d974 100644
--- a/chromium/components/signin/core/browser/account_reconcilor.h
+++ b/chromium/components/signin/core/browser/account_reconcilor.h
@@ -31,10 +31,6 @@
class ProfileOAuth2TokenService;
class SigninClient;
-namespace net {
-class CanonicalCookie;
-}
-
class AccountReconcilor : public KeyedService,
public content_settings::Observer,
public GaiaCookieManagerService::Observer,
diff --git a/chromium/components/signin/core/browser/android/BUILD.gn b/chromium/components/signin/core/browser/android/BUILD.gn
index c9f5bc3f598..400ccabe384 100644
--- a/chromium/components/signin/core/browser/android/BUILD.gn
+++ b/chromium/components/signin/core/browser/android/BUILD.gn
@@ -35,6 +35,7 @@ android_library("javatests") {
":signin_java_test_support",
"//base:base_java",
"//base:base_java_test_support",
+ "//third_party/android_support_test_runner:runner_java",
]
java_files = [ "javatests/src/org/chromium/components/signin/test/AccountManagerHelperTest.java" ]
diff --git a/chromium/components/signin/core/browser/fake_account_fetcher_service.h b/chromium/components/signin/core/browser/fake_account_fetcher_service.h
index 3e1d6de5cb5..761940ad228 100644
--- a/chromium/components/signin/core/browser/fake_account_fetcher_service.h
+++ b/chromium/components/signin/core/browser/fake_account_fetcher_service.h
@@ -12,10 +12,6 @@
class KeyedService;
-namespace content {
-class BrowserContext;
-}
-
// AccountTrackerService is a KeyedService that retrieves and caches GAIA
// information about Google Accounts. This fake class can be used in tests
// to prevent AccountTrackerService from sending network requests.
diff --git a/chromium/components/signin/core/browser/fake_gaia_cookie_manager_service.cc b/chromium/components/signin/core/browser/fake_gaia_cookie_manager_service.cc
index bf95c888a37..10bd27a1e98 100644
--- a/chromium/components/signin/core/browser/fake_gaia_cookie_manager_service.cc
+++ b/chromium/components/signin/core/browser/fake_gaia_cookie_manager_service.cc
@@ -109,8 +109,14 @@ void FakeGaiaCookieManagerService::SetListAccountsResponseTwoAccountsWithExpiry(
}
std::string FakeGaiaCookieManagerService::GetSourceForRequest(
- const GaiaCookieManagerService::GaiaCookieRequest& request,
- const std::string& source_default) {
+ const GaiaCookieManagerService::GaiaCookieRequest& request) {
+ // Always return the default. This value must match the source used in the
+ // SetXXXResponseYYY methods above so that the test URLFetcher factory will
+ // be able to find the URLs.
+ return GaiaConstants::kChromeSource;
+}
+
+std::string FakeGaiaCookieManagerService::GetDefaultSourceForRequest() {
// Always return the default. This value must match the source used in the
// SetXXXResponseYYY methods above so that the test URLFetcher factory will
// be able to find the URLs.
diff --git a/chromium/components/signin/core/browser/fake_gaia_cookie_manager_service.h b/chromium/components/signin/core/browser/fake_gaia_cookie_manager_service.h
index 4d67f40b41a..504eb03e125 100644
--- a/chromium/components/signin/core/browser/fake_gaia_cookie_manager_service.h
+++ b/chromium/components/signin/core/browser/fake_gaia_cookie_manager_service.h
@@ -11,10 +11,6 @@
#include "components/signin/core/browser/gaia_cookie_manager_service.h"
#include "net/url_request/test_url_fetcher_factory.h"
-namespace content {
-class BrowserContext;
-}
-
class FakeGaiaCookieManagerService : public GaiaCookieManagerService {
public:
FakeGaiaCookieManagerService(OAuth2TokenService* token_service,
@@ -44,8 +40,8 @@ class FakeGaiaCookieManagerService : public GaiaCookieManagerService {
private:
std::string GetSourceForRequest(
- const GaiaCookieManagerService::GaiaCookieRequest& request,
- const std::string& source_default) override;
+ const GaiaCookieManagerService::GaiaCookieRequest& request) override;
+ std::string GetDefaultSourceForRequest() override;
// Provide a fake response for calls to /ListAccounts.
net::FakeURLFetcherFactory* url_fetcher_factory_;
diff --git a/chromium/components/signin/core/browser/gaia_cookie_manager_service.cc b/chromium/components/signin/core/browser/gaia_cookie_manager_service.cc
index 9cfd9c9ae0f..3d14c265528 100644
--- a/chromium/components/signin/core/browser/gaia_cookie_manager_service.cc
+++ b/chromium/components/signin/core/browser/gaia_cookie_manager_service.cc
@@ -62,6 +62,9 @@ const int kMaxFetcherRetries = 8;
// accounts have changed in the content-area.
const char* kGaiaCookieName = "APISID";
+// String format appended to GAIA fetcher source if request context has changed.
+const char* kRequestContextChangedTag = "__changed_%d__";
+
enum GaiaCookieRequestType {
ADD_ACCOUNT,
LOG_OUT_ALL_ACCOUNTS,
@@ -69,6 +72,11 @@ enum GaiaCookieRequestType {
LIST_ACCOUNTS
};
+void AppendRequestContextChangedTagIfNeeded(std::string* source, int changes) {
+ if (changes != 0)
+ base::StringAppendF(source, kRequestContextChangedTag, changes);
+}
+
} // namespace
GaiaCookieManagerService::GaiaCookieRequest::GaiaCookieRequest(
@@ -99,6 +107,7 @@ GaiaCookieManagerService::GaiaCookieRequest::CreateLogOutRequest(
source);
}
+// static
GaiaCookieManagerService::GaiaCookieRequest
GaiaCookieManagerService::GaiaCookieRequest::CreateListAccountsRequest(
const std::string& source) {
@@ -134,7 +143,8 @@ void GaiaCookieManagerService::ExternalCcResultFetcher::Start() {
results_.clear();
helper_->gaia_auth_fetcher_.reset(
helper_->signin_client_->CreateGaiaAuthFetcher(
- this, helper_->source_, helper_->request_context()));
+ this, helper_->GetDefaultSourceForRequest(),
+ helper_->request_context()));
helper_->gaia_auth_fetcher_->StartGetCheckConnectionInfo();
// Some fetches may timeout. Start a timer to decide when the result fetcher
@@ -462,9 +472,20 @@ void GaiaCookieManagerService::CancelAll() {
}
std::string GaiaCookieManagerService::GetSourceForRequest(
- const GaiaCookieManagerService::GaiaCookieRequest& request,
- const std::string& source_default) {
- return request.source().empty() ? source_default : request.source();
+ const GaiaCookieManagerService::GaiaCookieRequest& request) {
+ std::string source = request.source().empty() ? source_ : request.source();
+ AppendRequestContextChangedTagIfNeeded(
+ &source,
+ signin_client_->number_of_request_context_pointer_changes());
+ return source;
+}
+
+std::string GaiaCookieManagerService::GetDefaultSourceForRequest() {
+ std::string source = source_;
+ AppendRequestContextChangedTagIfNeeded(
+ &source,
+ signin_client_->number_of_request_context_pointer_changes());
+ return source;
}
void GaiaCookieManagerService::OnCookieChanged(
@@ -480,13 +501,22 @@ void GaiaCookieManagerService::OnCookieChanged(
// cause an endless loop (see crbug.com/516070).
if (requests_.empty()) {
// Build gaia "source" based on cause to help track down channel id issues.
- std::string source(source_);
+ std::string source(GetDefaultSourceForRequest());
switch (cause) {
case net::CookieStore::ChangeCause::INSERTED:
source += "INSERTED";
break;
- case net::CookieStore::ChangeCause::EXPLICIT:
- source += "EXPLICIT";
+ case net::CookieStore::ChangeCause::EXPLICIT_DELETE:
+ source += "EXPLICIT_DELETE";
+ break;
+ case net::CookieStore::ChangeCause::EXPLICIT_DUPLICATE_IN_BACKING_STORE:
+ source += "EXPLICIT_DUPLICATE_IN_BACKING_STORE";
+ break;
+ case net::CookieStore::ChangeCause::EXPLICIT_DONT_RECORD:
+ source += "EXPLICIT_DONT_RECORD";
+ break;
+ case net::CookieStore::ChangeCause::EXPLICIT_LAST_ENTRY:
+ source += "EXPLICIT_LAST_ENTRY";
break;
case net::CookieStore::ChangeCause::UNKNOWN_DELETION:
source += "UNKNOWN_DELETION";
@@ -700,7 +730,8 @@ void GaiaCookieManagerService::StartFetchingUbertoken() {
VLOG(1) << "GaiaCookieManagerService::StartFetchingUbertoken account_id="
<< requests_.front().account_id();
uber_token_fetcher_.reset(new UbertokenFetcher(
- token_service_, this, source_, signin_client_->GetURLRequestContext(),
+ token_service_, this, GetDefaultSourceForRequest(),
+ signin_client_->GetURLRequestContext(),
base::Bind(&SigninClient::CreateGaiaAuthFetcher,
base::Unretained(signin_client_))));
if (access_token_.empty()) {
@@ -714,7 +745,7 @@ void GaiaCookieManagerService::StartFetchingUbertoken() {
void GaiaCookieManagerService::StartFetchingMergeSession() {
DCHECK(!uber_token_.empty());
gaia_auth_fetcher_.reset(signin_client_->CreateGaiaAuthFetcher(
- this, GetSourceForRequest(requests_.front(), source_),
+ this, GetSourceForRequest(requests_.front()),
signin_client_->GetURLRequestContext()));
gaia_auth_fetcher_->StartMergeSession(uber_token_,
@@ -725,7 +756,7 @@ void GaiaCookieManagerService::StartFetchingLogOut() {
DCHECK(requests_.front().request_type() == GaiaCookieRequestType::LOG_OUT);
VLOG(1) << "GaiaCookieManagerService::StartFetchingLogOut";
gaia_auth_fetcher_.reset(signin_client_->CreateGaiaAuthFetcher(
- this, GetSourceForRequest(requests_.front(), source_),
+ this, GetSourceForRequest(requests_.front()),
signin_client_->GetURLRequestContext()));
gaia_auth_fetcher_->StartLogOut();
}
@@ -733,7 +764,7 @@ void GaiaCookieManagerService::StartFetchingLogOut() {
void GaiaCookieManagerService::StartFetchingListAccounts() {
VLOG(1) << "GaiaCookieManagerService::ListAccounts";
gaia_auth_fetcher_.reset(signin_client_->CreateGaiaAuthFetcher(
- this, GetSourceForRequest(requests_.front(), source_),
+ this, GetSourceForRequest(requests_.front()),
signin_client_->GetURLRequestContext()));
gaia_auth_fetcher_->StartListAccounts();
}
diff --git a/chromium/components/signin/core/browser/gaia_cookie_manager_service.h b/chromium/components/signin/core/browser/gaia_cookie_manager_service.h
index 72f178d72bc..ae4246422c1 100644
--- a/chromium/components/signin/core/browser/gaia_cookie_manager_service.h
+++ b/chromium/components/signin/core/browser/gaia_cookie_manager_service.h
@@ -242,8 +242,11 @@ class GaiaCookieManagerService : public KeyedService,
// Returns the source value to use for GaiaFetcher requests. This is
// virtual to allow tests and fake classes to override.
virtual std::string GetSourceForRequest(
- const GaiaCookieManagerService::GaiaCookieRequest& request,
- const std::string& source_default);
+ const GaiaCookieManagerService::GaiaCookieRequest& request);
+
+ // Returns the default source value to use for GaiaFetcher requests. This is
+ // virtual to allow tests and fake classes to override.
+ virtual std::string GetDefaultSourceForRequest();
// Called when a cookie changes. If the cookie relates to a GAIA APISID
// cookie, then we call ListAccounts and fire OnGaiaAccountsInCookieUpdated.
diff --git a/chromium/components/signin/core/browser/signin_client.cc b/chromium/components/signin/core/browser/signin_client.cc
index 9473e0bb59c..f9018c85900 100644
--- a/chromium/components/signin/core/browser/signin_client.cc
+++ b/chromium/components/signin/core/browser/signin_client.cc
@@ -36,6 +36,10 @@ void SigninClient::PreSignOut(const base::Callback<void()>& sign_out) {
sign_out.Run();
}
+int SigninClient::number_of_request_context_pointer_changes() const {
+ return 0;
+}
+
void SigninClient::SignOut() {
GetPrefs()->ClearPref(prefs::kGoogleServicesSigninScopedDeviceId);
OnSignedOut();
diff --git a/chromium/components/signin/core/browser/signin_client.h b/chromium/components/signin/core/browser/signin_client.h
index 6c2c17dc323..43d90bc9d69 100644
--- a/chromium/components/signin/core/browser/signin_client.h
+++ b/chromium/components/signin/core/browser/signin_client.h
@@ -16,7 +16,6 @@
#include "url/gurl.h"
class PrefService;
-class SigninManagerBase;
class TokenWebData;
namespace content_settings {
@@ -127,6 +126,10 @@ class SigninClient : public KeyedService {
// Called once the credentials has been copied to another SigninManager.
virtual void AfterCredentialsCopied() {}
+ // Used do debug channel id binding problem in chrome. Returns the number of
+ // times the request context changed unexpectedly.
+ virtual int number_of_request_context_pointer_changes() const;
+
protected:
// Returns device id that is scoped to single signin.
// Stores the ID in the kGoogleServicesSigninScopedDeviceId pref.
diff --git a/chromium/components/signin/core/browser/signin_header_helper_unittest.cc b/chromium/components/signin/core/browser/signin_header_helper_unittest.cc
index cd560ab5ee4..239b0a57e96 100644
--- a/chromium/components/signin/core/browser/signin_header_helper_unittest.cc
+++ b/chromium/components/signin/core/browser/signin_header_helper_unittest.cc
@@ -7,9 +7,9 @@
#include "base/command_line.h"
#include "base/message_loop/message_loop.h"
#include "components/content_settings/core/browser/cookie_settings.h"
-#include "components/pref_registry/testing_pref_service_syncable.h"
#include "components/signin/core/browser/signin_header_helper.h"
#include "components/signin/core/common/signin_switches.h"
+#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "net/url_request/url_request_test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
@@ -58,7 +58,7 @@ class SigninHeaderHelperTest : public testing::Test {
base::MessageLoop loop_;
- user_prefs::TestingPrefServiceSyncable prefs_;
+ sync_preferences::TestingPrefServiceSyncable prefs_;
net::TestURLRequestContext url_request_context_;
scoped_refptr<HostContentSettingsMap> settings_map_;
diff --git a/chromium/components/signin/core/browser/signin_manager.cc b/chromium/components/signin/core/browser/signin_manager.cc
index fc3a0c503a5..2e3a7044510 100644
--- a/chromium/components/signin/core/browser/signin_manager.cc
+++ b/chromium/components/signin/core/browser/signin_manager.cc
@@ -269,7 +269,7 @@ bool SigninManager::IsSigninAllowed() const {
}
void SigninManager::OnSigninAllowedPrefChanged() {
- if (!IsSigninAllowed())
+ if (!IsSigninAllowed() && (IsAuthenticated() || AuthInProgress()))
SignOut(signin_metrics::SIGNOUT_PREF_CHANGED,
signin_metrics::SignoutDelete::IGNORE_METRIC);
}
diff --git a/chromium/components/signin/core/browser/signin_status_metrics_provider.cc b/chromium/components/signin/core/browser/signin_status_metrics_provider.cc
index 04d54fa8a7f..699e61d6190 100644
--- a/chromium/components/signin/core/browser/signin_status_metrics_provider.cc
+++ b/chromium/components/signin/core/browser/signin_status_metrics_provider.cc
@@ -8,6 +8,7 @@
#include "base/bind.h"
#include "base/location.h"
+#include "base/memory/ptr_util.h"
#include "base/metrics/histogram.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
@@ -45,9 +46,11 @@ void SigninStatusMetricsProvider::ProvideGeneralMetrics(
}
// static
-SigninStatusMetricsProvider* SigninStatusMetricsProvider::CreateInstance(
+std::unique_ptr<SigninStatusMetricsProvider>
+SigninStatusMetricsProvider::CreateInstance(
std::unique_ptr<SigninStatusMetricsProviderDelegate> delegate) {
- return new SigninStatusMetricsProvider(std::move(delegate), false);
+ return base::WrapUnique(
+ new SigninStatusMetricsProvider(std::move(delegate), false));
}
void SigninStatusMetricsProvider::OnSigninManagerCreated(
diff --git a/chromium/components/signin/core/browser/signin_status_metrics_provider.h b/chromium/components/signin/core/browser/signin_status_metrics_provider.h
index 859363ea813..9d6e663d126 100644
--- a/chromium/components/signin/core/browser/signin_status_metrics_provider.h
+++ b/chromium/components/signin/core/browser/signin_status_metrics_provider.h
@@ -37,7 +37,7 @@ class SigninStatusMetricsProvider : public SigninStatusMetricsProviderBase,
metrics::ChromeUserMetricsExtension* uma_proto) override;
// Factory method, creates a new instance of this class.
- static SigninStatusMetricsProvider* CreateInstance(
+ static std::unique_ptr<SigninStatusMetricsProvider> CreateInstance(
std::unique_ptr<SigninStatusMetricsProviderDelegate> delegate);
// Update the sign-in status when a SigninManager is created.
diff --git a/chromium/components/signin/core/browser/webdata/token_web_data.cc b/chromium/components/signin/core/browser/webdata/token_web_data.cc
index 8c390faf642..0c6425529c0 100644
--- a/chromium/components/signin/core/browser/webdata/token_web_data.cc
+++ b/chromium/components/signin/core/browser/webdata/token_web_data.cc
@@ -6,7 +6,7 @@
#include "base/bind.h"
#include "base/memory/ptr_util.h"
-#include "base/memory/ref_counted_delete_on_message_loop.h"
+#include "base/memory/ref_counted_delete_on_sequence.h"
#include "base/single_thread_task_runner.h"
#include "base/stl_util.h"
#include "components/signin/core/browser/webdata/token_service_table.h"
@@ -16,11 +16,10 @@ using base::Bind;
using base::Time;
class TokenWebDataBackend
- : public base::RefCountedDeleteOnMessageLoop<TokenWebDataBackend> {
-
+ : public base::RefCountedDeleteOnSequence<TokenWebDataBackend> {
public:
TokenWebDataBackend(scoped_refptr<base::SingleThreadTaskRunner> db_thread)
- : base::RefCountedDeleteOnMessageLoop<TokenWebDataBackend>(db_thread) {}
+ : base::RefCountedDeleteOnSequence<TokenWebDataBackend>(db_thread) {}
WebDatabase::State RemoveAllTokens(WebDatabase* db) {
if (TokenServiceTable::FromWebDatabase(db)->RemoveAllTokens()) {
@@ -59,7 +58,7 @@ class TokenWebDataBackend
}
private:
- friend class base::RefCountedDeleteOnMessageLoop<TokenWebDataBackend>;
+ friend class base::RefCountedDeleteOnSequence<TokenWebDataBackend>;
friend class base::DeleteHelper<TokenWebDataBackend>;
};
diff --git a/chromium/components/signin/ios/browser/BUILD.gn b/chromium/components/signin/ios/browser/BUILD.gn
index c0a9f35c7ed..9a736cc272a 100644
--- a/chromium/components/signin/ios/browser/BUILD.gn
+++ b/chromium/components/signin/ios/browser/BUILD.gn
@@ -55,11 +55,11 @@ source_set("unit_tests") {
deps = [
":test_support",
- "//components/pref_registry:test_support",
"//components/prefs:test_support",
"//components/signin/core/browser",
"//components/signin/core/browser:test_support",
"//components/signin/core/common",
+ "//components/sync_preferences:test_support",
"//ios/web",
"//ios/web:test_support",
"//third_party/ocmock",
diff --git a/chromium/components/signin/ios/browser/account_consistency_service.h b/chromium/components/signin/ios/browser/account_consistency_service.h
index cc61d8fe64a..1f7a1e6eb3f 100644
--- a/chromium/components/signin/ios/browser/account_consistency_service.h
+++ b/chromium/components/signin/ios/browser/account_consistency_service.h
@@ -116,7 +116,7 @@ class AccountConsistencyService : public KeyedService,
// Can return nil if the browser state is not active.
WKWebView* GetWKWebView();
// Actually creates a WKWebView. Virtual for testing.
- virtual WKWebView* CreateWKWebView() NS_RETURNS_RETAINED;
+ virtual WKWebView* BuildWKWebView();
// Stops any page loading in the WKWebView currently in use and releases it.
void ResetWKWebView();
diff --git a/chromium/components/signin/ios/browser/account_consistency_service.mm b/chromium/components/signin/ios/browser/account_consistency_service.mm
index 1ce0e2e2cc4..5f15df39e15 100644
--- a/chromium/components/signin/ios/browser/account_consistency_service.mm
+++ b/chromium/components/signin/ios/browser/account_consistency_service.mm
@@ -4,7 +4,7 @@
#include "components/signin/ios/browser/account_consistency_service.h"
-#include <WebKit/WebKit.h>
+#import <WebKit/WebKit.h>
#import "base/ios/weak_nsobject.h"
#include "base/logging.h"
@@ -390,7 +390,7 @@ WKWebView* AccountConsistencyService::GetWKWebView() {
return nil;
}
if (!web_view_) {
- web_view_.reset(CreateWKWebView());
+ web_view_.reset([BuildWKWebView() retain]);
navigation_delegate_.reset([[AccountConsistencyNavigationDelegate alloc]
initWithCallback:base::Bind(&AccountConsistencyService::
FinishedApplyingCookieRequest,
@@ -400,8 +400,8 @@ WKWebView* AccountConsistencyService::GetWKWebView() {
return web_view_.get();
}
-WKWebView* AccountConsistencyService::CreateWKWebView() {
- return web::CreateWKWebView(CGRectZero, browser_state_);
+WKWebView* AccountConsistencyService::BuildWKWebView() {
+ return web::BuildWKWebView(CGRectZero, browser_state_);
}
void AccountConsistencyService::ResetWKWebView() {
diff --git a/chromium/components/signin/ios/browser/account_consistency_service_unittest.mm b/chromium/components/signin/ios/browser/account_consistency_service_unittest.mm
index 984a802ead7..ba160b6bf69 100644
--- a/chromium/components/signin/ios/browser/account_consistency_service_unittest.mm
+++ b/chromium/components/signin/ios/browser/account_consistency_service_unittest.mm
@@ -9,16 +9,16 @@
#include <memory>
#import "base/mac/scoped_nsobject.h"
-#include "components/pref_registry/testing_pref_service_syncable.h"
#include "components/signin/core/browser/account_reconcilor.h"
#include "components/signin/core/browser/account_tracker_service.h"
#include "components/signin/core/browser/fake_signin_manager.h"
#include "components/signin/core/browser/gaia_cookie_manager_service.h"
#include "components/signin/core/browser/test_signin_client.h"
#include "components/signin/core/common/signin_pref_names.h"
+#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "google_apis/gaia/gaia_constants.h"
-#include "ios/web/public/test/test_browser_state.h"
-#include "ios/web/public/test/test_web_state.h"
+#include "ios/web/public/test/fakes/test_browser_state.h"
+#import "ios/web/public/test/fakes/test_web_state.h"
#include "ios/web/public/test/test_web_thread_bundle.h"
#include "ios/web/public/web_state/web_state_policy_decider.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -58,17 +58,17 @@ class FakeAccountConsistencyService : public AccountConsistencyService {
cookie_settings,
gaia_cookie_manager_service,
signin_client,
- signin_manager),
- mock_web_view_(nil) {}
+ signin_manager) {}
private:
- WKWebView* CreateWKWebView() override {
+ WKWebView* BuildWKWebView() override {
if (!mock_web_view_) {
- mock_web_view_ = [OCMockObject niceMockForClass:[WKWebView class]];
+ mock_web_view_.reset(
+ [[OCMockObject niceMockForClass:[WKWebView class]] retain]);
}
- return [mock_web_view_ retain];
+ return mock_web_view_;
}
- id mock_web_view_;
+ base::scoped_nsobject<id> mock_web_view_;
};
// Mock AccountReconcilor to catch call to OnReceivedManageAccountsResponse.
@@ -202,7 +202,7 @@ class AccountConsistencyServiceTest : public PlatformTest {
MockAccountReconcilor account_reconcilor_;
AccountTrackerService account_tracker_service_;
web::TestBrowserState browser_state_;
- user_prefs::TestingPrefServiceSyncable prefs_;
+ sync_preferences::TestingPrefServiceSyncable prefs_;
TestWebState web_state_;
// AccountConsistencyService being tested. Actually a
// FakeAccountConsistencyService to be able to use a mock web view.
diff --git a/chromium/components/signin/ios/browser/fake_profile_oauth2_token_service_ios_provider.mm b/chromium/components/signin/ios/browser/fake_profile_oauth2_token_service_ios_provider.mm
index 763fa823542..50cb0f853b0 100644
--- a/chromium/components/signin/ios/browser/fake_profile_oauth2_token_service_ios_provider.mm
+++ b/chromium/components/signin/ios/browser/fake_profile_oauth2_token_service_ios_provider.mm
@@ -4,7 +4,7 @@
#include "components/signin/ios/browser/fake_profile_oauth2_token_service_ios_provider.h"
-#include <Foundation/Foundation.h>
+#import <Foundation/Foundation.h>
#include "base/logging.h"
#include "base/strings/sys_string_conversions.h"
diff --git a/chromium/components/signin/ios/browser/profile_oauth2_token_service_ios_delegate.h b/chromium/components/signin/ios/browser/profile_oauth2_token_service_ios_delegate.h
index 10ea6c9d379..d437a8b44a7 100644
--- a/chromium/components/signin/ios/browser/profile_oauth2_token_service_ios_delegate.h
+++ b/chromium/components/signin/ios/browser/profile_oauth2_token_service_ios_delegate.h
@@ -15,6 +15,7 @@
class AccountTrackerService;
class ProfileOAuth2TokenServiceIOSProvider;
+class SigninClient;
class ProfileOAuth2TokenServiceIOSDelegate : public OAuth2TokenServiceDelegate {
public:
diff --git a/chromium/components/signin/ios/browser/profile_oauth2_token_service_ios_delegate.mm b/chromium/components/signin/ios/browser/profile_oauth2_token_service_ios_delegate.mm
index 6577c507280..49606f24e79 100644
--- a/chromium/components/signin/ios/browser/profile_oauth2_token_service_ios_delegate.mm
+++ b/chromium/components/signin/ios/browser/profile_oauth2_token_service_ios_delegate.mm
@@ -4,7 +4,7 @@
#include "components/signin/ios/browser/profile_oauth2_token_service_ios_delegate.h"
-#include <Foundation/Foundation.h>
+#import <Foundation/Foundation.h>
#include <memory>
#include <set>
diff --git a/chromium/components/signin/public/interfaces/BUILD.gn b/chromium/components/signin/public/interfaces/BUILD.gn
new file mode 100644
index 00000000000..98d8a275153
--- /dev/null
+++ b/chromium/components/signin/public/interfaces/BUILD.gn
@@ -0,0 +1,11 @@
+# Copyright 2017 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//mojo/public/tools/bindings/mojom.gni")
+
+mojom("interfaces") {
+ sources = [
+ "account_id.mojom",
+ ]
+}
diff --git a/chromium/components/signin/public/interfaces/OWNERS b/chromium/components/signin/public/interfaces/OWNERS
new file mode 100644
index 00000000000..08850f42120
--- /dev/null
+++ b/chromium/components/signin/public/interfaces/OWNERS
@@ -0,0 +1,2 @@
+per-file *.mojom=set noparent
+per-file *.mojom=file://ipc/SECURITY_OWNERS
diff --git a/chromium/components/signin/public/interfaces/account_id.mojom b/chromium/components/signin/public/interfaces/account_id.mojom
new file mode 100644
index 00000000000..f0f9abdc1a3
--- /dev/null
+++ b/chromium/components/signin/public/interfaces/account_id.mojom
@@ -0,0 +1,19 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+module signin.mojom;
+
+// Matches AccountType of AccountId.
+enum AccountType {
+ UNKNOWN,
+ GOOGLE,
+ ACTIVE_DIRECTORY,
+};
+
+// Mirror of AccountId in Mojo.
+struct AccountId {
+ AccountType account_type;
+ string id;
+ string user_email;
+};
diff --git a/chromium/components/signin/public/interfaces/account_id.typemap b/chromium/components/signin/public/interfaces/account_id.typemap
new file mode 100644
index 00000000000..9d44e045e8e
--- /dev/null
+++ b/chromium/components/signin/public/interfaces/account_id.typemap
@@ -0,0 +1,14 @@
+# Copyright 2017 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+mojom = "//components/signin/public/interfaces/account_id.mojom"
+public_headers = [ "//components/signin/core/account_id/account_id.h" ]
+traits_headers = [ "//components/signin/public/interfaces/account_id_traits.h" ]
+public_deps = [
+ "//components/signin/core/account_id",
+]
+type_mappings = [
+ "signin.mojom.AccountType=AccountType",
+ "signin.mojom.AccountId=AccountId",
+]
diff --git a/chromium/components/signin/public/interfaces/account_id_traits.h b/chromium/components/signin/public/interfaces/account_id_traits.h
new file mode 100644
index 00000000000..cc1d39de917
--- /dev/null
+++ b/chromium/components/signin/public/interfaces/account_id_traits.h
@@ -0,0 +1,107 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_SIGNIN_PUBLIC_INTERFACES_ACCOUNT_ID_TRAITS_H_
+#define COMPONENTS_SIGNIN_PUBLIC_INTERFACES_ACCOUNT_ID_TRAITS_H_
+
+#include <string>
+
+#include "components/signin/core/account_id/account_id.h"
+#include "components/signin/public/interfaces/account_id.mojom.h"
+
+namespace mojo {
+
+template <>
+struct EnumTraits<signin::mojom::AccountType, AccountType> {
+ static signin::mojom::AccountType ToMojom(AccountType input) {
+ switch (input) {
+ case AccountType::UNKNOWN:
+ return signin::mojom::AccountType::UNKNOWN;
+ case AccountType::GOOGLE:
+ return signin::mojom::AccountType::GOOGLE;
+ case AccountType::ACTIVE_DIRECTORY:
+ return signin::mojom::AccountType::ACTIVE_DIRECTORY;
+ }
+ NOTREACHED();
+ return signin::mojom::AccountType::UNKNOWN;
+ }
+
+ static bool FromMojom(signin::mojom::AccountType input,
+ AccountType* out) {
+ switch (input) {
+ case signin::mojom::AccountType::UNKNOWN:
+ *out = AccountType::UNKNOWN;
+ return true;
+ case signin::mojom::AccountType::GOOGLE:
+ *out = AccountType::GOOGLE;
+ return true;
+ case signin::mojom::AccountType::ACTIVE_DIRECTORY:
+ *out = AccountType::ACTIVE_DIRECTORY;
+ return true;
+ }
+ NOTREACHED();
+ return false;
+ }
+};
+
+
+template <>
+struct StructTraits<signin::mojom::AccountIdDataView, AccountId> {
+ static AccountType account_type(const AccountId& r) {
+ return r.GetAccountType();
+ }
+ static std::string id(const AccountId& r) {
+ switch (r.GetAccountType()) {
+ case AccountType::GOOGLE:
+ return r.GetGaiaId();
+ case AccountType::ACTIVE_DIRECTORY:
+ return r.GetObjGuid();
+ case AccountType::UNKNOWN:
+ // UNKNOWN type is used for users that have only email (e.g. in tests
+ // or legacy users that have not run through migration code).
+ // Return an empty string for such accounts.
+ return std::string();
+ }
+ NOTREACHED();
+ return std::string();
+ }
+ static std::string user_email(const AccountId& r) {
+ return r.GetUserEmail();
+ }
+
+ static bool Read(signin::mojom::AccountIdDataView data, AccountId* out) {
+ AccountType account_type;
+ std::string id;
+ std::string user_email;
+ if (!data.ReadAccountType(&account_type) ||
+ !data.ReadId(&id) ||
+ !data.ReadUserEmail(&user_email)) {
+ return false;
+ }
+
+ switch (account_type) {
+ case AccountType::GOOGLE:
+ *out = AccountId::FromUserEmailGaiaId(user_email, id);
+ break;
+ case AccountType::ACTIVE_DIRECTORY:
+ *out = AccountId::AdFromUserEmailObjGuid(user_email, id);
+ break;
+ case AccountType::UNKNOWN:
+ // UNKNOWN type is used for users that have only email (e.g. in tests
+ // or legacy users that have not run through migration code).
+ // Bail if there is no user email.
+ if (user_email.empty())
+ return false;
+
+ *out = AccountId::FromUserEmail(user_email);
+ break;
+ }
+
+ return out->is_valid();
+ }
+};
+
+} // namespace mojo
+
+#endif // COMPONENTS_SIGNIN_PUBLIC_INTERFACES_ACCOUNT_ID_TRAITS_H_