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

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

Issue 7633011: Added WebIntents GetAll support (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fix review nit 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
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 intent.service_url = GURL(tmp); 62 intent.service_url = GURL(tmp);
63 63
64 intent.action = s.ColumnString16(1); 64 intent.action = s.ColumnString16(1);
65 intent.type = s.ColumnString16(2); 65 intent.type = s.ColumnString16(2);
66 66
67 intents->push_back(intent); 67 intents->push_back(intent);
68 } 68 }
69 return true; 69 return true;
70 } 70 }
71 71
72 bool WebIntentsTable::GetAllWebIntents(std::vector<WebIntentData>* intents) {
73 DCHECK(intents);
74 sql::Statement s(db_->GetUniqueStatement(
75 "SELECT service_url, action, type FROM web_intents"));
76 if (!s) {
77 NOTREACHED() << "Statement prepare failed";
78 return false;
79 }
80
81 while (s.Step()) {
82 WebIntentData intent;
83 string16 tmp = s.ColumnString16(0);
84 intent.service_url = GURL(tmp);
85
86 intent.action = s.ColumnString16(1);
87 intent.type = s.ColumnString16(2);
88
89 intents->push_back(intent);
90 }
91 return true;
92 }
93
72 bool WebIntentsTable::SetWebIntent(const WebIntentData& intent) { 94 bool WebIntentsTable::SetWebIntent(const WebIntentData& intent) {
73 sql::Statement s(db_->GetUniqueStatement( 95 sql::Statement s(db_->GetUniqueStatement(
74 "INSERT OR REPLACE INTO web_intents (service_url, type, action, title) " 96 "INSERT OR REPLACE INTO web_intents (service_url, type, action, title) "
75 "VALUES (?, ?, ?, ?)")); 97 "VALUES (?, ?, ?, ?)"));
76 if (!s) { 98 if (!s) {
77 NOTREACHED() << "Statement prepare failed"; 99 NOTREACHED() << "Statement prepare failed";
78 return false; 100 return false;
79 } 101 }
80 102
81 s.BindString(0, intent.service_url.spec()); 103 s.BindString(0, intent.service_url.spec());
82 s.BindString16(1, intent.type); 104 s.BindString16(1, intent.type);
83 s.BindString16(2, intent.action); 105 s.BindString16(2, intent.action);
84 s.BindString16(3, intent.title); 106 s.BindString16(3, intent.title);
85 return s.Run(); 107 return s.Run();
86 } 108 }
87 109
88 // TODO(jhawkins): Investigate the need to remove rows matching only 110 // TODO(jhawkins): Investigate the need to remove rows matching only
89 // |intent.service_url|. It's unlikely the user will be given the ability to 111 // |intent.service_url|. It's unlikely the user will be given the ability to
90 // remove at the granularity of actions or types. 112 // remove at the granularity of actions or types.
91 bool WebIntentsTable::RemoveWebIntent(const WebIntentData& intent) { 113 bool WebIntentsTable::RemoveWebIntent(const WebIntentData& intent) {
92 sql::Statement delete_s(db_->GetUniqueStatement( 114 sql::Statement s(db_->GetUniqueStatement(
93 "DELETE FROM web_intents " 115 "DELETE FROM web_intents "
94 "WHERE service_url = ? AND action = ? AND type = ?")); 116 "WHERE service_url = ? AND action = ? AND type = ?"));
95 if (!delete_s) { 117 if (!s) {
96 NOTREACHED() << "Statement prepare failed"; 118 NOTREACHED() << "Statement prepare failed";
97 return false; 119 return false;
98 } 120 }
99 121
100 delete_s.BindString(0, intent.service_url.spec()); 122 s.BindString(0, intent.service_url.spec());
101 delete_s.BindString16(1, intent.action); 123 s.BindString16(1, intent.action);
102 delete_s.BindString16(2, intent.type); 124 s.BindString16(2, intent.type);
103 return delete_s.Run(); 125 return s.Run();
104 } 126 }
105 127
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