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

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

Issue 8966003: Update webdata files to take advantage of DLOG(FATAL) in (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix typo Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "googleurl/src/gurl.h" 9 #include "googleurl/src/gurl.h"
10 #include "sql/statement.h" 10 #include "sql/statement.h"
(...skipping 16 matching lines...) Expand all
27 service.action = s->ColumnString16(1); 27 service.action = s->ColumnString16(1);
28 service.type = s->ColumnString16(2); 28 service.type = s->ColumnString16(2);
29 service.title = s->ColumnString16(3); 29 service.title = s->ColumnString16(3);
30 tmp = s->ColumnString16(4); 30 tmp = s->ColumnString16(4);
31 // Default to window disposition. 31 // Default to window disposition.
32 service.disposition = WebIntentServiceData::DISPOSITION_WINDOW; 32 service.disposition = WebIntentServiceData::DISPOSITION_WINDOW;
33 if (tmp == ASCIIToUTF16("inline")) 33 if (tmp == ASCIIToUTF16("inline"))
34 service.disposition = WebIntentServiceData::DISPOSITION_INLINE; 34 service.disposition = WebIntentServiceData::DISPOSITION_INLINE;
35 services->push_back(service); 35 services->push_back(service);
36 } 36 }
37 return true; 37 return s->Succeeded();
38 } 38 }
39 39
40 } // namespace 40 } // namespace
41 41
42 WebIntentsTable::WebIntentsTable(sql::Connection* db, 42 WebIntentsTable::WebIntentsTable(sql::Connection* db,
43 sql::MetaTable* meta_table) 43 sql::MetaTable* meta_table)
44 : WebDatabaseTable(db, meta_table) { 44 : WebDatabaseTable(db, meta_table) {
45 } 45 }
46 46
47 WebIntentsTable::~WebIntentsTable() { 47 WebIntentsTable::~WebIntentsTable() {
(...skipping 24 matching lines...) Expand all
72 return false; 72 return false;
73 } 73 }
74 74
75 bool WebIntentsTable::GetWebIntentServices( 75 bool WebIntentsTable::GetWebIntentServices(
76 const string16& action, 76 const string16& action,
77 std::vector<WebIntentServiceData>* services) { 77 std::vector<WebIntentServiceData>* services) {
78 DCHECK(services); 78 DCHECK(services);
79 sql::Statement s(db_->GetUniqueStatement( 79 sql::Statement s(db_->GetUniqueStatement(
80 "SELECT service_url, action, type, title, disposition FROM web_intents " 80 "SELECT service_url, action, type, title, disposition FROM web_intents "
81 "WHERE action=?")); 81 "WHERE action=?"));
82 s.BindString16(0, action);
82 83
83 s.BindString16(0, action);
84 return ExtractIntents(&s, services); 84 return ExtractIntents(&s, services);
85 } 85 }
86 86
87 // TODO(gbillock): This currently does a full-table scan. Eventually we will 87 // TODO(gbillock): This currently does a full-table scan. Eventually we will
88 // store registrations by domain, and so have an indexed origin. At that time, 88 // store registrations by domain, and so have an indexed origin. At that time,
89 // this should just change to do lookup by origin instead of URL. 89 // this should just change to do lookup by origin instead of URL.
90 bool WebIntentsTable::GetWebIntentServicesForURL( 90 bool WebIntentsTable::GetWebIntentServicesForURL(
91 const string16& service_url, 91 const string16& service_url,
92 std::vector<WebIntentServiceData>* services) { 92 std::vector<WebIntentServiceData>* services) {
93 DCHECK(services); 93 DCHECK(services);
94 sql::Statement s(db_->GetUniqueStatement( 94 sql::Statement s(db_->GetUniqueStatement(
95 "SELECT service_url, action, type, title, disposition FROM web_intents " 95 "SELECT service_url, action, type, title, disposition FROM web_intents "
96 "WHERE service_url=?")); 96 "WHERE service_url=?"));
97 s.BindString16(0, service_url);
97 98
98 s.BindString16(0, service_url);
99 return ExtractIntents(&s, services); 99 return ExtractIntents(&s, services);
100 } 100 }
101 101
102 bool WebIntentsTable::GetAllWebIntentServices( 102 bool WebIntentsTable::GetAllWebIntentServices(
103 std::vector<WebIntentServiceData>* services) { 103 std::vector<WebIntentServiceData>* services) {
104 DCHECK(services); 104 DCHECK(services);
105 sql::Statement s(db_->GetUniqueStatement( 105 sql::Statement s(db_->GetUniqueStatement(
106 "SELECT service_url, action, type, title, disposition FROM web_intents")); 106 "SELECT service_url, action, type, title, disposition FROM web_intents"));
107 107
108 return ExtractIntents(&s, services); 108 return ExtractIntents(&s, services);
109 } 109 }
110 110
111 bool WebIntentsTable::SetWebIntentService(const WebIntentServiceData& service) { 111 bool WebIntentsTable::SetWebIntentService(const WebIntentServiceData& service) {
112 sql::Statement s(db_->GetUniqueStatement( 112 sql::Statement s(db_->GetUniqueStatement(
113 "INSERT OR REPLACE INTO web_intents " 113 "INSERT OR REPLACE INTO web_intents "
114 "(service_url, type, action, title, disposition) " 114 "(service_url, type, action, title, disposition) "
115 "VALUES (?, ?, ?, ?, ?)")); 115 "VALUES (?, ?, ?, ?, ?)"));
116 116
117 // Default to window disposition. 117 // Default to window disposition.
118 string16 disposition = ASCIIToUTF16("window"); 118 string16 disposition = ASCIIToUTF16("window");
119 if (service.disposition == WebIntentServiceData::DISPOSITION_INLINE) 119 if (service.disposition == WebIntentServiceData::DISPOSITION_INLINE)
120 disposition = ASCIIToUTF16("inline"); 120 disposition = ASCIIToUTF16("inline");
121 s.BindString(0, service.service_url.spec()); 121 s.BindString(0, service.service_url.spec());
122 s.BindString16(1, service.type); 122 s.BindString16(1, service.type);
123 s.BindString16(2, service.action); 123 s.BindString16(2, service.action);
124 s.BindString16(3, service.title); 124 s.BindString16(3, service.title);
125 s.BindString16(4, disposition); 125 s.BindString16(4, disposition);
126
126 return s.Run(); 127 return s.Run();
127 } 128 }
128 129
129 // TODO(jhawkins): Investigate the need to remove rows matching only 130 // TODO(jhawkins): Investigate the need to remove rows matching only
130 // |service.service_url|. It's unlikely the user will be given the ability to 131 // |service.service_url|. It's unlikely the user will be given the ability to
131 // remove at the granularity of actions or types. 132 // remove at the granularity of actions or types.
132 bool WebIntentsTable::RemoveWebIntentService( 133 bool WebIntentsTable::RemoveWebIntentService(
133 const WebIntentServiceData& service) { 134 const WebIntentServiceData& service) {
134 sql::Statement s(db_->GetUniqueStatement( 135 sql::Statement s(db_->GetUniqueStatement(
135 "DELETE FROM web_intents " 136 "DELETE FROM web_intents "
136 "WHERE service_url = ? AND action = ? AND type = ?")); 137 "WHERE service_url = ? AND action = ? AND type = ?"));
137
138 s.BindString(0, service.service_url.spec()); 138 s.BindString(0, service.service_url.spec());
139 s.BindString16(1, service.action); 139 s.BindString16(1, service.action);
140 s.BindString16(2, service.type); 140 s.BindString16(2, service.type);
141
141 return s.Run(); 142 return s.Run();
142 } 143 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698