Commit 25defaf7 authored by sunil.ratnu's avatar sunil.ratnu Committed by Commit bot

Save password infobar should only work on schemes on which the bubble does

Currently, the password bubble opens up only on "webby" URLs i.e. it
does not work on URLs such as chrome: or file: but the save password
infobar shows up also for the "non-webby" URLs making both the prompts
behave in a different manner. This patch makes the behaviour for both
the prompts consistent.

BUG=393138

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

Cr-Commit-Position: refs/heads/master@{#296701}
parent 01f80ea6
......@@ -10,6 +10,7 @@
#include "base/metrics/histogram.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browsing_data/browsing_data_helper.h"
#include "chrome/browser/password_manager/password_manager_util.h"
#include "chrome/browser/password_manager/password_store_factory.h"
#include "chrome/browser/password_manager/save_password_infobar_delegate.h"
......@@ -150,6 +151,13 @@ void ChromePasswordManagerClient::AutofillResultsComputed() {
void ChromePasswordManagerClient::PromptUserToSavePassword(
scoped_ptr<password_manager::PasswordFormManager> form_to_save) {
// Save password infobar and the password bubble prompts in case of
// "webby" URLs and do not prompt in case of "non-webby" URLS (e.g. file://).
if (!BrowsingDataHelper::IsWebScheme(
web_contents()->GetLastCommittedURL().scheme())) {
return;
}
if (IsTheHotNewBubbleUIEnabled()) {
ManagePasswordsUIController* manage_passwords_ui_controller =
ManagePasswordsUIController::FromWebContents(web_contents());
......
......@@ -7,6 +7,7 @@
#include "base/command_line.h"
#include "base/metrics/histogram_samples.h"
#include "base/metrics/statistics_recorder.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
......@@ -21,6 +22,7 @@
#include "chrome/browser/ui/login/login_prompt_test_utils.h"
#include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/test/base/in_process_browser_test.h"
......@@ -41,6 +43,7 @@
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_utils.h"
#include "net/base/filename_util.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/embedded_test_server/http_request.h"
#include "net/test/embedded_test_server/http_response.h"
......@@ -208,6 +211,14 @@ class BubbleObserver : public PromptObserver {
DISALLOW_COPY_AND_ASSIGN(BubbleObserver);
};
GURL GetFileURL(const char* filename) {
base::FilePath path;
PathService::Get(chrome::DIR_TEST_DATA, &path);
path = path.AppendASCII("password").AppendASCII(filename);
CHECK(base::PathExists(path));
return net::FilePathToFileURL(path);
}
// static
scoped_ptr<PromptObserver> PromptObserver::Create(
content::WebContents* web_contents) {
......@@ -825,6 +836,24 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
EXPECT_FALSE(prompt_observer->IsShowingPrompt());
}
// Test for checking that no prompt is shown for URLs with file: scheme.
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
NoPromptForFileSchemeURLs) {
GURL url = GetFileURL("password_form.html");
ui_test_utils::NavigateToURL(browser(), url);
NavigationObserver observer(WebContents());
scoped_ptr<PromptObserver> prompt_observer(
PromptObserver::Create(WebContents()));
std::string fill_and_submit =
"document.getElementById('username_field').value = 'temp';"
"document.getElementById('password_field').value = 'random';"
"document.getElementById('input_submit_button').click();";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
observer.Wait();
EXPECT_FALSE(prompt_observer->IsShowingPrompt());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, DeleteFrameBeforeSubmit) {
NavigateToFile("/password/multi_frames.html");
......
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