| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "base/mime_util.h" | 5 #include "base/mime_util.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 #include <sys/time.h> | 8 #include <sys/time.h> |
| 9 #include <time.h> | 9 #include <time.h> |
| 10 | 10 |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 } | 554 } |
| 555 | 555 |
| 556 } // namespace | 556 } // namespace |
| 557 | 557 |
| 558 namespace mime_util { | 558 namespace mime_util { |
| 559 | 559 |
| 560 std::string GetFileMimeType(const FilePath& filepath) { | 560 std::string GetFileMimeType(const FilePath& filepath) { |
| 561 return xdg_mime_get_mime_type_from_file_name(filepath.value().c_str()); | 561 return xdg_mime_get_mime_type_from_file_name(filepath.value().c_str()); |
| 562 } | 562 } |
| 563 | 563 |
| 564 std::string GetDataMimeType(const std::string& data) { |
| 565 return xdg_mime_get_mime_type_for_data(data.data(), data.length(), NULL); |
| 566 } |
| 567 |
| 564 FilePath GetMimeIcon(const std::string& mime_type, size_t size) { | 568 FilePath GetMimeIcon(const std::string& mime_type, size_t size) { |
| 565 std::vector<std::string> icon_names; | 569 std::vector<std::string> icon_names; |
| 566 std::string icon_name; | 570 std::string icon_name; |
| 567 FilePath icon_file; | 571 FilePath icon_file; |
| 568 | 572 |
| 569 const char* icon = xdg_mime_get_icon(mime_type.c_str()); | 573 const char* icon = xdg_mime_get_icon(mime_type.c_str()); |
| 570 icon_name = std::string(icon ? icon : ""); | 574 icon_name = std::string(icon ? icon : ""); |
| 571 if (icon_name.length()) | 575 if (icon_name.length()) |
| 572 icon_names.push_back(icon_name); | 576 icon_names.push_back(icon_name); |
| 573 | 577 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 600 } else { | 604 } else { |
| 601 icon_file = LookupIconInDefaultTheme(icon_names[i], size); | 605 icon_file = LookupIconInDefaultTheme(icon_names[i], size); |
| 602 if (!icon_file.empty()) | 606 if (!icon_file.empty()) |
| 603 return icon_file; | 607 return icon_file; |
| 604 } | 608 } |
| 605 } | 609 } |
| 606 return FilePath(); | 610 return FilePath(); |
| 607 } | 611 } |
| 608 | 612 |
| 609 } // namespace mime_util | 613 } // namespace mime_util |
| OLD | NEW |