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

Issue 10381016: Remove the "autogenerate keyword" bit on TemplateURL. (Closed)

Created:
8 years, 7 months ago by Peter Kasting
Modified:
8 years, 7 months ago
CC:
chromium-reviews, Avi (use Gerrit), creis+watch_chromium.org, tfarina, dhollowa+watch_chromium.org, brettw-cc_chromium.org, ajwong+watch_chromium.org
Visibility:
Public.

Description

Remove the "autogenerate keyword" bit on TemplateURL. This is a large change because a number of other significant pieces were either inherently tied to the above change, or too difficult to separate from it: * Because autogeneration was really only ever supposed to be used for the prepopulated Google entry, replace it with a system that auto-regenerates keywords for TemplateURLs that (a) use {google:baseURL} and (b) have a keyword that's currently "google.<TLD>" whenever the base URL changes. This means that users who manually create such TemplateURLs will automatically get the benefit of "autogenerated" keywords. * Pass information to the KeywordTable as bare TemplateURLData objects instead of TemplateURLs, now that the latter are not needed to perform keyword generation. * Remove the "autogenerate_keyword" column from the KeywordTable. This also takes the opportunity to remove the already-dead "logo_id" column (which I previously asked msw to leave in in order to only have to write the migration code once). This in turn requires adding version numbers to a lot of functions so they know which column set to use, as well as writing migration code to manually generate keywords for previously-autogenerated entries. * Migrate the "autogenerate_keyword" bit in data from prefs and sync as well. For sync this requires a variety of followon changes to send back ACTION_UPDATEs for migrated TemplateURLs and coalesce multiple SyncChanges to the same GUID. * Move various bits of TemplateURLService::GenerateKeyword() that were only used for the "autodetected on a webpage" case to the specific code for that case, in order to make GenerateKeyword() incapable of failing. This is important for the next item. * Remove the possibility for keywords to simply be empty. All TemplateURLs should now have a keyword, whether they were previously marked as "autogenerated" or not. While the UI already tried to guarantee this, the TemplateURL class itself and various pieces of TemplateURLService did not, or didn't deal correctly with exceptions. Enforcing this makes it much easier to reason about keywords and is important for the next item. * Guarantee that all keywords are unique, with one exception noted below. This allows callers to reliably refer to TemplateURLs by keyword; a future change will make AutocompleteMatch do precisely this. It also prevents weird edge cases in the UI and sync. * Exception: explicitly allow extension keywords to overlap with each other and with one non-extension TemplateURL. Previously, the behavior was somewhat random and buggy when we added and removed extensions that defined keywords, especially if we also tried to add/edit/remove keywords from the settings UI. We now define an explicit precedence order: non-replaceable TemplateURL > extension-provided TemplateURLs > replaceable TemplateURL; within the extensions section, the most recently-added extension wins. As we add and remove keywords, the current "TemplateURL for keyword" is always kept up-to-date according to this precedence order (so e.g. removing a later extension will "expose" an earlier one). BUG=none TEST=Adding extensions that specify omnibox keywords which conflict with local keywords should result in predictable behavior as described above; removing the extensions should restore the prior behavior. Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=135775

Patch Set 1 #

Patch Set 2 : #

Total comments: 16

Patch Set 3 : #

Patch Set 4 : #

Total comments: 4

Patch Set 5 : #

Total comments: 32

Patch Set 6 : #

Total comments: 8
Unified diffs Side-by-side diffs Delta from patch set Stats (+1337 lines, -686 lines) Patch
M chrome/browser/importer/ie_importer.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/importer/profile_import_process_messages.h View 1 3 chunks +1 line, -5 lines 0 comments Download
M chrome/browser/protector/default_search_provider_change.cc View 1 2 3 2 chunks +1 line, -8 lines 0 comments Download
M chrome/browser/protector/default_search_provider_change_browsertest.cc View 1 1 chunk +1 line, -4 lines 0 comments Download
M chrome/browser/search_engines/search_host_to_urls_map.cc View 1 2 chunks +2 lines, -0 lines 0 comments Download
M chrome/browser/search_engines/search_provider_install_data.cc View 1 2 chunks +3 lines, -0 lines 0 comments Download
M chrome/browser/search_engines/template_url.h View 1 2 3 4 5 chunks +20 lines, -37 lines 0 comments Download
M chrome/browser/search_engines/template_url.cc View 1 2 4 chunks +27 lines, -27 lines 0 comments Download
M chrome/browser/search_engines/template_url_parser.cc View 1 1 chunk +1 line, -3 lines 0 comments Download
M chrome/browser/search_engines/template_url_prepopulate_data.cc View 1 4 chunks +4 lines, -10 lines 0 comments Download
M chrome/browser/search_engines/template_url_service.h View 1 2 6 chunks +34 lines, -25 lines 2 comments Download
M chrome/browser/search_engines/template_url_service.cc View 1 2 3 4 5 47 chunks +310 lines, -102 lines 0 comments Download
M chrome/browser/search_engines/template_url_service_sync_unittest.cc View 1 2 36 chunks +286 lines, -157 lines 0 comments Download
M chrome/browser/search_engines/template_url_service_unittest.cc View 1 18 chunks +207 lines, -94 lines 2 comments Download
M chrome/browser/search_engines/template_url_unittest.cc View 1 1 chunk +0 lines, -14 lines 0 comments Download
M chrome/browser/search_engines/util.cc View 1 1 chunk +3 lines, -4 lines 0 comments Download
M chrome/browser/tab_contents/render_view_context_menu.cc View 1 2 chunks +2 lines, -3 lines 0 comments Download
M chrome/browser/ui/search_engines/search_engine_tab_helper.cc View 1 2 chunks +11 lines, -1 line 0 comments Download
M chrome/browser/webdata/keyword_table.h View 1 2 3 4 5 7 chunks +18 lines, -8 lines 2 comments Download
M chrome/browser/webdata/keyword_table.cc View 1 2 3 4 5 19 chunks +189 lines, -53 lines 0 comments Download
M chrome/browser/webdata/keyword_table_unittest.cc View 1 17 chunks +51 lines, -55 lines 0 comments Download
M chrome/browser/webdata/web_data_service.h View 1 2 chunks +4 lines, -4 lines 0 comments Download
M chrome/browser/webdata/web_data_service.cc View 1 4 chunks +11 lines, -14 lines 0 comments Download
M chrome/browser/webdata/web_database.cc View 1 2 chunks +10 lines, -2 lines 0 comments Download
M chrome/browser/webdata/web_database_migration_unittest.cc View 1 2 3 4 5 6 chunks +138 lines, -54 lines 0 comments Download
M sync/protocol/search_engine_specifics.proto View 1 2 3 4 5 1 chunk +2 lines, -1 line 2 comments Download

Messages

Total messages: 14 (0 generated)
Peter Kasting
All reviewers: note the presence of some "REVIEWERS:" questions in the comments; please provide feedback. ...
8 years, 7 months ago (2012-05-04 20:51:13 UTC) #1
sky
https://chromiumcodereview.appspot.com/10381016/diff/10003/chrome/browser/search_engines/template_url_service.cc File chrome/browser/search_engines/template_url_service.cc (right): https://chromiumcodereview.appspot.com/10381016/diff/10003/chrome/browser/search_engines/template_url_service.cc#newcode73 chrome/browser/search_engines/template_url_service.cc:73: ((url1->keyword() == url2->keyword()) || Is it worth moving this ...
8 years, 7 months ago (2012-05-04 23:20:25 UTC) #2
Peter Kasting
New snap up. sky, please look at the diffs against patch set 2. In particular ...
8 years, 7 months ago (2012-05-07 17:50:24 UTC) #3
SteveT
A few initial comments about comments. Will continue review with the new snap. https://chromiumcodereview.appspot.com/10381016/diff/10003/chrome/browser/search_engines/template_url.cc File ...
8 years, 7 months ago (2012-05-07 18:17:46 UTC) #4
SteveT
A few more comments. R+zea to look at a couple sync internals questions in template_url_service ...
8 years, 7 months ago (2012-05-07 19:33:49 UTC) #5
SteveT
A few more comments. R+zea to look at a couple sync internals questions in template_url_service ...
8 years, 7 months ago (2012-05-07 19:33:50 UTC) #6
Peter Kasting
http://codereview.chromium.org/10381016/diff/10003/chrome/browser/search_engines/template_url.cc File chrome/browser/search_engines/template_url.cc (right): http://codereview.chromium.org/10381016/diff/10003/chrome/browser/search_engines/template_url.cc#newcode539 chrome/browser/search_engines/template_url.cc:539: keyword_(ASCIIToUTF16("dummy")), On 2012/05/07 18:17:47, SteveT wrote: > Kind of ...
8 years, 7 months ago (2012-05-07 19:39:13 UTC) #7
Ivan Korotkov
protector and keyword_table LGTM with nits http://codereview.chromium.org/10381016/diff/2014/chrome/browser/webdata/keyword_table.cc File chrome/browser/webdata/keyword_table.cc (right): http://codereview.chromium.org/10381016/diff/2014/chrome/browser/webdata/keyword_table.cc#newcode229 chrome/browser/webdata/keyword_table.cc:229: return false; Good ...
8 years, 7 months ago (2012-05-07 20:56:46 UTC) #8
sky
> The real best answer would be to reorder the columns in the > keyword ...
8 years, 7 months ago (2012-05-07 22:03:59 UTC) #9
Nicolas Zea
Some sync related comments. http://codereview.chromium.org/10381016/diff/2014/chrome/browser/search_engines/template_url_service.cc File chrome/browser/search_engines/template_url_service.cc (right): http://codereview.chromium.org/10381016/diff/2014/chrome/browser/search_engines/template_url_service.cc#newcode106 chrome/browser/search_engines/template_url_service.cc:106: // that the server will ...
8 years, 7 months ago (2012-05-07 22:27:27 UTC) #10
Peter Kasting
New patch up, all reviewers but sky should take another look http://codereview.chromium.org/10381016/diff/2014/chrome/browser/search_engines/template_url_service.cc File chrome/browser/search_engines/template_url_service.cc (right): ...
8 years, 7 months ago (2012-05-08 00:37:06 UTC) #11
Nicolas Zea
Sync LGTM http://codereview.chromium.org/10381016/diff/2014/chrome/browser/search_engines/template_url_service.cc File chrome/browser/search_engines/template_url_service.cc (right): http://codereview.chromium.org/10381016/diff/2014/chrome/browser/search_engines/template_url_service.cc#newcode111 chrome/browser/search_engines/template_url_service.cc:111: if ((change_i.change_type() != SyncChange::ACTION_ADD) && On 2012/05/08 ...
8 years, 7 months ago (2012-05-08 00:51:02 UTC) #12
SteveT
lgtm - with a couple nits and an optional test request inline. http://codereview.chromium.org/10381016/diff/2014/chrome/browser/search_engines/template_url_service_unittest.cc File chrome/browser/search_engines/template_url_service_unittest.cc ...
8 years, 7 months ago (2012-05-08 01:17:14 UTC) #13
Peter Kasting
8 years, 7 months ago (2012-05-08 01:31:41 UTC) #14
Submitting.

http://codereview.chromium.org/10381016/diff/2014/chrome/browser/search_engin...
File chrome/browser/search_engines/template_url_service.cc (right):

http://codereview.chromium.org/10381016/diff/2014/chrome/browser/search_engin...
chrome/browser/search_engines/template_url_service.cc:111: if
((change_i.change_type() != SyncChange::ACTION_ADD) &&
On 2012/05/08 00:51:03, nzea wrote:
> On 2012/05/08 00:37:06, Peter Kasting wrote:
> > On 2012/05/07 22:27:27, nzea wrote:
> > > nit: multi-line condition -> curly brace
> > 
> > Not the style rule.  The rule is multi-line body.  Conditional length
doesn't
> > matter.
> 
> I'll take your word for it. I suppose I based my interpretation on: "Omit {}
for
> conditional or loop bodies where both the body and the header are just one
> physical line each.  Otherwise, use {}." But I guess header != condition.

No, you read correctly, but the style guide is wrong.  This was erroneously
changed in the most recent version of the style guide, less than a month ago. 
I've reverted the change.

http://codereview.chromium.org/10381016/diff/15030/chrome/browser/search_engi...
File chrome/browser/search_engines/template_url_service.h (right):

http://codereview.chromium.org/10381016/diff/15030/chrome/browser/search_engi...
chrome/browser/search_engines/template_url_service.h:509: // last_modified
dates, |sync_turl| wins.
On 2012/05/08 01:17:15, SteveT wrote:
> nit: Please mention that |local_turl| cannot be an extension keyword.

Done.

http://codereview.chromium.org/10381016/diff/15030/chrome/browser/search_engi...
File chrome/browser/search_engines/template_url_service_unittest.cc (right):

http://codereview.chromium.org/10381016/diff/15030/chrome/browser/search_engi...
chrome/browser/search_engines/template_url_service_unittest.cc:413: 
On 2012/05/08 01:17:15, SteveT wrote:
> Optional: Would it be helpful at all to write a small test for
> FindNonExtensionTemplateURLForKeyword?

I think that helper is simple enough that the broader behavioral test in the
AddSameKeywordWithExtensionPresent test below safely covers this.  Testing this
function directly feels too much like testing the low-level implementation
details.

http://codereview.chromium.org/10381016/diff/15030/chrome/browser/webdata/key...
File chrome/browser/webdata/keyword_table.h (right):

http://codereview.chromium.org/10381016/diff/15030/chrome/browser/webdata/key...
chrome/browser/webdata/keyword_table.h:47: //   autogenerate_keyword
On 2012/05/08 01:17:15, SteveT wrote:
> Nit: Is it worth adding a comment here about this being deprecated?

Oops, this should have been removed entirely!

http://codereview.chromium.org/10381016/diff/15030/sync/protocol/search_engin...
File sync/protocol/search_engine_specifics.proto (right):

http://codereview.chromium.org/10381016/diff/15030/sync/protocol/search_engin...
sync/protocol/search_engine_specifics.proto:45: // Do not use this field in the
future.
On 2012/05/08 00:51:03, nzea wrote:
> Nit: Change to "do not write to this field" and mention that we keep the
> definition around for so we can migrate from old versions.

Done.

Powered by Google App Engine
This is Rietveld 408576698