Commit 4ecfe306 authored by wfh's avatar wfh Committed by Commit bot

Never display unauthorized plugin info bar.

The IPC still needs to be sent because it's used by the webview permission helper to permit PPAPI plugins to run inside a webview.

Remove all the code that backed this, including UMA actions, and a test.  The NPAPI purge, begun, it has.

BUG=439972

Review URL: https://codereview.chromium.org/801053003

Cr-Commit-Position: refs/heads/master@{#308433}
parent 6c40a7e5
......@@ -52,7 +52,6 @@ void ChromeBrowserFieldTrials::InstantiateDynamicTrials() {
// Mark here so they will be sync-ed.
base::FieldTrialList::FindValue("CLD1VsCLD2");
base::FieldTrialList::FindValue("MouseEventPreconnect");
base::FieldTrialList::FindValue("UnauthorizedPluginInfoBar");
base::FieldTrialList::FindValue("DisplayList2dCanvas");
base::FieldTrialList::FindValue("V8ScriptStreaming");
// Activate the autocomplete dynamic field trials.
......
// 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.
#include "base/bind.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
#include "base/metrics/field_trial.h"
#include "base/path_service.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/net/url_request_mock_util.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/render_messages.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/common/content_paths.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_utils.h"
#include "net/test/url_request/url_request_mock_http_job.h"
#include "url/gurl.h"
using content::BrowserThread;
using net::URLRequestMockHTTPJob;
namespace {
// Tests that the NPAPI unauthorized plugin infobar is:
// (1) Shown when the Finch trial is set to "Enabled"
// (2) Not shown when the Finch trial is set to "Disabled"
// TODO(cthomp): Remove/simplify when Finch trial is completed crbug.com/381944
class UnauthorizedPluginInfoBarBrowserTest : public InProcessBrowserTest {
protected:
UnauthorizedPluginInfoBarBrowserTest() {}
// Makes URLRequestMockHTTPJobs serve data from content::DIR_TEST_DATA
// instead of chrome::DIR_TEST_DATA.
void ServeContentTestData() {
base::FilePath root_http;
PathService::Get(content::DIR_TEST_DATA, &root_http);
scoped_refptr<content::MessageLoopRunner> runner =
new content::MessageLoopRunner;
BrowserThread::PostTaskAndReply(
BrowserThread::IO,
FROM_HERE,
base::Bind(URLRequestMockHTTPJob::AddUrlHandler,
root_http,
make_scoped_refptr(BrowserThread::GetBlockingPool())),
runner->QuitClosure());
runner->Run();
}
public:
// Verifies that the test page exists (only present with src-internal)
bool TestPageExists() {
return base::PathExists(ui_test_utils::GetTestFilePath(
base::FilePath(FILE_PATH_LITERAL("plugin")),
base::FilePath(FILE_PATH_LITERAL("quicktime.html"))));
}
void InfoBarCountTest(size_t number_infobars_expected,
Browser* browser) {
ServeContentTestData();
content::WebContents* contents =
browser->tab_strip_model()->GetActiveWebContents();
ASSERT_TRUE(contents);
InfoBarService* infobar_service = InfoBarService::FromWebContents(contents);
ASSERT_TRUE(infobar_service);
EXPECT_EQ(0u, infobar_service->infobar_count());
base::FilePath path(FILE_PATH_LITERAL("plugin/quicktime.html"));
GURL url(URLRequestMockHTTPJob::GetMockUrl(path));
ui_test_utils::NavigateToURL(browser, url);
ASSERT_EQ(number_infobars_expected, infobar_service->infobar_count());
}
private:
DISALLOW_COPY_AND_ASSIGN(UnauthorizedPluginInfoBarBrowserTest);
};
// When "UnauthorizedPluginInfoBar" is "Enabled", infobar for NPAPI plugin
// should be shown.
IN_PROC_BROWSER_TEST_F(UnauthorizedPluginInfoBarBrowserTest, InfobarEnabled) {
if (!TestPageExists()) {
LOG(INFO) <<
"Test skipped because plugin/quicktime.html test file wasn't found.";
return;
}
base::FieldTrialList::CreateTrialsFromString(
"UnauthorizedPluginInfoBar/Enabled/",
base::FieldTrialList::ACTIVATE_TRIALS,
std::set<std::string>());
InfoBarCountTest(1u, browser());
}
// When "UnauthorizedPluginInfoBar" is "Disabled", infobar for NPAPI plugin
// should not be shown.
IN_PROC_BROWSER_TEST_F(UnauthorizedPluginInfoBarBrowserTest, InfobarDisabled) {
if (!TestPageExists()) {
LOG(INFO) <<
"Test skipped because plugin/quicktime.html test file wasn't found.";
return;
}
base::FieldTrialList::CreateTrialsFromString(
"UnauthorizedPluginInfoBar/Disabled/",
base::FieldTrialList::ACTIVATE_TRIALS,
std::set<std::string>());
InfoBarCountTest(0u, browser());
}
} // namespace
......@@ -17,7 +17,6 @@
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/locale_settings.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/google/core/browser/google_util.h"
#include "components/infobars/core/infobar.h"
#include "content/public/browser/render_process_host.h"
......@@ -81,92 +80,6 @@ base::string16 PluginInfoBarDelegate::GetLinkText() const {
return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
}
// UnauthorizedPluginInfoBarDelegate ------------------------------------------
// static
void UnauthorizedPluginInfoBarDelegate::Create(
InfoBarService* infobar_service,
HostContentSettingsMap* content_settings,
const base::string16& name,
const std::string& identifier) {
infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar(
scoped_ptr<ConfirmInfoBarDelegate>(new UnauthorizedPluginInfoBarDelegate(
content_settings, name, identifier))));
content::RecordAction(UserMetricsAction("BlockedPluginInfobar.Shown"));
std::string utf8_name(base::UTF16ToUTF8(name));
if (utf8_name == PluginMetadata::kJavaGroupName) {
content::RecordAction(UserMetricsAction("BlockedPluginInfobar.Shown.Java"));
} else if (utf8_name == PluginMetadata::kQuickTimeGroupName) {
content::RecordAction(
UserMetricsAction("BlockedPluginInfobar.Shown.QuickTime"));
} else if (utf8_name == PluginMetadata::kShockwaveGroupName) {
content::RecordAction(
UserMetricsAction("BlockedPluginInfobar.Shown.Shockwave"));
} else if (utf8_name == PluginMetadata::kRealPlayerGroupName) {
content::RecordAction(
UserMetricsAction("BlockedPluginInfobar.Shown.RealPlayer"));
} else if (utf8_name == PluginMetadata::kWindowsMediaPlayerGroupName) {
content::RecordAction(
UserMetricsAction("BlockedPluginInfobar.Shown.WindowsMediaPlayer"));
}
}
UnauthorizedPluginInfoBarDelegate::UnauthorizedPluginInfoBarDelegate(
HostContentSettingsMap* content_settings,
const base::string16& name,
const std::string& identifier)
: PluginInfoBarDelegate(identifier),
content_settings_(content_settings),
name_(name) {
}
UnauthorizedPluginInfoBarDelegate::~UnauthorizedPluginInfoBarDelegate() {
content::RecordAction(UserMetricsAction("BlockedPluginInfobar.Closed"));
}
std::string UnauthorizedPluginInfoBarDelegate::GetLearnMoreURL() const {
return chrome::kBlockedPluginLearnMoreURL;
}
base::string16 UnauthorizedPluginInfoBarDelegate::GetMessageText() const {
return l10n_util::GetStringFUTF16(IDS_PLUGIN_NOT_AUTHORIZED, name_);
}
base::string16 UnauthorizedPluginInfoBarDelegate::GetButtonLabel(
InfoBarButton button) const {
return l10n_util::GetStringUTF16((button == BUTTON_OK) ?
IDS_PLUGIN_ENABLE_TEMPORARILY : IDS_PLUGIN_ENABLE_ALWAYS);
}
bool UnauthorizedPluginInfoBarDelegate::Accept() {
content::RecordAction(
UserMetricsAction("BlockedPluginInfobar.AllowThisTime"));
LoadBlockedPlugins();
return true;
}
bool UnauthorizedPluginInfoBarDelegate::Cancel() {
content::RecordAction(UserMetricsAction("BlockedPluginInfobar.AlwaysAllow"));
const GURL& url = InfoBarService::WebContentsFromInfoBar(infobar())->GetURL();
content_settings_->AddExceptionForURL(url, url, CONTENT_SETTINGS_TYPE_PLUGINS,
CONTENT_SETTING_ALLOW);
LoadBlockedPlugins();
return true;
}
void UnauthorizedPluginInfoBarDelegate::InfoBarDismissed() {
content::RecordAction(UserMetricsAction("BlockedPluginInfobar.Dismissed"));
}
bool UnauthorizedPluginInfoBarDelegate::LinkClicked(
WindowOpenDisposition disposition) {
content::RecordAction(UserMetricsAction("BlockedPluginInfobar.LearnMore"));
return PluginInfoBarDelegate::LinkClicked(disposition);
}
#if defined(ENABLE_PLUGIN_INSTALLATION)
// OutdatedPluginInfoBarDelegate ----------------------------------------------
......
......@@ -44,37 +44,6 @@ class PluginInfoBarDelegate : public ConfirmInfoBarDelegate {
DISALLOW_COPY_AND_ASSIGN(PluginInfoBarDelegate);
};
// Infobar that's shown when a plug-in requires user authorization to run.
class UnauthorizedPluginInfoBarDelegate : public PluginInfoBarDelegate {
public:
// Creates an unauthorized plugin infobar and delegate and adds the infobar to
// |infobar_service|.
static void Create(InfoBarService* infobar_service,
HostContentSettingsMap* content_settings,
const base::string16& name,
const std::string& identifier);
private:
UnauthorizedPluginInfoBarDelegate(HostContentSettingsMap* content_settings,
const base::string16& name,
const std::string& identifier);
~UnauthorizedPluginInfoBarDelegate() override;
// PluginInfoBarDelegate:
base::string16 GetMessageText() const override;
base::string16 GetButtonLabel(InfoBarButton button) const override;
bool Accept() override;
bool Cancel() override;
void InfoBarDismissed() override;
bool LinkClicked(WindowOpenDisposition disposition) override;
std::string GetLearnMoreURL() const override;
HostContentSettingsMap* content_settings_;
base::string16 name_;
DISALLOW_COPY_AND_ASSIGN(UnauthorizedPluginInfoBarDelegate);
};
#if defined(ENABLE_PLUGIN_INSTALLATION)
// Infobar that's shown when a plug-in is out of date.
class OutdatedPluginInfoBarDelegate : public PluginInfoBarDelegate,
......
......@@ -335,8 +335,6 @@ bool PluginObserver::OnMessageReceived(
IPC_BEGIN_MESSAGE_MAP(PluginObserver, message)
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_BlockedOutdatedPlugin,
OnBlockedOutdatedPlugin)
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_BlockedUnauthorizedPlugin,
OnBlockedUnauthorizedPlugin)
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_NPAPINotSupported,
OnNPAPINotSupported)
#if defined(ENABLE_PLUGIN_INSTALLATION)
......@@ -367,16 +365,6 @@ bool PluginObserver::OnMessageReceived(const IPC::Message& message) {
return true;
}
void PluginObserver::OnBlockedUnauthorizedPlugin(
const base::string16& name,
const std::string& identifier) {
UnauthorizedPluginInfoBarDelegate::Create(
InfoBarService::FromWebContents(web_contents()),
Profile::FromBrowserContext(web_contents()->GetBrowserContext())->
GetHostContentSettingsMap(),
name, identifier);
}
void PluginObserver::OnBlockedOutdatedPlugin(int placeholder_id,
const std::string& identifier) {
#if defined(ENABLE_PLUGIN_INSTALLATION)
......
......@@ -485,7 +485,6 @@
'browser/notifications/login_state_notification_blocker_chromeos_browsertest.cc',
'browser/notifications/message_center_notifications_browsertest.cc',
'browser/password_manager/password_manager_browsertest.cc',
'browser/plugins/npapi_infobar_browsertest.cc',
'browser/policy/cloud/cloud_policy_browsertest.cc',
'browser/policy/cloud/cloud_policy_manager_browsertest.cc',
'browser/policy/cloud/component_cloud_policy_browsertest.cc',
......@@ -494,7 +493,6 @@
'browser/policy/cloud/test_request_interceptor.h',
'browser/policy/policy_browsertest.cc',
'browser/policy/policy_prefs_browsertest.cc',
'browser/plugins/npapi_infobar_browsertest.cc',
'browser/prefetch/prefetch_browsertest.cc',
'browser/prefs/pref_functional_browsertest.cc',
'browser/prefs/pref_service_browsertest.cc',
......
......@@ -878,19 +878,13 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin(
l10n_util::GetStringFUTF16(IDS_PLUGIN_NOT_AUTHORIZED, group_name),
GURL());
placeholder->set_allow_loading(true);
// Check to see if old infobar should be displayed.
std::string trial_group =
base::FieldTrialList::FindFullName("UnauthorizedPluginInfoBar");
if (plugin.type != content::WebPluginInfo::PLUGIN_TYPE_NPAPI ||
trial_group == "Enabled") {
if (plugin.type != content::WebPluginInfo::PLUGIN_TYPE_NPAPI) {
render_frame->Send(new ChromeViewHostMsg_BlockedUnauthorizedPlugin(
render_frame->GetRoutingID(),
group_name,
identifier));
} else {
// Send IPC for showing blocked plugins page action.
observer->DidBlockContentType(content_type, group_name);
}
observer->DidBlockContentType(content_type, group_name);
break;
}
case ChromeViewHostMsg_GetPluginInfo_Status::kClickToPlay: {
......
......@@ -1266,56 +1266,67 @@ should be able to be added at any place in this file.
<action name="BlockedPluginInfobar.AllowThisTime">
<owner>Please list the metric's owners. Add more owner tags as needed.</owner>
<description>Please enter the description of this user action.</description>
<obsolete>This infobar has been removed.</obsolete>
</action>
<action name="BlockedPluginInfobar.AlwaysAllow">
<owner>Please list the metric's owners. Add more owner tags as needed.</owner>
<description>Please enter the description of this user action.</description>
<obsolete>This infobar has been removed.</obsolete>
</action>
<action name="BlockedPluginInfobar.Closed">
<owner>Please list the metric's owners. Add more owner tags as needed.</owner>
<description>Please enter the description of this user action.</description>
<obsolete>This infobar has been removed.</obsolete>
</action>
<action name="BlockedPluginInfobar.Dismissed">
<owner>Please list the metric's owners. Add more owner tags as needed.</owner>
<description>Please enter the description of this user action.</description>
<obsolete>This infobar has been removed.</obsolete>
</action>
<action name="BlockedPluginInfobar.LearnMore">
<owner>Please list the metric's owners. Add more owner tags as needed.</owner>
<description>Please enter the description of this user action.</description>
<obsolete>This infobar has been removed.</obsolete>
</action>
<action name="BlockedPluginInfobar.Shown">
<owner>Please list the metric's owners. Add more owner tags as needed.</owner>
<description>Please enter the description of this user action.</description>
<obsolete>This infobar has been removed.</obsolete>
</action>
<action name="BlockedPluginInfobar.Shown.Java">
<owner>Please list the metric's owners. Add more owner tags as needed.</owner>
<description>Please enter the description of this user action.</description>
<obsolete>This infobar has been removed.</obsolete>
</action>
<action name="BlockedPluginInfobar.Shown.QuickTime">
<owner>Please list the metric's owners. Add more owner tags as needed.</owner>
<description>Please enter the description of this user action.</description>
<obsolete>This infobar has been removed.</obsolete>
</action>
<action name="BlockedPluginInfobar.Shown.RealPlayer">
<owner>Please list the metric's owners. Add more owner tags as needed.</owner>
<description>Please enter the description of this user action.</description>
<obsolete>This infobar has been removed.</obsolete>
</action>
<action name="BlockedPluginInfobar.Shown.Shockwave">
<owner>Please list the metric's owners. Add more owner tags as needed.</owner>
<description>Please enter the description of this user action.</description>
<obsolete>This infobar has been removed.</obsolete>
</action>
<action name="BlockedPluginInfobar.Shown.WindowsMediaPlayer">
<owner>Please list the metric's owners. Add more owner tags as needed.</owner>
<description>Please enter the description of this user action.</description>
<obsolete>This infobar has been removed.</obsolete>
</action>
<action name="Bold">
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment