Template URL Orphan Code? (handling non-autodetected keywords) |
||||
Issue description
I cannot see how this block of code ever gets triggered.
if (keyword_.empty()) {
// Use the parser-generated new keyword from the URL in the OSDD for the
// non-autodetected case. The existing |keyword_| was generated from the
// URL that hosted the OSDD, which results in the wrong keyword when the
// OSDD was located on a third-party site that has nothing in common with
// search engine described by OSDD.
keyword_ = template_url_->keyword();
DCHECK(!keyword_.empty());
}
https://cs.chromium.org/chromium/src/components/search_engines/template_url_fetcher.cc?l=158-166
It appears to me that we always have a keyword.
This fragment is in the middle of TemplateURLFetcher::RequestDelegate::OnURLFetchComplete(). This function is only called when this class (a URL fetcher) has fetched a URL.
This class is only instantiated here:
https://cs.chromium.org/chromium/src/components/search_engines/template_url_fetcher.cc?l=249-250
Earlier in this function is
DCHECK(!keyword.empty());
https://cs.chromium.org/chromium/src/components/search_engines/template_url_fetcher.cc?l=228
And this function is only called from one place also:
https://cs.chromium.org/chromium/src/chrome/browser/ui/search_engines/search_engine_tab_helper.cc?l=139-143
And a mere two lines above that call is
if (keyword.empty())
return;
Thus, I think the keyword can never be empty in template URL fetcher. But I don't understand the comment there fully (it's likely got some history I'm not aware of), so I don't feel comfortable removing it.
,
Feb 8 2018
Clearly the code cannot be triggered now. This probably made sense before https://chromium.googlesource.com/chromium/src/+/7bfdaf717592bb62de6ef2dd1a518be6e8353e03 . I would just rip this out.
,
Feb 28 2018
,
Mar 1 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/ac4523f708690a15fe83c8653689b76ee1eb0f1b commit ac4523f708690a15fe83c8653689b76ee1eb0f1b Author: Mark Pearson <mpearson@chromium.org> Date: Thu Mar 01 01:27:16 2018 Adding Search Engines - Remove Unnecessary Empty Keyword Guard Bug: 726044 Change-Id: Id607c942778e89fc4c1e89b372196a5c711ce51b Reviewed-on: https://chromium-review.googlesource.com/940820 Reviewed-by: Peter Kasting <pkasting@chromium.org> Commit-Queue: Mark Pearson <mpearson@chromium.org> Cr-Commit-Position: refs/heads/master@{#539972} [modify] https://crrev.com/ac4523f708690a15fe83c8653689b76ee1eb0f1b/components/search_engines/template_url_fetcher.cc
,
Mar 1 2018
|
||||
►
Sign in to add a comment |
||||
Comment 1 by mpear...@chromium.org
, Feb 8 2018Owner: ----
Status: Available (was: Assigned)