New issue
Advanced search Search tips

Issue 726044 link

Starred by 0 users

Issue metadata

Status: Fixed
Owner:
Closed: Mar 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 3
Type: Bug



Sign in to add a comment

Template URL Orphan Code? (handling non-autodetected keywords)

Project Member Reported by mpear...@chromium.org, May 24 2017

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.

 
Cc: pkasting@chromium.org
Owner: ----
Status: Available (was: Assigned)
Moving from assigned to pkasting@ to available.

pkasting@, I'm still curious about the story behind this comment.
Owner: mpear...@chromium.org
Status: Assigned (was: Available)
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.
Status: Started (was: Assigned)
Project Member

Comment 4 by bugdroid1@chromium.org, 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

Status: Fixed (was: Started)

Sign in to add a comment