summaryrefslogtreecommitdiffstats
path: root/chrome/browser/plugin_observer.h
blob: 2acca57fe43ddacd14d5e1abb26c700386d9ec94 (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
// 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_OBSERVER_H_
#define CHROME_BROWSER_PLUGIN_OBSERVER_H_
#pragma once

#include "base/memory/weak_ptr.h"
#include "content/public/browser/web_contents_observer.h"

#if defined(ENABLE_PLUGIN_INSTALLATION)
#include "base/memory/scoped_vector.h"
#endif

class GURL;
class InfoBarDelegate;
class PluginInstaller;
class TabContentsWrapper;

#if defined(ENABLE_PLUGIN_INSTALLATION)
class PluginInstaller;
#endif

class PluginObserver : public content::WebContentsObserver {
 public:
  explicit PluginObserver(TabContentsWrapper* tab_contents);
  virtual ~PluginObserver();

  // content::WebContentsObserver implementation.
  virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;

  // Shows the infobar that offers to install a missing plug-in.
  void ShowPluginInstallationInfoBar(PluginInstaller* installer);

 private:
#if defined(ENABLE_PLUGIN_INSTALLATION)
  class MissingPluginHost;
#endif

  void OnBlockedOutdatedPlugin(const string16& name, const GURL& update_url);
#if defined(ENABLE_PLUGIN_INSTALLATION)
  void OnFindMissingPlugin(int placeholder_id, const std::string& mime_type);

  void FoundMissingPlugin(int placeholder_id,
                          const std::string& mime_type,
                          PluginInstaller* installer);
  void DidNotFindMissingPlugin(int placeholder_id);
  void InstallMissingPlugin(PluginInstaller* installer);
#endif

  base::WeakPtrFactory<PluginObserver> weak_ptr_factory_;

  TabContentsWrapper* tab_contents_;

#if defined(ENABLE_PLUGIN_INSTALLATION)
  ScopedVector<MissingPluginHost> missing_plugins_;
#endif

  DISALLOW_COPY_AND_ASSIGN(PluginObserver);
};

#endif  // CHROME_BROWSER_PLUGIN_OBSERVER_H_