| OLD | NEW |
| 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 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 // TODO(jhawkins): Figure out Sync story. | 42 // TODO(jhawkins): Figure out Sync story. |
| 43 bool WebIntentsTable::IsSyncable() { | 43 bool WebIntentsTable::IsSyncable() { |
| 44 return false; | 44 return false; |
| 45 } | 45 } |
| 46 | 46 |
| 47 bool WebIntentsTable::GetWebIntents(const string16& action, | 47 bool WebIntentsTable::GetWebIntents(const string16& action, |
| 48 std::vector<WebIntentData>* intents) { | 48 std::vector<WebIntentData>* intents) { |
| 49 DCHECK(intents); | 49 DCHECK(intents); |
| 50 sql::Statement s(db_->GetUniqueStatement( | 50 sql::Statement s(db_->GetUniqueStatement( |
| 51 "SELECT service_url, action, type FROM web_intents " | 51 "SELECT service_url, action, type, title FROM web_intents " |
| 52 "WHERE action=?")); | 52 "WHERE action=?")); |
| 53 if (!s) { | 53 if (!s) { |
| 54 NOTREACHED() << "Statement prepare failed"; | 54 NOTREACHED() << "Statement prepare failed"; |
| 55 return false; | 55 return false; |
| 56 } | 56 } |
| 57 | 57 |
| 58 s.BindString16(0, action); | 58 s.BindString16(0, action); |
| 59 while (s.Step()) { | 59 while (s.Step()) { |
| 60 WebIntentData intent; | 60 WebIntentData intent; |
| 61 string16 tmp = s.ColumnString16(0); | 61 string16 tmp = s.ColumnString16(0); |
| 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 intent.title = s.ColumnString16(3); |
| 66 | 67 |
| 67 intents->push_back(intent); | 68 intents->push_back(intent); |
| 68 } | 69 } |
| 69 return true; | 70 return true; |
| 70 } | 71 } |
| 71 | 72 |
| 72 bool WebIntentsTable::GetAllWebIntents(std::vector<WebIntentData>* intents) { | 73 bool WebIntentsTable::GetAllWebIntents(std::vector<WebIntentData>* intents) { |
| 73 DCHECK(intents); | 74 DCHECK(intents); |
| 74 sql::Statement s(db_->GetUniqueStatement( | 75 sql::Statement s(db_->GetUniqueStatement( |
| 75 "SELECT service_url, action, type FROM web_intents")); | 76 "SELECT service_url, action, type, title FROM web_intents")); |
| 76 if (!s) { | 77 if (!s) { |
| 77 NOTREACHED() << "Statement prepare failed"; | 78 NOTREACHED() << "Statement prepare failed"; |
| 78 return false; | 79 return false; |
| 79 } | 80 } |
| 80 | 81 |
| 81 while (s.Step()) { | 82 while (s.Step()) { |
| 82 WebIntentData intent; | 83 WebIntentData intent; |
| 83 string16 tmp = s.ColumnString16(0); | 84 string16 tmp = s.ColumnString16(0); |
| 84 intent.service_url = GURL(tmp); | 85 intent.service_url = GURL(tmp); |
| 85 | 86 |
| 86 intent.action = s.ColumnString16(1); | 87 intent.action = s.ColumnString16(1); |
| 87 intent.type = s.ColumnString16(2); | 88 intent.type = s.ColumnString16(2); |
| 89 intent.title = s.ColumnString16(3); |
| 88 | 90 |
| 89 intents->push_back(intent); | 91 intents->push_back(intent); |
| 90 } | 92 } |
| 91 return true; | 93 return true; |
| 92 } | 94 } |
| 93 | 95 |
| 94 bool WebIntentsTable::SetWebIntent(const WebIntentData& intent) { | 96 bool WebIntentsTable::SetWebIntent(const WebIntentData& intent) { |
| 95 sql::Statement s(db_->GetUniqueStatement( | 97 sql::Statement s(db_->GetUniqueStatement( |
| 96 "INSERT OR REPLACE INTO web_intents (service_url, type, action, title) " | 98 "INSERT OR REPLACE INTO web_intents (service_url, type, action, title) " |
| 97 "VALUES (?, ?, ?, ?)")); | 99 "VALUES (?, ?, ?, ?)")); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 117 if (!s) { | 119 if (!s) { |
| 118 NOTREACHED() << "Statement prepare failed"; | 120 NOTREACHED() << "Statement prepare failed"; |
| 119 return false; | 121 return false; |
| 120 } | 122 } |
| 121 | 123 |
| 122 s.BindString(0, intent.service_url.spec()); | 124 s.BindString(0, intent.service_url.spec()); |
| 123 s.BindString16(1, intent.action); | 125 s.BindString16(1, intent.action); |
| 124 s.BindString16(2, intent.type); | 126 s.BindString16(2, intent.type); |
| 125 return s.Run(); | 127 return s.Run(); |
| 126 } | 128 } |
| 127 | |
| OLD | NEW |