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/plugin_finder.h" | 5 #include "chrome/browser/plugin_finder.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/plugin_installer.h" | |
12 #include "chrome/browser/prefs/pref_service.h" | 13 #include "chrome/browser/prefs/pref_service.h" |
13 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
14 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
15 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
16 #include "grit/browser_resources.h" | 17 #include "grit/browser_resources.h" |
17 #include "ui/base/resource/resource_bundle.h" | 18 #include "ui/base/resource/resource_bundle.h" |
18 | 19 |
19 PluginFinder* PluginFinder::GetInstance() { | 20 PluginFinder* PluginFinder::GetInstance() { |
20 return Singleton<PluginFinder>::get(); | 21 return Singleton<PluginFinder>::get(); |
21 } | 22 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 continue; | 75 continue; |
75 ListValue* mime_types = NULL; | 76 ListValue* mime_types = NULL; |
76 success = plugin->GetList("mime_types", &mime_types); | 77 success = plugin->GetList("mime_types", &mime_types); |
77 DCHECK(success); | 78 DCHECK(success); |
78 for (ListValue::const_iterator mime_type_it = mime_types->begin(); | 79 for (ListValue::const_iterator mime_type_it = mime_types->begin(); |
79 mime_type_it != mime_types->end(); ++mime_type_it) { | 80 mime_type_it != mime_types->end(); ++mime_type_it) { |
80 std::string mime_type_str; | 81 std::string mime_type_str; |
81 success = (*mime_type_it)->GetAsString(&mime_type_str); | 82 success = (*mime_type_it)->GetAsString(&mime_type_str); |
82 DCHECK(success); | 83 DCHECK(success); |
83 if (mime_type_str == mime_type) { | 84 if (mime_type_str == mime_type) { |
84 std::string url; | 85 std::string identifier; |
85 success = plugin->GetString("url", &url); | 86 success = plugin->GetString("identifier", &identifier); |
86 DCHECK(success); | 87 DCHECK(success); |
87 string16 name; | 88 PluginInstaller* installer = installers_[identifier]; |
88 success = plugin->GetString("name", &name); | 89 if (!installer) { |
89 DCHECK(success); | 90 std::string url; |
90 bool display_url = false; | 91 success = plugin->GetString("url", &url); |
91 plugin->GetBoolean("displayurl", &display_url); | 92 DCHECK(success); |
93 std::string help_url; | |
94 plugin->GetString("help_url", &help_url); | |
95 string16 name; | |
96 success = plugin->GetString("name", &name); | |
97 DCHECK(success); | |
98 bool display_url = false; | |
99 plugin->GetBoolean("displayurl", &display_url); | |
100 installer = new PluginInstaller(identifier, | |
101 GURL(url), GURL(help_url), name, | |
102 display_url); | |
103 installers_[identifier] = installer; | |
battre
2011/11/30 14:10:06
do you need to free the installers_ in the destruc
Bernhard Bauer
2011/11/30 14:29:23
True, there might be circumstances where we destro
Bernhard Bauer
2011/12/01 09:39:25
Done.
| |
104 } | |
92 MessageLoop::current()->PostTask( | 105 MessageLoop::current()->PostTask( |
93 FROM_HERE, | 106 FROM_HERE, |
94 base::Bind(found_callback, GURL(url), name, display_url)); | 107 base::Bind(found_callback, installer)); |
battre
2011/11/30 14:10:06
once you free the installers_ int he destructor yo
Bernhard Bauer
2011/11/30 14:29:23
Hm, during normal browser runs I think it's reason
| |
95 return; | 108 return; |
96 } | 109 } |
97 } | 110 } |
98 } | 111 } |
99 MessageLoop::current()->PostTask(FROM_HERE, not_found_callback); | 112 MessageLoop::current()->PostTask(FROM_HERE, not_found_callback); |
100 } | 113 } |
101 | 114 |
OLD | NEW |