Commit e265e467 authored by cthomp@chromium.org's avatar cthomp@chromium.org

Removed NPAPI plugin infobar, with Finch trial gate (disabled by default).

This change is related to the new plugin page action UI https://codereview.chromium.org/319553008/

BUG=307323

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278549 0039d316-1c4b-4281-b951-d872f2087c98
parent acfa5be0
...@@ -61,6 +61,7 @@ void ChromeBrowserFieldTrials::InstantiateDynamicTrials() { ...@@ -61,6 +61,7 @@ void ChromeBrowserFieldTrials::InstantiateDynamicTrials() {
// Mark here so they will be sync-ed. // Mark here so they will be sync-ed.
base::FieldTrialList::FindValue("CLD1VsCLD2"); base::FieldTrialList::FindValue("CLD1VsCLD2");
base::FieldTrialList::FindValue("MouseEventPreconnect"); base::FieldTrialList::FindValue("MouseEventPreconnect");
base::FieldTrialList::FindValue("UnauthorizedPluginInfoBar");
// Activate the autocomplete dynamic field trials. // Activate the autocomplete dynamic field trials.
OmniboxFieldTrial::ActivateDynamicTrials(); OmniboxFieldTrial::ActivateDynamicTrials();
} }
// 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/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 "content/test/net/url_request_mock_http_job.h"
#include "url/gurl.h"
using content::BrowserThread;
using content::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),
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
...@@ -76,6 +76,7 @@ ...@@ -76,6 +76,7 @@
'browser/extensions/window_open_interactive_apitest.cc', 'browser/extensions/window_open_interactive_apitest.cc',
'browser/mouseleave_browsertest.cc', 'browser/mouseleave_browsertest.cc',
'browser/notifications/notification_browsertest.cc', 'browser/notifications/notification_browsertest.cc',
'browser/plugins/npapi_infobar_browsertest.cc',
'browser/password_manager/password_generation_interactive_uitest.cc', 'browser/password_manager/password_generation_interactive_uitest.cc',
'browser/renderer_context_menu/render_view_context_menu_browsertest_util.cc', 'browser/renderer_context_menu/render_view_context_menu_browsertest_util.cc',
'browser/renderer_context_menu/render_view_context_menu_browsertest_util.h', 'browser/renderer_context_menu/render_view_context_menu_browsertest_util.h',
...@@ -1297,7 +1298,8 @@ ...@@ -1297,7 +1298,8 @@
'browser/notifications/message_center_notifications_browsertest.cc', 'browser/notifications/message_center_notifications_browsertest.cc',
'browser/notifications/sync_notifier/sync_notifier_test_utils.cc', 'browser/notifications/sync_notifier/sync_notifier_test_utils.cc',
'browser/notifications/sync_notifier/sync_notifier_test_utils.h', 'browser/notifications/sync_notifier/sync_notifier_test_utils.h',
'browser/password_manager/password_manager_browsertest.cc', 'browser/plugins/npapi_infobar_browsertest.cc',
'browser/password_manager/password_manager_browsertest.cc',
'browser/performance_monitor/performance_monitor_browsertest.cc', 'browser/performance_monitor/performance_monitor_browsertest.cc',
'browser/policy/cloud/cloud_policy_browsertest.cc', 'browser/policy/cloud/cloud_policy_browsertest.cc',
'browser/policy/cloud/cloud_policy_manager_browsertest.cc', 'browser/policy/cloud/cloud_policy_manager_browsertest.cc',
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/debug/crash_logging.h" #include "base/debug/crash_logging.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/histogram.h" #include "base/metrics/histogram.h"
#include "base/metrics/user_metrics_action.h" #include "base/metrics/user_metrics_action.h"
#include "base/path_service.h" #include "base/path_service.h"
...@@ -810,12 +811,19 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin( ...@@ -810,12 +811,19 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin(
IDR_BLOCKED_PLUGIN_HTML, IDR_BLOCKED_PLUGIN_HTML,
l10n_util::GetStringFUTF16(IDS_PLUGIN_NOT_AUTHORIZED, group_name)); l10n_util::GetStringFUTF16(IDS_PLUGIN_NOT_AUTHORIZED, group_name));
placeholder->set_allow_loading(true); placeholder->set_allow_loading(true);
render_frame->Send(new ChromeViewHostMsg_BlockedUnauthorizedPlugin( // Check to see if old infobar should be displayed.
render_frame->GetRoutingID(), std::string trial_group =
group_name, base::FieldTrialList::FindFullName("UnauthorizedPluginInfoBar");
identifier)); if (plugin.type != content::WebPluginInfo::PLUGIN_TYPE_NPAPI ||
// Send IPC for showing content_setting_image/bubble. trial_group == "Enabled") {
observer->DidBlockContentType(content_type); 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);
}
break; break;
} }
case ChromeViewHostMsg_GetPluginInfo_Status::kClickToPlay: { case ChromeViewHostMsg_GetPluginInfo_Status::kClickToPlay: {
......
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