summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-11 14:03:45 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-11 14:03:45 +0000
commit73704c8719ee45cbf0a92c16d2450952799dccac (patch)
tree6a322da6aa6bb914863f8145f1af21c9f10da796
parent519af5947d9c4c3535863b330c3c6623715c1ffc (diff)
downloadchromium_src-73704c8719ee45cbf0a92c16d2450952799dccac.zip
chromium_src-73704c8719ee45cbf0a92c16d2450952799dccac.tar.gz
chromium_src-73704c8719ee45cbf0a92c16d2450952799dccac.tar.bz2
Splits out the LoginModel into a separate class so that we other
platforms aren't including views. BUG=none TEST=none Review URL: http://codereview.chromium.org/164269 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23019 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/login_model.h28
-rw-r--r--chrome/browser/login_prompt_win.cc1
-rw-r--r--chrome/browser/password_manager/password_manager.h8
-rw-r--r--chrome/browser/views/login_view.cc21
-rw-r--r--chrome/browser/views/login_view.h44
-rw-r--r--chrome/chrome.gyp1
6 files changed, 57 insertions, 46 deletions
diff --git a/chrome/browser/login_model.h b/chrome/browser/login_model.h
new file mode 100644
index 0000000..cbd2fef
--- /dev/null
+++ b/chrome/browser/login_model.h
@@ -0,0 +1,28 @@
+// Copyright (c) 2009 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_LOGIN_MODEL_H_
+#define CHROME_BROWSER_LOGIN_MODEL_H_
+
+#include <string>
+
+// Simple Model & Observer interfaces for a LoginView to facilitate exchanging
+// information.
+class LoginModelObserver {
+ public:
+ // Called by the model when a username,password pair has been identified
+ // as a match for the pending login prompt.
+ virtual void OnAutofillDataAvailable(const std::wstring& username,
+ const std::wstring& password) = 0;
+};
+
+class LoginModel {
+ public:
+ // Set the observer interested in the data from the model.
+ // observer can be null, signifying there is no longer any observer
+ // interested in the data.
+ virtual void SetObserver(LoginModelObserver* observer) = 0;
+};
+
+#endif // CHROME_BROWSER_LOGIN_MODEL_H_
diff --git a/chrome/browser/login_prompt_win.cc b/chrome/browser/login_prompt_win.cc
index 463bb7d..b3da33a 100644
--- a/chrome/browser/login_prompt_win.cc
+++ b/chrome/browser/login_prompt_win.cc
@@ -17,7 +17,6 @@
#include "net/url_request/url_request.h"
#include "views/window/dialog_delegate.h"
-using views::LoginView;
using webkit_glue::PasswordForm;
// ----------------------------------------------------------------------------
diff --git a/chrome/browser/password_manager/password_manager.h b/chrome/browser/password_manager/password_manager.h
index 5487da3..085366f 100644
--- a/chrome/browser/password_manager/password_manager.h
+++ b/chrome/browser/password_manager/password_manager.h
@@ -7,8 +7,8 @@
#include "base/scoped_ptr.h"
#include "base/stl_util-inl.h"
+#include "chrome/browser/login_model.h"
#include "chrome/browser/tab_contents/infobar_delegate.h"
-#include "chrome/browser/views/login_view.h"
#include "chrome/common/pref_member.h"
#include "webkit/glue/password_form.h"
#include "webkit/glue/password_form_dom_manager.h"
@@ -21,7 +21,7 @@ class TabContents;
// receiving password form data from the renderer and managing the password
// database through the WebDataService. The PasswordManager is a LoginModel
// for purposes of supporting HTTP authentication dialogs.
-class PasswordManager : public views::LoginModel {
+class PasswordManager : public LoginModel {
public:
static void RegisterUserPrefs(PrefService* prefs);
@@ -55,7 +55,7 @@ class PasswordManager : public views::LoginModel {
void ClearProvisionalSave();
// LoginModel implementation.
- virtual void SetObserver(views::LoginModelObserver* observer) {
+ virtual void SetObserver(LoginModelObserver* observer) {
observer_ = observer;
}
@@ -92,7 +92,7 @@ class PasswordManager : public views::LoginModel {
TabContents* tab_contents_;
// The LoginModelObserver (i.e LoginView) requiring autofill.
- views::LoginModelObserver* observer_;
+ LoginModelObserver* observer_;
// Set to false to disable the password manager (will no longer fill
// passwords or ask you if you want to save passwords).
diff --git a/chrome/browser/views/login_view.cc b/chrome/browser/views/login_view.cc
index 2cc7ba6..0476892 100644
--- a/chrome/browser/views/login_view.cc
+++ b/chrome/browser/views/login_view.cc
@@ -16,26 +16,26 @@
#include "views/standard_layout.h"
#include "views/widget/root_view.h"
-namespace views {
-
static const int kMessageWidth = 320;
static const int kTextfieldStackHorizontalSpacing = 30;
+using views::GridLayout;
+
///////////////////////////////////////////////////////////////////////////////
// LoginView, public:
LoginView::LoginView(const std::wstring& explanation)
- : username_field_(new Textfield),
- password_field_(new Textfield(Textfield::STYLE_PASSWORD)),
- username_label_(new Label(
+ : username_field_(new views::Textfield),
+ password_field_(new views::Textfield(views::Textfield::STYLE_PASSWORD)),
+ username_label_(new views::Label(
l10n_util::GetString(IDS_LOGIN_DIALOG_USERNAME_FIELD))),
- password_label_(new Label(
+ password_label_(new views::Label(
l10n_util::GetString(IDS_LOGIN_DIALOG_PASSWORD_FIELD))),
- message_label_(new Label(explanation)),
+ message_label_(new views::Label(explanation)),
ALLOW_THIS_IN_INITIALIZER_LIST(focus_grabber_factory_(this)),
login_model_(NULL) {
message_label_->SetMultiLine(true);
- message_label_->SetHorizontalAlignment(Label::ALIGN_LEFT);
+ message_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
// Initialize the Grid Layout Manager used for this dialog box.
GridLayout* layout = CreatePanelGridLayout(this);
@@ -44,7 +44,8 @@ LoginView::LoginView(const std::wstring& explanation)
// Add the column set for the information message at the top of the dialog
// box.
const int single_column_view_set_id = 0;
- ColumnSet* column_set = layout->AddColumnSet(single_column_view_set_id);
+ views::ColumnSet* column_set =
+ layout->AddColumnSet(single_column_view_set_id);
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
GridLayout::FIXED, kMessageWidth, 0);
@@ -120,5 +121,3 @@ void LoginView::OnAutofillDataAvailable(const std::wstring& username,
void LoginView::FocusFirstField() {
username_field_->RequestFocus();
}
-
-} // namespace
diff --git a/chrome/browser/views/login_view.h b/chrome/browser/views/login_view.h
index b5868b1..e5b7d20 100644
--- a/chrome/browser/views/login_view.h
+++ b/chrome/browser/views/login_view.h
@@ -2,38 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_VIEWS_LOGIN_VIEW_H__
-#define CHROME_BROWSER_VIEWS_LOGIN_VIEW_H__
+#ifndef CHROME_BROWSER_VIEWS_LOGIN_VIEW_H_
+#define CHROME_BROWSER_VIEWS_LOGIN_VIEW_H_
#include "base/task.h"
+#include "chrome/browser/login_model.h"
#include "views/view.h"
namespace views {
class Label;
class Textfield;
class LoginModel;
-
-// Simple Model & Observer interfaces for a LoginView to facilitate exchanging
-// information.
-class LoginModelObserver {
- public:
- // Called by the model when a username,password pair has been identified
- // as a match for the pending login prompt.
- virtual void OnAutofillDataAvailable(const std::wstring& username,
- const std::wstring& password) = 0;
-};
-
-class LoginModel {
- public:
- // Set the observer interested in the data from the model.
- // observer can be null, signifying there is no longer any observer
- // interested in the data.
- virtual void SetObserver(LoginModelObserver* observer) = 0;
-};
+} // namespace views
// This class is responsible for displaying the contents of a login window
// for HTTP/FTP authentication.
-class LoginView : public View, public LoginModelObserver {
+class LoginView : public views::View, public LoginModelObserver {
public:
explicit LoginView(const std::wstring& explanation);
virtual ~LoginView();
@@ -54,21 +38,22 @@ class LoginView : public View, public LoginModelObserver {
protected:
// views::View overrides:
- virtual void ViewHierarchyChanged(bool is_add, View *parent, View *child);
+ virtual void ViewHierarchyChanged(bool is_add, views::View *parent,
+ views::View *child);
private:
void FocusFirstField();
// Non-owning refs to the input text fields.
- Textfield* username_field_;
- Textfield* password_field_;
+ views::Textfield* username_field_;
+ views::Textfield* password_field_;
// Button labels
- Label* username_label_;
- Label* password_label_;
+ views::Label* username_label_;
+ views::Label* password_label_;
// Authentication message.
- Label* message_label_;
+ views::Label* message_label_;
// 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.
@@ -76,8 +61,7 @@ class LoginView : public View, public LoginModelObserver {
ScopedRunnableMethodFactory<LoginView> focus_grabber_factory_;
- DISALLOW_EVIL_CONSTRUCTORS(LoginView);
+ DISALLOW_COPY_AND_ASSIGN(LoginView);
};
-} // namespace
-#endif // CHROME_BROWSER_VIEWS_LOGIN_VIEW_H__
+#endif // CHROME_BROWSER_VIEWS_LOGIN_VIEW_H_
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index 145c3e0..7bd55dd 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -1330,6 +1330,7 @@
'browser/load_from_memory_cache_details.h',
'browser/load_notification_details.h',
'browser/location_bar.h',
+ 'browser/login_model.h',
'browser/login_prompt.cc',
'browser/login_prompt.h',
'browser/login_prompt_gtk.cc',