diff options
author | cthomp@chromium.org <cthomp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-20 00:36:30 +0000 |
---|---|---|
committer | cthomp@chromium.org <cthomp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-20 00:36:30 +0000 |
commit | e265e46749c837d5d881a42b1f73142a390ca8b7 (patch) | |
tree | 940d9dba94fb47616c35aa905e02403b5d307abb | |
parent | acfa5be029f1eb15e226f7fe985b8718427680a4 (diff) | |
download | chromium_src-e265e46749c837d5d881a42b1f73142a390ca8b7.zip chromium_src-e265e46749c837d5d881a42b1f73142a390ca8b7.tar.gz chromium_src-e265e46749c837d5d881a42b1f73142a390ca8b7.tar.bz2 |
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
-rw-r--r-- | chrome/browser/chrome_browser_field_trials.cc | 1 | ||||
-rw-r--r-- | chrome/browser/plugins/npapi_infobar_browsertest.cc | 112 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 4 | ||||
-rw-r--r-- | chrome/renderer/chrome_content_renderer_client.cc | 20 |
4 files changed, 130 insertions, 7 deletions
diff --git a/chrome/browser/chrome_browser_field_trials.cc b/chrome/browser/chrome_browser_field_trials.cc index ee74e52..08e7a1c 100644 --- a/chrome/browser/chrome_browser_field_trials.cc +++ b/chrome/browser/chrome_browser_field_trials.cc @@ -61,6 +61,7 @@ void ChromeBrowserFieldTrials::InstantiateDynamicTrials() { // Mark here so they will be sync-ed. base::FieldTrialList::FindValue("CLD1VsCLD2"); base::FieldTrialList::FindValue("MouseEventPreconnect"); + base::FieldTrialList::FindValue("UnauthorizedPluginInfoBar"); // Activate the autocomplete dynamic field trials. OmniboxFieldTrial::ActivateDynamicTrials(); } diff --git a/chrome/browser/plugins/npapi_infobar_browsertest.cc b/chrome/browser/plugins/npapi_infobar_browsertest.cc new file mode 100644 index 0000000..a0dd6ab --- /dev/null +++ b/chrome/browser/plugins/npapi_infobar_browsertest.cc @@ -0,0 +1,112 @@ +// 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 diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 26826f2..3001384 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -76,6 +76,7 @@ 'browser/extensions/window_open_interactive_apitest.cc', 'browser/mouseleave_browsertest.cc', 'browser/notifications/notification_browsertest.cc', + 'browser/plugins/npapi_infobar_browsertest.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.h', @@ -1297,7 +1298,8 @@ 'browser/notifications/message_center_notifications_browsertest.cc', 'browser/notifications/sync_notifier/sync_notifier_test_utils.cc', '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/policy/cloud/cloud_policy_browsertest.cc', 'browser/policy/cloud/cloud_policy_manager_browsertest.cc', diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc index 1cef128..b4f26ca 100644 --- a/chrome/renderer/chrome_content_renderer_client.cc +++ b/chrome/renderer/chrome_content_renderer_client.cc @@ -7,6 +7,7 @@ #include "base/command_line.h" #include "base/debug/crash_logging.h" #include "base/logging.h" +#include "base/metrics/field_trial.h" #include "base/metrics/histogram.h" #include "base/metrics/user_metrics_action.h" #include "base/path_service.h" @@ -810,12 +811,19 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin( IDR_BLOCKED_PLUGIN_HTML, l10n_util::GetStringFUTF16(IDS_PLUGIN_NOT_AUTHORIZED, group_name)); placeholder->set_allow_loading(true); - render_frame->Send(new ChromeViewHostMsg_BlockedUnauthorizedPlugin( - render_frame->GetRoutingID(), - group_name, - identifier)); - // Send IPC for showing content_setting_image/bubble. - observer->DidBlockContentType(content_type); + // 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") { + 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; } case ChromeViewHostMsg_GetPluginInfo_Status::kClickToPlay: { |