Commit c9de5c63 authored by Devlin Cronin's avatar Devlin Cronin Committed by Commit Bot

[Extensions] Update CookiesSetFunction to never set results and an error

Extension functions should never both set results and an error - it
should always be one or the other. Enforce this more strictly in
the cookies.set function.

Bug: None
Change-Id: I6d75973f78f46d3895abad633d8069a09c14c70e
Reviewed-on: https://chromium-review.googlesource.com/1048395Reviewed-by: default avatarMike West <mkwst@chromium.org>
Commit-Queue: Devlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#556784}
parent 44a18130
...@@ -400,6 +400,16 @@ void CookiesSetFunction::GetCookieListCallback( ...@@ -400,6 +400,16 @@ void CookiesSetFunction::GetCookieListCallback(
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK_EQ(SET_COMPLETED, state_); DCHECK_EQ(SET_COMPLETED, state_);
state_ = GET_COMPLETED; state_ = GET_COMPLETED;
if (!success_) {
std::string name = parsed_args_->details.name.get()
? *parsed_args_->details.name
: std::string();
error_ = ErrorUtils::FormatErrorMessage(keys::kCookieSetFailedError, name);
SendResponse(false);
return;
}
for (const net::CanonicalCookie& cookie : cookie_list) { for (const net::CanonicalCookie& cookie : cookie_list) {
// Return the first matching cookie. Relies on the fact that the // Return the first matching cookie. Relies on the fact that the
// CookieMonster returns them in canonical order (longest path, then // CookieMonster returns them in canonical order (longest path, then
...@@ -415,15 +425,7 @@ void CookiesSetFunction::GetCookieListCallback( ...@@ -415,15 +425,7 @@ void CookiesSetFunction::GetCookieListCallback(
} }
} }
if (!success_) { SendResponse(true);
std::string name =
parsed_args_->details.name.get() ? *parsed_args_->details.name
: std::string();
// TODO(rdevlin.cronin): Avoid setting both error_ and results_ in the
// same call.
error_ = ErrorUtils::FormatErrorMessage(keys::kCookieSetFailedError, name);
}
SendResponse(success_);
} }
CookiesRemoveFunction::CookiesRemoveFunction() { CookiesRemoveFunction::CookiesRemoveFunction() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment