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 73 74 75 76 77 78 79 80 81 82
|
// 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_PLUGINS_PLUGIN_OBSERVER_H_
#define CHROME_BROWSER_PLUGINS_PLUGIN_OBSERVER_H_
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
#if defined(ENABLE_PLUGIN_INSTALLATION)
#include <map>
#endif
class GURL;
class PluginFinder;
class PluginMetadata;
#if defined(ENABLE_PLUGIN_INSTALLATION)
class PluginInstaller;
class PluginPlaceholderHost;
#endif
namespace content {
class WebContents;
}
namespace infobars {
class InfoBarDelegate;
}
class PluginObserver : public content::WebContentsObserver,
public content::WebContentsUserData<PluginObserver> {
public:
~PluginObserver() override;
// content::WebContentsObserver implementation.
void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override;
void PluginCrashed(const base::FilePath& plugin_path,
base::ProcessId plugin_pid) override;
bool OnMessageReceived(const IPC::Message& message,
content::RenderFrameHost* render_frame_host) override;
bool OnMessageReceived(const IPC::Message& message) override;
private:
explicit PluginObserver(content::WebContents* web_contents);
friend class content::WebContentsUserData<PluginObserver>;
class PluginPlaceholderHost;
#if defined(ENABLE_PLUGIN_INSTALLATION)
void InstallMissingPlugin(PluginInstaller* installer,
const PluginMetadata* plugin_metadata);
#endif
// Message handlers:
void OnBlockedUnauthorizedPlugin(const base::string16& name,
const std::string& identifier);
void OnBlockedOutdatedPlugin(int placeholder_id,
const std::string& identifier);
#if defined(ENABLE_PLUGIN_INSTALLATION)
void OnFindMissingPlugin(int placeholder_id, const std::string& mime_type);
void OnRemovePluginPlaceholderHost(int placeholder_id);
#endif
void OnOpenAboutPlugins();
void OnCouldNotLoadPlugin(const base::FilePath& plugin_path);
void OnNPAPINotSupported(const std::string& identifier);
#if defined(ENABLE_PLUGIN_INSTALLATION)
// Stores all PluginPlaceholderHosts, keyed by their routing ID.
std::map<int, PluginPlaceholderHost*> plugin_placeholders_;
#endif
base::WeakPtrFactory<PluginObserver> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(PluginObserver);
};
#endif // CHROME_BROWSER_PLUGINS_PLUGIN_OBSERVER_H_
|