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 #ifndef CHROME_BROWSER_PLUGIN_FINDER_H_ | 5 #ifndef CHROME_BROWSER_PLUGIN_FINDER_H_ |
6 #define CHROME_BROWSER_PLUGIN_FINDER_H_ | 6 #define CHROME_BROWSER_PLUGIN_FINDER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/singleton.h" | 14 #include "base/memory/singleton.h" |
15 #include "base/string16.h" | 15 #include "base/string16.h" |
16 | 16 |
17 namespace base { | 17 namespace base { |
18 class DictionaryValue; | 18 class DictionaryValue; |
19 class ListValue; | |
20 } | 19 } |
21 | 20 |
22 class GURL; | 21 class GURL; |
23 class PluginInstaller; | 22 class PluginInstaller; |
24 | 23 |
25 class PluginFinder { | 24 class PluginFinder { |
26 public: | 25 public: |
27 typedef base::Callback<void(PluginInstaller*)> FindPluginCallback; | 26 static void Get(const base::Callback<void(PluginFinder*)>& cb); |
28 | |
29 static PluginFinder* GetInstance(); | |
30 | 27 |
31 // Loads the plug-in information from the browser resources and parses it. | 28 // Loads the plug-in information from the browser resources and parses it. |
32 // Returns NULL if the plug-in list couldn't be parsed. | 29 // Returns NULL if the plug-in list couldn't be parsed. |
33 static scoped_ptr<base::ListValue> LoadPluginList(); | 30 static scoped_ptr<base::DictionaryValue> LoadPluginList(); |
34 | 31 |
35 // Finds a plug-in for the given MIME type and language (specified as an IETF | 32 // Finds a plug-in for the given MIME type and language (specified as an IETF |
36 // language tag, i.e. en-US) and calls the callback with the PluginInstaller | 33 // language tag, i.e. en-US) and returns the PluginInstaller for the plug-in, |
37 // for the plug-in, or NULL if no plug-in is found. | 34 // or NULL if no plug-in is found. |
38 void FindPlugin(const std::string& mime_type, | 35 PluginInstaller* FindPlugin(const std::string& mime_type, |
39 const std::string& language, | 36 const std::string& language); |
40 const FindPluginCallback& callback); | |
41 | 37 |
42 // Finds the plug-in with the given identifier and calls the callback. | 38 // Returns the plug-in with the given identifier. |
43 void FindPluginWithIdentifier(const std::string& identifier, | 39 PluginInstaller* FindPluginWithIdentifier(const std::string& identifier); |
44 const FindPluginCallback& callback); | |
45 | 40 |
46 private: | 41 private: |
47 friend struct DefaultSingletonTraits<PluginFinder>; | 42 friend struct DefaultSingletonTraits<PluginFinder>; |
| 43 friend class Singleton<PluginFinder>; |
| 44 |
| 45 static PluginFinder* GetInstance(); |
48 | 46 |
49 PluginFinder(); | 47 PluginFinder(); |
50 ~PluginFinder(); | 48 ~PluginFinder(); |
51 | 49 |
52 static base::ListValue* LoadPluginListInternal(); | 50 static base::DictionaryValue* LoadPluginListInternal(); |
53 | 51 |
54 PluginInstaller* CreateInstaller(const std::string& identifier, | 52 PluginInstaller* CreateInstaller(const std::string& identifier, |
55 const base::DictionaryValue* plugin_dict); | 53 const base::DictionaryValue* plugin_dict); |
56 PluginInstaller* FindPluginInternal(const std::string& mime_type, | |
57 const std::string& language); | |
58 | 54 |
59 scoped_ptr<base::ListValue> plugin_list_; | 55 scoped_ptr<base::DictionaryValue> plugin_list_; |
60 std::map<std::string, PluginInstaller*> installers_; | 56 std::map<std::string, PluginInstaller*> installers_; |
61 | 57 |
62 DISALLOW_COPY_AND_ASSIGN(PluginFinder); | 58 DISALLOW_COPY_AND_ASSIGN(PluginFinder); |
63 }; | 59 }; |
64 | 60 |
65 #endif // CHROME_BROWSER_PLUGIN_FINDER_H_ | 61 #endif // CHROME_BROWSER_PLUGIN_FINDER_H_ |
OLD | NEW |