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 #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 <string> | 10 #include <string> |
10 #include <vector> | |
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 ListValue; | 18 class ListValue; |
19 } | 19 } |
20 | 20 |
21 class GURL; | 21 class GURL; |
| 22 class PluginInstaller; |
22 | 23 |
23 class PluginFinder { | 24 class PluginFinder { |
24 public: | 25 public: |
25 // If |display_url| is false, |plugin_url| is the URL of the download page for | 26 typedef base::Callback<void(PluginInstaller*)> FindPluginCallback; |
26 // the plug-in, which should be opened in a new tab. If it is true, | |
27 // |plugin_url| is the URL of the plug-in installer binary, which can be | |
28 // directly downloaded. | |
29 typedef base::Callback<void(GURL /* plugin_url */, | |
30 string16 /* name */, | |
31 bool /* display_url */)> FindPluginCallback; | |
32 | 27 |
33 static PluginFinder* GetInstance(); | 28 static PluginFinder* GetInstance(); |
34 | 29 |
35 // Finds a plug-in for the given MIME type and language (specified as an IETF | 30 // Finds a plug-in for the given MIME type and language (specified as an IETF |
36 // language tag, i.e. en-US) and calls one of the two passed in callbacks, | 31 // language tag, i.e. en-US) and calls one of the two passed in callbacks, |
37 // depending on whether a plug-in is found. | 32 // depending on whether a plug-in is found. |
38 void FindPlugin(const std::string& mime_type, | 33 void FindPlugin(const std::string& mime_type, |
39 const std::string& language, | 34 const std::string& language, |
40 const FindPluginCallback& found_callback, | 35 const FindPluginCallback& found_callback, |
41 const base::Closure& not_found_callback); | 36 const base::Closure& not_found_callback); |
42 | 37 |
43 private: | 38 private: |
44 friend struct DefaultSingletonTraits<PluginFinder>; | 39 friend struct DefaultSingletonTraits<PluginFinder>; |
45 | 40 |
46 PluginFinder(); | 41 PluginFinder(); |
47 ~PluginFinder(); | 42 ~PluginFinder(); |
48 | 43 |
49 scoped_ptr<base::ListValue> plugin_list_; | 44 scoped_ptr<base::ListValue> plugin_list_; |
| 45 std::map<std::string, PluginInstaller*> installers_; |
50 | 46 |
51 DISALLOW_COPY_AND_ASSIGN(PluginFinder); | 47 DISALLOW_COPY_AND_ASSIGN(PluginFinder); |
52 }; | 48 }; |
53 | 49 |
54 #endif // CHROME_BROWSER_PLUGIN_FINDER_H_ | 50 #endif // CHROME_BROWSER_PLUGIN_FINDER_H_ |
OLD | NEW |