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

Unified Diff: chrome/browser/webshare/share_service_impl.cc

Issue 2708023002: Web Share (desktop): DCHECK instead of user error for invalid URLs. (Closed)
Patch Set: DCHECK instead of failing. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/webshare/share_service_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/webshare/share_service_impl.cc
diff --git a/chrome/browser/webshare/share_service_impl.cc b/chrome/browser/webshare/share_service_impl.cc
index 608707fcad5e188c7de11184f939b3d31d3d453a..2ae7404a92dedad8966e1cb75e57836bb168edda 100644
--- a/chrome/browser/webshare/share_service_impl.cc
+++ b/chrome/browser/webshare/share_service_impl.cc
@@ -237,11 +237,13 @@ void ShareServiceImpl::OnPickerClosed(
chosen_target.data(),
chosen_target.size() - GURL(chosen_target).ExtractFileName().size());
const GURL target(url_base.as_string() + url_template_filled);
- if (!target.is_valid()) {
- callback.Run(base::Optional<std::string>(
- "Error: url of share target is not a valid url."));
- return;
- }
+ // User should not be able to cause an invalid target URL. Possibilities are:
+ // - The base URL: can't be invalid since it's derived from the manifest URL.
+ // - The template: can only be invalid if it contains a NUL character or
+ // invalid UTF-8 sequence (which it can't have).
+ // - The replaced pieces: these are escaped.
+ // If somehow we slip through this DCHECK, it will just open about:blank.
+ DCHECK(target.is_valid());
OpenTargetURL(target);
callback.Run(base::nullopt);
« no previous file with comments | « no previous file | chrome/browser/webshare/share_service_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698