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

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

Issue 7601013: Web Intents: Hook up the register intent InfoBar with the WebIntentsRegistry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nit fixes. Created 9 years, 4 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) 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 "googleurl/src/gurl.h" 8 #include "googleurl/src/gurl.h"
9 #include "sql/statement.h" 9 #include "sql/statement.h"
10 10
11 WebIntentsTable::WebIntentsTable(sql::Connection* db, 11 WebIntentsTable::WebIntentsTable(sql::Connection* db,
12 sql::MetaTable* meta_table) 12 sql::MetaTable* meta_table)
13 : WebDatabaseTable(db, meta_table) { 13 : WebDatabaseTable(db, meta_table) {
14 } 14 }
15 15
16 WebIntentsTable::~WebIntentsTable() { 16 WebIntentsTable::~WebIntentsTable() {
17 } 17 }
18 18
19 bool WebIntentsTable::Init() { 19 bool WebIntentsTable::Init() {
20 if (db_->DoesTableExist("web_intents")) 20 if (db_->DoesTableExist("web_intents"))
21 return true; 21 return true;
22 22
23 if (!db_->Execute("CREATE TABLE web_intents (" 23 if (!db_->Execute("CREATE TABLE web_intents ("
24 "service_url LONGVARCHAR," 24 "service_url LONGVARCHAR,"
25 "action VARCHAR," 25 "action VARCHAR,"
26 "type VARCHAR," 26 "type VARCHAR,"
27 "title VARCHAR,"
27 "UNIQUE (service_url, action, type))")) { 28 "UNIQUE (service_url, action, type))")) {
28 NOTREACHED(); 29 NOTREACHED();
29 return false; 30 return false;
30 } 31 }
31 32
32 if (!db_->Execute("CREATE INDEX web_intents_index " 33 if (!db_->Execute("CREATE INDEX web_intents_index "
33 "ON web_intents (action)")) { 34 "ON web_intents (action)")) {
34 NOTREACHED(); 35 NOTREACHED();
35 return false; 36 return false;
36 } 37 }
(...skipping 24 matching lines...) Expand all
61 intent.service_url = GURL(tmp); 62 intent.service_url = GURL(tmp);
62 63
63 intent.action = s.ColumnString16(1); 64 intent.action = s.ColumnString16(1);
64 intent.type = s.ColumnString16(2); 65 intent.type = s.ColumnString16(2);
65 66
66 intents->push_back(intent); 67 intents->push_back(intent);
67 } 68 }
68 return true; 69 return true;
69 } 70 }
70 71
71 bool WebIntentsTable::SetWebIntent(const string16& action, 72 bool WebIntentsTable::SetWebIntent(const WebIntentData& intent) {
72 const string16& type,
73 const GURL& service_url) {
74 sql::Statement s(db_->GetUniqueStatement( 73 sql::Statement s(db_->GetUniqueStatement(
75 "INSERT OR REPLACE INTO web_intents (service_url, type, action) " 74 "INSERT OR REPLACE INTO web_intents (service_url, type, action, title) "
76 "VALUES (?, ?, ?)")); 75 "VALUES (?, ?, ?, ?)"));
77 if (!s) { 76 if (!s) {
78 NOTREACHED() << "Statement prepare failed"; 77 NOTREACHED() << "Statement prepare failed";
79 return false; 78 return false;
80 } 79 }
81 80
82 s.BindString(0, service_url.spec()); 81 s.BindString(0, intent.service_url.spec());
83 s.BindString16(1, type); 82 s.BindString16(1, intent.type);
84 s.BindString16(2, action); 83 s.BindString16(2, intent.action);
84 s.BindString16(3, intent.title);
85 return s.Run(); 85 return s.Run();
86 } 86 }
87 87
88 bool WebIntentsTable::RemoveWebIntent(const string16& action, 88 // TODO(jhawkins): Investigate the need to remove rows matching only
89 const string16& type, 89 // |intent.service_url|. It's unlikely the user will be given the ability to
90 const GURL& service_url) { 90 // remove at the granularity of actions or types.
91 bool WebIntentsTable::RemoveWebIntent(const WebIntentData& intent) {
91 sql::Statement delete_s(db_->GetUniqueStatement( 92 sql::Statement delete_s(db_->GetUniqueStatement(
92 "DELETE FROM web_intents " 93 "DELETE FROM web_intents "
93 "WHERE service_url = ? AND action = ? AND type = ?")); 94 "WHERE service_url = ? AND action = ? AND type = ?"));
94 if (!delete_s) { 95 if (!delete_s) {
95 NOTREACHED() << "Statement prepare failed"; 96 NOTREACHED() << "Statement prepare failed";
96 return false; 97 return false;
97 } 98 }
98 99
99 delete_s.BindString(0, service_url.spec()); 100 delete_s.BindString(0, intent.service_url.spec());
100 delete_s.BindString16(1, action); 101 delete_s.BindString16(1, intent.action);
101 delete_s.BindString16(2, type); 102 delete_s.BindString16(2, intent.type);
102 return delete_s.Run(); 103 return delete_s.Run();
103 } 104 }
104 105
OLDNEW
« no previous file with comments | « chrome/browser/webdata/web_intents_table.h ('k') | chrome/browser/webdata/web_intents_table_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698