summaryrefslogtreecommitdiff
path: root/chromium/google_apis
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2022-09-07 13:12:05 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2022-11-09 10:02:59 +0000
commit33fc33aa94d4add0878ec30dc818e34e1dd3cc2a (patch)
treef6af110909c79b2759136554f1143d8b0572af0a /chromium/google_apis
parent7d2c5d177e9813077a621df8d18c0deda73099b3 (diff)
downloadqtwebengine-chromium-33fc33aa94d4add0878ec30dc818e34e1dd3cc2a.tar.gz
BASELINE: Update Chromium to 104.0.5112.120
Change-Id: I5d2726c2ab018d75d055739b6ba64317904f05bb Reviewed-on: https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/438935 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/google_apis')
-rw-r--r--chromium/google_apis/BUILD.gn6
-rw-r--r--chromium/google_apis/calendar/calendar_api_requests.cc24
-rw-r--r--chromium/google_apis/calendar/calendar_api_requests_unittest.cc16
-rw-r--r--chromium/google_apis/calendar/calendar_api_response_types.cc171
-rw-r--r--chromium/google_apis/calendar/calendar_api_response_types.h32
-rw-r--r--chromium/google_apis/calendar/calendar_api_response_types_unittest.cc53
-rw-r--r--chromium/google_apis/calendar/calendar_api_url_generator.cc21
-rw-r--r--chromium/google_apis/calendar/calendar_api_url_generator.h7
-rw-r--r--chromium/google_apis/calendar/calendar_api_url_generator_unittest.cc22
-rw-r--r--chromium/google_apis/common/time_util.cc28
-rw-r--r--chromium/google_apis/common/time_util.h4
-rw-r--r--chromium/google_apis/common/time_util_unittest.cc10
-rw-r--r--chromium/google_apis/drive/drive_api_requests.cc4
-rw-r--r--chromium/google_apis/drive/drive_api_url_generator.cc44
-rw-r--r--chromium/google_apis/gaia/core_account_id.cc14
-rw-r--r--chromium/google_apis/gaia/core_account_id.h20
-rw-r--r--chromium/google_apis/gaia/gaia_auth_fetcher.cc48
-rw-r--r--chromium/google_apis/gaia/gaia_auth_util.cc21
-rw-r--r--chromium/google_apis/gaia/gaia_auth_util.h9
-rw-r--r--chromium/google_apis/gaia/gaia_auth_util_unittest.cc52
-rw-r--r--chromium/google_apis/gaia/gaia_constants.cc9
-rw-r--r--chromium/google_apis/gaia/gaia_constants.h4
-rw-r--r--chromium/google_apis/gaia/gaia_oauth_client.cc30
-rw-r--r--chromium/google_apis/gaia/gaia_urls.cc100
-rw-r--r--chromium/google_apis/gaia/gaia_urls.h6
-rw-r--r--chromium/google_apis/gaia/oauth2_access_token_fetcher_impl.cc12
-rw-r--r--chromium/google_apis/gaia/oauth2_api_call_flow.cc2
-rw-r--r--chromium/google_apis/gaia/oauth2_mint_token_flow.cc26
-rw-r--r--chromium/google_apis/gaia/oauth_multilogin_result.cc15
-rw-r--r--chromium/google_apis/gaia/oauth_multilogin_result_unittest.cc12
-rw-r--r--chromium/google_apis/gcm/base/gcm_util.cc4
-rw-r--r--chromium/google_apis/gcm/engine/mcs_client.cc2
-rw-r--r--chromium/google_apis/gcm/engine/registration_request_unittest.cc4
-rw-r--r--chromium/google_apis/gcm/engine/unregistration_request.cc2
34 files changed, 619 insertions, 215 deletions
diff --git a/chromium/google_apis/BUILD.gn b/chromium/google_apis/BUILD.gn
index 1d9df40aa69..1f74cd0a36d 100644
--- a/chromium/google_apis/BUILD.gn
+++ b/chromium/google_apis/BUILD.gn
@@ -259,9 +259,9 @@ test("google_apis_unittests") {
}
if (is_fuchsia) {
- use_cfv2 = false
+ use_cfv1 = false
additional_manifest_fragments =
- [ "//build/config/fuchsia/test/network_capabilities.test-cmx" ]
+ [ "//build/config/fuchsia/test/network.shard.test-cml" ]
}
if (enable_extensions) {
@@ -278,6 +278,8 @@ test("google_apis_unittests") {
bundle_data("google_apis_unittest_bundle_data") {
testonly = true
sources = [
+ "test/data/calendar/event_self_response_statuses.json",
+ "test/data/calendar/event_statuses.json",
"test/data/calendar/events.json",
"test/data/calendar/invalid_events.json",
"test/data/gaia/all_base_urls.json",
diff --git a/chromium/google_apis/calendar/calendar_api_requests.cc b/chromium/google_apis/calendar/calendar_api_requests.cc
index 1dd538bb77a..1c526d15aaa 100644
--- a/chromium/google_apis/calendar/calendar_api_requests.cc
+++ b/chromium/google_apis/calendar/calendar_api_requests.cc
@@ -14,9 +14,15 @@ namespace google_apis {
namespace calendar {
-const char kCalendarEventListFields[] =
- "timeZone,etag,kind,items(id,summary,colorId, "
- "status,start(dateTime),end(dateTime),htmlLink)";
+constexpr char kFieldsParameterName[] = "fields";
+// According to the docs
+// (https://developers.google.com/calendar/api/v3/reference/events/list), it
+// should return the participant/requester only as an attendee.
+constexpr int kMaxAttendees = 1;
+constexpr char kCalendarEventListFields[] =
+ "timeZone,etag,kind,items(id,kind,summary,colorId,"
+ "status,start(date),end(date),start(dateTime),end(dateTime),htmlLink,"
+ "attendees(responseStatus,self),attendeesOmitted,creator(self))";
CalendarApiGetRequest::CalendarApiGetRequest(RequestSender* sender,
const std::string& fields)
@@ -27,8 +33,10 @@ CalendarApiGetRequest::~CalendarApiGetRequest() = default;
GURL CalendarApiGetRequest::GetURL() const {
GURL url = GetURLInternal();
- if (!fields_.empty())
- url = net::AppendOrReplaceQueryParameter(url, "fields", fields_);
+ if (!fields_.empty()) {
+ url =
+ net::AppendOrReplaceQueryParameter(url, kFieldsParameterName, fields_);
+ }
return url;
}
@@ -67,8 +75,10 @@ CalendarApiEventsRequest::CalendarApiEventsRequest(
CalendarApiEventsRequest::~CalendarApiEventsRequest() = default;
GURL CalendarApiEventsRequest::GetURLInternal() const {
- return url_generator_.GetCalendarEventListUrl(start_time_, end_time_,
- /*single_events=*/true);
+ return url_generator_.GetCalendarEventListUrl(
+ start_time_, end_time_,
+ /*single_events=*/true,
+ /*max_attendees=*/kMaxAttendees);
}
void CalendarApiEventsRequest::ProcessURLFetchResults(
diff --git a/chromium/google_apis/calendar/calendar_api_requests_unittest.cc b/chromium/google_apis/calendar/calendar_api_requests_unittest.cc
index 4a520d6a679..b682c0c9812 100644
--- a/chromium/google_apis/calendar/calendar_api_requests_unittest.cc
+++ b/chromium/google_apis/calendar/calendar_api_requests_unittest.cc
@@ -102,11 +102,17 @@ TEST_F(CalendarApiRequestsTest, GetEventListRequest) {
EXPECT_EQ(HTTP_SUCCESS, error);
EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method);
EXPECT_EQ(
- "/calendar/v3/calendars/primary/"
- "events?timeMin=2021-06-13T10%3A00%3A00.000Z&timeMax=2021-06-16T10%3A00%"
- "3A00.000Z&singleEvents=true&fields=timeZone%2Cetag%2Ckind%2Citems(id%"
- "2Csummary%2CcolorId%2C+status%2Cstart(dateTime)%2Cend(dateTime)%"
- "2ChtmlLink)",
+ "/calendar/v3/calendars/primary/events"
+ "?timeMin=2021-06-13T10%3A00%3A00.000Z"
+ "&timeMax=2021-06-16T10%3A00%3A00.000Z"
+ "&singleEvents=true"
+ "&maxAttendees=1"
+ "&fields=timeZone%2Cetag%2Ckind%2Citems(id%2Ckind%"
+ "2Csummary%2CcolorId%2Cstatus%"
+ "2Cstart(date)%2Cend(date)%"
+ "2Cstart(dateTime)%2Cend(dateTime)%"
+ "2ChtmlLink%2Cattendees(responseStatus%2Cself)%2CattendeesOmitted%"
+ "2Ccreator(self))",
http_request_.relative_url);
ASSERT_TRUE(events.get());
diff --git a/chromium/google_apis/calendar/calendar_api_response_types.cc b/chromium/google_apis/calendar/calendar_api_response_types.cc
index d09234963ee..bf3ef85f12c 100644
--- a/chromium/google_apis/calendar/calendar_api_response_types.cc
+++ b/chromium/google_apis/calendar/calendar_api_response_types.cc
@@ -6,8 +6,11 @@
#include <stddef.h>
+#include <map>
#include <memory>
+#include <string>
+#include "base/containers/fixed_flat_map.h"
#include "base/json/json_value_converter.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
@@ -16,6 +19,7 @@
#include "base/values.h"
#include "google_apis/common/parser_util.h"
#include "google_apis/common/time_util.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
namespace google_apis {
@@ -24,20 +28,145 @@ namespace calendar {
namespace {
// EventList
-const char kTimeZone[] = "timeZone";
-const char kCalendarEventListKind[] = "calendar#events";
+constexpr char kCalendarEventListKind[] = "calendar#events";
+constexpr char kTimeZone[] = "timeZone";
// DateTime
-const char kDateTime[] = "dateTime";
+constexpr char kDateTime[] = "dateTime";
+
+// Date
+constexpr char kDate[] = "date";
// CalendarEvent
-const char kSummary[] = "summary";
-const char kStart[] = "start";
-const char kEnd[] = "end";
-const char kColorId[] = "colorId";
-const char kStatus[] = "status";
-const char kHtmlLink[] = "htmlLink";
-const char kCalendarEventKind[] = "calendar#event";
+constexpr char kAttendees[] = "attendees";
+constexpr char kAttendeesOmitted[] = "attendeesOmitted";
+constexpr char kAttendeesResponseStatus[] = "responseStatus";
+constexpr char kAttendeesSelf[] = "self";
+constexpr char kCalendarEventKind[] = "calendar#event";
+constexpr char kColorId[] = "colorId";
+constexpr char kEnd[] = "end";
+constexpr char kHtmlLink[] = "htmlLink";
+constexpr char kPathToCreatorSelf[] = "creator.self";
+constexpr char kStart[] = "start";
+constexpr char kStatus[] = "status";
+constexpr char kSummary[] = "summary";
+
+constexpr auto kEventStatuses =
+ base::MakeFixedFlatMap<base::StringPiece, CalendarEvent::EventStatus>(
+ {{"cancelled", CalendarEvent::EventStatus::kCancelled},
+ {"confirmed", CalendarEvent::EventStatus::kConfirmed},
+ {"tentative", CalendarEvent::EventStatus::kTentative}});
+
+constexpr auto kAttendeesResponseStatuses =
+ base::MakeFixedFlatMap<base::StringPiece, CalendarEvent::ResponseStatus>(
+ {{"accepted", CalendarEvent::ResponseStatus::kAccepted},
+ {"declined", CalendarEvent::ResponseStatus::kDeclined},
+ {"needsAction", CalendarEvent::ResponseStatus::kNeedsAction},
+ {"tentative", CalendarEvent::ResponseStatus::kTentative}});
+
+// Converts the `items` field from the response. This method helps to use the
+// custom conversion entrypoint `CalendarEvent::CreateFrom`.
+// Returns false when it fails (e.g. the value is structurally different from
+// expected).
+bool ConvertResponseItems(const base::Value* value,
+ std::vector<std::unique_ptr<CalendarEvent>>* result) {
+ const auto* items = value->GetIfList();
+ if (!items)
+ return false;
+
+ result->reserve(items->size());
+ for (const auto& item : *items) {
+ auto event = CalendarEvent::CreateFrom(item);
+ if (!event)
+ return false;
+ result->push_back(std::move(event));
+ }
+
+ return true;
+}
+
+// Converts the event status to `EventStatus`. Returns false when it fails
+// (e.g. the value is structurally different from expected).
+bool ConvertEventStatus(const base::Value* value,
+ CalendarEvent::EventStatus* result) {
+ DCHECK(value);
+ DCHECK(result);
+
+ const auto* status = value->GetIfString();
+ if (!status) {
+ return false;
+ }
+
+ const auto* it = kEventStatuses.find(*status);
+ if (it != kEventStatuses.end()) {
+ *result = it->second;
+ } else {
+ *result = CalendarEvent::EventStatus::kUnknown;
+ }
+ return true;
+}
+
+// Returns user's self response status on the event, or `absl::nullopt` in case
+// the passed value is structurally different from expected.
+absl::optional<CalendarEvent::ResponseStatus> CalculateSelfResponseStatus(
+ const base::Value& value) {
+ const auto* event = value.GetIfDict();
+ if (!event)
+ return absl::nullopt;
+
+ const auto* attendees_raw_value = event->Find(kAttendees);
+ if (!attendees_raw_value) {
+ // It's okay not to have `attendees` field in the response, it's possible
+ // in two cases:
+ // - this is a personal event of the `default` type without other
+ // attendees;
+ // - user invited 2+ guests and removed themselves from the event (also,
+ // the `attendeesOmitted` flag will be set to true).
+
+ const bool is_self_created =
+ event->FindBoolByDottedPath(kPathToCreatorSelf).value_or(false);
+ const bool has_omitted_attendees =
+ event->FindBool(kAttendeesOmitted).value_or(false);
+
+ if (is_self_created && !has_omitted_attendees) {
+ // It's not possible to create a personal event and mark it as
+ // tentative or declined.
+ return CalendarEvent::ResponseStatus::kAccepted;
+ }
+
+ return CalendarEvent::ResponseStatus::kUnknown;
+ }
+
+ const auto* attendees = attendees_raw_value->GetIfList();
+ if (!attendees)
+ return absl::nullopt;
+
+ for (const auto& x : *attendees) {
+ const auto* attendee = x.GetIfDict();
+ if (!attendee)
+ return absl::nullopt;
+
+ const bool is_self = attendee->FindBool(kAttendeesSelf).value_or(false);
+ if (!is_self) {
+ // A special case when user invited 1 more guest and removed themselves
+ // from the event. In this case that user will be returned as an
+ // attendee (the total number of attendees <= the requested number), safe
+ // to ignore this item.
+ continue;
+ }
+
+ const auto* responseStatus = attendee->FindString(kAttendeesResponseStatus);
+ if (!responseStatus)
+ return absl::nullopt;
+
+ const auto* it = kAttendeesResponseStatuses.find(*responseStatus);
+ if (it != kAttendeesResponseStatuses.end()) {
+ return it->second;
+ }
+ }
+
+ return CalendarEvent::ResponseStatus::kUnknown;
+}
} // namespace
@@ -54,6 +183,8 @@ void DateTime::RegisterJSONConverter(
base::JSONValueConverter<DateTime>* converter) {
converter->RegisterCustomField<base::Time>(kDateTime, &DateTime::date_time_,
&util::GetTimeFromString);
+ converter->RegisterCustomField<base::Time>(kDate, &DateTime::date_time_,
+ &util::GetDateOnlyFromString);
}
// static
@@ -82,7 +213,8 @@ void CalendarEvent::RegisterJSONConverter(
converter->RegisterStringField(kSummary, &CalendarEvent::summary_);
converter->RegisterStringField(kHtmlLink, &CalendarEvent::html_link_);
converter->RegisterStringField(kColorId, &CalendarEvent::color_id_);
- converter->RegisterStringField(kStatus, &CalendarEvent::status_);
+ converter->RegisterCustomValueField(kStatus, &CalendarEvent::status_,
+ &ConvertEventStatus);
converter->RegisterCustomValueField(kStart, &CalendarEvent::start_time_,
&DateTime::CreateDateTimeFromValue);
converter->RegisterCustomValueField(kEnd, &CalendarEvent::end_time_,
@@ -100,7 +232,15 @@ std::unique_ptr<CalendarEvent> CalendarEvent::CreateFrom(
return nullptr;
}
- return event;
+ auto self_response_status = CalculateSelfResponseStatus(value);
+ if (self_response_status.has_value()) {
+ event->set_self_response_status(self_response_status.value());
+ return event;
+ }
+
+ DVLOG(1) << "Unable to calculate self response status: Invalid "
+ "CalendarEvent JSON!";
+ return nullptr;
}
int CalendarEvent::GetApproximateSizeInBytes() const {
@@ -111,7 +251,8 @@ int CalendarEvent::GetApproximateSizeInBytes() const {
total_bytes += summary_.length();
total_bytes += html_link_.length();
total_bytes += color_id_.length();
- total_bytes += status_.length();
+ total_bytes += sizeof(status_);
+ total_bytes += sizeof(self_response_status_);
return total_bytes;
}
@@ -126,8 +267,8 @@ void EventList::RegisterJSONConverter(
converter->RegisterStringField(kTimeZone, &EventList::time_zone_);
converter->RegisterStringField(kApiResponseETagKey, &EventList::etag_);
converter->RegisterStringField(kApiResponseKindKey, &EventList::kind_);
- converter->RegisterRepeatedMessage<CalendarEvent>(kApiResponseItemsKey,
- &EventList::items_);
+ converter->RegisterCustomValueField(kApiResponseItemsKey, &EventList::items_,
+ &ConvertResponseItems);
}
// static
diff --git a/chromium/google_apis/calendar/calendar_api_response_types.h b/chromium/google_apis/calendar/calendar_api_response_types.h
index fb333c21b1e..9ecd1f2fda6 100644
--- a/chromium/google_apis/calendar/calendar_api_response_types.h
+++ b/chromium/google_apis/calendar/calendar_api_response_types.h
@@ -28,7 +28,7 @@ namespace google_apis {
namespace calendar {
-// Parses the time filed in the calendar Events.list response.
+// Parses the time field in the calendar Events.list response.
class DateTime {
public:
DateTime();
@@ -60,6 +60,23 @@ class CalendarEvent {
CalendarEvent& operator=(const CalendarEvent&);
~CalendarEvent();
+ // Status of the event.
+ enum class EventStatus {
+ kUnknown,
+ kCancelled,
+ kConfirmed,
+ kTentative,
+ };
+
+ // The attendee's response status.
+ enum class ResponseStatus {
+ kUnknown,
+ kAccepted,
+ kDeclined,
+ kNeedsAction,
+ kTentative,
+ };
+
// Registers the mapping between JSON field names and the members in this
// class.
static void RegisterJSONConverter(
@@ -85,8 +102,14 @@ class CalendarEvent {
void set_color_id(const std::string& color_id) { color_id_ = color_id; }
// The status of the event.
- const std::string& status() const { return status_; }
- void set_status(const std::string& status) { status_ = status; }
+ EventStatus status() const { return status_; }
+ void set_status(EventStatus status) { status_ = status; }
+
+ // The self attendency response status of the event.
+ ResponseStatus self_response_status() const { return self_response_status_; }
+ void set_self_response_status(ResponseStatus self_response_status) {
+ self_response_status_ = self_response_status;
+ }
const DateTime& start_time() const { return start_time_; }
void set_start_time(const DateTime& start_time) { start_time_ = start_time; }
@@ -102,7 +125,8 @@ class CalendarEvent {
std::string summary_;
std::string html_link_;
std::string color_id_;
- std::string status_;
+ EventStatus status_ = EventStatus::kUnknown;
+ ResponseStatus self_response_status_ = ResponseStatus::kUnknown;
DateTime start_time_;
DateTime end_time_;
};
diff --git a/chromium/google_apis/calendar/calendar_api_response_types_unittest.cc b/chromium/google_apis/calendar/calendar_api_response_types_unittest.cc
index d3dc2d2e480..687e70191e8 100644
--- a/chromium/google_apis/calendar/calendar_api_response_types_unittest.cc
+++ b/chromium/google_apis/calendar/calendar_api_response_types_unittest.cc
@@ -42,7 +42,58 @@ TEST(CalendarAPIResponseTypesTest, ParseEventList) {
event.html_link(),
"https://www.google.com/calendar/event?eid=b3I4MjIxc2lydDRvZ2Ztest");
EXPECT_EQ(event.color_id(), "3");
- EXPECT_EQ(event.status(), "confirmed");
+ EXPECT_EQ(event.status(), CalendarEvent::EventStatus::kConfirmed);
+ EXPECT_EQ(event.self_response_status(),
+ CalendarEvent::ResponseStatus::kNeedsAction);
+}
+
+TEST(CalendarAPIResponseTypesTest, ParseEventListWithCorrectEventStatuses) {
+ std::unique_ptr<base::Value> events =
+ test_util::LoadJSONFile("calendar/event_statuses.json");
+ ASSERT_TRUE(events.get());
+
+ ASSERT_EQ(base::Value::Type::DICTIONARY, events->type());
+ auto event_list = EventList::CreateFrom(*events);
+
+ EXPECT_EQ(4U, event_list->items().size());
+
+ EXPECT_EQ(event_list->items()[0]->status(),
+ CalendarEvent::EventStatus::kConfirmed);
+ EXPECT_EQ(event_list->items()[1]->status(),
+ CalendarEvent::EventStatus::kCancelled);
+ EXPECT_EQ(event_list->items()[2]->status(),
+ CalendarEvent::EventStatus::kTentative);
+ EXPECT_EQ(event_list->items()[3]->status(),
+ CalendarEvent::EventStatus::kUnknown);
+}
+
+TEST(CalendarAPIResponseTypesTest,
+ ParseEventListWithCorrectSelfResponseStatus) {
+ std::unique_ptr<base::Value> events =
+ test_util::LoadJSONFile("calendar/event_self_response_statuses.json");
+ ASSERT_TRUE(events.get());
+
+ ASSERT_EQ(base::Value::Type::DICTIONARY, events->type());
+ auto event_list = EventList::CreateFrom(*events);
+
+ EXPECT_EQ(8U, event_list->items().size());
+
+ EXPECT_EQ(event_list->items()[0]->self_response_status(),
+ CalendarEvent::ResponseStatus::kUnknown);
+ EXPECT_EQ(event_list->items()[1]->self_response_status(),
+ CalendarEvent::ResponseStatus::kAccepted);
+ EXPECT_EQ(event_list->items()[2]->self_response_status(),
+ CalendarEvent::ResponseStatus::kDeclined);
+ EXPECT_EQ(event_list->items()[3]->self_response_status(),
+ CalendarEvent::ResponseStatus::kNeedsAction);
+ EXPECT_EQ(event_list->items()[4]->self_response_status(),
+ CalendarEvent::ResponseStatus::kTentative);
+ EXPECT_EQ(event_list->items()[5]->self_response_status(),
+ CalendarEvent::ResponseStatus::kAccepted);
+ EXPECT_EQ(event_list->items()[6]->self_response_status(),
+ CalendarEvent::ResponseStatus::kUnknown);
+ EXPECT_EQ(event_list->items()[7]->self_response_status(),
+ CalendarEvent::ResponseStatus::kUnknown);
}
TEST(CalendarAPIResponseTypesTest, ParseFailed) {
diff --git a/chromium/google_apis/calendar/calendar_api_url_generator.cc b/chromium/google_apis/calendar/calendar_api_url_generator.cc
index a360205f19d..132e8be56a3 100644
--- a/chromium/google_apis/calendar/calendar_api_url_generator.cc
+++ b/chromium/google_apis/calendar/calendar_api_url_generator.cc
@@ -4,8 +4,10 @@
#include "google_apis/calendar/calendar_api_url_generator.h"
+#include "base/strings/string_number_conversions.h"
#include "google_apis/common/time_util.h"
#include "net/base/url_util.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
namespace google_apis {
@@ -14,11 +16,12 @@ namespace calendar {
namespace {
// Hard coded URLs for communication with a google calendar server.
-const char kCalendarV3EventsUrl[] = "calendar/v3/calendars/primary/events";
-const char kCalendarV3ColorUrl[] = "calendar/v3/colors";
-const char kTimeMaxParameterName[] = "timeMax";
-const char kTimeMinParameterName[] = "timeMin";
-const char kSingleEventsParameterName[] = "singleEvents";
+constexpr char kCalendarV3EventsUrl[] = "calendar/v3/calendars/primary/events";
+constexpr char kCalendarV3ColorUrl[] = "calendar/v3/colors";
+constexpr char kTimeMaxParameterName[] = "timeMax";
+constexpr char kTimeMinParameterName[] = "timeMin";
+constexpr char kSingleEventsParameterName[] = "singleEvents";
+constexpr char kMaxAttendeesParameterName[] = "maxAttendees";
} // namespace
@@ -35,7 +38,8 @@ CalendarApiUrlGenerator::~CalendarApiUrlGenerator() = default;
GURL CalendarApiUrlGenerator::GetCalendarEventListUrl(
const base::Time& start_time,
const base::Time& end_time,
- bool single_events) const {
+ bool single_events,
+ absl::optional<int> max_attendees) const {
GURL url = base_url_.Resolve(kCalendarV3EventsUrl);
std::string start_time_string = util::FormatTimeAsString(start_time);
std::string end_time_string = util::FormatTimeAsString(end_time);
@@ -45,6 +49,11 @@ GURL CalendarApiUrlGenerator::GetCalendarEventListUrl(
end_time_string);
url = net::AppendOrReplaceQueryParameter(url, kSingleEventsParameterName,
single_events ? "true" : "false");
+ if (max_attendees.has_value()) {
+ url = net::AppendOrReplaceQueryParameter(
+ url, kMaxAttendeesParameterName,
+ base::NumberToString(max_attendees.value()));
+ }
return url;
}
diff --git a/chromium/google_apis/calendar/calendar_api_url_generator.h b/chromium/google_apis/calendar/calendar_api_url_generator.h
index 53e9ebf48cb..8fe059b6a92 100644
--- a/chromium/google_apis/calendar/calendar_api_url_generator.h
+++ b/chromium/google_apis/calendar/calendar_api_url_generator.h
@@ -9,6 +9,7 @@
#include "base/time/time.h"
#include "google_apis/gaia/gaia_urls.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/gurl.h"
namespace google_apis {
@@ -31,9 +32,13 @@ class CalendarApiUrlGenerator {
// return single one-off events and instances of recurring
// events, but not the underlying recurring events
// themselves
+ // |max_attendees| The maximum number of attendees to include in the response.
+ // If there are more than the specified number of attendees,
+ // only the participant is returned. Optional.
GURL GetCalendarEventListUrl(const base::Time& start_time,
const base::Time& end_time,
- bool single_events) const;
+ bool single_events,
+ absl::optional<int> max_attendees) const;
// Returns a URL to fetch a map of calendar color id to color code.
GURL GetCalendarColorListUrl() const;
diff --git a/chromium/google_apis/calendar/calendar_api_url_generator_unittest.cc b/chromium/google_apis/calendar/calendar_api_url_generator_unittest.cc
index 3cf5fcff26b..62ae87eb920 100644
--- a/chromium/google_apis/calendar/calendar_api_url_generator_unittest.cc
+++ b/chromium/google_apis/calendar/calendar_api_url_generator_unittest.cc
@@ -28,8 +28,28 @@ TEST(CalendarApiUrlGeneratorTest, GetEventListUrl) {
"https://www.googleapis.com/calendar/v3/calendars/primary/"
"events?timeMin=2021-06-13T18%3A00%3A00.000Z"
"&timeMax=2021-06-16T18%3A00%3A00.000Z"
+ "&singleEvents=true"
+ "&maxAttendees=1",
+ url_generator_
+ .GetCalendarEventListUrl(start, end, /*single_events=*/true,
+ /*max_attendees=*/1)
+ .spec());
+}
+
+TEST(CalendarApiUrlGeneratorTest, GetEventListUrlWithDefaultMaxAttendees) {
+ CalendarApiUrlGenerator url_generator_;
+ base::Time start;
+ EXPECT_TRUE(base::Time::FromString("13 Jun 2021 10:00 PST", &start));
+ base::Time end;
+ EXPECT_TRUE(base::Time::FromString("16 Jun 2021 10:00 PST", &end));
+ EXPECT_EQ(
+ "https://www.googleapis.com/calendar/v3/calendars/primary/"
+ "events?timeMin=2021-06-13T18%3A00%3A00.000Z"
+ "&timeMax=2021-06-16T18%3A00%3A00.000Z"
"&singleEvents=true",
- url_generator_.GetCalendarEventListUrl(start, end, /*single_events=*/true)
+ url_generator_
+ .GetCalendarEventListUrl(start, end, /*single_events=*/true,
+ /*max_attendees=*/absl::nullopt)
.spec());
}
diff --git a/chromium/google_apis/common/time_util.cc b/chromium/google_apis/common/time_util.cc
index 680d078be7f..3af0f5d2e9a 100644
--- a/chromium/google_apis/common/time_util.cc
+++ b/chromium/google_apis/common/time_util.cc
@@ -154,6 +154,34 @@ bool GetTimeFromString(base::StringPiece raw_value, base::Time* parsed_time) {
return true;
}
+bool GetDateOnlyFromString(base::StringPiece raw_value,
+ base::Time* parsed_time) {
+ base::Time::Exploded exploded = {0};
+ base::Time time;
+
+ // Parses the date part only.
+ {
+ std::vector<base::StringPiece> parts = base::SplitStringPiece(
+ raw_value, "-", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
+ if (parts.size() != 3)
+ return false;
+
+ if (!base::StringToInt(parts[0], &exploded.year) ||
+ !base::StringToInt(parts[1], &exploded.month) ||
+ !base::StringToInt(parts[2], &exploded.day_of_month)) {
+ return false;
+ }
+ }
+
+ if (!base::Time::FromUTCExploded(exploded, &time))
+ return false;
+
+ // Ensure that the time section (everything after the "yyyy-mm-dd" date) is
+ // zeros.
+ *parsed_time = time.UTCMidnight();
+ return true;
+}
+
std::string FormatTimeAsString(const base::Time& time) {
if (time.is_null())
return kNullTimeString;
diff --git a/chromium/google_apis/common/time_util.h b/chromium/google_apis/common/time_util.h
index 20fc746a07f..e29883ed770 100644
--- a/chromium/google_apis/common/time_util.h
+++ b/chromium/google_apis/common/time_util.h
@@ -21,6 +21,10 @@ namespace util {
// either '+hh:mm', '-hh:mm', 'Z' (representing UTC), or an empty string).
bool GetTimeFromString(base::StringPiece raw_value, base::Time* time);
+// Parses a date string of format "yyyy-mm-dd," returning true on success. The
+// time part of `time` is 00:00 (midnight) UTC.
+bool GetDateOnlyFromString(base::StringPiece raw_value, base::Time* time);
+
// Formats a base::Time as an RFC 3339 date/time (in UTC).
// If |time| is null, returns "null".
std::string FormatTimeAsString(const base::Time& time);
diff --git a/chromium/google_apis/common/time_util_unittest.cc b/chromium/google_apis/common/time_util_unittest.cc
index 181f556b593..866737ff4d6 100644
--- a/chromium/google_apis/common/time_util_unittest.cc
+++ b/chromium/google_apis/common/time_util_unittest.cc
@@ -78,6 +78,16 @@ TEST(TimeUtilTest, GetTimeFromStringBasic) {
EXPECT_EQ(FormatTime(out_time), FormatTime(test_time));
}
+TEST(TimeUtilTest, GetDateOnlyFromStringBasic) {
+ base::Time test_time;
+ base::Time out_time;
+
+ base::Time::Exploded target_time1 = {2009, 10, 0, 23};
+ EXPECT_TRUE(GetDateOnlyFromString("2009-10-23", &test_time));
+ EXPECT_TRUE(base::Time::FromUTCExploded(target_time1, &out_time));
+ EXPECT_EQ(FormatTime(out_time), FormatTime(test_time));
+}
+
TEST(TimeUtilTest, FormatTimeAsString) {
base::Time::Exploded exploded_time = {2012, 7, 0, 19, 15, 59, 13, 123};
base::Time time;
diff --git a/chromium/google_apis/drive/drive_api_requests.cc b/chromium/google_apis/drive/drive_api_requests.cc
index a74bd20f6a6..6f992eedc59 100644
--- a/chromium/google_apis/drive/drive_api_requests.cc
+++ b/chromium/google_apis/drive/drive_api_requests.cc
@@ -1129,8 +1129,8 @@ BatchUploadRequest::BatchUploadRequest(
const DriveApiUrlGenerator& url_generator)
: DriveUrlFetchRequestBase(
sender,
- // Safe to not retain as the SimpleURLoader is owned by our base class
- // and cannot outlive this instance.
+ // Safe to not retain as the SimpleURLLoader is owned by our base
+ // class and cannot outlive this instance.
base::BindRepeating(&BatchUploadRequest::OnUploadProgress,
base::Unretained(this)),
ProgressCallback()),
diff --git a/chromium/google_apis/drive/drive_api_url_generator.cc b/chromium/google_apis/drive/drive_api_url_generator.cc
index e0fa9432bcc..c2d94ed6581 100644
--- a/chromium/google_apis/drive/drive_api_url_generator.cc
+++ b/chromium/google_apis/drive/drive_api_url_generator.cc
@@ -7,10 +7,10 @@
#include "base/check_op.h"
#include "base/command_line.h"
#include "base/notreached.h"
+#include "base/strings/escape.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "google_apis/google_api_keys.h"
-#include "net/base/escape.h"
#include "net/base/url_util.h"
namespace google_apis {
@@ -94,7 +94,7 @@ GURL DriveApiUrlGenerator::GetAboutGetUrl() const {
GURL DriveApiUrlGenerator::GetFilesGetUrl(const std::string& file_id,
const GURL& embed_origin) const {
GURL url =
- base_url_.Resolve(kDriveV2FileUrlPrefix + net::EscapePath(file_id));
+ base_url_.Resolve(kDriveV2FileUrlPrefix + base::EscapePath(file_id));
url = net::AppendOrReplaceQueryParameter(url, kSupportsTeamDrives, "true");
if (!embed_origin.is_empty()) {
@@ -127,7 +127,7 @@ GURL DriveApiUrlGenerator::GetFilesPatchUrl(const std::string& file_id,
bool set_modified_date,
bool update_viewed_date) const {
GURL url =
- base_url_.Resolve(kDriveV2FileUrlPrefix + net::EscapePath(file_id));
+ base_url_.Resolve(kDriveV2FileUrlPrefix + base::EscapePath(file_id));
url = net::AppendOrReplaceQueryParameter(url, kSupportsTeamDrives, "true");
// setModifiedDate is "false" by default.
@@ -144,8 +144,8 @@ GURL DriveApiUrlGenerator::GetFilesPatchUrl(const std::string& file_id,
GURL DriveApiUrlGenerator::GetFilesCopyUrl(
const std::string& file_id,
const std::string& visibility) const {
- GURL url = base_url_.Resolve(base::StringPrintf(
- kDriveV2FileCopyUrlFormat, net::EscapePath(file_id).c_str()));
+ GURL url = base_url_.Resolve(base::StringPrintf(
+ kDriveV2FileCopyUrlFormat, base::EscapePath(file_id).c_str()));
url = net::AppendOrReplaceQueryParameter(url, kSupportsTeamDrives, "true");
if (!visibility.empty())
@@ -183,14 +183,14 @@ GURL DriveApiUrlGenerator::GetFilesListUrl(int max_results,
GURL DriveApiUrlGenerator::GetFilesDeleteUrl(const std::string& file_id) const {
GURL url = base_url_.Resolve(base::StringPrintf(
- kDriveV2FileDeleteUrlFormat, net::EscapePath(file_id).c_str()));
+ kDriveV2FileDeleteUrlFormat, base::EscapePath(file_id).c_str()));
url = net::AppendOrReplaceQueryParameter(url, kSupportsTeamDrives, "true");
return url;
}
GURL DriveApiUrlGenerator::GetFilesTrashUrl(const std::string& file_id) const {
GURL url = base_url_.Resolve(base::StringPrintf(
- kDriveV2FileTrashUrlFormat, net::EscapePath(file_id).c_str()));
+ kDriveV2FileTrashUrlFormat, base::EscapePath(file_id).c_str()));
url = net::AppendOrReplaceQueryParameter(url, kSupportsTeamDrives, "true");
return url;
}
@@ -232,17 +232,16 @@ GURL DriveApiUrlGenerator::GetChangesListUrl(
GURL DriveApiUrlGenerator::GetChildrenInsertUrl(
const std::string& file_id) const {
GURL url = base_url_.Resolve(base::StringPrintf(
- kDriveV2ChildrenUrlFormat, net::EscapePath(file_id).c_str()));
+ kDriveV2ChildrenUrlFormat, base::EscapePath(file_id).c_str()));
url = net::AppendOrReplaceQueryParameter(url, kSupportsTeamDrives, "true");
return url;
}
GURL DriveApiUrlGenerator::GetChildrenDeleteUrl(
const std::string& child_id, const std::string& folder_id) const {
- return base_url_.Resolve(
- base::StringPrintf(kDriveV2ChildrenUrlForRemovalFormat,
- net::EscapePath(folder_id).c_str(),
- net::EscapePath(child_id).c_str()));
+ return base_url_.Resolve(base::StringPrintf(
+ kDriveV2ChildrenUrlForRemovalFormat, base::EscapePath(folder_id).c_str(),
+ base::EscapePath(child_id).c_str()));
}
GURL DriveApiUrlGenerator::GetInitiateUploadNewFileUrl(
@@ -261,9 +260,8 @@ GURL DriveApiUrlGenerator::GetInitiateUploadNewFileUrl(
GURL DriveApiUrlGenerator::GetInitiateUploadExistingFileUrl(
const std::string& resource_id,
bool set_modified_date) const {
- GURL url = base_url_.Resolve(
- kDriveV2UploadExistingFileUrlPrefix +
- net::EscapePath(resource_id));
+ GURL url = base_url_.Resolve(kDriveV2UploadExistingFileUrlPrefix +
+ base::EscapePath(resource_id));
url = AddResumableUploadParam(url);
url = net::AppendOrReplaceQueryParameter(url, kSupportsTeamDrives, "true");
@@ -290,9 +288,8 @@ GURL DriveApiUrlGenerator::GetMultipartUploadNewFileUrl(
GURL DriveApiUrlGenerator::GetMultipartUploadExistingFileUrl(
const std::string& resource_id,
bool set_modified_date) const {
- GURL url = base_url_.Resolve(
- kDriveV2UploadExistingFileUrlPrefix +
- net::EscapePath(resource_id));
+ GURL url = base_url_.Resolve(kDriveV2UploadExistingFileUrlPrefix +
+ base::EscapePath(resource_id));
url = AddMultipartUploadParam(url);
url = net::AppendOrReplaceQueryParameter(url, kSupportsTeamDrives, "true");
@@ -306,7 +303,7 @@ GURL DriveApiUrlGenerator::GetMultipartUploadExistingFileUrl(
GURL DriveApiUrlGenerator::GenerateDownloadFileUrl(
const std::string& resource_id) const {
GURL url = base_url_.Resolve(base::StringPrintf(
- kDriveV2DownloadUrlFormat, net::EscapePath(resource_id).c_str()));
+ kDriveV2DownloadUrlFormat, base::EscapePath(resource_id).c_str()));
url = net::AppendOrReplaceQueryParameter(url, kSupportsTeamDrives, "true");
return url;
}
@@ -314,7 +311,7 @@ GURL DriveApiUrlGenerator::GenerateDownloadFileUrl(
GURL DriveApiUrlGenerator::GetPermissionsInsertUrl(
const std::string& resource_id) const {
GURL url = base_url_.Resolve(base::StringPrintf(
- kDriveV2PermissionsUrlFormat, net::EscapePath(resource_id).c_str()));
+ kDriveV2PermissionsUrlFormat, base::EscapePath(resource_id).c_str()));
url = net::AppendOrReplaceQueryParameter(url, kSupportsTeamDrives, "true");
return url;
}
@@ -323,10 +320,9 @@ GURL DriveApiUrlGenerator::GetThumbnailUrl(const std::string& resource_id,
int width,
int height,
bool crop) const {
- return base_thumbnail_url_.Resolve(
- base::StringPrintf(
- crop ? kDriveV2ThumbnailUrlWithCropFormat : kDriveV2ThumbnailUrlFormat,
- net::EscapePath(resource_id).c_str(), width, height));
+ return base_thumbnail_url_.Resolve(base::StringPrintf(
+ crop ? kDriveV2ThumbnailUrlWithCropFormat : kDriveV2ThumbnailUrlFormat,
+ base::EscapePath(resource_id).c_str(), width, height));
}
GURL DriveApiUrlGenerator::GetBatchUploadUrl() const {
diff --git a/chromium/google_apis/gaia/core_account_id.cc b/chromium/google_apis/gaia/core_account_id.cc
index 0440b22e726..68c8543690f 100644
--- a/chromium/google_apis/gaia/core_account_id.cc
+++ b/chromium/google_apis/gaia/core_account_id.cc
@@ -5,6 +5,7 @@
#include "google_apis/gaia/core_account_id.h"
#include "base/check.h"
+#include "google_apis/gaia/gaia_auth_util.h"
namespace {
// Returns whether the string looks like an email (the test is
@@ -37,6 +38,16 @@ CoreAccountId CoreAccountId::FromGaiaId(const std::string& gaia_id) {
}
// static
+CoreAccountId CoreAccountId::FromRobotEmail(const std::string& robot_email) {
+ if (robot_email.empty())
+ return CoreAccountId();
+ DCHECK(gaia::IsGoogleRobotAccountEmail(robot_email))
+ << "Not a valid robot email [robot_email = " << robot_email << "]";
+ return CoreAccountId::FromString(robot_email);
+}
+
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+// static
CoreAccountId CoreAccountId::FromEmail(const std::string& email) {
if (email.empty())
return CoreAccountId();
@@ -45,9 +56,10 @@ CoreAccountId CoreAccountId::FromEmail(const std::string& email) {
<< "Expected an email [actual = " << email << "]";
return CoreAccountId::FromString(email);
}
+#endif
// static
-CoreAccountId CoreAccountId::FromString(const std::string value) {
+CoreAccountId CoreAccountId::FromString(const std::string& value) {
CoreAccountId account_id;
account_id.id_ = value;
return account_id;
diff --git a/chromium/google_apis/gaia/core_account_id.h b/chromium/google_apis/gaia/core_account_id.h
index 43294c9bdf1..9eed6b406ff 100644
--- a/chromium/google_apis/gaia/core_account_id.h
+++ b/chromium/google_apis/gaia/core_account_id.h
@@ -10,6 +10,7 @@
#include <vector>
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
// Represent the id of an account for interaction with GAIA.
//
@@ -57,16 +58,21 @@ struct CoreAccountId {
// Returns an empty CoreAccountId if |gaia_id| is empty.
static CoreAccountId FromGaiaId(const std::string& gaia_id);
- // Create a CoreAccountId object from an email.
+ // Create a CoreAccountId object from an email of a robot account.
// Returns an empty CoreAccountId if |email| is empty.
- static CoreAccountId FromEmail(const std::string& email);
+ static CoreAccountId FromRobotEmail(const std::string& robot_email);
+
+ // Create a CoreAccountId object from a string that was serialized via
+ // |CoreAccountId::ToString()|.
+ static CoreAccountId FromString(const std::string& value);
- // Create a CoreAccountId object from a string that is either a gaia_id
- // or an email.
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ // Only on ChromeOS, CoreAccountId objects may be created from Gaia emails.
//
- // Note: This method only exits while the code is being migrated to
- // use Gaia ID as the value of a CoreAccountId.
- static CoreAccountId FromString(const std::string gaia_id_or_email);
+ // Create a CoreAccountId object from an email.
+ // Returns an empty CoreAccountId if |email| is empty.
+ static CoreAccountId FromEmail(const std::string& email);
+#endif
// ---------------------------------------- ---------------------------------
// --------------------------------------------------------------------------
diff --git a/chromium/google_apis/gaia/gaia_auth_fetcher.cc b/chromium/google_apis/gaia/gaia_auth_fetcher.cc
index dd7ea44f3b3..11454f055f1 100644
--- a/chromium/google_apis/gaia/gaia_auth_fetcher.cc
+++ b/chromium/google_apis/gaia/gaia_auth_fetcher.cc
@@ -16,6 +16,7 @@
#include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h"
#include "base/stl_util.h"
+#include "base/strings/escape.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
@@ -28,7 +29,6 @@
#include "google_apis/gaia/google_service_auth_error.h"
#include "google_apis/gaia/oauth2_id_token_decoder.h"
#include "google_apis/gaia/oauth_multilogin_result.h"
-#include "net/base/escape.h"
#include "net/base/isolation_info.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_status_code.h"
@@ -298,11 +298,9 @@ void GaiaAuthFetcher::CreateAndStartGaiaFetcher(
original_url_ = gaia_gurl;
if (credentials_mode != network::mojom::CredentialsMode::kOmit) {
- DCHECK_EQ(GaiaUrls::GetInstance()->gaia_url(),
- gaia_gurl.DeprecatedGetOriginAsURL())
- << gaia_gurl;
- url::Origin origin =
- url::Origin::Create(GaiaUrls::GetInstance()->gaia_url());
+ CHECK(gaia::HasGaiaSchemeHostPort(gaia_gurl)) << gaia_gurl;
+
+ url::Origin origin = GaiaUrls::GetInstance()->gaia_origin();
resource_request->site_for_cookies =
net::SiteForCookies::FromOrigin(origin);
resource_request->trusted_params =
@@ -359,8 +357,8 @@ std::string GaiaAuthFetcher::MakeIssueAuthTokenBody(
const std::string& sid,
const std::string& lsid,
const char* const service) {
- std::string encoded_sid = net::EscapeUrlEncodedData(sid, true);
- std::string encoded_lsid = net::EscapeUrlEncodedData(lsid, true);
+ std::string encoded_sid = base::EscapeUrlEncodedData(sid, true);
+ std::string encoded_lsid = base::EscapeUrlEncodedData(lsid, true);
// All tokens should be session tokens except the gaia auth token.
bool session = true;
@@ -378,13 +376,13 @@ std::string GaiaAuthFetcher::MakeIssueAuthTokenBody(
std::string GaiaAuthFetcher::MakeGetTokenPairBody(
const std::string& auth_code,
const std::string& device_id) {
- std::string encoded_scope = net::EscapeUrlEncodedData(
- GaiaConstants::kOAuth1LoginScope, true);
- std::string encoded_client_id = net::EscapeUrlEncodedData(
+ std::string encoded_scope =
+ base::EscapeUrlEncodedData(GaiaConstants::kOAuth1LoginScope, true);
+ std::string encoded_client_id = base::EscapeUrlEncodedData(
GaiaUrls::GetInstance()->oauth2_chrome_client_id(), true);
- std::string encoded_client_secret = net::EscapeUrlEncodedData(
+ std::string encoded_client_secret = base::EscapeUrlEncodedData(
GaiaUrls::GetInstance()->oauth2_chrome_client_secret(), true);
- std::string encoded_auth_code = net::EscapeUrlEncodedData(auth_code, true);
+ std::string encoded_auth_code = base::EscapeUrlEncodedData(auth_code, true);
std::string body = base::StringPrintf(
kOAuth2CodeToTokenPairBodyFormat, encoded_scope.c_str(),
encoded_client_id.c_str(), encoded_client_secret.c_str(),
@@ -404,7 +402,7 @@ std::string GaiaAuthFetcher::MakeRevokeTokenBody(
// static
std::string GaiaAuthFetcher::MakeGetUserInfoBody(const std::string& lsid) {
- std::string encoded_lsid = net::EscapeUrlEncodedData(lsid, true);
+ std::string encoded_lsid = base::EscapeUrlEncodedData(lsid, true);
return base::StringPrintf(kGetUserInfoFormat, encoded_lsid.c_str());
}
@@ -414,18 +412,18 @@ std::string GaiaAuthFetcher::MakeMergeSessionQuery(
const std::string& external_cc_result,
const std::string& continue_url,
const std::string& source) {
- std::string encoded_auth_token = net::EscapeUrlEncodedData(auth_token, true);
- std::string encoded_continue_url = net::EscapeUrlEncodedData(continue_url,
- true);
- std::string encoded_source = net::EscapeUrlEncodedData(source, true);
+ std::string encoded_auth_token = base::EscapeUrlEncodedData(auth_token, true);
+ std::string encoded_continue_url =
+ base::EscapeUrlEncodedData(continue_url, true);
+ std::string encoded_source = base::EscapeUrlEncodedData(source, true);
std::string result = base::StringPrintf(kMergeSessionFormat,
encoded_auth_token.c_str(),
encoded_continue_url.c_str(),
encoded_source.c_str());
if (!external_cc_result.empty()) {
- base::StringAppendF(&result, "&externalCcResult=%s",
- net::EscapeUrlEncodedData(
- external_cc_result, true).c_str());
+ base::StringAppendF(
+ &result, "&externalCcResult=%s",
+ base::EscapeUrlEncodedData(external_cc_result, true).c_str());
}
return result;
@@ -470,8 +468,8 @@ void GaiaAuthFetcher::ParseClientLoginResponse(const std::string& data,
// static
std::string GaiaAuthFetcher::MakeOAuthLoginBody(const std::string& service,
const std::string& source) {
- std::string encoded_service = net::EscapeUrlEncodedData(service, true);
- std::string encoded_source = net::EscapeUrlEncodedData(source, true);
+ std::string encoded_service = base::EscapeUrlEncodedData(service, true);
+ std::string encoded_source = base::EscapeUrlEncodedData(source, true);
return base::StringPrintf(kOAuthLoginFormat,
encoded_service.c_str(),
encoded_source.c_str());
@@ -800,7 +798,7 @@ void GaiaAuthFetcher::StartOAuthMultilogin(
kOAuthMultiBearerHeaderFormat,
base::JoinString(authorization_header_parts, ",").c_str());
- std::string source_string = net::EscapeUrlEncodedData(source_, true);
+ std::string source_string = base::EscapeUrlEncodedData(source_, true);
std::string parameters = base::StringPrintf(
"?source=%s&reuseCookies=%i", source_string.c_str(),
mode == gaia::MultiloginMode::MULTILOGIN_PRESERVE_COOKIE_ACCOUNTS_ORDER
@@ -809,7 +807,7 @@ void GaiaAuthFetcher::StartOAuthMultilogin(
if (!external_cc_result.empty()) {
base::StringAppendF(
&parameters, "&externalCcResult=%s",
- net::EscapeUrlEncodedData(external_cc_result, true).c_str());
+ base::EscapeUrlEncodedData(external_cc_result, true).c_str());
}
net::NetworkTrafficAnnotationTag traffic_annotation =
diff --git a/chromium/google_apis/gaia/gaia_auth_util.cc b/chromium/google_apis/gaia/gaia_auth_util.cc
index 074dc0f5208..3e4903b2ff0 100644
--- a/chromium/google_apis/gaia/gaia_auth_util.cc
+++ b/chromium/google_apis/gaia/gaia_auth_util.cc
@@ -19,6 +19,8 @@
#include "google_apis/gaia/gaia_urls.h"
#include "google_apis/gaia/oauth2_mint_token_consent_result.pb.h"
#include "url/gurl.h"
+#include "url/origin.h"
+#include "url/scheme_host_port.h"
namespace gaia {
@@ -102,13 +104,22 @@ bool IsGoogleInternalAccountEmail(const std::string& email) {
return ExtractDomainName(SanitizeEmail(email)) == kGoogleDomain;
}
-bool IsGaiaSignonRealm(const GURL& url) {
- if (!url.SchemeIsCryptographic())
- return false;
-
- return url == GaiaUrls::GetInstance()->gaia_url();
+bool IsGoogleRobotAccountEmail(const std::string& email) {
+ std::string domain_name = gaia::ExtractDomainName(SanitizeEmail(email));
+ return base::EndsWith(domain_name, "gserviceaccount.com") ||
+ base::EndsWith(domain_name, "googleusercontent.com");
}
+bool HasGaiaSchemeHostPort(const GURL& url) {
+ const url::Origin& gaia_origin = GaiaUrls::GetInstance()->gaia_origin();
+ CHECK(!gaia_origin.opaque());
+ CHECK(gaia_origin.GetURL().SchemeIsHTTPOrHTTPS());
+
+ const url::SchemeHostPort& gaia_scheme_host_port =
+ gaia_origin.GetTupleOrPrecursorTupleIfOpaque();
+
+ return url::SchemeHostPort(url) == gaia_scheme_host_port;
+}
bool ParseListAccountsData(const std::string& data,
std::vector<ListedAccount>* accounts,
diff --git a/chromium/google_apis/gaia/gaia_auth_util.h b/chromium/google_apis/gaia/gaia_auth_util.h
index 17aa3b1fbd5..6295739d819 100644
--- a/chromium/google_apis/gaia/gaia_auth_util.h
+++ b/chromium/google_apis/gaia/gaia_auth_util.h
@@ -55,7 +55,14 @@ std::string ExtractDomainName(const std::string& email);
// to be used sparingly since it ship Googler-only code to all users.
bool IsGoogleInternalAccountEmail(const std::string& email);
-bool IsGaiaSignonRealm(const GURL& url);
+// Returns true if |email| correspnds to the email of a robot account.
+bool IsGoogleRobotAccountEmail(const std::string& email);
+
+// Mechanically compares the scheme, host, and port of the |url| against the
+// GAIA url in GaiaUrls. This means that this function will *not* work for
+// determining whether a frame with an "about:blank" URL or "blob:..." URL has
+// a GAIA origin and will in that case return false.
+bool HasGaiaSchemeHostPort(const GURL& url);
// Parses JSON data returned by /ListAccounts call, returning a vector of
// email/valid pairs. An email addresses is considered valid if a passive
diff --git a/chromium/google_apis/gaia/gaia_auth_util_unittest.cc b/chromium/google_apis/gaia/gaia_auth_util_unittest.cc
index 7138a83c4dd..12c7c9c05db 100644
--- a/chromium/google_apis/gaia/gaia_auth_util_unittest.cc
+++ b/chromium/google_apis/gaia/gaia_auth_util_unittest.cc
@@ -135,24 +135,54 @@ TEST(GaiaAuthUtilTest, AreEmailsSame) {
EXPECT_FALSE(AreEmailsSame("user@gmail.com", "foo@gmail.com"));
}
+TEST(GaiaAuthUtilTest, IsGoogleRobotAccountEmail) {
+ EXPECT_FALSE(IsGoogleRobotAccountEmail(""));
+ EXPECT_FALSE(IsGoogleRobotAccountEmail("foo"));
+ EXPECT_FALSE(IsGoogleRobotAccountEmail("1234567890"));
+ EXPECT_FALSE(IsGoogleRobotAccountEmail("foo@gmail.com"));
+ EXPECT_FALSE(IsGoogleRobotAccountEmail("system.gserviceaccount.com"));
+ EXPECT_TRUE(IsGoogleRobotAccountEmail("foo@system.gserviceaccount.com"));
+ EXPECT_TRUE(IsGoogleRobotAccountEmail("foo@system.googleusercontent.com"));
+ EXPECT_TRUE(IsGoogleRobotAccountEmail("foo@System.Gserviceaccount.com"));
+ EXPECT_TRUE(IsGoogleRobotAccountEmail("foo@System.Googleusercontent.com"));
+}
+
TEST(GaiaAuthUtilTest, GmailAndGooglemailAreSame) {
EXPECT_TRUE(AreEmailsSame("foo@gmail.com", "foo@googlemail.com"));
EXPECT_FALSE(AreEmailsSame("bar@gmail.com", "foo@googlemail.com"));
}
-TEST(GaiaAuthUtilTest, IsGaiaSignonRealm) {
- // Only https versions of Gaia URLs should be considered valid.
- EXPECT_TRUE(IsGaiaSignonRealm(GURL("https://accounts.google.com/")));
- EXPECT_FALSE(IsGaiaSignonRealm(GURL("http://accounts.google.com/")));
+TEST(GaiaAuthUtilTest, HasGaiaSchemeHostPort) {
+ EXPECT_TRUE(HasGaiaSchemeHostPort(GURL("https://accounts.google.com/")));
+
+ // Paths and queries should be ignored.
+ EXPECT_TRUE(HasGaiaSchemeHostPort(GURL("https://accounts.google.com/foo")));
+ EXPECT_TRUE(
+ HasGaiaSchemeHostPort(GURL("https://accounts.google.com/foo?bar=1#baz")));
+
+ // Scheme mismatch should lead to false.
+ EXPECT_FALSE(HasGaiaSchemeHostPort(GURL("http://accounts.google.com/")));
+
+ // Port mismatch should lead to false.
+ EXPECT_FALSE(HasGaiaSchemeHostPort(GURL("https://accounts.google.com:123/")));
+
+ // Host mismatch should lead to false, including Google URLs.
+ EXPECT_FALSE(HasGaiaSchemeHostPort(GURL("https://example.com/")));
+ EXPECT_FALSE(HasGaiaSchemeHostPort(GURL("https://www.example.com/")));
+ EXPECT_FALSE(HasGaiaSchemeHostPort(GURL("https://www.google.com/")));
+ EXPECT_FALSE(HasGaiaSchemeHostPort(GURL("https://google.com/")));
+ EXPECT_FALSE(HasGaiaSchemeHostPort(GURL("https://mail.google.com/")));
+
+ // about: scheme.
+ EXPECT_FALSE(HasGaiaSchemeHostPort(GURL("about:blank")));
+ EXPECT_FALSE(HasGaiaSchemeHostPort(GURL("about:srcdoc")));
- // Other Google URLs are not valid.
- EXPECT_FALSE(IsGaiaSignonRealm(GURL("https://www.google.com/")));
- EXPECT_FALSE(IsGaiaSignonRealm(GURL("http://www.google.com/")));
- EXPECT_FALSE(IsGaiaSignonRealm(GURL("https://google.com/")));
- EXPECT_FALSE(IsGaiaSignonRealm(GURL("https://mail.google.com/")));
+ // blob: scheme.
+ EXPECT_FALSE(HasGaiaSchemeHostPort(
+ GURL("blob:https://accounts.google.com/mocked-blob-guid")));
- // Other https URLs are not valid.
- EXPECT_FALSE(IsGaiaSignonRealm(GURL("https://www.example.com/")));
+ // Invalid/empty URL.
+ EXPECT_FALSE(HasGaiaSchemeHostPort(GURL()));
}
TEST(GaiaAuthUtilTest, ParseListAccountsData) {
diff --git a/chromium/google_apis/gaia/gaia_constants.cc b/chromium/google_apis/gaia/gaia_constants.cc
index f8ac94e7484..680155b079c 100644
--- a/chromium/google_apis/gaia/gaia_constants.cc
+++ b/chromium/google_apis/gaia/gaia_constants.cc
@@ -15,14 +15,6 @@ const char kUnexpectedServiceResponse[] = "UnexpectedServiceResponse";
// Service name for Gaia. Used to convert to cookie auth.
const char kGaiaService[] = "gaia";
-// Service name for Picasa API. API is used to get user's image.
-const char kPicasaService[] = "lh2";
-
-// Service/scope names for sync.
-const char kSyncService[] = "chromiumsync";
-
-// Service name for remoting.
-const char kRemotingService[] = "chromoting";
// OAuth scopes.
const char kOAuth1LoginScope[] = "https://www.google.com/accounts/OAuthLogin";
@@ -175,7 +167,6 @@ const char kGaiaLsid[] = "lsid";
const char kGaiaOAuthToken[] = "oauthToken";
const char kGaiaOAuthSecret[] = "oauthSecret";
const char kGaiaOAuthDuration[] = "3600";
-const char kGaiaOAuth2LoginRefreshToken[] = "oauth2LoginRefreshToken";
// Used to construct a channel ID for push messaging.
const char kObfuscatedGaiaId[] = "obfuscatedGaiaId";
diff --git a/chromium/google_apis/gaia/gaia_constants.h b/chromium/google_apis/gaia/gaia_constants.h
index 3561a9c15cd..75c8e8887b8 100644
--- a/chromium/google_apis/gaia/gaia_constants.h
+++ b/chromium/google_apis/gaia/gaia_constants.h
@@ -18,9 +18,6 @@ extern const char kUnexpectedServiceResponse[];
// Gaia services for requesting
extern const char kGaiaService[]; // uber token
-extern const char kPicasaService[];
-extern const char kSyncService[];
-extern const char kRemotingService[];
// OAuth2 scopes.
extern const char kOAuth1LoginScope[];
@@ -70,7 +67,6 @@ extern const char kGaiaLsid[];
extern const char kGaiaOAuthToken[];
extern const char kGaiaOAuthSecret[];
extern const char kGaiaOAuthDuration[];
-extern const char kGaiaOAuth2LoginRefreshToken[];
// Used to construct a channel ID for push messaging.
extern const char kObfuscatedGaiaId[];
diff --git a/chromium/google_apis/gaia/gaia_oauth_client.cc b/chromium/google_apis/gaia/gaia_oauth_client.cc
index 1c149906ca9..f8b923e0fa2 100644
--- a/chromium/google_apis/gaia/gaia_oauth_client.cc
+++ b/chromium/google_apis/gaia/gaia_oauth_client.cc
@@ -14,6 +14,7 @@
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/notreached.h"
+#include "base/strings/escape.h"
#include "base/strings/strcat.h"
#include "base/strings/string_util.h"
#include "base/threading/thread_task_runner_handle.h"
@@ -21,7 +22,6 @@
#include "google_apis/gaia/gaia_auth_util.h"
#include "google_apis/gaia/gaia_urls.h"
#include "net/base/backoff_entry.h"
-#include "net/base/escape.h"
#include "net/base/load_flags.h"
#include "net/http/http_status_code.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
@@ -164,13 +164,12 @@ void GaiaOAuthClient::Core::GetTokensFromAuthCode(
int max_retries,
GaiaOAuthClient::Delegate* delegate) {
std::string post_body =
- "code=" + net::EscapeUrlEncodedData(auth_code, true) +
- "&client_id=" + net::EscapeUrlEncodedData(oauth_client_info.client_id,
- true) +
+ "code=" + base::EscapeUrlEncodedData(auth_code, true) + "&client_id=" +
+ base::EscapeUrlEncodedData(oauth_client_info.client_id, true) +
"&client_secret=" +
- net::EscapeUrlEncodedData(oauth_client_info.client_secret, true) +
+ base::EscapeUrlEncodedData(oauth_client_info.client_secret, true) +
"&redirect_uri=" +
- net::EscapeUrlEncodedData(oauth_client_info.redirect_uri, true) +
+ base::EscapeUrlEncodedData(oauth_client_info.redirect_uri, true) +
"&grant_type=authorization_code";
net::MutableNetworkTrafficAnnotationTag traffic_annotation(
net::DefineNetworkTrafficAnnotation("gaia_oauth_client_get_tokens", R"(
@@ -216,16 +215,16 @@ void GaiaOAuthClient::Core::RefreshToken(
int max_retries,
GaiaOAuthClient::Delegate* delegate) {
std::string post_body =
- "refresh_token=" + net::EscapeUrlEncodedData(refresh_token, true) +
- "&client_id=" + net::EscapeUrlEncodedData(oauth_client_info.client_id,
- true) +
+ "refresh_token=" + base::EscapeUrlEncodedData(refresh_token, true) +
+ "&client_id=" +
+ base::EscapeUrlEncodedData(oauth_client_info.client_id, true) +
"&client_secret=" +
- net::EscapeUrlEncodedData(oauth_client_info.client_secret, true) +
+ base::EscapeUrlEncodedData(oauth_client_info.client_secret, true) +
"&grant_type=refresh_token";
if (!scopes.empty()) {
std::string scopes_string = base::JoinString(scopes, " ");
- post_body += "&scope=" + net::EscapeUrlEncodedData(scopes_string, true);
+ post_body += "&scope=" + base::EscapeUrlEncodedData(scopes_string, true);
}
net::MutableNetworkTrafficAnnotationTag traffic_annotation(
@@ -325,7 +324,7 @@ void GaiaOAuthClient::Core::GetTokenInfo(const std::string& qualifier,
int max_retries,
Delegate* delegate) {
std::string post_body =
- qualifier + "=" + net::EscapeUrlEncodedData(query, true);
+ qualifier + "=" + base::EscapeUrlEncodedData(query, true);
net::MutableNetworkTrafficAnnotationTag traffic_annotation(
net::DefineNetworkTrafficAnnotation("gaia_oauth_client_get_token_info",
R"(
@@ -373,12 +372,13 @@ void GaiaOAuthClient::Core::GetAccountCapabilities(
Delegate* delegate) {
DCHECK(!capabilities_names.empty());
- std::string post_body = base::StrCat(
- {"names=", net::EscapeUrlEncodedData(*capabilities_names.begin(), true)});
+ std::string post_body =
+ base::StrCat({"names=", base::EscapeUrlEncodedData(
+ *capabilities_names.begin(), true)});
for (auto it = capabilities_names.begin() + 1; it != capabilities_names.end();
++it) {
base::StrAppend(&post_body,
- {"&names=", net::EscapeUrlEncodedData(*it, true)});
+ {"&names=", base::EscapeUrlEncodedData(*it, true)});
}
std::string auth = base::StrCat({"Bearer ", oauth_access_token});
diff --git a/chromium/google_apis/gaia/gaia_urls.cc b/chromium/google_apis/gaia/gaia_urls.cc
index eac8ffc173e..2314ab4655d 100644
--- a/chromium/google_apis/gaia/gaia_urls.cc
+++ b/chromium/google_apis/gaia/gaia_urls.cc
@@ -121,6 +121,20 @@ GURL GetURLSwitchValueWithDefault(base::StringPiece switch_value,
return GURL(default_value);
}
+url::Origin GetOriginSwitchValueWithDefault(base::StringPiece switch_value,
+ base::StringPiece default_value) {
+ std::string string_value;
+ GetSwitchValueWithDefault(switch_value, default_value, &string_value);
+ const url::Origin result = url::Origin::Create(GURL(string_value));
+ if (result.GetURL().SchemeIsHTTPOrHTTPS() &&
+ result.GetURL() == GURL(string_value)) {
+ return result;
+ }
+ LOG(ERROR) << "Ignoring invalid origin \"" << string_value
+ << "\" for switch \"" << switch_value << "\"";
+ return url::Origin::Create(GURL(default_value));
+}
+
void SetDefaultURLIfInvalid(GURL* url_to_set,
base::StringPiece switch_value,
base::StringPiece default_value) {
@@ -129,6 +143,16 @@ void SetDefaultURLIfInvalid(GURL* url_to_set,
}
}
+void SetDefaultOriginIfOpaqueOrInvalidScheme(url::Origin* origin_to_set,
+ base::StringPiece switch_value,
+ base::StringPiece default_value) {
+ if (origin_to_set->opaque() ||
+ !origin_to_set->GetURL().SchemeIsHTTPOrHTTPS()) {
+ *origin_to_set =
+ GetOriginSwitchValueWithDefault(switch_value, default_value);
+ }
+}
+
void ResolveURLIfInvalid(GURL* url_to_set,
const GURL& base_url,
base::StringPiece suffix) {
@@ -161,8 +185,12 @@ const GURL& GaiaUrls::secure_google_url() const {
return secure_google_url_;
}
-const GURL& GaiaUrls::gaia_url() const {
- return gaia_url_;
+const url::Origin& GaiaUrls::gaia_origin() const {
+ return gaia_origin_;
+}
+
+GURL GaiaUrls::gaia_url() const {
+ return gaia_origin_.GetURL();
}
const GURL& GaiaUrls::client_login_url() const {
@@ -335,7 +363,8 @@ GURL GaiaUrls::GetCheckConnectionInfoURLWithSource(const std::string& source) {
void GaiaUrls::InitializeDefault() {
SetDefaultURLIfInvalid(&google_url_, switches::kGoogleUrl, kDefaultGoogleUrl);
- SetDefaultURLIfInvalid(&gaia_url_, switches::kGaiaUrl, kDefaultGaiaUrl);
+ SetDefaultOriginIfOpaqueOrInvalidScheme(&gaia_origin_, switches::kGaiaUrl,
+ kDefaultGaiaUrl);
SetDefaultURLIfInvalid(&lso_origin_url_, switches::kLsoUrl, kDefaultGaiaUrl);
SetDefaultURLIfInvalid(&google_apis_origin_url_, switches::kGoogleApisUrl,
kDefaultGoogleApisBaseUrl);
@@ -356,49 +385,52 @@ void GaiaUrls::InitializeDefault() {
oauth2_chrome_client_secret_ =
google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_MAIN);
- // URLs from |gaia_url_|.
- ResolveURLIfInvalid(&client_login_url_, gaia_url_, kClientLoginUrlSuffix);
- ResolveURLIfInvalid(&service_login_url_, gaia_url_, kServiceLoginUrlSuffix);
- ResolveURLIfInvalid(&embedded_setup_chromeos_url_v2_, gaia_url_,
+ CHECK(!gaia_origin_.opaque());
+ const GURL gaia_url = gaia_origin_.GetURL();
+ CHECK(gaia_url.SchemeIsHTTPOrHTTPS());
+
+ // URLs from |gaia_origin_|.
+ ResolveURLIfInvalid(&client_login_url_, gaia_url, kClientLoginUrlSuffix);
+ ResolveURLIfInvalid(&service_login_url_, gaia_url, kServiceLoginUrlSuffix);
+ ResolveURLIfInvalid(&embedded_setup_chromeos_url_v2_, gaia_url,
kEmbeddedSetupChromeOsUrlSuffixV2);
- ResolveURLIfInvalid(&embedded_setup_chromeos_kid_signup_url_, gaia_url_,
+ ResolveURLIfInvalid(&embedded_setup_chromeos_kid_signup_url_, gaia_url,
kEmbeddedSetupChromeOsKidSignupUrlSuffix);
- ResolveURLIfInvalid(&embedded_setup_chromeos_kid_signin_url_, gaia_url_,
+ ResolveURLIfInvalid(&embedded_setup_chromeos_kid_signin_url_, gaia_url,
kEmbeddedSetupChromeOsKidSigninUrlSuffix);
- ResolveURLIfInvalid(&embedded_setup_windows_url_, gaia_url_,
+ ResolveURLIfInvalid(&embedded_setup_windows_url_, gaia_url,
kEmbeddedSetupWindowsUrlSuffix);
- ResolveURLIfInvalid(&embedded_reauth_chromeos_url_, gaia_url_,
+ ResolveURLIfInvalid(&embedded_reauth_chromeos_url_, gaia_url,
kEmbeddedReauthChromeOsUrlSuffix);
- ResolveURLIfInvalid(&signin_chrome_sync_dice_, gaia_url_,
+ ResolveURLIfInvalid(&signin_chrome_sync_dice_, gaia_url,
kSigninChromeSyncDice);
- ResolveURLIfInvalid(&signin_chrome_sync_keys_retrieval_url_, gaia_url_,
+ ResolveURLIfInvalid(&signin_chrome_sync_keys_retrieval_url_, gaia_url,
kSigninChromeSyncKeysRetrievalUrl);
ResolveURLIfInvalid(
- &signin_chrome_sync_keys_recoverability_degraded_url_, gaia_url_,
+ &signin_chrome_sync_keys_recoverability_degraded_url_, gaia_url,
base::StrCat({kSigninChromeSyncKeysRetrievalUrl,
kSigninChromeSyncKeysRecoverabilityUrlSuffix}));
- ResolveURLIfInvalid(&service_login_auth_url_, gaia_url_,
+ ResolveURLIfInvalid(&service_login_auth_url_, gaia_url,
kServiceLoginAuthUrlSuffix);
- ResolveURLIfInvalid(&service_logout_url_, gaia_url_, kServiceLogoutUrlSuffix);
- ResolveURLIfInvalid(&continue_url_for_logout_, gaia_url_,
+ ResolveURLIfInvalid(&service_logout_url_, gaia_url, kServiceLogoutUrlSuffix);
+ ResolveURLIfInvalid(&continue_url_for_logout_, gaia_url,
kContinueUrlForLogoutSuffix);
- ResolveURLIfInvalid(&get_user_info_url_, gaia_url_, kGetUserInfoUrlSuffix);
- ResolveURLIfInvalid(&token_auth_url_, gaia_url_, kTokenAuthUrlSuffix);
- ResolveURLIfInvalid(&merge_session_url_, gaia_url_, kMergeSessionUrlSuffix);
- ResolveURLIfInvalid(&oauth_multilogin_url_, gaia_url_,
- kOAuthMultiloginSuffix);
- ResolveURLIfInvalid(&oauth_get_access_token_url_, gaia_url_,
+ ResolveURLIfInvalid(&get_user_info_url_, gaia_url, kGetUserInfoUrlSuffix);
+ ResolveURLIfInvalid(&token_auth_url_, gaia_url, kTokenAuthUrlSuffix);
+ ResolveURLIfInvalid(&merge_session_url_, gaia_url, kMergeSessionUrlSuffix);
+ ResolveURLIfInvalid(&oauth_multilogin_url_, gaia_url, kOAuthMultiloginSuffix);
+ ResolveURLIfInvalid(&oauth_get_access_token_url_, gaia_url,
kOAuthGetAccessTokenUrlSuffix);
- ResolveURLIfInvalid(&oauth_wrap_bridge_url_, gaia_url_,
+ ResolveURLIfInvalid(&oauth_wrap_bridge_url_, gaia_url,
kOAuthWrapBridgeUrlSuffix);
- ResolveURLIfInvalid(&oauth_revoke_token_url_, gaia_url_,
+ ResolveURLIfInvalid(&oauth_revoke_token_url_, gaia_url,
kOAuthRevokeTokenUrlSuffix);
- ResolveURLIfInvalid(&oauth1_login_url_, gaia_url_, kOAuth1LoginUrlSuffix);
- ResolveURLIfInvalid(&list_accounts_url_, gaia_url_, kListAccountsSuffix);
- ResolveURLIfInvalid(&embedded_signin_url_, gaia_url_, kEmbeddedSigninSuffix);
- ResolveURLIfInvalid(&add_account_url_, gaia_url_, kAddAccountSuffix);
- ResolveURLIfInvalid(&reauth_url_, gaia_url_, kReauthSuffix);
- ResolveURLIfInvalid(&get_check_connection_info_url_, gaia_url_,
+ ResolveURLIfInvalid(&oauth1_login_url_, gaia_url, kOAuth1LoginUrlSuffix);
+ ResolveURLIfInvalid(&list_accounts_url_, gaia_url, kListAccountsSuffix);
+ ResolveURLIfInvalid(&embedded_signin_url_, gaia_url, kEmbeddedSigninSuffix);
+ ResolveURLIfInvalid(&add_account_url_, gaia_url, kAddAccountSuffix);
+ ResolveURLIfInvalid(&reauth_url_, gaia_url, kReauthSuffix);
+ ResolveURLIfInvalid(&get_check_connection_info_url_, gaia_url,
kGetCheckConnectionInfoSuffix);
// URLs from |lso_origin_url_|.
@@ -436,7 +468,11 @@ void GaiaUrls::InitializeFromConfig() {
config->GetURLIfExists(URL_KEY_AND_PTR(google_url));
config->GetURLIfExists(URL_KEY_AND_PTR(secure_google_url));
- config->GetURLIfExists(URL_KEY_AND_PTR(gaia_url));
+
+ GURL gaia_origin_url;
+ config->GetURLIfExists("gaia_url", &gaia_origin_url);
+ gaia_origin_ = url::Origin::Create(gaia_origin_url);
+
config->GetURLIfExists(URL_KEY_AND_PTR(lso_origin_url));
config->GetURLIfExists(URL_KEY_AND_PTR(google_apis_origin_url));
config->GetURLIfExists(URL_KEY_AND_PTR(oauth_account_manager_origin_url));
diff --git a/chromium/google_apis/gaia/gaia_urls.h b/chromium/google_apis/gaia/gaia_urls.h
index a95b41c7302..b30241195fe 100644
--- a/chromium/google_apis/gaia/gaia_urls.h
+++ b/chromium/google_apis/gaia/gaia_urls.h
@@ -9,6 +9,7 @@
#include "base/memory/singleton.h"
#include "url/gurl.h"
+#include "url/origin.h"
// A signleton that provides all the URLs that are used for connecting to GAIA.
//
@@ -23,7 +24,8 @@ class GaiaUrls {
// The URLs for different calls in the Google Accounts programmatic login API.
const GURL& google_url() const;
const GURL& secure_google_url() const;
- const GURL& gaia_url() const;
+ const url::Origin& gaia_origin() const;
+ GURL gaia_url() const;
const GURL& client_login_url() const;
const GURL& service_login_url() const;
const GURL& embedded_setup_chromeos_url(unsigned version) const;
@@ -79,7 +81,7 @@ class GaiaUrls {
GURL google_url_;
GURL secure_google_url_;
- GURL gaia_url_;
+ url::Origin gaia_origin_;
GURL lso_origin_url_;
GURL google_apis_origin_url_;
diff --git a/chromium/google_apis/gaia/oauth2_access_token_fetcher_impl.cc b/chromium/google_apis/gaia/oauth2_access_token_fetcher_impl.cc
index e7a582a2c05..5df5180dccc 100644
--- a/chromium/google_apis/gaia/oauth2_access_token_fetcher_impl.cc
+++ b/chromium/google_apis/gaia/oauth2_access_token_fetcher_impl.cc
@@ -10,13 +10,13 @@
#include "base/bind.h"
#include "base/json/json_reader.h"
+#include "base/strings/escape.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/time/time.h"
#include "base/values.h"
#include "google_apis/gaia/gaia_auth_util.h"
#include "google_apis/gaia/google_service_auth_error.h"
-#include "net/base/escape.h"
#include "net/http/http_status_code.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
@@ -291,9 +291,9 @@ std::string OAuth2AccessTokenFetcherImpl::MakeGetAccessTokenBody(
// to specify both at the same time.
CHECK_NE(refresh_token.empty(), auth_code.empty());
- std::string enc_client_id = net::EscapeUrlEncodedData(client_id, true);
+ std::string enc_client_id = base::EscapeUrlEncodedData(client_id, true);
std::string enc_client_secret =
- net::EscapeUrlEncodedData(client_secret, true);
+ base::EscapeUrlEncodedData(client_secret, true);
const char* key = nullptr;
const char* grant_type = nullptr;
@@ -301,11 +301,11 @@ std::string OAuth2AccessTokenFetcherImpl::MakeGetAccessTokenBody(
if (refresh_token.empty()) {
key = kKeyAuthCode;
grant_type = kGrantTypeAuthCode;
- enc_value = net::EscapeUrlEncodedData(auth_code, true);
+ enc_value = base::EscapeUrlEncodedData(auth_code, true);
} else {
key = kKeyRefreshToken;
grant_type = kGrantTypeRefreshToken;
- enc_value = net::EscapeUrlEncodedData(refresh_token, true);
+ enc_value = base::EscapeUrlEncodedData(refresh_token, true);
}
if (scopes.empty()) {
@@ -317,7 +317,7 @@ std::string OAuth2AccessTokenFetcherImpl::MakeGetAccessTokenBody(
return base::StringPrintf(
kGetAccessTokenBodyWithScopeFormat, enc_client_id.c_str(),
enc_client_secret.c_str(), grant_type, key, enc_value.c_str(),
- net::EscapeUrlEncodedData(scopes_string, true).c_str());
+ base::EscapeUrlEncodedData(scopes_string, true).c_str());
}
}
diff --git a/chromium/google_apis/gaia/oauth2_api_call_flow.cc b/chromium/google_apis/gaia/oauth2_api_call_flow.cc
index eb829ab0aef..aa4038071c5 100644
--- a/chromium/google_apis/gaia/oauth2_api_call_flow.cc
+++ b/chromium/google_apis/gaia/oauth2_api_call_flow.cc
@@ -8,10 +8,10 @@
#include <vector>
#include "base/bind.h"
+#include "base/strings/escape.h"
#include "base/strings/stringprintf.h"
#include "google_apis/gaia/gaia_auth_util.h"
#include "google_apis/gaia/gaia_urls.h"
-#include "net/base/escape.h"
#include "net/base/load_flags.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_status_code.h"
diff --git a/chromium/google_apis/gaia/oauth2_mint_token_flow.cc b/chromium/google_apis/gaia/oauth2_mint_token_flow.cc
index 27459ce8629..da756f94b3c 100644
--- a/chromium/google_apis/gaia/oauth2_mint_token_flow.cc
+++ b/chromium/google_apis/gaia/oauth2_mint_token_flow.cc
@@ -15,6 +15,7 @@
#include "base/containers/span.h"
#include "base/json/json_reader.h"
#include "base/metrics/histogram_functions.h"
+#include "base/strings/escape.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
@@ -23,7 +24,6 @@
#include "base/values.h"
#include "google_apis/gaia/gaia_urls.h"
#include "google_apis/gaia/google_service_auth_error.h"
-#include "net/base/escape.h"
#include "net/base/net_errors.h"
#include "net/cookies/cookie_constants.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
@@ -203,30 +203,32 @@ std::string OAuth2MintTokenFlow::CreateApiCallBody() {
parameters_.enable_granular_permissions ? kValueTrue : kValueFalse;
std::string body = base::StringPrintf(
kOAuth2IssueTokenBodyFormat,
- net::EscapeUrlEncodedData(force_value, true).c_str(),
- net::EscapeUrlEncodedData(response_type_value, true).c_str(),
- net::EscapeUrlEncodedData(base::JoinString(parameters_.scopes, " "), true)
+ base::EscapeUrlEncodedData(force_value, true).c_str(),
+ base::EscapeUrlEncodedData(response_type_value, true).c_str(),
+ base::EscapeUrlEncodedData(base::JoinString(parameters_.scopes, " "),
+ true)
.c_str(),
- net::EscapeUrlEncodedData(enable_granular_permissions_value, true)
+ base::EscapeUrlEncodedData(enable_granular_permissions_value, true)
.c_str(),
- net::EscapeUrlEncodedData(parameters_.client_id, true).c_str(),
- net::EscapeUrlEncodedData(parameters_.extension_id, true).c_str(),
- net::EscapeUrlEncodedData(parameters_.version, true).c_str(),
- net::EscapeUrlEncodedData(parameters_.channel, true).c_str());
+ base::EscapeUrlEncodedData(parameters_.client_id, true).c_str(),
+ base::EscapeUrlEncodedData(parameters_.extension_id, true).c_str(),
+ base::EscapeUrlEncodedData(parameters_.version, true).c_str(),
+ base::EscapeUrlEncodedData(parameters_.channel, true).c_str());
if (!parameters_.device_id.empty()) {
body.append(base::StringPrintf(
kOAuth2IssueTokenBodyFormatDeviceIdAddendum,
- net::EscapeUrlEncodedData(parameters_.device_id, true).c_str()));
+ base::EscapeUrlEncodedData(parameters_.device_id, true).c_str()));
}
if (!parameters_.selected_user_id.empty()) {
body.append(base::StringPrintf(
kOAuth2IssueTokenBodyFormatSelectedUserIdAddendum,
- net::EscapeUrlEncodedData(parameters_.selected_user_id, true).c_str()));
+ base::EscapeUrlEncodedData(parameters_.selected_user_id, true)
+ .c_str()));
}
if (!parameters_.consent_result.empty()) {
body.append(base::StringPrintf(
kOAuth2IssueTokenBodyFormatConsentResultAddendum,
- net::EscapeUrlEncodedData(parameters_.consent_result, true).c_str()));
+ base::EscapeUrlEncodedData(parameters_.consent_result, true).c_str()));
}
return body;
}
diff --git a/chromium/google_apis/gaia/oauth_multilogin_result.cc b/chromium/google_apis/gaia/oauth_multilogin_result.cc
index a9d97df8aac..b3cc5d2a775 100644
--- a/chromium/google_apis/gaia/oauth_multilogin_result.cc
+++ b/chromium/google_apis/gaia/oauth_multilogin_result.cc
@@ -105,8 +105,14 @@ void OAuthMultiloginResult::TryParseCookiesFromValue(base::Value* json_value) {
const std::string* same_site = cookie.FindStringKey("sameSite");
const std::string* same_party = cookie.FindStringKey("sameParty");
- base::TimeDelta before_expiration =
- base::Seconds(expiration_delta.value_or(0.0));
+ base::Time now = base::Time::Now();
+ // TODO(crbug.com/1264458) If CreateSanitizedCookie were used below, this
+ // wouldn't be needed and ValidateAndAdjustExpiryDate could be moved back
+ // into anon namespace instead of being exposed as a static function.
+ // Alternatly, if we were sure GAIA cookies wouldn't try to expire more
+ // than 400 days in the future we wouldn't need this either.
+ base::Time expiration = net::CanonicalCookie::ValidateAndAdjustExpiryDate(
+ now + base::Seconds(expiration_delta.value_or(0.0)), now);
std::string cookie_domain = domain ? *domain : "";
std::string cookie_host = host ? *host : "";
if (cookie_domain.empty() && !cookie_host.empty() &&
@@ -127,9 +133,8 @@ void OAuthMultiloginResult::TryParseCookiesFromValue(base::Value* json_value) {
std::unique_ptr<net::CanonicalCookie> new_cookie =
net::CanonicalCookie::FromStorage(
name ? *name : "", value ? *value : "", cookie_domain,
- path ? *path : "", /*creation=*/base::Time::Now(),
- base::Time::Now() + before_expiration,
- /*last_access=*/base::Time::Now(), is_secure.value_or(true),
+ path ? *path : "", /*creation=*/now, expiration,
+ /*last_access=*/now, /*last_update=*/now, is_secure.value_or(true),
is_http_only.value_or(true), samesite_mode,
net::StringToCookiePriority(priority ? *priority : "medium"),
same_party_bool, /*partition_key=*/absl::nullopt,
diff --git a/chromium/google_apis/gaia/oauth_multilogin_result_unittest.cc b/chromium/google_apis/gaia/oauth_multilogin_result_unittest.cc
index 3f9a9f32de0..b3fa429d648 100644
--- a/chromium/google_apis/gaia/oauth_multilogin_result_unittest.cc
+++ b/chromium/google_apis/gaia/oauth_multilogin_result_unittest.cc
@@ -91,30 +91,30 @@ TEST(OAuthMultiloginResultTest, TryParseCookiesFromValue) {
result.TryParseCookiesFromValue(dictionary_value.get());
base::Time time_now = base::Time::Now();
- base::Time expiration_time = (time_now + base::Seconds(63070000.));
+ base::Time expiration_time = (time_now + base::Seconds(34560000.));
double now = time_now.ToDoubleT();
double expiration = expiration_time.ToDoubleT();
const std::vector<CanonicalCookie> cookies = {
*CanonicalCookie::CreateUnsafeCookieForTesting(
"SID", "vAlUe1", ".google.ru", "/", time_now, time_now,
- expiration_time, /*secure=*/true,
+ expiration_time, time_now, /*secure=*/true,
/*httponly=*/false, net::CookieSameSite::UNSPECIFIED,
net::CookiePriority::COOKIE_PRIORITY_HIGH,
/*same_party=*/false),
*CanonicalCookie::CreateUnsafeCookieForTesting(
"SAPISID", "vAlUe2", "google.com", "/", time_now, time_now,
- expiration_time, /*secure=*/false,
+ expiration_time, time_now, /*secure=*/false,
/*httponly=*/true, net::CookieSameSite::LAX_MODE,
net::CookiePriority::COOKIE_PRIORITY_HIGH,
/*same_party=*/false),
*CanonicalCookie::CreateUnsafeCookieForTesting(
- "HSID", "vAlUe4", "", "/", time_now, time_now, time_now,
+ "HSID", "vAlUe4", "", "/", time_now, time_now, time_now, time_now,
/*secure=*/true, /*httponly=*/true, net::CookieSameSite::STRICT_MODE,
net::CookiePriority::COOKIE_PRIORITY_HIGH,
/*same_party=*/false),
*CanonicalCookie::CreateUnsafeCookieForTesting(
"__Secure-1PSID", "vAlUe4", ".google.fr", "/", time_now, time_now,
- expiration_time, /*secure=*/true, /*httponly=*/true,
+ expiration_time, time_now, /*secure=*/true, /*httponly=*/true,
net::CookieSameSite::UNSPECIFIED,
net::CookiePriority::COOKIE_PRIORITY_HIGH,
/*same_party=*/true)};
@@ -186,6 +186,8 @@ TEST(OAuthMultiloginResultTest, TryParseCookiesFromValue) {
DoubleNear(now, 0.5));
EXPECT_THAT(result.cookies()[0].ExpiryDate().ToDoubleT(),
DoubleNear(expiration, 0.5));
+ EXPECT_THAT(result.cookies()[0].LastUpdateDate().ToDoubleT(),
+ DoubleNear(now, 0.5));
}
TEST(OAuthMultiloginResultTest, CreateOAuthMultiloginResultFromString) {
diff --git a/chromium/google_apis/gcm/base/gcm_util.cc b/chromium/google_apis/gcm/base/gcm_util.cc
index e51a498dfdc..5c221d27929 100644
--- a/chromium/google_apis/gcm/base/gcm_util.cc
+++ b/chromium/google_apis/gcm/base/gcm_util.cc
@@ -4,7 +4,7 @@
#include "google_apis/gcm/base/gcm_util.h"
-#include "net/base/escape.h"
+#include "base/strings/escape.h"
namespace gcm {
@@ -13,7 +13,7 @@ void BuildFormEncoding(const std::string& key,
std::string* out) {
if (!out->empty())
out->append("&");
- out->append(key + "=" + net::EscapeUrlEncodedData(value, true));
+ out->append(key + "=" + base::EscapeUrlEncodedData(value, true));
}
} // namespace gcm
diff --git a/chromium/google_apis/gcm/engine/mcs_client.cc b/chromium/google_apis/gcm/engine/mcs_client.cc
index d68b69f3f96..bc1d2103ebc 100644
--- a/chromium/google_apis/gcm/engine/mcs_client.cc
+++ b/chromium/google_apis/gcm/engine/mcs_client.cc
@@ -57,7 +57,7 @@ const size_t kMaxSendQueueSize = 10 * 1024;
const int kMaxMessageBytes = 4 * 1024; // 4KB, like the server.
// Helper for converting a proto persistent id list to a vector of strings.
-bool BuildPersistentIdListFromProto(const google::protobuf::string& bytes,
+bool BuildPersistentIdListFromProto(const std::string& bytes,
std::vector<std::string>* id_list) {
mcs_proto::SelectiveAck selective_ack;
if (!selective_ack.ParseFromString(bytes))
diff --git a/chromium/google_apis/gcm/engine/registration_request_unittest.cc b/chromium/google_apis/gcm/engine/registration_request_unittest.cc
index 26b6dfc1a61..5e0c935a5dc 100644
--- a/chromium/google_apis/gcm/engine/registration_request_unittest.cc
+++ b/chromium/google_apis/gcm/engine/registration_request_unittest.cc
@@ -11,6 +11,7 @@
#include <vector>
#include "base/bind.h"
+#include "base/strings/escape.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_tokenizer.h"
#include "base/threading/thread_task_runner_handle.h"
@@ -18,7 +19,6 @@
#include "google_apis/gcm/engine/gcm_request_test_base.h"
#include "google_apis/gcm/engine/instance_id_get_token_request_handler.h"
#include "google_apis/gcm/monitoring/fake_gcm_stats_recorder.h"
-#include "net/base/escape.h"
#include "net/base/load_flags.h"
#include "net/base/net_errors.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
@@ -166,7 +166,7 @@ TEST_F(GCMRegistrationRequestTest, RequestRegistrationWithMultipleSenderIds) {
continue;
ASSERT_TRUE(data_tokenizer.GetNext());
- std::string senders(net::UnescapeBinaryURLComponent(data_tokenizer.token()));
+ std::string senders(base::UnescapeBinaryURLComponent(data_tokenizer.token()));
base::StringTokenizer sender_tokenizer(senders, ",");
ASSERT_TRUE(sender_tokenizer.GetNext());
EXPECT_EQ("sender1", sender_tokenizer.token());
diff --git a/chromium/google_apis/gcm/engine/unregistration_request.cc b/chromium/google_apis/gcm/engine/unregistration_request.cc
index 48607865304..2994eef85d5 100644
--- a/chromium/google_apis/gcm/engine/unregistration_request.cc
+++ b/chromium/google_apis/gcm/engine/unregistration_request.cc
@@ -8,12 +8,12 @@
#include "base/bind.h"
#include "base/location.h"
+#include "base/strings/escape.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_piece.h"
#include "base/values.h"
#include "google_apis/gcm/base/gcm_util.h"
#include "google_apis/gcm/monitoring/gcm_stats_recorder.h"
-#include "net/base/escape.h"
#include "net/base/load_flags.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_status_code.h"