OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "components/history/core/browser/android/favicon_sql_handler.h" | 5 #include "components/history/core/browser/android/favicon_sql_handler.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/ref_counted_memory.h" | 10 #include "base/memory/ref_counted_memory.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 bool FaviconSQLHandler::Update(const HistoryAndBookmarkRow& row, | 33 bool FaviconSQLHandler::Update(const HistoryAndBookmarkRow& row, |
34 const TableIDRows& ids_set) { | 34 const TableIDRows& ids_set) { |
35 if (!row.favicon_valid()) | 35 if (!row.favicon_valid()) |
36 return Delete(ids_set); | 36 return Delete(ids_set); |
37 | 37 |
38 // If the image_data will be updated, it is not reasonable to find if the | 38 // If the image_data will be updated, it is not reasonable to find if the |
39 // icon is already in database, just create a new favicon. | 39 // icon is already in database, just create a new favicon. |
40 // TODO(pkotwicz): Pass in real pixel size. | 40 // TODO(pkotwicz): Pass in real pixel size. |
41 favicon_base::FaviconID favicon_id = thumbnail_db_->AddFavicon( | 41 favicon_base::FaviconID favicon_id = thumbnail_db_->AddFavicon( |
42 GURL(), favicon_base::FAVICON, row.favicon(), Time::Now(), gfx::Size()); | 42 GURL(), favicon_base::FAVICON, row.favicon(), FaviconBitmapType::ON_VISIT, |
| 43 Time::Now(), gfx::Size()); |
43 | 44 |
44 if (!favicon_id) | 45 if (!favicon_id) |
45 return false; | 46 return false; |
46 | 47 |
47 std::vector<favicon_base::FaviconID> favicon_ids; | 48 std::vector<favicon_base::FaviconID> favicon_ids; |
48 for (TableIDRows::const_iterator i = ids_set.begin(); | 49 for (TableIDRows::const_iterator i = ids_set.begin(); |
49 i != ids_set.end(); ++i) { | 50 i != ids_set.end(); ++i) { |
50 // Remove all icon mappings to favicons of type FAVICON. | 51 // Remove all icon mappings to favicons of type FAVICON. |
51 std::vector<IconMapping> icon_mappings; | 52 std::vector<IconMapping> icon_mappings; |
52 thumbnail_db_->GetIconMappingsForPageURL( | 53 thumbnail_db_->GetIconMappingsForPageURL( |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 bool FaviconSQLHandler::Insert(HistoryAndBookmarkRow* row) { | 98 bool FaviconSQLHandler::Insert(HistoryAndBookmarkRow* row) { |
98 if (!row->is_value_set_explicitly(HistoryAndBookmarkRow::FAVICON) || | 99 if (!row->is_value_set_explicitly(HistoryAndBookmarkRow::FAVICON) || |
99 !row->favicon_valid()) | 100 !row->favicon_valid()) |
100 return true; | 101 return true; |
101 | 102 |
102 DCHECK(row->is_value_set_explicitly(HistoryAndBookmarkRow::URL)); | 103 DCHECK(row->is_value_set_explicitly(HistoryAndBookmarkRow::URL)); |
103 | 104 |
104 // Is it a problem to give a empty URL? | 105 // Is it a problem to give a empty URL? |
105 // TODO(pkotwicz): Pass in real pixel size. | 106 // TODO(pkotwicz): Pass in real pixel size. |
106 favicon_base::FaviconID id = thumbnail_db_->AddFavicon( | 107 favicon_base::FaviconID id = thumbnail_db_->AddFavicon( |
107 GURL(), favicon_base::FAVICON, row->favicon(), Time::Now(), gfx::Size()); | 108 GURL(), favicon_base::FAVICON, row->favicon(), |
| 109 FaviconBitmapType::ON_VISIT, Time::Now(), gfx::Size()); |
108 if (!id) | 110 if (!id) |
109 return false; | 111 return false; |
110 return thumbnail_db_->AddIconMapping(row->url(), id); | 112 return thumbnail_db_->AddIconMapping(row->url(), id); |
111 } | 113 } |
112 | 114 |
113 bool FaviconSQLHandler::DeleteUnusedFavicon( | 115 bool FaviconSQLHandler::DeleteUnusedFavicon( |
114 const std::vector<favicon_base::FaviconID>& ids) { | 116 const std::vector<favicon_base::FaviconID>& ids) { |
115 for (std::vector<favicon_base::FaviconID>::const_iterator i = ids.begin(); | 117 for (std::vector<favicon_base::FaviconID>::const_iterator i = ids.begin(); |
116 i != ids.end(); | 118 i != ids.end(); |
117 ++i) { | 119 ++i) { |
118 if (!thumbnail_db_->HasMappingFor(*i) && !thumbnail_db_->DeleteFavicon(*i)) | 120 if (!thumbnail_db_->HasMappingFor(*i) && !thumbnail_db_->DeleteFavicon(*i)) |
119 return false; | 121 return false; |
120 } | 122 } |
121 return true; | 123 return true; |
122 } | 124 } |
123 | 125 |
124 } // namespace history. | 126 } // namespace history. |
OLD | NEW |