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

Unified Diff: chrome/browser/webdata/web_intents_table.cc

Issue 8144013: Add a check to the registry before the intent infobar is shown. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix up returns. Created 9 years, 2 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
Index: chrome/browser/webdata/web_intents_table.cc
diff --git a/chrome/browser/webdata/web_intents_table.cc b/chrome/browser/webdata/web_intents_table.cc
index 9be56b721d4a7a69de68032c443dc9460658ffb6..dbc5497382215747abd19a50744a32f5f5644666 100644
--- a/chrome/browser/webdata/web_intents_table.cc
+++ b/chrome/browser/webdata/web_intents_table.cc
@@ -10,9 +10,13 @@
#include "sql/statement.h"
namespace {
+
bool ExtractIntents(sql::Statement* s,
std::vector<WebIntentServiceData>* services) {
DCHECK(s);
+ if (!s)
James Hawkins 2011/10/26 23:50:06 You're going to remove this early return, right?
Greg Billock 2011/10/29 00:03:19 It needs to be here for the contract. Otherwise it
+ return false;
+
while (s->Step()) {
WebIntentServiceData service;
string16 tmp = s->ColumnString16(0);
@@ -30,6 +34,7 @@ bool ExtractIntents(sql::Statement* s,
}
return true;
}
+
}
James Hawkins 2011/10/26 23:50:06 // namespace
Greg Billock 2011/10/29 00:03:19 Done.
WebIntentsTable::WebIntentsTable(sql::Connection* db,
@@ -51,11 +56,11 @@ bool WebIntentsTable::Init() {
"title VARCHAR,"
"disposition VARCHAR,"
"UNIQUE (service_url, action, type))")) {
- NOTREACHED();
James Hawkins 2011/10/26 23:50:06 Please leave the NOTREACHEDs in place.
Greg Billock 2011/10/29 00:03:19 This is a bug in your change. These calls can fail
+ return false;
}
if (!db_->Execute("CREATE INDEX web_intents_index ON web_intents (action)"))
- NOTREACHED();
+ return false;
return true;
}
@@ -72,20 +77,31 @@ bool WebIntentsTable::GetWebIntents(
sql::Statement s(db_->GetUniqueStatement(
"SELECT service_url, action, type, title, disposition FROM web_intents "
"WHERE action=?"));
- if (!s)
James Hawkins 2011/10/26 23:50:06 I prefer the existing construct.
- NOTREACHED() << "Statement prepare failed";
s.BindString16(0, action);
return ExtractIntents(&s, intents);
}
+// TODO(gbillock): This currently does a full-table scan. Eventually we will
+// store registrations by domain, and so have an indexed origin. At that time,
+// this should just change to do lookup by origin instead of URL.
+bool WebIntentsTable::GetWebIntentsForURL(
+ const string16& service_url,
+ std::vector<WebIntentServiceData>* intents) {
+ DCHECK(intents);
+ sql::Statement s(db_->GetUniqueStatement(
+ "SELECT service_url, action, type, title, disposition FROM web_intents "
+ "WHERE service_url=?"));
+
+ s.BindString16(0, service_url);
+ return ExtractIntents(&s, intents);
+}
+
bool WebIntentsTable::GetAllWebIntents(
std::vector<WebIntentServiceData>* intents) {
DCHECK(intents);
sql::Statement s(db_->GetUniqueStatement(
"SELECT service_url, action, type, title, disposition FROM web_intents"));
- if (!s)
- NOTREACHED() << "Statement prepare failed";
return ExtractIntents(&s, intents);
}
@@ -95,8 +111,6 @@ bool WebIntentsTable::SetWebIntent(const WebIntentServiceData& intent) {
"INSERT OR REPLACE INTO web_intents "
"(service_url, type, action, title, disposition) "
"VALUES (?, ?, ?, ?, ?)"));
- if (!s)
- NOTREACHED() << "Statement prepare failed";
// Default to window disposition.
string16 disposition = ASCIIToUTF16("window");
@@ -117,8 +131,6 @@ bool WebIntentsTable::RemoveWebIntent(const WebIntentServiceData& intent) {
sql::Statement s(db_->GetUniqueStatement(
"DELETE FROM web_intents "
"WHERE service_url = ? AND action = ? AND type = ?"));
- if (!s)
- NOTREACHED() << "Statement prepare failed";
s.BindString(0, intent.service_url.spec());
s.BindString16(1, intent.action);

Powered by Google App Engine
This is Rietveld 408576698