OLD | NEW |
1 /* | 1 /* |
2 Copyright (C) 2000 Harri Porten (porten@kde.org) | 2 Copyright (C) 2000 Harri Porten (porten@kde.org) |
3 Copyright (C) 2000 Daniel Molkentin (molkentin@kde.org) | 3 Copyright (C) 2000 Daniel Molkentin (molkentin@kde.org) |
4 Copyright (C) 2000 Stefan Schimanski (schimmi@kde.org) | 4 Copyright (C) 2000 Stefan Schimanski (schimmi@kde.org) |
5 Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All Rights Reserved. | 5 Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All Rights Reserved. |
6 Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 6 Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
7 | 7 |
8 This library is free software; you can redistribute it and/or | 8 This library is free software; you can redistribute it and/or |
9 modify it under the terms of the GNU Library General Public | 9 modify it under the terms of the GNU Library General Public |
10 License as published by the Free Software Foundation; either | 10 License as published by the Free Software Foundation; either |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 #include "platform/plugins/PluginData.h" | 24 #include "platform/plugins/PluginData.h" |
25 | 25 |
26 #include "platform/plugins/PluginListBuilder.h" | 26 #include "platform/plugins/PluginListBuilder.h" |
27 #include "platform/weborigin/SecurityOrigin.h" | 27 #include "platform/weborigin/SecurityOrigin.h" |
28 #include "public/platform/Platform.h" | 28 #include "public/platform/Platform.h" |
29 #include "public/platform/WebSecurityOrigin.h" | 29 #include "public/platform/WebSecurityOrigin.h" |
30 | 30 |
31 namespace blink { | 31 namespace blink { |
32 | 32 |
33 PluginData::PluginData(SecurityOrigin* main_frame_origin) | 33 // static |
34 : main_frame_origin_(main_frame_origin) { | 34 void PluginData::RefreshBrowserSidePluginCache() { |
| 35 PluginListBuilder builder(nullptr); |
| 36 Platform::Current()->GetPluginList(true, WebSecurityOrigin::CreateUnique(), |
| 37 &builder); |
| 38 } |
| 39 |
| 40 DEFINE_TRACE(MimeClassInfo) { |
| 41 visitor->Trace(plugin_); |
| 42 } |
| 43 |
| 44 DEFINE_TRACE(PluginInfo) { |
| 45 visitor->Trace(mimes_); |
| 46 } |
| 47 |
| 48 DEFINE_TRACE(PluginData) { |
| 49 visitor->Trace(plugins_); |
| 50 visitor->Trace(mimes_); |
| 51 } |
| 52 |
| 53 MimeClassInfo::MimeClassInfo(String type, String desc, PluginInfo* plugin) |
| 54 : type_(type), desc_(desc), plugin_(plugin) {} |
| 55 |
| 56 PluginInfo::PluginInfo(String name, String file, String desc) |
| 57 : name_(name), file_(file), desc_(desc) {} |
| 58 |
| 59 void PluginInfo::AddMimeType(MimeClassInfo* info) { |
| 60 mimes_.push_back(info); |
| 61 } |
| 62 |
| 63 const MimeClassInfo* PluginInfo::GetMimeClassInfo(size_t index) const { |
| 64 if (index > mimes_.size()) |
| 65 return nullptr; |
| 66 return mimes_[index]; |
| 67 } |
| 68 |
| 69 const MimeClassInfo* PluginInfo::GetMimeClassInfo(const String& type) const { |
| 70 for (MimeClassInfo* mime : mimes_) { |
| 71 if (mime->type() == type) |
| 72 return mime; |
| 73 } |
| 74 |
| 75 return nullptr; |
| 76 } |
| 77 |
| 78 size_t PluginInfo::GetMimeClassInfoSize() const { |
| 79 return mimes_.size(); |
| 80 } |
| 81 |
| 82 void PluginData::UpdatePluginList(SecurityOrigin* main_frame_origin) { |
| 83 main_frame_origin_ = main_frame_origin; |
35 PluginListBuilder builder(&plugins_); | 84 PluginListBuilder builder(&plugins_); |
36 Platform::Current()->GetPluginList( | 85 Platform::Current()->GetPluginList( |
37 false, WebSecurityOrigin(main_frame_origin_), &builder); | 86 false, WebSecurityOrigin(main_frame_origin_), &builder); |
38 | 87 |
39 for (unsigned i = 0; i < plugins_.size(); ++i) { | 88 for (PluginInfo* plugin_info : plugins_) { |
40 const PluginInfo& plugin = plugins_[i]; | 89 for (MimeClassInfo* mime_class_info : plugin_info->mimes_) |
41 for (unsigned j = 0; j < plugin.mimes.size(); ++j) { | 90 mimes_.push_back(mime_class_info); |
42 mimes_.push_back(plugin.mimes[j]); | |
43 mime_plugin_indices_.push_back(i); | |
44 } | |
45 } | 91 } |
46 } | 92 } |
47 | 93 |
| 94 void PluginData::ResetPluginData() { |
| 95 plugins_.clear(); |
| 96 mimes_.clear(); |
| 97 main_frame_origin_ = nullptr; |
| 98 } |
| 99 |
48 bool PluginData::SupportsMimeType(const String& mime_type) const { | 100 bool PluginData::SupportsMimeType(const String& mime_type) const { |
49 for (unsigned i = 0; i < mimes_.size(); ++i) | 101 for (const MimeClassInfo* info : mimes_) { |
50 if (mimes_[i].type == mime_type) | 102 if (info->type_ == mime_type) |
51 return true; | 103 return true; |
| 104 } |
| 105 |
52 return false; | 106 return false; |
53 } | 107 } |
54 | 108 |
55 const PluginInfo* PluginData::PluginInfoForMimeType( | 109 const PluginInfo* PluginData::PluginInfoForMimeType( |
56 const String& mime_type) const { | 110 const String& mime_type) const { |
57 for (unsigned i = 0; i < mimes_.size(); ++i) { | 111 for (const MimeClassInfo* info : mimes_) { |
58 const MimeClassInfo& info = mimes_[i]; | 112 if (info->type() == mime_type) |
59 | 113 return info->plugin_; |
60 if (info.type == mime_type) | |
61 return &plugins_[mime_plugin_indices_[i]]; | |
62 } | 114 } |
63 | 115 |
64 return 0; | 116 return nullptr; |
65 } | 117 } |
66 | 118 |
67 String PluginData::PluginNameForMimeType(const String& mime_type) const { | 119 String PluginData::PluginNameForMimeType(const String& mime_type) const { |
68 if (const PluginInfo* info = PluginInfoForMimeType(mime_type)) | 120 if (const PluginInfo* info = PluginInfoForMimeType(mime_type)) |
69 return info->name; | 121 return info->name(); |
70 return String(); | 122 return String(); |
71 } | 123 } |
72 | 124 |
73 void PluginData::RefreshBrowserSidePluginCache() { | |
74 Vector<PluginInfo> plugins; | |
75 PluginListBuilder builder(&plugins); | |
76 Platform::Current()->GetPluginList(true, WebSecurityOrigin::CreateUnique(), | |
77 &builder); | |
78 } | |
79 | |
80 } // namespace blink | 125 } // namespace blink |
OLD | NEW |