Commit 70291900 authored by Trent Apted's avatar Trent Apted Committed by Commit Bot

Update HTTP-Auth to latest Harmony mocks.

With *and without* --secondary-ui-md:
 * Removes the colons from the field labels
 * Alters the text for insecure domains to say "Your connection to this site is not private"
 * Makes the dialog title and "Log in" button text sentence case on non-Mac/iOS
 * Removes " requires a username and password" after the domain for non-Proxy auth requests
 * Removes the insets on the sides of the textfield stack relative to the dialog title.
 * Removes the close button from the http-auth dialog

With --secondary-ui-md only:
 * Uses SECONDARY / gray text for the second line of header text
 * Makes textfields 28px tall

3 general adjustments applicable to a class of dialogs remain to be done:
 * Too much spacing from the title to the body text, and
 * Too little spacing from the last textfield to the button row.
 * Textfields should horizontally align "somehow" we don't know how yet

Adds ui/views/harmony/layout_helper.h to encapsulate methods for creating a
textfield stack in the standard layout.

Bug: 602392
Change-Id: I27fbc52c95d9bd8ac2a3551d916d3f161f51593f
Reviewed-on: https://chromium-review.googlesource.com/559205Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarBret Sepulveda <bsep@chromium.org>
Commit-Queue: Trent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#487030}
parent 0a992857
...@@ -1540,6 +1540,8 @@ split_static_library("ui") { ...@@ -1540,6 +1540,8 @@ split_static_library("ui") {
"views/harmony/harmony_layout_provider.h", "views/harmony/harmony_layout_provider.h",
"views/harmony/harmony_typography_provider.cc", "views/harmony/harmony_typography_provider.cc",
"views/harmony/harmony_typography_provider.h", "views/harmony/harmony_typography_provider.h",
"views/harmony/textfield_layout.cc",
"views/harmony/textfield_layout.h",
"views/importer/import_lock_dialog_view.cc", "views/importer/import_lock_dialog_view.cc",
"views/importer/import_lock_dialog_view.h", "views/importer/import_lock_dialog_view.h",
"views/location_bar/location_bar_bubble_delegate_view.cc", "views/location_bar/location_bar_bubble_delegate_view.cc",
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
#include "build/build_config.h"
#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/password_manager/chrome_password_manager_client.h" #include "chrome/browser/password_manager/chrome_password_manager_client.h"
#include "chrome/browser/prerender/prerender_contents.h" #include "chrome/browser/prerender/prerender_contents.h"
...@@ -507,16 +508,20 @@ void LoginHandler::GetDialogStrings(const GURL& request_url, ...@@ -507,16 +508,20 @@ void LoginHandler::GetDialogStrings(const GURL& request_url,
auth_info.challenger, url_formatter::SchemeDisplay::SHOW)); auth_info.challenger, url_formatter::SchemeDisplay::SHOW));
authority_url = auth_info.challenger.GetURL(); authority_url = auth_info.challenger.GetURL();
} else { } else {
*authority = l10n_util::GetStringFUTF16( *authority = url_formatter::FormatUrlForSecurityDisplay(request_url);
IDS_LOGIN_DIALOG_AUTHORITY, #if defined(OS_ANDROID)
url_formatter::FormatUrlForSecurityDisplay(request_url)); // Android concatenates with a space rather than displaying on two separate
// lines, so it needs some surrounding text.
*authority =
l10n_util::GetStringFUTF16(IDS_LOGIN_DIALOG_AUTHORITY, *authority);
#endif
authority_url = request_url; authority_url = request_url;
} }
if (!content::IsOriginSecure(authority_url)) { if (!content::IsOriginSecure(authority_url)) {
// TODO(asanka): The string should be different for proxies and servers. // TODO(asanka): The string should be different for proxies and servers.
// http://crbug.com/620756 // http://crbug.com/620756
*explanation = l10n_util::GetStringUTF16(IDS_PAGE_INFO_NOT_SECURE_SUMMARY); *explanation = l10n_util::GetStringUTF16(IDS_LOGIN_DIALOG_NOT_PRIVATE);
} else { } else {
explanation->clear(); explanation->clear();
} }
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "chrome/browser/ui/login/login_handler.h" #include "chrome/browser/ui/login/login_handler.h"
#include "net/base/auth.h" #include "net/base/auth.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -16,7 +17,7 @@ namespace { ...@@ -16,7 +17,7 @@ namespace {
const char kHttpUrl[] = "http://example.com/foo/bar"; const char kHttpUrl[] = "http://example.com/foo/bar";
const char kBasicAuthScheme[] = "Basic"; const char kBasicAuthScheme[] = "Basic";
const char kFooRealm[] = "Foo"; const char kFooRealm[] = "Foo";
const char kInsecureProxy[] = "Your connection to this site is not secure"; const char kInsecureProxy[] = "Your connection to this site is not private";
enum TargetType { PROXY, SERVER }; enum TargetType { PROXY, SERVER };
...@@ -37,76 +38,79 @@ const struct TestCase { ...@@ -37,76 +38,79 @@ const struct TestCase {
// Insecure proxy // Insecure proxy
{kHttpUrl, {kHttpUrl,
{PROXY, kBasicAuthScheme, kFooRealm, "http://example.com"}, {PROXY, kBasicAuthScheme, kFooRealm, "http://example.com"},
{"The proxy http://example.com requires a username and password.", {"The proxy http://example.com", kInsecureProxy, "example.com:80/Foo"}},
kInsecureProxy, "example.com:80/Foo"}},
// Insecure proxy on non-standard port // Insecure proxy on non-standard port
{kHttpUrl, {kHttpUrl,
{PROXY, kBasicAuthScheme, kFooRealm, "http://example.com:8009"}, {PROXY, kBasicAuthScheme, kFooRealm, "http://example.com:8009"},
{"The proxy http://example.com:8009 requires a username and password.", {"The proxy http://example.com:8009", kInsecureProxy,
kInsecureProxy, "example.com:8009/Foo"}}, "example.com:8009/Foo"}},
// Secure proxy // Secure proxy
{kHttpUrl, {kHttpUrl,
{PROXY, kBasicAuthScheme, kFooRealm, "https://example.com"}, {PROXY, kBasicAuthScheme, kFooRealm, "https://example.com"},
{"The proxy https://example.com requires a username and password.", "", {"The proxy https://example.com", "", "example.com:443/Foo"}},
"example.com:443/Foo"}},
// Secure proxy on non-standard port // Secure proxy on non-standard port
{kHttpUrl, {kHttpUrl,
{PROXY, kBasicAuthScheme, kFooRealm, "https://example.com:446"}, {PROXY, kBasicAuthScheme, kFooRealm, "https://example.com:446"},
{"The proxy https://example.com:446 requires a username and password.", "", {"The proxy https://example.com:446", "", "example.com:446/Foo"}},
"example.com:446/Foo"}},
// localhost // localhost
{kHttpUrl, {kHttpUrl,
{PROXY, kBasicAuthScheme, kFooRealm, "http://localhost:7323"}, {PROXY, kBasicAuthScheme, kFooRealm, "http://localhost:7323"},
{"The proxy http://localhost:7323 requires a username and password.", "", {"The proxy http://localhost:7323", "", "localhost:7323/Foo"}},
"localhost:7323/Foo"}},
// Secure server // Secure server
{"https://www.nowhere.org/dir/index.html", {"https://www.nowhere.org/dir/index.html",
{SERVER, kBasicAuthScheme, kFooRealm, nullptr}, {SERVER, kBasicAuthScheme, kFooRealm, nullptr},
{"https://www.nowhere.org requires a username and password.", "", {"https://www.nowhere.org", "", "https://www.nowhere.org/Foo"}},
"https://www.nowhere.org/Foo"}},
// URL uses default port. // URL uses default port.
{"https://www.nowhere.org:443/dir/index.html", {"https://www.nowhere.org:443/dir/index.html",
{SERVER, kBasicAuthScheme, kFooRealm, nullptr}, {SERVER, kBasicAuthScheme, kFooRealm, nullptr},
{"https://www.nowhere.org requires a username and password.", "", {"https://www.nowhere.org", "", "https://www.nowhere.org/Foo"}},
"https://www.nowhere.org/Foo"}},
// URL uses non-default port. // URL uses non-default port.
{"https://www.nowhere.org:8443/dir/index.html", {"https://www.nowhere.org:8443/dir/index.html",
{SERVER, kBasicAuthScheme, kFooRealm, nullptr}, {SERVER, kBasicAuthScheme, kFooRealm, nullptr},
{"https://www.nowhere.org:8443 requires a username and password.", "", {"https://www.nowhere.org:8443", "", "https://www.nowhere.org:8443/Foo"}},
"https://www.nowhere.org:8443/Foo"}},
// URL has no trailing slash. // URL has no trailing slash.
{"https://www.nowhere.org", {"https://www.nowhere.org",
{SERVER, kBasicAuthScheme, kFooRealm, nullptr}, {SERVER, kBasicAuthScheme, kFooRealm, nullptr},
{"https://www.nowhere.org requires a username and password.", "", {"https://www.nowhere.org", "", "https://www.nowhere.org/Foo"}},
"https://www.nowhere.org/Foo"}},
// username:password // username:password
{"https://foo:bar@www.nowhere.org/dir/index.html", {"https://foo:bar@www.nowhere.org/dir/index.html",
{SERVER, kBasicAuthScheme, kFooRealm, nullptr}, {SERVER, kBasicAuthScheme, kFooRealm, nullptr},
{"https://www.nowhere.org requires a username and password.", "", {"https://www.nowhere.org", "", "https://www.nowhere.org/Foo"}},
"https://www.nowhere.org/Foo"}},
// query // query
{"https://www.nowhere.org/dir/index.html?id=965362", {"https://www.nowhere.org/dir/index.html?id=965362",
{SERVER, kBasicAuthScheme, kFooRealm, nullptr}, {SERVER, kBasicAuthScheme, kFooRealm, nullptr},
{"https://www.nowhere.org requires a username and password.", "", {"https://www.nowhere.org", "", "https://www.nowhere.org/Foo"}},
"https://www.nowhere.org/Foo"}},
// reference // reference
{"https://www.nowhere.org/dir/index.html#toc", {"https://www.nowhere.org/dir/index.html#toc",
{SERVER, kBasicAuthScheme, kFooRealm, nullptr}, {SERVER, kBasicAuthScheme, kFooRealm, nullptr},
{"https://www.nowhere.org requires a username and password.", "", {"https://www.nowhere.org", "", "https://www.nowhere.org/Foo"}},
"https://www.nowhere.org/Foo"}},
}; };
base::string16 ExpectedAuthority(bool is_proxy, const char* prefix) {
base::string16 str = base::ASCIIToUTF16(prefix);
// Proxies and Android have additional surrounding text. Otherwise, only the
// host URL is shown.
bool extra_text = is_proxy;
#if defined(OS_ANDROID)
extra_text = true;
#endif
if (extra_text)
str += base::ASCIIToUTF16(" requires a username and password.");
return str;
}
} // namespace } // namespace
TEST(LoginHandlerTest, DialogStringsAndRealm) { TEST(LoginHandlerTest, DialogStringsAndRealm) {
...@@ -131,8 +135,9 @@ TEST(LoginHandlerTest, DialogStringsAndRealm) { ...@@ -131,8 +135,9 @@ TEST(LoginHandlerTest, DialogStringsAndRealm) {
LoginHandler::GetDialogStrings(request_url, *auth_info, &authority, LoginHandler::GetDialogStrings(request_url, *auth_info, &authority,
&explanation); &explanation);
EXPECT_STREQ(test_case.expected.authority, EXPECT_EQ(ExpectedAuthority(test_case.auth_info.target_type == PROXY,
base::UTF16ToASCII(authority).c_str()); test_case.expected.authority),
authority);
EXPECT_STREQ(test_case.expected.explanation, EXPECT_STREQ(test_case.expected.explanation,
base::UTF16ToASCII(explanation).c_str()); base::UTF16ToASCII(explanation).c_str());
......
...@@ -4,11 +4,14 @@ ...@@ -4,11 +4,14 @@
#include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h"
#include <algorithm>
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "chrome/browser/ui/views/harmony/chrome_typography.h" #include "chrome/browser/ui/views/harmony/chrome_typography.h"
#include "chrome/browser/ui/views/harmony/harmony_layout_provider.h" #include "chrome/browser/ui/views/harmony/harmony_layout_provider.h"
#include "ui/base/material_design/material_design_controller.h" #include "ui/base/material_design/material_design_controller.h"
#include "ui/gfx/font_list.h"
// static // static
ChromeLayoutProvider* ChromeLayoutProvider::Get() { ChromeLayoutProvider* ChromeLayoutProvider::Get() {
...@@ -23,12 +26,22 @@ ChromeLayoutProvider::CreateLayoutProvider() { ...@@ -23,12 +26,22 @@ ChromeLayoutProvider::CreateLayoutProvider() {
: base::MakeUnique<ChromeLayoutProvider>(); : base::MakeUnique<ChromeLayoutProvider>();
} }
// static
int ChromeLayoutProvider::GetControlHeightForFont(const gfx::FontList& font) {
return std::max(views::style::GetLineHeight(views::style::CONTEXT_LABEL,
views::style::STYLE_PRIMARY),
font.GetHeight()) +
Get()->GetDistanceMetric(DISTANCE_CONTROL_TOTAL_VERTICAL_TEXT_PADDING);
}
int ChromeLayoutProvider::GetDistanceMetric(int metric) const { int ChromeLayoutProvider::GetDistanceMetric(int metric) const {
switch (metric) { switch (metric) {
case DISTANCE_BUTTON_MINIMUM_WIDTH: case DISTANCE_BUTTON_MINIMUM_WIDTH:
return 48; return 48;
case DISTANCE_CONTROL_LIST_VERTICAL: case DISTANCE_CONTROL_LIST_VERTICAL:
return GetDistanceMetric(views::DISTANCE_UNRELATED_CONTROL_VERTICAL); return GetDistanceMetric(views::DISTANCE_UNRELATED_CONTROL_VERTICAL);
case DISTANCE_CONTROL_TOTAL_VERTICAL_TEXT_PADDING:
return 6;
case DISTANCE_RELATED_CONTROL_HORIZONTAL_SMALL: case DISTANCE_RELATED_CONTROL_HORIZONTAL_SMALL:
return 8; return 8;
case DISTANCE_RELATED_CONTROL_VERTICAL_SMALL: case DISTANCE_RELATED_CONTROL_VERTICAL_SMALL:
......
...@@ -17,6 +17,8 @@ enum ChromeDistanceMetric { ...@@ -17,6 +17,8 @@ enum ChromeDistanceMetric {
DISTANCE_BUTTON_MINIMUM_WIDTH = views::VIEWS_DISTANCE_END, DISTANCE_BUTTON_MINIMUM_WIDTH = views::VIEWS_DISTANCE_END,
// Vertical spacing between a list of multiple controls in one column. // Vertical spacing between a list of multiple controls in one column.
DISTANCE_CONTROL_LIST_VERTICAL, DISTANCE_CONTROL_LIST_VERTICAL,
// The combined vertical padding applied to text in a control.
DISTANCE_CONTROL_TOTAL_VERTICAL_TEXT_PADDING,
// Smaller horizontal spacing between other controls that are logically // Smaller horizontal spacing between other controls that are logically
// related. // related.
DISTANCE_RELATED_CONTROL_HORIZONTAL_SMALL, DISTANCE_RELATED_CONTROL_HORIZONTAL_SMALL,
...@@ -47,6 +49,10 @@ class ChromeLayoutProvider : public views::LayoutProvider { ...@@ -47,6 +49,10 @@ class ChromeLayoutProvider : public views::LayoutProvider {
static ChromeLayoutProvider* Get(); static ChromeLayoutProvider* Get();
static std::unique_ptr<views::LayoutProvider> CreateLayoutProvider(); static std::unique_ptr<views::LayoutProvider> CreateLayoutProvider();
// Calculates the control height based on the |font|'s reported glyph height,
// the default line spacing and DISTANCE_CONTROL_TOTAL_VERTICAL_TEXT_PADDING.
static int GetControlHeightForFont(const gfx::FontList& font);
// views::LayoutProvider: // views::LayoutProvider:
int GetDistanceMetric(int metric) const override; int GetDistanceMetric(int metric) const override;
const views::TypographyProvider& GetTypographyProvider() const override; const views::TypographyProvider& GetTypographyProvider() const override;
......
...@@ -36,6 +36,8 @@ int HarmonyLayoutProvider::GetDistanceMetric(int metric) const { ...@@ -36,6 +36,8 @@ int HarmonyLayoutProvider::GetDistanceMetric(int metric) const {
// margin we need to subtract out the padding. // margin we need to subtract out the padding.
return kVisibleMargin - kHarmonyLayoutUnit / 4; return kVisibleMargin - kHarmonyLayoutUnit / 4;
} }
case DISTANCE_CONTROL_TOTAL_VERTICAL_TEXT_PADDING:
return kHarmonyLayoutUnit / 2;
case views::DISTANCE_RELATED_BUTTON_HORIZONTAL: case views::DISTANCE_RELATED_BUTTON_HORIZONTAL:
return kHarmonyLayoutUnit / 2; return kHarmonyLayoutUnit / 2;
case views::DISTANCE_RELATED_CONTROL_HORIZONTAL: case views::DISTANCE_RELATED_CONTROL_HORIZONTAL:
......
// Copyright 2017 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/browser/ui/views/harmony/textfield_layout.h"
#include "chrome/browser/ui/views/harmony/chrome_layout_provider.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/layout/grid_layout.h"
using views::GridLayout;
namespace {
// GridLayout "resize percent" constants.
constexpr float kFixed = 0.f;
constexpr float kStretchy = 1.f;
} // namespace
views::ColumnSet* ConfigureTextfieldStack(GridLayout* layout,
int column_set_id) {
ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
const int between_padding =
provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_HORIZONTAL);
views::ColumnSet* column_set = layout->AddColumnSet(column_set_id);
column_set->AddColumn(provider->GetControlLabelGridAlignment(),
GridLayout::CENTER, kFixed, GridLayout::USE_PREF, 0, 0);
// TODO(tapted): This column may need some additional alignment logic under
// Harmony so that its x-offset is not wholly dictated by the string length
// of labels in the first column.
column_set->AddPaddingColumn(kFixed, between_padding);
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, kStretchy,
GridLayout::USE_PREF, 0, 0);
return column_set;
}
views::Textfield* AddFirstTextfieldRow(GridLayout* layout,
const base::string16& label_text,
int column_set_id) {
views::Textfield* textfield = new views::Textfield();
layout->StartRow(
kFixed, column_set_id,
ChromeLayoutProvider::GetControlHeightForFont(textfield->GetFontList()));
views::Label* label = new views::Label(
label_text, views::style::CONTEXT_LABEL, views::style::STYLE_PRIMARY);
textfield->SetAccessibleName(label_text);
layout->AddView(label);
layout->AddView(textfield);
return textfield;
}
views::Textfield* AddTextfieldRow(GridLayout* layout,
const base::string16& label,
int column_set_id) {
layout->AddPaddingRow(kFixed, ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_CONTROL_LIST_VERTICAL));
return AddFirstTextfieldRow(layout, label, column_set_id);
}
// Copyright 2017 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_BROWSER_UI_VIEWS_HARMONY_TEXTFIELD_LAYOUT_H_
#define CHROME_BROWSER_UI_VIEWS_HARMONY_TEXTFIELD_LAYOUT_H_
#include "base/strings/string16.h"
namespace views {
class ColumnSet;
class GridLayout;
class Textfield;
} // namespace views
// Configures a three-column ColumnSet for the standard textfield stack layout
// with: {Label, Padding, Textfield}.
views::ColumnSet* ConfigureTextfieldStack(views::GridLayout* layout,
int column_set_id);
// Adds a views::Label and Textfield to |column_set_id| in |layout|, which has
// been configured as a Textfield stack. The returned Textfield will be owned by
// the View hosting |layout|.
views::Textfield* AddFirstTextfieldRow(views::GridLayout* layout,
const base::string16& label,
int column_set_id);
views::Textfield* AddTextfieldRow(views::GridLayout* layout,
const base::string16& label,
int column_set_id);
#endif // CHROME_BROWSER_UI_VIEWS_HARMONY_TEXTFIELD_LAYOUT_H_
...@@ -46,6 +46,8 @@ class LoginHandlerViews : public LoginHandler, public views::DialogDelegate { ...@@ -46,6 +46,8 @@ class LoginHandlerViews : public LoginHandler, public views::DialogDelegate {
void OnLoginModelDestroying() override {} void OnLoginModelDestroying() override {}
// views::DialogDelegate: // views::DialogDelegate:
bool ShouldShowCloseButton() const override { return false; }
base::string16 GetDialogButtonLabel(ui::DialogButton button) const override { base::string16 GetDialogButtonLabel(ui::DialogButton button) const override {
if (button == ui::DIALOG_BUTTON_OK) if (button == ui::DIALOG_BUTTON_OK)
return l10n_util::GetStringUTF16(IDS_LOGIN_DIALOG_OK_BUTTON_LABEL); return l10n_util::GetStringUTF16(IDS_LOGIN_DIALOG_OK_BUTTON_LABEL);
......
...@@ -5,96 +5,73 @@ ...@@ -5,96 +5,73 @@
#include "chrome/browser/ui/views/login_view.h" #include "chrome/browser/ui/views/login_view.h"
#include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h"
#include "chrome/browser/ui/views/harmony/chrome_typography.h"
#include "chrome/browser/ui/views/harmony/textfield_layout.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/views/controls/label.h" #include "ui/views/controls/label.h"
#include "ui/views/controls/textfield/textfield.h" #include "ui/views/controls/textfield/textfield.h"
#include "ui/views/layout/grid_layout.h" #include "ui/views/layout/grid_layout.h"
static const int kMessageWidth = 320;
static const int kTextfieldStackHorizontalSpacing = 30;
using password_manager::LoginModel;
using views::GridLayout; using views::GridLayout;
namespace {
constexpr int kHeaderColumnSetId = 0;
constexpr int kFieldsColumnSetId = 1;
constexpr float kFixed = 0.f;
constexpr float kStretchy = 1.f;
// Adds a row to |layout| and puts a Label in it.
void AddHeaderLabel(GridLayout* layout,
const base::string16& text,
int text_style) {
views::Label* label =
new views::Label(text, views::style::CONTEXT_LABEL, text_style);
label->SetMultiLine(true);
label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
label->SetAllowCharacterBreak(true);
layout->StartRow(kFixed, kHeaderColumnSetId);
layout->AddView(label);
}
} // namespace
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// LoginView, public: // LoginView, public:
LoginView::LoginView(const base::string16& authority, LoginView::LoginView(const base::string16& authority,
const base::string16& explanation, const base::string16& explanation,
LoginHandler::LoginModelData* login_model_data) LoginHandler::LoginModelData* login_model_data)
: username_field_(new views::Textfield()), : login_model_(login_model_data ? login_model_data->model : nullptr) {
password_field_(new views::Textfield()), // TODO(tapted): When Harmony is default, this should be removed and left up
username_label_(new views::Label( // to textfield_layout.h to decide.
l10n_util::GetStringUTF16(IDS_LOGIN_DIALOG_USERNAME_FIELD))), constexpr int kMessageWidth = 320;
password_label_(new views::Label(
l10n_util::GetStringUTF16(IDS_LOGIN_DIALOG_PASSWORD_FIELD))),
authority_label_(new views::Label(authority)),
message_label_(nullptr),
login_model_(login_model_data ? login_model_data->model : nullptr) {
ChromeLayoutProvider* provider = ChromeLayoutProvider::Get(); ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
password_field_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
authority_label_->SetMultiLine(true);
authority_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
authority_label_->SetAllowCharacterBreak(true);
// Initialize the Grid Layout Manager used for this dialog box. // Initialize the Grid Layout Manager used for this dialog box.
GridLayout* layout = GridLayout::CreatePanel(this); GridLayout* layout = GridLayout::CreatePanel(this);
views::ColumnSet* column_set = layout->AddColumnSet(kHeaderColumnSetId);
// Add the column set for the information message at the top of the dialog column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, kStretchy,
// box.
const int single_column_view_set_id = 0;
views::ColumnSet* column_set =
layout->AddColumnSet(single_column_view_set_id);
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
GridLayout::FIXED, kMessageWidth, 0); GridLayout::FIXED, kMessageWidth, 0);
AddHeaderLabel(layout, authority, views::style::STYLE_PRIMARY);
// Add the column set for the user name and password fields and labels. AddHeaderLabel(layout, explanation, STYLE_SECONDARY);
const int labels_column_set_id = 1; layout->AddPaddingRow(kFixed, provider->GetDistanceMetric(
column_set = layout->AddColumnSet(labels_column_set_id); DISTANCE_UNRELATED_CONTROL_VERTICAL_LARGE));
if (provider->UseExtraDialogPadding())
column_set->AddPaddingColumn(0, kTextfieldStackHorizontalSpacing); ConfigureTextfieldStack(layout, kFieldsColumnSetId);
column_set->AddColumn(provider->GetControlLabelGridAlignment(), username_field_ = AddFirstTextfieldRow(
GridLayout::CENTER, 0, GridLayout::USE_PREF, 0, 0); layout, l10n_util::GetStringUTF16(IDS_LOGIN_DIALOG_USERNAME_FIELD),
column_set->AddPaddingColumn( kFieldsColumnSetId);
0, password_field_ = AddTextfieldRow(
provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_HORIZONTAL)); layout, l10n_util::GetStringUTF16(IDS_LOGIN_DIALOG_PASSWORD_FIELD),
column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1, kFieldsColumnSetId);
GridLayout::USE_PREF, 0, 0); password_field_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
if (provider->UseExtraDialogPadding())
column_set->AddPaddingColumn(0, kTextfieldStackHorizontalSpacing);
layout->StartRow(0, single_column_view_set_id);
layout->AddView(authority_label_);
if (!explanation.empty()) {
message_label_ = new views::Label(explanation);
message_label_->SetMultiLine(true);
message_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
message_label_->SetAllowCharacterBreak(true);
layout->AddPaddingRow(0, provider->GetDistanceMetric(
views::DISTANCE_RELATED_CONTROL_VERTICAL));
layout->StartRow(0, single_column_view_set_id);
layout->AddView(message_label_);
}
layout->AddPaddingRow(0, provider->GetDistanceMetric(
DISTANCE_UNRELATED_CONTROL_VERTICAL_LARGE));
layout->StartRow(0, labels_column_set_id);
layout->AddView(username_label_);
layout->AddView(username_field_);
layout->AddPaddingRow(
0, provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL));
layout->StartRow(0, labels_column_set_id);
layout->AddView(password_label_);
layout->AddView(password_field_);
if (provider->UseExtraDialogPadding()) { if (provider->UseExtraDialogPadding()) {
layout->AddPaddingRow(0, provider->GetDistanceMetric( layout->AddPaddingRow(kFixed,
views::DISTANCE_UNRELATED_CONTROL_VERTICAL)); provider->GetDistanceMetric(
views::DISTANCE_UNRELATED_CONTROL_VERTICAL));
} }
if (login_model_data) { if (login_model_data) {
......
...@@ -5,15 +5,13 @@ ...@@ -5,15 +5,13 @@
#ifndef CHROME_BROWSER_UI_VIEWS_LOGIN_VIEW_H_ #ifndef CHROME_BROWSER_UI_VIEWS_LOGIN_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_LOGIN_VIEW_H_ #define CHROME_BROWSER_UI_VIEWS_LOGIN_VIEW_H_
#include "base/compiler_specific.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/strings/string16.h"
#include "chrome/browser/ui/login/login_handler.h" #include "chrome/browser/ui/login/login_handler.h"
#include "components/autofill/core/common/password_form.h"
#include "components/password_manager/core/browser/login_model.h" #include "components/password_manager/core/browser/login_model.h"
#include "ui/views/view.h" #include "ui/views/view.h"
namespace views { namespace views {
class Label;
class Textfield; class Textfield;
} }
...@@ -39,7 +37,7 @@ class LoginView : public views::View, ...@@ -39,7 +37,7 @@ class LoginView : public views::View,
const base::string16& password) override; const base::string16& password) override;
void OnLoginModelDestroying() override; void OnLoginModelDestroying() override;
// Used by LoginHandlerWin to set the initial focus. // Used by LoginHandlerViews to set the initial focus.
views::View* GetInitiallyFocusedView(); views::View* GetInitiallyFocusedView();
private: private:
...@@ -50,14 +48,6 @@ class LoginView : public views::View, ...@@ -50,14 +48,6 @@ class LoginView : public views::View,
views::Textfield* username_field_; views::Textfield* username_field_;
views::Textfield* password_field_; views::Textfield* password_field_;
// Button labels
views::Label* username_label_;
views::Label* password_label_;
// Authority and security state messages.
views::Label* authority_label_;
views::Label* message_label_;
// If not null, points to a model we need to notify of our own destruction // If not null, points to a model we need to notify of our own destruction
// so it doesn't try and access this when its too late. // so it doesn't try and access this when its too late.
password_manager::LoginModel* login_model_; password_manager::LoginModel* login_model_;
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<grit-part> <grit-part>
<message name="IDS_LOGIN_DIALOG_TITLE" desc="String to be displayed in the title bar of the login prompt dialog" formatter_data="android_java"> <if expr="use_titlecase">
Authentication Required <message name="IDS_LOGIN_DIALOG_TITLE" desc="In title case: String to be displayed in the title bar of the login prompt dialog" formatter_data="android_java">
</message> Authentication Required
</message>
<message name="IDS_LOGIN_DIALOG_OK_BUTTON_LABEL" desc="In title case: The label of the 'Log In' button on the login prompt dialog" formatter_data="android_java">
Log In
</message>
</if>
<if expr="not use_titlecase">
<message name="IDS_LOGIN_DIALOG_TITLE" desc="In sentence case: String to be displayed in the title bar of the login prompt dialog" formatter_data="android_java">
Authentication required
</message>
<message name="IDS_LOGIN_DIALOG_OK_BUTTON_LABEL" desc="In sentence case: The label of the 'Log in' button on the login prompt dialog" formatter_data="android_java">
Log in
</message>
</if>
<message name="IDS_LOGIN_DIALOG_AUTHORITY" desc="String to be displayed in the login prompt dialog to explain that the user needs to log in, and the name of the web site"> <message name="IDS_LOGIN_DIALOG_AUTHORITY" desc="String to be displayed in the login prompt dialog to explain that the user needs to log in, and the name of the web site">
<ph name="DOMAIN">$1<ex>google.com</ex></ph> requires a username and password. <ph name="DOMAIN">$1<ex>google.com</ex></ph> requires a username and password.
</message> </message>
<message name="IDS_LOGIN_DIALOG_PROXY_AUTHORITY" desc="String to be displayed in the proxy login prompt dialog to explain that the user needs to log in, and the name of the proxy"> <message name="IDS_LOGIN_DIALOG_PROXY_AUTHORITY" desc="String to be displayed in the proxy login prompt dialog to explain that the user needs to log in, and the name of the proxy">
The proxy <ph name="DOMAIN">$1<ex>google.com</ex></ph> requires a username and password. The proxy <ph name="DOMAIN">$1<ex>google.com</ex></ph> requires a username and password.
</message> </message>
<message name="IDS_LOGIN_DIALOG_NOT_PRIVATE" desc="A phrase displayed on login dialogs if the connection to the current website is not private.">
Your connection to this site is not private
</message>
<message name="IDS_LOGIN_DIALOG_USERNAME_FIELD" desc="The label of the username field in the login prompt dialog" formatter_data="android_java"> <message name="IDS_LOGIN_DIALOG_USERNAME_FIELD" desc="The label of the username field in the login prompt dialog" formatter_data="android_java">
User Name: Username
</message> </message>
<message name="IDS_LOGIN_DIALOG_PASSWORD_FIELD" desc="The label of the password field in the login prompt dialog" formatter_data="android_java"> <message name="IDS_LOGIN_DIALOG_PASSWORD_FIELD" desc="The label of the password field in the login prompt dialog" formatter_data="android_java">
Password: Password
</message>
<message name="IDS_LOGIN_DIALOG_OK_BUTTON_LABEL" desc="The label of the 'Log In' button on the login prompt dialog" formatter_data="android_java">
Log In
</message> </message>
</grit-part> </grit-part>
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<message name="IDS_PAGE_INFO_MIXED_CONTENT_SUMMARY" desc="A one-line summary at the top of the Page Info bubble (which shows when you click the security indicator) if the connection to the current website is using mainly using a secure connection but has some insecure parts (like insecurely loaded images)."> <message name="IDS_PAGE_INFO_MIXED_CONTENT_SUMMARY" desc="A one-line summary at the top of the Page Info bubble (which shows when you click the security indicator) if the connection to the current website is using mainly using a secure connection but has some insecure parts (like insecurely loaded images).">
Your connection to this site is not fully secure Your connection to this site is not fully secure
</message> </message>
<message name="IDS_PAGE_INFO_NOT_SECURE_SUMMARY" desc="A one-line summary at the top of the Page Info bubble (which shows when you click the security indicator) if the connection to the current website is secure."> <message name="IDS_PAGE_INFO_NOT_SECURE_SUMMARY" desc="A one-line summary at the top of the Page Info bubble (which shows when you click the security indicator) if the connection to the current website is not secure.">
Your connection to this site is not secure Your connection to this site is not secure
</message> </message>
<message name="IDS_PAGE_INFO_MALWARE_SUMMARY" desc="A one-line summary at the top of the Page Info bubble (which shows when you click the security indicator) if the current website has been flagged as containing malware."> <message name="IDS_PAGE_INFO_MALWARE_SUMMARY" desc="A one-line summary at the top of the Page Info bubble (which shows when you click the security indicator) if the current website has been flagged as containing malware.">
......
...@@ -220,6 +220,10 @@ void MdTextButton::UpdatePadding() { ...@@ -220,6 +220,10 @@ void MdTextButton::UpdatePadding() {
label()->font_list().GetFontSize() - label()->font_list().GetFontSize() -
style::GetFont(style::CONTEXT_BUTTON_MD, style::STYLE_PRIMARY) style::GetFont(style::CONTEXT_BUTTON_MD, style::STYLE_PRIMARY)
.GetFontSize(); .GetFontSize();
// TODO(tapted): This should get |target_height| using LayoutProvider::
// GetControlHeightForFont(). It can't because that only returns a correct
// result with --secondary-ui-md, and MdTextButtons appear in top chrome
// without that.
const int kBaseHeight = 28; const int kBaseHeight = 28;
int target_height = std::max(kBaseHeight + size_delta * 2, int target_height = std::max(kBaseHeight + size_delta * 2,
label()->font_list().GetFontSize() * 2); label()->font_list().GetFontSize() * 2);
......
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