forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable shadow DOM-based "missing plugin" placeholder.
This is guarded by a command-line switch. TEST=OverrideCreatePluginTest BUG=364716 Review URL: https://codereview.chromium.org/649873006 Cr-Commit-Position: refs/heads/master@{#301996}
- Loading branch information
1 parent
526d813
commit 73e9f79
Showing
12 changed files
with
297 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Copyright 2013 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. | ||
|
||
#include "chrome/renderer/plugins/shadow_dom_plugin_placeholder.h" | ||
|
||
#include "base/command_line.h" | ||
#include "chrome/common/chrome_switches.h" | ||
#include "chrome/common/render_messages.h" | ||
#include "chrome/grit/generated_resources.h" | ||
#include "chrome/renderer/plugins/plugin_uma.h" | ||
#include "content/public/renderer/render_frame.h" | ||
#include "third_party/WebKit/public/web/WebDocument.h" | ||
#include "third_party/WebKit/public/web/WebLocalFrame.h" | ||
#include "third_party/WebKit/public/web/WebPluginParams.h" | ||
#include "ui/base/l10n/l10n_util.h" | ||
|
||
namespace { | ||
|
||
class MissingPluginPlaceholder : public blink::WebPluginPlaceholder { | ||
public: | ||
// blink::WebPluginPlaceholder overrides | ||
blink::WebString message() const override { | ||
// TODO(jbroman): IDS_PLUGIN_SEARCHING if ENABLE_PLUGIN_INSTALLATION | ||
return l10n_util::GetStringUTF16(IDS_PLUGIN_NOT_SUPPORTED); | ||
} | ||
}; | ||
|
||
} // namespace | ||
|
||
bool ShadowDOMPluginPlaceholderEnabled() { | ||
return base::CommandLine::ForCurrentProcess()->HasSwitch( | ||
switches::kEnablePluginPlaceholderShadowDom); | ||
} | ||
|
||
scoped_ptr<blink::WebPluginPlaceholder> CreateShadowDOMPlaceholderForPluginInfo( | ||
content::RenderFrame* render_frame, | ||
blink::WebLocalFrame* frame, | ||
const blink::WebPluginParams& orig_params) { | ||
using Status = ChromeViewHostMsg_GetPluginInfo_Status; | ||
|
||
if (!ShadowDOMPluginPlaceholderEnabled()) | ||
return nullptr; | ||
|
||
std::string orig_mime_type = orig_params.mimeType.utf8(); | ||
// TODO(jbroman): Investigate whether browser plugin needs special handling. | ||
ChromeViewHostMsg_GetPluginInfo_Output output; | ||
#if defined(ENABLE_PLUGINS) | ||
render_frame->Send( | ||
new ChromeViewHostMsg_GetPluginInfo(render_frame->GetRoutingID(), | ||
GURL(orig_params.url), | ||
frame->top()->document().url(), | ||
orig_mime_type, | ||
&output)); | ||
#else | ||
output.status.value = Status::kNotFound; | ||
#endif | ||
|
||
if (output.status.value == Status::kNotFound) { | ||
// TODO(jbroman): Handle YouTube specially here, as in | ||
// ChromeContentRendererClient::CreatePlugin. | ||
PluginUMAReporter::GetInstance()->ReportPluginMissing(orig_mime_type, | ||
orig_params.url); | ||
return CreateShadowDOMPlaceholderForMissingPlugin(); | ||
} | ||
|
||
return nullptr; | ||
} | ||
|
||
scoped_ptr<blink::WebPluginPlaceholder> | ||
CreateShadowDOMPlaceholderForMissingPlugin() { | ||
return make_scoped_ptr(new MissingPluginPlaceholder); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2014 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_RENDERER_PLUGINS_SHADOW_DOM_PLUGIN_PLACEHOLDER_H_ | ||
#define CHROME_RENDERER_PLUGINS_SHADOW_DOM_PLUGIN_PLACEHOLDER_H_ | ||
|
||
#include "base/memory/scoped_ptr.h" | ||
#include "third_party/WebKit/public/web/WebPluginPlaceholder.h" | ||
|
||
namespace blink { | ||
class WebLocalFrame; | ||
struct WebPluginParams; | ||
} | ||
|
||
namespace content { | ||
class RenderFrame; | ||
} | ||
|
||
// This is the Chrome implementation of shadow DOM plugin placeholders, | ||
// intended to ultimately replace those based on WebViewPlugin. | ||
// It is guarded by the --enable-plugin-placeholder-shadow-dom switch. | ||
|
||
// Returns |true| if shadow DOM plugin placeholders are enabled. | ||
bool ShadowDOMPluginPlaceholderEnabled(); | ||
|
||
// Possibly creates a placeholder given plugin info output. | ||
// Returns nullptr if it is not appropriate to create a placeholder | ||
// (for instance, because the plugin should be allowed to load). | ||
scoped_ptr<blink::WebPluginPlaceholder> CreateShadowDOMPlaceholderForPluginInfo( | ||
content::RenderFrame* render_frame, | ||
blink::WebLocalFrame* frame, | ||
const blink::WebPluginParams& orig_params); | ||
|
||
// Creates a placeholder suitable for representing a missing plugin. | ||
scoped_ptr<blink::WebPluginPlaceholder> | ||
CreateShadowDOMPlaceholderForMissingPlugin(); | ||
|
||
#endif // CHROME_RENDERER_PLUGINS_SHADOW_DOM_PLUGIN_PLACEHOLDER_H_ |
Oops, something went wrong.