diff options
author | olege@google.com <olege@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-31 17:20:22 +0000 |
---|---|---|
committer | olege@google.com <olege@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-31 17:20:22 +0000 |
commit | 71fbb49c3e39cb70760c2d4b3976c0a748950c7b (patch) | |
tree | 97a520a69b6bd1b5ec30e4fd2ec8784ee4aa8420 /chrome | |
parent | dc104e331b49c60d045f431b01b631b78cf72cf0 (diff) | |
download | chromium_src-71fbb49c3e39cb70760c2d4b3976c0a748950c7b.zip chromium_src-71fbb49c3e39cb70760c2d4b3976c0a748950c7b.tar.gz chromium_src-71fbb49c3e39cb70760c2d4b3976c0a748950c7b.tar.bz2 |
Revert CL 79685.
TBR=xiyuan
Review URL: http://codereview.chromium.org/6728026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80019 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/browser_resources.grd | 1 | ||||
-rw-r--r-- | chrome/browser/resources/http_auth.html | 90 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/constrained_html_delegate_mac.mm | 3 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/constrained_html_delegate_gtk.cc | 3 | ||||
-rw-r--r-- | chrome/browser/ui/login/login_prompt_ui.cc | 251 | ||||
-rw-r--r-- | chrome/browser/ui/views/constrained_html_delegate_gtk.cc | 3 | ||||
-rw-r--r-- | chrome/browser/ui/views/constrained_html_delegate_win.cc | 3 | ||||
-rw-r--r-- | chrome/browser/ui/webui/chrome_web_ui_factory.cc | 3 | ||||
-rw-r--r-- | chrome/browser/ui/webui/constrained_html_ui.h | 7 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 4 | ||||
-rw-r--r-- | chrome/common/url_constants.cc | 2 | ||||
-rw-r--r-- | chrome/common/url_constants.h | 2 |
12 files changed, 8 insertions, 364 deletions
diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd index 73a93ad..69998ba 100644 --- a/chrome/browser/browser_resources.grd +++ b/chrome/browser/browser_resources.grd @@ -95,7 +95,6 @@ without changes to the corresponding grd file. etaa --> <include name="IDR_GUEST_SESSION_TAB_HTML" file="resources\guest_session_tab.html" flattenhtml="true" type="BINDATA" /> <include name="IDR_FILEBROWSE_HTML" file="resources\filebrowse.html" flattenhtml="true" type="BINDATA" /> <include name="IDR_HOST_REGISTRATION_PAGE_HTML" file="resources\host_registration_page.html" flattenhtml="true" type="BINDATA" /> - <include name="IDR_HTTP_AUTH_HTML" file="resources\http_auth.html" flattenhtml="true" type="BINDATA" /> <include name="IDR_IMAGEBURNER_HTML" file="resources\imageburner.html" flattenhtml="true" type="BINDATA" /> <include name="IDR_KEYBOARD_OVERLAY_CSS" file="resources\keyboard_overlay.css" flattenhtml="true" type="BINDATA" /> <include name="IDR_KEYBOARD_OVERLAY_DATA_JS" file="resources\keyboard_overlay_data.js" flattenhtml="true" type="BINDATA" /> diff --git a/chrome/browser/resources/http_auth.html b/chrome/browser/resources/http_auth.html deleted file mode 100644 index 53fb699..0000000 --- a/chrome/browser/resources/http_auth.html +++ /dev/null @@ -1,90 +0,0 @@ -<!DOCTYPE html> -<html i18n-values="dir:textdirection"> -<head> - <style type="text/css"> - body { - margin: 0px; - } - - #buttons { - text-align: right; - } - - html[dir='rtl'] #buttons { - text-align: left; - } - - #username, - #password { - width: 220px; - } - </style> - <script type="text/javascript"> - function $(o) { - return document.getElementById(o); - } - - function disableControls() { - $('username').disabled = true; - $('password').disabled = true; - $('login').disabled = true; - $('cancel').disabled = true; - } - - function sendCredentialsAndClose() { - disableControls(); - - var result = JSON.stringify({ - 'username': $('username').value, - 'password': $('password').value}); - - chrome.send('DialogClose', [result]); - } - - function setAutofillCredentials(username, password) { - $('username').value = username; - $('password').value = password; - } - - function load() { - $('explanation').textContent = chrome.dialogArguments; - - $('cancel').onclick = function() { - disableControls(); - chrome.send('DialogClose', ['']); - }; - - $('login').onclick = function() { - sendCredentialsAndClose(); - }; - - $('username').focus(); - - chrome.send('GetAutofill', ['']); - } - - document.addEventListener('DOMContentLoaded', load); - </script> -</head> -<body i18n-values=".style.fontFamily:fontfamily;.style.fontSize:fontsize"> - <div id="explanation"></div> - <table> - <tr> - <td i18n-content="username"></td> - <td> - <input id="username" type="text"> - </td> - </tr> - <tr> - <td i18n-content="password"></td> - <td> - <input id="password" name="password" type="password"> - </td> - </tr> - </table> - <div id="buttons"> - <input id="cancel" type="button" i18n-values="value:cancel"> - <input id="login" type="button" i18n-values="value:signin"> - </div> -</body> -</html> diff --git a/chrome/browser/ui/cocoa/constrained_html_delegate_mac.mm b/chrome/browser/ui/cocoa/constrained_html_delegate_mac.mm index 4338cc3..adc1d6b 100644 --- a/chrome/browser/ui/cocoa/constrained_html_delegate_mac.mm +++ b/chrome/browser/ui/cocoa/constrained_html_delegate_mac.mm @@ -121,7 +121,7 @@ void ConstrainedHtmlDelegateMac::OnDialogClose() { } // static -ConstrainedWindow* ConstrainedHtmlUI::CreateConstrainedHtmlDialog( +void ConstrainedHtmlUI::CreateConstrainedHtmlDialog( Profile* profile, HtmlDialogUIDelegate* delegate, TabContents* overshadowed) { @@ -132,7 +132,6 @@ ConstrainedWindow* ConstrainedHtmlUI::CreateConstrainedHtmlDialog( ConstrainedWindow* constrained_window = overshadowed->CreateConstrainedDialog(constrained_delegate); constrained_delegate->set_window(constrained_window); - return constrained_window; } @implementation ConstrainedHtmlDialogSheetCocoa diff --git a/chrome/browser/ui/gtk/constrained_html_delegate_gtk.cc b/chrome/browser/ui/gtk/constrained_html_delegate_gtk.cc index 6bae176..de2ec7a 100644 --- a/chrome/browser/ui/gtk/constrained_html_delegate_gtk.cc +++ b/chrome/browser/ui/gtk/constrained_html_delegate_gtk.cc @@ -104,7 +104,7 @@ void ConstrainedHtmlDelegateGtk::OnDialogClose() { } // static -ConstrainedWindow* ConstrainedHtmlUI::CreateConstrainedHtmlDialog( +void ConstrainedHtmlUI::CreateConstrainedHtmlDialog( Profile* profile, HtmlDialogUIDelegate* delegate, TabContents* overshadowed) { @@ -113,5 +113,4 @@ ConstrainedWindow* ConstrainedHtmlUI::CreateConstrainedHtmlDialog( ConstrainedWindow* constrained_window = overshadowed->CreateConstrainedDialog(constrained_delegate); constrained_delegate->set_window(constrained_window); - return constrained_window; } diff --git a/chrome/browser/ui/login/login_prompt_ui.cc b/chrome/browser/ui/login/login_prompt_ui.cc deleted file mode 100644 index e78dbfb..0000000 --- a/chrome/browser/ui/login/login_prompt_ui.cc +++ /dev/null @@ -1,251 +0,0 @@ -// Copyright (c) 2011 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/login/login_prompt.h" - -#include <string> - -#include "base/json/json_reader.h" -#include "base/utf_string_conversions.h" -#include "base/values.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/ui/webui/chrome_url_data_manager.h" -#include "chrome/browser/ui/webui/constrained_html_ui.h" -#include "chrome/browser/ui/webui/html_dialog_ui.h" -#include "chrome/common/jstemplate_builder.h" -#include "chrome/common/url_constants.h" -#include "content/browser/tab_contents/tab_contents.h" -#include "grit/browser_resources.h" -#include "grit/generated_resources.h" -#include "ui/base/l10n/l10n_util.h" -#include "ui/base/resource/resource_bundle.h" - -class LoginHandlerSource : public ChromeURLDataManager::DataSource { - public: - LoginHandlerSource() - : DataSource(chrome::kChromeUIHttpAuthHost, MessageLoop::current()) {} - - virtual void StartDataRequest(const std::string& path, - bool is_off_the_record, - int request_id) { - DictionaryValue dict; - dict.SetString("username", - l10n_util::GetStringUTF16(IDS_LOGIN_DIALOG_USERNAME_FIELD)); - dict.SetString("password", - l10n_util::GetStringUTF16(IDS_LOGIN_DIALOG_PASSWORD_FIELD)); - dict.SetString("signin", - l10n_util::GetStringUTF16(IDS_LOGIN_DIALOG_OK_BUTTON_LABEL)); - dict.SetString("cancel", l10n_util::GetStringUTF16(IDS_CANCEL)); - - SetFontAndTextDirection(&dict); - - const base::StringPiece html( - ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_HTTP_AUTH_HTML)); - std::string response = jstemplate_builder::GetI18nTemplateHtml(html, &dict); - - // Send the response. - scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); - html_bytes->data.resize(response.size()); - std::copy(response.begin(), response.end(), html_bytes->data.begin()); - SendResponse(request_id, html_bytes); - } - - virtual std::string GetMimeType(const std::string& path) const { - return "text/html"; - } - - static void RegisterDataSource(Profile *profile) { - ChromeURLDataManager* url_manager = profile->GetChromeURLDataManager(); - LoginHandlerSource *source = new LoginHandlerSource(); - url_manager->AddDataSource(source); - } - - private: - virtual ~LoginHandlerSource() {} - - DISALLOW_COPY_AND_ASSIGN(LoginHandlerSource); -}; - -class LoginHandlerHtml; - -class LoginHandlerHtmlDelegate : public HtmlDialogUIDelegate, - public WebUIMessageHandler { - public: - LoginHandlerHtmlDelegate(LoginHandlerHtml *login_handler, - TabContents *tab_contents, - const string16 explanation) - : login_handler_(login_handler), - tab_contents_(tab_contents), - explanation_(UTF16ToUTF8(explanation)), - closed_(false), - has_autofill_(false), - ready_for_autofill_(false) { - } - - // HtmlDialogUIDelegate methods: - virtual bool IsDialogModal() const { - return true; - } - - virtual std::wstring GetDialogTitle() const { - return UTF16ToWide(l10n_util::GetStringUTF16(IDS_LOGIN_DIALOG_TITLE)); - } - - virtual GURL GetDialogContentURL() const { - return GURL(chrome::kChromeUIHttpAuthURL); - } - - virtual void GetWebUIMessageHandlers( - std::vector<WebUIMessageHandler*>* handlers) const { - const WebUIMessageHandler* handler = this; - handlers->push_back(const_cast<WebUIMessageHandler*>(handler)); - } - - virtual void GetDialogSize(gfx::Size* size) const { - size->set_width(kDialogWidth); - size->set_height(kDialogHeight); - } - - virtual std::string GetDialogArgs() const { - return explanation_; - } - - virtual void OnDialogClosed(const std::string& json_retval); - - virtual void OnCloseContents(TabContents* source, bool* out_close_dialog) {} - - virtual bool ShouldShowDialogTitle() const { - return true; - } - - // WebUIMessageHandler method: - virtual void RegisterMessages() { - web_ui_->RegisterMessageCallback( - "GetAutofill", - NewCallback(this, &LoginHandlerHtmlDelegate::GetAutofill)); - } - - void ShowAutofillData(const std::wstring& username, - const std::wstring& password); - - private: - // Send autofill data to HTML once the dialog is ready and the data is - // available. - void SendAutofillData(); - - // Handle the request for autofill data from HTML. - void GetAutofill(const ListValue* args) { - ready_for_autofill_ = true; - SendAutofillData(); - } - - LoginHandlerHtml *login_handler_; - TabContents *tab_contents_; - std::string explanation_; - bool closed_; - - bool has_autofill_; - bool ready_for_autofill_; - std::string autofill_username_; - std::string autofill_password_; - - static const int kDialogWidth = 400; - static const int kDialogHeight = 130; - - DISALLOW_COPY_AND_ASSIGN(LoginHandlerHtmlDelegate); -}; - -class LoginHandlerHtml : public LoginHandler { - public: - LoginHandlerHtml(net::AuthChallengeInfo* auth_info, net::URLRequest* request) - : LoginHandler(auth_info, request), - delegate_(NULL) { - } - - // LoginModelObserver method: - virtual void OnAutofillDataAvailable(const std::wstring& username, - const std::wstring& password) { - if (delegate_) - delegate_->ShowAutofillData(username, password); - } - - // LoginHandler method: - virtual void BuildViewForPasswordManager(PasswordManager* manager, - const string16& explanation); - - friend class LoginHandlerHtmlDelegate; - - protected: - virtual ~LoginHandlerHtml() {} - - private: - LoginHandlerHtmlDelegate *delegate_; - - DISALLOW_COPY_AND_ASSIGN(LoginHandlerHtml); -}; - -void LoginHandlerHtmlDelegate::OnDialogClosed(const std::string& json_retval) { - if (closed_) - return; - closed_ = true; - - scoped_ptr<Value> parsed_value(base::JSONReader::Read(json_retval, false)); - - if (!parsed_value.get() || !parsed_value->IsType(Value::TYPE_DICTIONARY)) { - login_handler_->CancelAuth(); - } else { - DictionaryValue* res = static_cast<DictionaryValue*>(parsed_value.get()); - string16 username; - string16 password; - - if (!res->GetString("username", &username) || - !res->GetString("password", &password)) { - login_handler_->CancelAuth(); - } else { - login_handler_->SetAuth(username, password); - } - } - - login_handler_->ReleaseSoon(); -} - -void LoginHandlerHtmlDelegate::ShowAutofillData(const std::wstring& username, - const std::wstring& password) { - autofill_username_ = WideToUTF8(username); - autofill_password_ = WideToUTF8(password); - has_autofill_ = true; - SendAutofillData(); -} - -void LoginHandlerHtmlDelegate::SendAutofillData() { - if (!closed_ && web_ui_ && has_autofill_ && ready_for_autofill_) { - StringValue username_v(autofill_username_); - StringValue password_v(autofill_password_); - web_ui_->CallJavascriptFunction("setAutofillCredentials", - username_v, password_v); - } -} - -void LoginHandlerHtml::BuildViewForPasswordManager( - PasswordManager* manager, const string16& explanation) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - - TabContents* tab_contents = GetTabContentsForLogin(); - LoginHandlerSource::RegisterDataSource(tab_contents->profile()); - delegate_ = new LoginHandlerHtmlDelegate(this, tab_contents, explanation); - ConstrainedWindow* dialog = ConstrainedHtmlUI::CreateConstrainedHtmlDialog( - tab_contents->profile(), delegate_, tab_contents); - - SetModel(manager); - SetDialog(dialog); - - NotifyAuthNeeded(); -} - -// static -LoginHandler* LoginHandler::Create(net::AuthChallengeInfo* auth_info, - net::URLRequest* request) { - return new LoginHandlerHtml(auth_info, request); -} diff --git a/chrome/browser/ui/views/constrained_html_delegate_gtk.cc b/chrome/browser/ui/views/constrained_html_delegate_gtk.cc index 36ee013..223f643 100644 --- a/chrome/browser/ui/views/constrained_html_delegate_gtk.cc +++ b/chrome/browser/ui/views/constrained_html_delegate_gtk.cc @@ -111,7 +111,7 @@ void ConstrainedHtmlDelegateGtk::OnDialogClose() { } // static -ConstrainedWindow* ConstrainedHtmlUI::CreateConstrainedHtmlDialog( +void ConstrainedHtmlUI::CreateConstrainedHtmlDialog( Profile* profile, HtmlDialogUIDelegate* delegate, TabContents* container) { @@ -120,5 +120,4 @@ ConstrainedWindow* ConstrainedHtmlUI::CreateConstrainedHtmlDialog( ConstrainedWindow* constrained_window = container->CreateConstrainedDialog(constrained_delegate); constrained_delegate->set_window(constrained_window); - return constrained_window; } diff --git a/chrome/browser/ui/views/constrained_html_delegate_win.cc b/chrome/browser/ui/views/constrained_html_delegate_win.cc index 262c67a..79faecf 100644 --- a/chrome/browser/ui/views/constrained_html_delegate_win.cc +++ b/chrome/browser/ui/views/constrained_html_delegate_win.cc @@ -100,7 +100,7 @@ void ConstrainedHtmlDelegateWin::OnDialogClose() { } // static -ConstrainedWindow* ConstrainedHtmlUI::CreateConstrainedHtmlDialog( +void ConstrainedHtmlUI::CreateConstrainedHtmlDialog( Profile* profile, HtmlDialogUIDelegate* delegate, TabContents* container) { @@ -109,5 +109,4 @@ ConstrainedWindow* ConstrainedHtmlUI::CreateConstrainedHtmlDialog( ConstrainedWindow* constrained_window = container->CreateConstrainedDialog(constrained_delegate); constrained_delegate->set_window(constrained_window); - return constrained_window; } diff --git a/chrome/browser/ui/webui/chrome_web_ui_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_factory.cc index f48a33fa..8358f15 100644 --- a/chrome/browser/ui/webui/chrome_web_ui_factory.cc +++ b/chrome/browser/ui/webui/chrome_web_ui_factory.cc @@ -178,8 +178,7 @@ static WebUIFactoryFunction GetWebUIFactoryFunction(Profile* profile, #endif #if defined(OS_CHROMEOS) - if (url.host() == chrome::kChromeUICollectedCookiesHost || - url.host() == chrome::kChromeUIHttpAuthHost) { + if (url.host() == chrome::kChromeUICollectedCookiesHost) { return &NewWebUI<ConstrainedHtmlUI>; } if (url.host() == chrome::kChromeUIFileBrowseHost) diff --git a/chrome/browser/ui/webui/constrained_html_ui.h b/chrome/browser/ui/webui/constrained_html_ui.h index 4186b36..8bfff8f 100644 --- a/chrome/browser/ui/webui/constrained_html_ui.h +++ b/chrome/browser/ui/webui/constrained_html_ui.h @@ -41,10 +41,9 @@ class ConstrainedHtmlUI : public WebUI { // Create a constrained HTML dialog. The actual object that gets created // is a ConstrainedHtmlUIDelegate, which later triggers construction of a // ConstrainedHtmlUI object. - static ConstrainedWindow* CreateConstrainedHtmlDialog( - Profile* profile, - HtmlDialogUIDelegate* delegate, - TabContents* overshadowed); + static void CreateConstrainedHtmlDialog(Profile* profile, + HtmlDialogUIDelegate* delegate, + TabContents* overshadowed); // Returns a property accessor that can be used to set the // ConstrainedHtmlUIDelegate property on a TabContents. diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 439a8af..4e72672 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -2686,7 +2686,6 @@ 'browser/ui/login/login_prompt_gtk.cc', 'browser/ui/login/login_prompt_mac.h', 'browser/ui/login/login_prompt_mac.mm', - 'browser/ui/login/login_prompt_ui.cc', 'browser/ui/login/login_prompt_win.cc', 'browser/ui/omnibox/location_bar.h', 'browser/ui/omnibox/location_bar_util.cc', @@ -3332,7 +3331,6 @@ ['exclude', '^browser/ui/webui/chromeos'], ['exclude', '^browser/ui/webui/options/chromeos'], ['exclude', 'browser/extensions/extension_tts_api_chromeos.cc'], - ['exclude', 'browser/ui/login/login_prompt_ui.cc'], ['exclude', 'browser/oom_priority_manager.cc'], ['exclude', 'browser/oom_priority_manager.h'], ['exclude', 'browser/policy/device_policy_cache\\.(h|cc)'], @@ -4071,12 +4069,10 @@ }], ['OS=="linux" and chromeos==1',{ 'sources/': [ - ['include', '^browser/ui/login/login_prompt_ui.cc'], ['exclude', '^browser/extensions/extension_tts_api_linux.cc'], ['exclude', '^browser/notifications/balloon_collection_impl.cc'], ['exclude', '^browser/notifications/balloon_collection_impl.h'], ['exclude', '^browser/notifications/balloon_collection_linux.cc'], - ['exclude', '^browser/ui/login/login_prompt_gtk.cc'], ], 'dependencies': [ '../third_party/protobuf/protobuf.gyp:protobuf_lite', diff --git a/chrome/common/url_constants.cc b/chrome/common/url_constants.cc index a641d5e..c5fca8c 100644 --- a/chrome/common/url_constants.cc +++ b/chrome/common/url_constants.cc @@ -102,7 +102,6 @@ const char kChromeUIAboutOSCreditsURL[] = "chrome://about/os-credits"; const char kChromeUIActivationMessage[] = "chrome://activationmessage/"; const char kChromeUIFileBrowseURL[] = "chrome://filebrowse/"; const char kChromeUICollectedCookiesURL[] = "chrome://collected-cookies/"; -const char kChromeUIHttpAuthURL[] = "chrome://http-auth/"; const char kChromeUIImageBurnerURL[] = "chrome://imageburner/"; const char kChromeUIKeyboardOverlayURL[] = "chrome://keyboardoverlay/"; const char kChromeUIMediaplayerURL[] = "chrome://mediaplayer/"; @@ -151,7 +150,6 @@ const char kChromeUIThumbnailPath[] = "thumb"; const char kChromeUIActivationMessageHost[] = "activationmessage"; const char kChromeUICollectedCookiesHost[] = "collected-cookies"; const char kChromeUIFileBrowseHost[] = "filebrowse"; -const char kChromeUIHttpAuthHost[] = "http-auth"; const char kChromeUIImageBurnerHost[] = "imageburner"; const char kChromeUIKeyboardOverlayHost[] = "keyboardoverlay"; const char kChromeUIMediaplayerHost[] = "mediaplayer"; diff --git a/chrome/common/url_constants.h b/chrome/common/url_constants.h index 87eb957..a687821 100644 --- a/chrome/common/url_constants.h +++ b/chrome/common/url_constants.h @@ -94,7 +94,6 @@ extern const char kChromeUIAboutOSCreditsURL[]; extern const char kChromeUIActivationMessage[]; extern const char kChromeUICollectedCookiesURL[]; extern const char kChromeUIFileBrowseURL[]; -extern const char kChromeUIHttpAuthURL[]; extern const char kChromeUIImageBurnerURL[]; extern const char kChromeUIKeyboardOverlayURL[]; extern const char kChromeUIMediaplayerURL[]; @@ -143,7 +142,6 @@ extern const char kChromeUIThumbnailPath[]; extern const char kChromeUIActivationMessageHost[]; extern const char kChromeUICollectedCookiesHost[]; extern const char kChromeUIFileBrowseHost[]; -extern const char kChromeUIHttpAuthHost[]; extern const char kChromeUIImageBurnerHost[]; extern const char kChromeUIKeyboardOverlayHost[]; extern const char kChromeUIMediaplayerHost[]; |