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

Side by Side Diff: chrome/browser/chromeos/plugin_selection_policy.h

Issue 3717005: This adds a plugin selection policy for selecting allowed plugins (Closed)
Patch Set: fix win build Created 10 years, 2 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
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_PLUGIN_SELECTION_POLICY_H_
6 #define CHROME_BROWSER_CHROMEOS_PLUGIN_SELECTION_POLICY_H_
7
8 #include <map>
9 #include <string>
10 #include <vector>
11
12 #include "base/gtest_prod_util.h"
13 #include "base/ref_counted.h"
14 #include "webkit/glue/plugins/webplugininfo.h"
15
16 class GURL;
17 class FilePath;
18
19 namespace chromeos {
20
21 #if !defined(OS_CHROMEOS)
22 #error This file is meant to be compiled on ChromeOS only.
23 #endif
24
25 // This class is used to provide logic for selection of a plugin
26 // executable path in the browser. It loads a policy file for
27 // selection of particular plugins based on the domain they are be
28 // instantiated for. It is used by the PluginService. It is (and
29 // should be) only used for ChromeOS.
30
31 // The functions in this class must only be called on the FILE thread
32 // (and will DCHECK if they aren't).
33
34 class PluginSelectionPolicy
35 : public base::RefCountedThreadSafe<PluginSelectionPolicy> {
36 public:
37 PluginSelectionPolicy();
38
39 // This should be called before any other method. This starts the
40 // process of initialization on the FILE thread.
41 void StartInit();
42
43 // Returns the first allowed plugin in the given vector of plugin
44 // information. Returns -1 if no plugins in the info vector are
45 // allowed (or if the info vector is empty). InitFromFile must
46 // complete before any calls to FindFirstAllowed happen or it will
47 // assert.
48 int FindFirstAllowed(const GURL& url, const std::vector<WebPluginInfo>& info);
49
50 // Applies the current policy to the given path using the url to
51 // look up what the policy for that domain is. Returns true if the
52 // given plugin is allowed for that domain. InitFromFile must
53 // complete before any calls to IsAllowed happen or it will assert.
54 bool IsAllowed(const GURL& url, const FilePath& path);
55
56 private:
57 // To allow access to InitFromFile
58 FRIEND_TEST_ALL_PREFIXES(PluginSelectionPolicyTest, Basic);
59 FRIEND_TEST_ALL_PREFIXES(PluginSelectionPolicyTest, InitFromFile);
60 FRIEND_TEST_ALL_PREFIXES(PluginSelectionPolicyTest, IsAllowed);
61 FRIEND_TEST_ALL_PREFIXES(PluginSelectionPolicyTest, FindFirstAllowed);
62
63 // Initializes from the default policy file.
64 bool Init();
65
66 // Initializes from the given file.
67 bool InitFromFile(const FilePath& policy_file);
68
69 typedef std::vector<std::pair<bool, std::string> > Policy;
70 typedef std::map<std::string, Policy> PolicyMap;
71
72 PolicyMap policies_;
73 bool initialized_;
74
75 DISALLOW_COPY_AND_ASSIGN(PluginSelectionPolicy);
76 };
77
78 } // namespace chromeos
79 #endif // CHROME_BROWSER_CHROMEOS_PLUGIN_SELECTION_POLICY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698