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

Side by Side Diff: chrome/browser/webdata/web_intents_table.cc

Issue 10914278: Fix for non-sticky defaults bug. Added a bunch of tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix up comments. Created 8 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/webdata/web_intents_table.h" 5 #include "chrome/browser/webdata/web_intents_table.h"
6 #include <string> 6 #include <string>
7 7
8 #include "base/i18n/case_conversion.h" 8 #include "base/i18n/case_conversion.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 " UNIQUE (action, scheme, type, url_pattern))")) { 83 " UNIQUE (action, scheme, type, url_pattern))")) {
84 return false; 84 return false;
85 } 85 }
86 if (!db_->Execute("CREATE INDEX IF NOT EXISTS web_intents_default_index" 86 if (!db_->Execute("CREATE INDEX IF NOT EXISTS web_intents_default_index"
87 " ON web_intents_defaults (action)")) 87 " ON web_intents_defaults (action)"))
88 return false; 88 return false;
89 89
90 if (!db_->Execute("CREATE INDEX IF NOT EXISTS web_intents_default_index" 90 if (!db_->Execute("CREATE INDEX IF NOT EXISTS web_intents_default_index"
91 " ON web_intents_defaults (scheme)")) 91 " ON web_intents_defaults (scheme)"))
92 return false; 92 return false;
93 } else {
94 // For a while, 'scheme' was set to null when setting a web_intents_defaults
95 // row. Due to a longstanding SQLite bug, a NULL entry in a unique key field
96 // is always considered distinct from any other NULL entry in that field,
97 // rendering the uniqueness obsolete. Get rid of any such entries.
Scott Hess - ex-Googler 2012/09/14 19:37:47 I think this mis-represents the problem, one NULL
Greg Billock 2012/09/14 21:32:33 I see what you're saying, and that's what I'm tryi
Greg Billock 2012/09/17 18:07:21 OK, rephrased. Are you OK with this approach, Scot
98 if (!db_->Execute("DELETE FROM web_intents_defaults WHERE scheme IS NULL"))
99 return false;
93 } 100 }
94 101
102
95 return true; 103 return true;
96 } 104 }
97 105
98 // TODO(jhawkins): Figure out Sync story. 106 // TODO(jhawkins): Figure out Sync story.
99 bool WebIntentsTable::IsSyncable() { 107 bool WebIntentsTable::IsSyncable() {
100 return false; 108 return false;
101 } 109 }
102 110
103 // Updates the table by way of renaming the old tables, rerunning 111 // Updates the table by way of renaming the old tables, rerunning
104 // the Init method, then selecting old values into the new tables. 112 // the Init method, then selecting old values into the new tables.
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 } 301 }
294 302
295 return s.Succeeded(); 303 return s.Succeeded();
296 304
297 } 305 }
298 306
299 bool WebIntentsTable::SetDefaultService( 307 bool WebIntentsTable::SetDefaultService(
300 const DefaultWebIntentService& default_service) { 308 const DefaultWebIntentService& default_service) {
301 sql::Statement s(db_->GetUniqueStatement( 309 sql::Statement s(db_->GetUniqueStatement(
302 "INSERT OR REPLACE INTO web_intents_defaults " 310 "INSERT OR REPLACE INTO web_intents_defaults "
303 "(action, type, url_pattern, user_date, suppression, service_url) " 311 "(action, type, url_pattern, user_date, suppression,"
304 "VALUES (?, ?, ?, ?, ?, ?)")); 312 " service_url, scheme) "
313 "VALUES (?, ?, ?, ?, ?, ?, ?)"));
305 s.BindString16(0, default_service.action); 314 s.BindString16(0, default_service.action);
306 s.BindString16(1, default_service.type); 315 s.BindString16(1, default_service.type);
307 s.BindString(2, default_service.url_pattern.GetAsString()); 316 s.BindString(2, default_service.url_pattern.GetAsString());
308 s.BindInt(3, default_service.user_date); 317 s.BindInt(3, default_service.user_date);
309 s.BindInt64(4, default_service.suppression); 318 s.BindInt64(4, default_service.suppression);
310 s.BindString(5, default_service.service_url); 319 s.BindString(5, default_service.service_url);
320 s.BindString16(6, default_service.scheme);
311 321
312 return s.Run(); 322 return s.Run();
313 } 323 }
314 324
315 bool WebIntentsTable::RemoveDefaultService( 325 bool WebIntentsTable::RemoveDefaultService(
316 const DefaultWebIntentService& default_service) { 326 const DefaultWebIntentService& default_service) {
317 sql::Statement s(db_->GetUniqueStatement( 327 sql::Statement s(db_->GetUniqueStatement(
318 "DELETE FROM web_intents_defaults " 328 "DELETE FROM web_intents_defaults "
319 "WHERE action = ? AND type = ? AND url_pattern = ?")); 329 "WHERE action = ? AND type = ? AND url_pattern = ?"));
320 s.BindString16(0, default_service.action); 330 s.BindString16(0, default_service.action);
321 s.BindString16(1, default_service.type); 331 s.BindString16(1, default_service.type);
322 s.BindString(2, default_service.url_pattern.GetAsString()); 332 s.BindString(2, default_service.url_pattern.GetAsString());
323 333
324 return s.Run(); 334 return s.Run();
325 } 335 }
326 336
327 bool WebIntentsTable::RemoveServiceDefaults(const GURL& service_url) { 337 bool WebIntentsTable::RemoveServiceDefaults(const GURL& service_url) {
328 sql::Statement s(db_->GetUniqueStatement( 338 sql::Statement s(db_->GetUniqueStatement(
329 "DELETE FROM web_intents_defaults WHERE service_url = ?")); 339 "DELETE FROM web_intents_defaults WHERE service_url = ?"));
330 s.BindString(0, service_url.spec()); 340 s.BindString(0, service_url.spec());
331 341
332 return s.Run(); 342 return s.Run();
333 } 343 }
OLDNEW
« no previous file with comments | « chrome/browser/intents/web_intents_registry_unittest.cc ('k') | chrome/browser/webdata/web_intents_table_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698