summaryrefslogtreecommitdiffstats
path: root/chrome/browser/plugin_status_pref_setter.h
blob: 8667f3ff940eb8f0694ec37e6aeff6b239d1d642 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_PLUGIN_STATUS_PREF_SETTER_H_
#define CHROME_BROWSER_PLUGIN_STATUS_PREF_SETTER_H_
#pragma once

#include <vector>

#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/prefs/pref_member.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"

class PluginPrefs;
class PrefService;
class Profile;

namespace webkit {
struct WebPluginInfo;
}

// Helper class modeled after BooleanPrefMember to (asynchronously) update
// preferences related to plugin enable status.
// It should only be used from the UI thread. The client has to make sure that
// the passed profile outlives this object.
class PluginStatusPrefSetter : public content::NotificationObserver {
 public:
  PluginStatusPrefSetter();
  virtual ~PluginStatusPrefSetter();

  // Binds the preferences in the profile's PrefService, notifying |observer| if
  // any value changes.
  // This asynchronously calls the PluginService to get the list of installed
  // plug-ins.
  void Init(Profile* profile,
            content::NotificationObserver* observer);

  bool IsClearPluginLSODataEnabled() const {
    return clear_plugin_lso_data_enabled_.GetValue();
  }

  bool IsPepperFlashSettingsEnabled() const {
    return pepper_flash_settings_enabled_.GetValue();
  }

  // content::NotificationObserver methods:
  virtual void Observe(int type,
                       const content::NotificationSource& source,
                       const content::NotificationDetails& details) OVERRIDE;

 private:
  void StartUpdate();
  void GotPlugins(scoped_refptr<PluginPrefs> plugin_prefs,
                  const std::vector<webkit::WebPluginInfo>& plugins);

  content::NotificationRegistrar registrar_;
  // Weak pointer.
  Profile* profile_;
  base::WeakPtrFactory<PluginStatusPrefSetter> factory_;

  // Whether clearing LSO data is supported.
  BooleanPrefMember clear_plugin_lso_data_enabled_;
  // Whether we should show Pepper Flash-specific settings.
  BooleanPrefMember pepper_flash_settings_enabled_;

  DISALLOW_COPY_AND_ASSIGN(PluginStatusPrefSetter);
};

#endif  // CHROME_BROWSER_PLUGIN_STATUS_PREF_SETTER_H_