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