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

Side by Side Diff: third_party/WebKit/Source/platform/plugins/PluginData.cpp

Issue 2901353002: Move blink::PluginData, blink::PluginInfo, blink::MimeTypeInfo to oilpan heap. (Closed)
Patch Set: remove some arguments Created 3 years, 6 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
OLDNEW
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
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() {
jbroman 2017/05/25 15:27:24 nit: why did this function move up here, far away
lfg 2017/05/25 21:34:42 Done.
35 PluginListBuilder builder(nullptr);
36 Platform::Current()->GetPluginList(true, WebSecurityOrigin::CreateUnique(),
37 &builder);
38 }
39
40 DEFINE_TRACE(MimeClassInfo) {
jbroman 2017/05/25 15:27:24 nit: put MimeClassInfo::trace next to the other Mi
lfg 2017/05/25 21:34:42 Done.
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(const String& type,
54 const String& desc,
55 PluginInfo& plugin)
56 : type_(type), desc_(desc), plugin_(&plugin) {}
57
58 PluginInfo::PluginInfo(const String& name,
59 const String& file,
60 const String& desc)
61 : name_(name), file_(file), desc_(desc) {}
62
63 void PluginInfo::AddMimeType(MimeClassInfo* info) {
64 mimes_.push_back(info);
65 }
66
67 const MimeClassInfo* PluginInfo::GetMimeClassInfo(size_t index) const {
68 if (index > mimes_.size())
69 return nullptr;
70 return mimes_[index];
71 }
72
73 const MimeClassInfo* PluginInfo::GetMimeClassInfo(const String& type) const {
74 for (MimeClassInfo* mime : mimes_) {
75 if (mime->Type() == type)
76 return mime;
77 }
78
79 return nullptr;
80 }
81
82 size_t PluginInfo::GetMimeClassInfoSize() const {
83 return mimes_.size();
84 }
85
86 void PluginData::UpdatePluginList(SecurityOrigin* main_frame_origin) {
87 main_frame_origin_ = main_frame_origin;
35 PluginListBuilder builder(&plugins_); 88 PluginListBuilder builder(&plugins_);
36 Platform::Current()->GetPluginList( 89 Platform::Current()->GetPluginList(
37 false, WebSecurityOrigin(main_frame_origin_), &builder); 90 false, WebSecurityOrigin(main_frame_origin_), &builder);
38 91
39 for (unsigned i = 0; i < plugins_.size(); ++i) { 92 for (PluginInfo* plugin_info : plugins_) {
40 const PluginInfo& plugin = plugins_[i]; 93 for (MimeClassInfo* mime_class_info : plugin_info->mimes_)
41 for (unsigned j = 0; j < plugin.mimes.size(); ++j) { 94 mimes_.push_back(mime_class_info);
42 mimes_.push_back(plugin.mimes[j]);
43 mime_plugin_indices_.push_back(i);
44 }
45 } 95 }
46 } 96 }
47 97
98 void PluginData::ResetPluginData() {
99 plugins_.clear();
100 mimes_.clear();
101 main_frame_origin_ = nullptr;
102 }
103
48 bool PluginData::SupportsMimeType(const String& mime_type) const { 104 bool PluginData::SupportsMimeType(const String& mime_type) const {
49 for (unsigned i = 0; i < mimes_.size(); ++i) 105 for (const MimeClassInfo* info : mimes_) {
50 if (mimes_[i].type == mime_type) 106 if (info->type_ == mime_type)
51 return true; 107 return true;
108 }
109
52 return false; 110 return false;
53 } 111 }
54 112
55 const PluginInfo* PluginData::PluginInfoForMimeType( 113 const PluginInfo* PluginData::PluginInfoForMimeType(
56 const String& mime_type) const { 114 const String& mime_type) const {
57 for (unsigned i = 0; i < mimes_.size(); ++i) { 115 for (const MimeClassInfo* info : mimes_) {
58 const MimeClassInfo& info = mimes_[i]; 116 if (info->Type() == mime_type)
59 117 return info->plugin_;
60 if (info.type == mime_type)
61 return &plugins_[mime_plugin_indices_[i]];
62 } 118 }
63 119
64 return 0; 120 return nullptr;
65 } 121 }
66 122
67 String PluginData::PluginNameForMimeType(const String& mime_type) const { 123 String PluginData::PluginNameForMimeType(const String& mime_type) const {
jbroman 2017/05/25 15:27:24 This function seems to be dead code.
lfg 2017/05/25 21:34:42 Done.
68 if (const PluginInfo* info = PluginInfoForMimeType(mime_type)) 124 if (const PluginInfo* info = PluginInfoForMimeType(mime_type))
69 return info->name; 125 return info->Name();
70 return String(); 126 return String();
71 } 127 }
72 128
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 129 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698