| 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 1a2ac595626cad530f7f30618d418b7c638d9020..b7f9ecd80bc92c792b890dba165224e876e25587 100644
|
| --- a/chrome/browser/webdata/web_intents_table.cc
|
| +++ b/chrome/browser/webdata/web_intents_table.cc
|
| @@ -9,42 +9,11 @@
|
| #include "base/logging.h"
|
| #include "base/string_util.h"
|
| #include "base/utf_string_conversions.h"
|
| -#include "chrome/browser/intents/default_web_intent_service.h"
|
| #include "googleurl/src/gurl.h"
|
| #include "net/base/mime_util.h"
|
| #include "sql/statement.h"
|
| #include "third_party/sqlite/sqlite3.h"
|
|
|
| -using webkit_glue::WebIntentServiceData;
|
| -
|
| -namespace {
|
| -
|
| -#if defined(ENABLE_WEB_INTENTS)
|
| -bool ExtractIntents(sql::Statement* s,
|
| - std::vector<WebIntentServiceData>* services) {
|
| - DCHECK(s);
|
| - if (!s->is_valid())
|
| - return false;
|
| -
|
| - while (s->Step()) {
|
| - WebIntentServiceData service;
|
| - service.action = s->ColumnString16(0);
|
| - service.type = s->ColumnString16(1);
|
| - service.scheme = s->ColumnString16(2);
|
| - service.service_url = GURL(s->ColumnString16(3));
|
| - service.title = s->ColumnString16(4);
|
| - // Default to window disposition.
|
| - service.disposition = WebIntentServiceData::DISPOSITION_WINDOW;
|
| - if (s->ColumnString16(5) == ASCIIToUTF16("inline"))
|
| - service.disposition = WebIntentServiceData::DISPOSITION_INLINE;
|
| - services->push_back(service);
|
| - }
|
| - return s->Succeeded();
|
| -}
|
| -#endif // defined(ENABLE_WEB_INTENTS)
|
| -
|
| -} // namespace
|
| -
|
| WebIntentsTable::WebIntentsTable(sql::Connection* db,
|
| sql::MetaTable* meta_table)
|
| : WebDatabaseTable(db, meta_table) {
|
| @@ -156,185 +125,3 @@ bool WebIntentsTable::MigrateToVersion46AddSchemeColumn() {
|
|
|
| return true;
|
| }
|
| -
|
| -#if defined(ENABLE_WEB_INTENTS)
|
| -bool WebIntentsTable::GetWebIntentServicesForAction(
|
| - const string16& action,
|
| - std::vector<WebIntentServiceData>* services) {
|
| - DCHECK(services);
|
| - sql::Statement s(db_->GetUniqueStatement(
|
| - "SELECT action, type, scheme, service_url, title, disposition"
|
| - " FROM web_intents"
|
| - " WHERE action=?"));
|
| - s.BindString16(0, action);
|
| -
|
| - return ExtractIntents(&s, services);
|
| -}
|
| -
|
| -bool WebIntentsTable::GetWebIntentServicesForScheme(
|
| - const string16& scheme,
|
| - std::vector<WebIntentServiceData>* services) {
|
| - DCHECK(services);
|
| - sql::Statement s(db_->GetUniqueStatement(
|
| - "SELECT action, type, scheme, service_url, title, disposition"
|
| - " FROM web_intents"
|
| - " WHERE scheme=?"));
|
| - s.BindString16(0, scheme);
|
| -
|
| - return ExtractIntents(&s, services);
|
| -}
|
| -
|
| -// 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::GetWebIntentServicesForURL(
|
| - const string16& service_url,
|
| - std::vector<WebIntentServiceData>* services) {
|
| - DCHECK(services);
|
| - sql::Statement s(db_->GetUniqueStatement(
|
| - "SELECT action, type, scheme, service_url, title, disposition"
|
| - " FROM web_intents"
|
| - " WHERE service_url=?"));
|
| - s.BindString16(0, service_url);
|
| -
|
| - return ExtractIntents(&s, services);
|
| -}
|
| -
|
| -bool WebIntentsTable::GetAllWebIntentServices(
|
| - std::vector<WebIntentServiceData>* services) {
|
| - DCHECK(services);
|
| - sql::Statement s(db_->GetUniqueStatement(
|
| - "SELECT action, type, scheme, service_url, title, disposition"
|
| - " FROM web_intents"));
|
| -
|
| - return ExtractIntents(&s, services);
|
| -}
|
| -
|
| -bool WebIntentsTable::SetWebIntentService(const WebIntentServiceData& service) {
|
| - sql::Statement s(db_->GetUniqueStatement(
|
| - "INSERT OR REPLACE INTO web_intents "
|
| - "(action, type, scheme, service_url, title, disposition) "
|
| - "VALUES (?, ?, ?, ?, ?, ?)"));
|
| -
|
| - // Default to window disposition.
|
| - string16 disposition = ASCIIToUTF16("window");
|
| - if (service.disposition == WebIntentServiceData::DISPOSITION_INLINE)
|
| - disposition = ASCIIToUTF16("inline");
|
| - s.BindString16(0, service.action);
|
| - s.BindString16(1, service.type);
|
| - s.BindString16(2, service.scheme);
|
| - s.BindString(3, service.service_url.spec());
|
| - s.BindString16(4, service.title);
|
| - s.BindString16(5, disposition);
|
| -
|
| - return s.Run();
|
| -}
|
| -
|
| -// TODO(jhawkins): Investigate the need to remove rows matching only
|
| -// |service.service_url|. It's unlikely the user will be given the ability to
|
| -// remove at the granularity of actions or types.
|
| -bool WebIntentsTable::RemoveWebIntentService(
|
| - const WebIntentServiceData& service) {
|
| - sql::Statement s(db_->GetUniqueStatement(
|
| - "DELETE FROM web_intents "
|
| - "WHERE action = ? AND type = ? AND scheme = ? AND service_url = ?"));
|
| -
|
| - s.BindString16(0, service.action);
|
| - s.BindString16(1, service.type);
|
| - s.BindString16(2, service.scheme);
|
| - s.BindString(3, service.service_url.spec());
|
| -
|
| - return s.Run();
|
| -}
|
| -
|
| -bool WebIntentsTable::GetDefaultServices(
|
| - const string16& action,
|
| - std::vector<DefaultWebIntentService>* default_services) {
|
| - sql::Statement s(db_->GetUniqueStatement(
|
| - "SELECT action, type, url_pattern, user_date, suppression, "
|
| - "service_url FROM web_intents_defaults "
|
| - "WHERE action=?"));
|
| - s.BindString16(0, action);
|
| -
|
| - while (s.Step()) {
|
| - DefaultWebIntentService entry;
|
| - entry.action = s.ColumnString16(0);
|
| - entry.type = s.ColumnString16(1);
|
| - if (entry.url_pattern.Parse(s.ColumnString(2)) !=
|
| - URLPattern::PARSE_SUCCESS) {
|
| - return false;
|
| - }
|
| - entry.user_date = s.ColumnInt(3);
|
| - entry.suppression = s.ColumnInt64(4);
|
| - entry.service_url = s.ColumnString(5);
|
| -
|
| - default_services->push_back(entry);
|
| - }
|
| -
|
| - return s.Succeeded();
|
| -}
|
| -
|
| -bool WebIntentsTable::GetAllDefaultServices(
|
| - std::vector<DefaultWebIntentService>* default_services) {
|
| - sql::Statement s(db_->GetUniqueStatement(
|
| - "SELECT action, type, url_pattern, user_date, suppression, "
|
| - "service_url FROM web_intents_defaults"));
|
| -
|
| - while (s.Step()) {
|
| - DefaultWebIntentService entry;
|
| - entry.action = s.ColumnString16(0);
|
| - entry.type = s.ColumnString16(1);
|
| - if (entry.url_pattern.Parse(s.ColumnString(2)) !=
|
| - URLPattern::PARSE_SUCCESS) {
|
| - return false;
|
| - }
|
| - entry.user_date = s.ColumnInt(3);
|
| - entry.suppression = s.ColumnInt64(4);
|
| - entry.service_url = s.ColumnString(5);
|
| -
|
| - default_services->push_back(entry);
|
| - }
|
| -
|
| - return s.Succeeded();
|
| -
|
| -}
|
| -
|
| -bool WebIntentsTable::SetDefaultService(
|
| - const DefaultWebIntentService& default_service) {
|
| - sql::Statement s(db_->GetUniqueStatement(
|
| - "INSERT OR REPLACE INTO web_intents_defaults "
|
| - "(action, type, url_pattern, user_date, suppression,"
|
| - " service_url, scheme) "
|
| - "VALUES (?, ?, ?, ?, ?, ?, ?)"));
|
| - s.BindString16(0, default_service.action);
|
| - s.BindString16(1, default_service.type);
|
| - s.BindString(2, default_service.url_pattern.GetAsString());
|
| - s.BindInt(3, default_service.user_date);
|
| - s.BindInt64(4, default_service.suppression);
|
| - s.BindString(5, default_service.service_url);
|
| - s.BindString16(6, default_service.scheme);
|
| -
|
| - return s.Run();
|
| -}
|
| -
|
| -bool WebIntentsTable::RemoveDefaultService(
|
| - const DefaultWebIntentService& default_service) {
|
| - sql::Statement s(db_->GetUniqueStatement(
|
| - "DELETE FROM web_intents_defaults "
|
| - "WHERE action = ? AND type = ? AND url_pattern = ?"));
|
| - s.BindString16(0, default_service.action);
|
| - s.BindString16(1, default_service.type);
|
| - s.BindString(2, default_service.url_pattern.GetAsString());
|
| -
|
| - return s.Run();
|
| -}
|
| -
|
| -bool WebIntentsTable::RemoveServiceDefaults(const GURL& service_url) {
|
| - sql::Statement s(db_->GetUniqueStatement(
|
| - "DELETE FROM web_intents_defaults WHERE service_url = ?"));
|
| - s.BindString(0, service_url.spec());
|
| -
|
| - return s.Run();
|
| -}
|
| -
|
| -#endif // defined(ENABLE_WEB_INTENTS)
|
|
|