diff options
author | rharrison@chromium.org <rharrison@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-04 07:58:31 +0000 |
---|---|---|
committer | rharrison@chromium.org <rharrison@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-04 07:58:31 +0000 |
commit | af1c080b4ef5c86ec4243771ac1ac2da97745298 (patch) | |
tree | 23e50f4c8f2afc39937e78f306c446e1f5754a2f | |
parent | 21e0cbf6bf480671aef2b3e07502bf665627f4ab (diff) | |
download | chromium_src-af1c080b4ef5c86ec4243771ac1ac2da97745298.zip chromium_src-af1c080b4ef5c86ec4243771ac1ac2da97745298.tar.gz chromium_src-af1c080b4ef5c86ec4243771ac1ac2da97745298.tar.bz2 |
This is the first CL for a sequence of CLs that will add in the display infrastructure that I have built for the DOM Login and touch keyboard. If have created a reference CL for what the end product of this sequence is intended to be, so that I can give context for the CL under review.This can be found at: http://codereview.chromium.org/6577003/
This CL adds in chrome://login-container to touchui==1 and chromeos==1 builds. This page is hooked into the WebUI to enable testing and development of a Browser based container for the DOM Login screens. In this CL all it does it
create a Browser with chrome://login in it. This functionality will be extended in following CLs.
Patch from Ryan Harrison <rharrison@chromium.org>
BUG=none
TEST=manual
Review URL: http://codereview.chromium.org/6579003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76894 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/browser_resources.grd | 1 | ||||
-rw-r--r-- | chrome/browser/chromeos/webui/login/login_container_ui.cc | 89 | ||||
-rw-r--r-- | chrome/browser/chromeos/webui/login/login_container_ui.h | 78 | ||||
-rw-r--r-- | chrome/browser/chromeos/webui/login/login_ui.cc | 1 | ||||
-rw-r--r-- | chrome/browser/chromeos/webui/login/login_ui_helpers.cc | 7 | ||||
-rw-r--r-- | chrome/browser/chromeos/webui/login/login_ui_helpers.h | 7 | ||||
-rw-r--r-- | chrome/browser/chromeos/webui/login/mock_login_ui_helpers.h | 16 | ||||
-rw-r--r-- | chrome/browser/resources/login_container.html | 23 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 3 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 11 | ||||
-rw-r--r-- | chrome/common/url_constants.cc | 6 | ||||
-rw-r--r-- | chrome/common/url_constants.h | 6 | ||||
-rw-r--r-- | content/browser/webui/web_ui_factory.cc | 3 |
13 files changed, 234 insertions, 17 deletions
diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd index 883f554..5850728 100644 --- a/chrome/browser/browser_resources.grd +++ b/chrome/browser/browser_resources.grd @@ -45,6 +45,7 @@ without changes to the corresponding grd file. etaa --> <include name="IDR_INCOGNITO_TAB_HTML" file="resources\incognito_tab.html" flattenhtml="true" type="BINDATA" /> <include name="IDR_KEYBOARD_MANIFEST" file="resources\keyboard\manifest.json" type="BINDATA" /> <include name="IDR_LOGIN_HTML" file="resources\login.html" flattenhtml="true" type="BINDATA" /> + <include name="IDR_LOGIN_CONTAINER_HTML" file="resources\login_container.html" flattenhtml="true" type="BINDATA" /> <include name="IDR_GPU_BLACKLIST" file="resources\software_rendering_list.json" type="BINDATA" /> <include name="IDR_NEW_INCOGNITO_TAB_THEME_CSS" file="resources\new_incognito_tab_theme.css" flattenhtml="true" type="BINDATA" /> <include name="IDR_NEW_NEW_TAB_HTML" file="resources\new_new_tab.html" flattenhtml="true" type="BINDATA" /> diff --git a/chrome/browser/chromeos/webui/login/login_container_ui.cc b/chrome/browser/chromeos/webui/login/login_container_ui.cc new file mode 100644 index 0000000..4ac8cd7 --- /dev/null +++ b/chrome/browser/chromeos/webui/login/login_container_ui.cc @@ -0,0 +1,89 @@ +// 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/chromeos/webui/login/login_container_ui.h" + +#include "base/ref_counted_memory.h" +#include "base/singleton.h" +#include "base/string_piece.h" +#include "base/values.h" +#include "chrome/browser/chromeos/webui/login/login_ui_helpers.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/browser_window.h" +#include "chrome/common/url_constants.h" +#include "content/browser/browser_thread.h" +#include "content/browser/tab_contents/tab_contents.h" +#include "views/screen.h" + +namespace { +const char* kLoginURL = "chrome://login"; +} +namespace chromeos { + +// LoginContainerUIHTMLSource -------------------------------------------------- + +LoginContainerUIHTMLSource::LoginContainerUIHTMLSource( + MessageLoop* message_loop) + : DataSource(chrome::kChromeUILoginContainerHost, message_loop), + html_operations_(new HTMLOperationsInterface()) { +} + +void LoginContainerUIHTMLSource::StartDataRequest(const std::string& path, + bool is_off_the_record, + int request_id) { + DictionaryValue localized_strings; + SetFontAndTextDirection(&localized_strings); + + base::StringPiece login_html = html_operations_->GetLoginContainerHTML(); + std::string full_html = html_operations_->GetFullHTML(login_html, + &localized_strings); + scoped_refptr<RefCountedBytes> html_bytes( + html_operations_->CreateHTMLBytes(full_html)); + SendResponse(request_id, (html_bytes.get())); +} + +// LoginContainerUIHandler ----------------------------------------------------- + +LoginContainerUIHandler::LoginContainerUIHandler() + : browser_operations_(new BrowserOperationsInterface), + profile_operations_(new ProfileOperationsInterface) { +} + +LoginContainerUIHandler::~LoginContainerUIHandler() { +} + +WebUIMessageHandler* LoginContainerUIHandler::Attach(WebUI* web_ui) { + return WebUIMessageHandler::Attach(web_ui); +} + +void LoginContainerUIHandler::RegisterMessages() { + web_ui_->RegisterMessageCallback( + "OpenLoginScreen", + NewCallback(this, + &LoginContainerUIHandler::HandleOpenLoginScreen)); +} + +void LoginContainerUIHandler::HandleOpenLoginScreen(const ListValue* args) { + Profile* profile = profile_operations_->GetDefaultProfileByPath(); + Browser* current_browser = browser_operations_->GetLoginBrowser(profile); + Browser* login_screen = browser_operations_->CreateBrowser(profile); + login_screen->AddSelectedTabWithURL(GURL(kLoginURL), PageTransition::LINK); + login_screen->window()->Show(); + current_browser->CloseWindow(); +} + +// LoginContainerUI ------------------------------------------------------------ + +LoginContainerUI::LoginContainerUI(TabContents* contents) + : WebUI(contents) { + LoginContainerUIHandler* handler = new LoginContainerUIHandler(); + AddMessageHandler(handler->Attach(this)); + LoginContainerUIHTMLSource* html_source = + new LoginContainerUIHTMLSource(MessageLoop::current()); + + contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); +} + +} // namespace chromeos diff --git a/chrome/browser/chromeos/webui/login/login_container_ui.h b/chrome/browser/chromeos/webui/login/login_container_ui.h new file mode 100644 index 0000000..9af1013 --- /dev/null +++ b/chrome/browser/chromeos/webui/login/login_container_ui.h @@ -0,0 +1,78 @@ +// 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. + +#ifndef CHROME_BROWSER_CHROMEOS_WEBUI_LOGIN_LOGIN_CONTAINER_UI_H_ +#define CHROME_BROWSER_CHROMEOS_WEBUI_LOGIN_LOGIN_CONTAINER_UI_H_ +#pragma once +#include <string> + +#include "base/scoped_ptr.h" +#include "chrome/browser/chromeos/webui/login/login_ui_helpers.h" +#include "chrome/browser/ui/webui/chrome_url_data_manager.h" +#include "content/browser/webui/web_ui.h" + +class Profile; + +namespace chromeos { + +class BrowserOperationsInterface; +class ProfileOperationsInterface; + +// Boilerplate class that is used to associate the LoginContainerUI code with +// the URL "chrome://login-container" +class LoginContainerUIHTMLSource : public ChromeURLDataManager::DataSource { + public: + explicit LoginContainerUIHTMLSource(MessageLoop* message_loop); + + virtual void StartDataRequest(const std::string& path, + bool is_off_the_record, + int request_id); + virtual std::string GetMimeType(const std::string&) const { + return "text/html"; + } + + private: + scoped_ptr<HTMLOperationsInterface> html_operations_; + + DISALLOW_COPY_AND_ASSIGN(LoginContainerUIHTMLSource); +}; + +// Main LoginContainerUI handling function. It handles the WebUI hooks that are +// supplied for the page to launch the login container. +class LoginContainerUIHandler : public WebUIMessageHandler { + public: + LoginContainerUIHandler(); + virtual ~LoginContainerUIHandler(); + + // WebUIMessageHandler implementation. + virtual WebUIMessageHandler* Attach(WebUI* web_ui); + virtual void RegisterMessages(); + + void HandleOpenLoginScreen(const ListValue* args); + + private: + scoped_ptr<BrowserOperationsInterface> browser_operations_; + scoped_ptr<ProfileOperationsInterface> profile_operations_; + + DISALLOW_COPY_AND_ASSIGN(LoginContainerUIHandler); +}; + +// Boilerplate class that is used to associate the LoginContainerUI code with +// the Webui code. +class LoginContainerUI : public WebUI { + public: + explicit LoginContainerUI(TabContents* contents); + + // Return the URL for a given search term. + static const GURL GetLoginURLWithSearchText(const string16& text); + + static RefCountedMemory* GetFaviconResourceBytes(); + + private: + DISALLOW_COPY_AND_ASSIGN(LoginContainerUI); +}; + +} // namespace chromeos + +#endif // CHROME_BROWSER_CHROMEOS_WEBUI_LOGIN_LOGIN_CONTAINER_UI_H_ diff --git a/chrome/browser/chromeos/webui/login/login_ui.cc b/chrome/browser/chromeos/webui/login/login_ui.cc index 537cc2d..6ca1a99 100644 --- a/chrome/browser/chromeos/webui/login/login_ui.cc +++ b/chrome/browser/chromeos/webui/login/login_ui.cc @@ -10,7 +10,6 @@ #include "chrome/browser/chromeos/cros/power_library.h" #include "chrome/browser/chromeos/webui/login/authenticator_facade.h" #include "chrome/browser/chromeos/webui/login/authenticator_facade_cros.h" -#include "chrome/browser/chromeos/webui/login/authenticator_facade_cros.h" #include "chrome/browser/chromeos/webui/login/login_ui.h" #include "chrome/browser/chromeos/webui/login/login_ui_helpers.h" #include "chrome/browser/profiles/profile.h" diff --git a/chrome/browser/chromeos/webui/login/login_ui_helpers.cc b/chrome/browser/chromeos/webui/login/login_ui_helpers.cc index fe7c88a..4fb6ffd 100644 --- a/chrome/browser/chromeos/webui/login/login_ui_helpers.cc +++ b/chrome/browser/chromeos/webui/login/login_ui_helpers.cc @@ -73,6 +73,13 @@ base::StringPiece HTMLOperationsInterface::GetLoginHTML() { return login_html; } +base::StringPiece HTMLOperationsInterface::GetLoginContainerHTML() { + base::StringPiece login_html( + ResourceBundle::GetSharedInstance().GetRawDataResource( + IDR_LOGIN_CONTAINER_HTML)); + return login_html; +} + std::string HTMLOperationsInterface::GetFullHTML( base::StringPiece login_html, DictionaryValue* localized_strings) { diff --git a/chrome/browser/chromeos/webui/login/login_ui_helpers.h b/chrome/browser/chromeos/webui/login/login_ui_helpers.h index e18fbc7..5bd8b2a 100644 --- a/chrome/browser/chromeos/webui/login/login_ui_helpers.h +++ b/chrome/browser/chromeos/webui/login/login_ui_helpers.h @@ -8,16 +8,14 @@ #include <string> +#include "base/string_piece.h" + class Browser; class DictionaryValue; class FilePath; class Profile; class RefCountedBytes; -namespace base { -class StringPiece; -}; // namespace base - namespace chromeos { // This class is used for encapsulating the statics and other other messy @@ -65,6 +63,7 @@ class HTMLOperationsInterface { virtual ~HTMLOperationsInterface() {} virtual base::StringPiece GetLoginHTML(); + virtual base::StringPiece GetLoginContainerHTML(); virtual std::string GetFullHTML(base::StringPiece login_html, DictionaryValue* localized_strings); virtual RefCountedBytes* CreateHTMLBytes(std::string full_html); diff --git a/chrome/browser/chromeos/webui/login/mock_login_ui_helpers.h b/chrome/browser/chromeos/webui/login/mock_login_ui_helpers.h index 2bdc53b..fdaba44 100644 --- a/chrome/browser/chromeos/webui/login/mock_login_ui_helpers.h +++ b/chrome/browser/chromeos/webui/login/mock_login_ui_helpers.h @@ -18,10 +18,8 @@ class MockProfileOperationsInterface public: MockProfileOperationsInterface() {} - MOCK_METHOD0(GetDefaultProfile, - Profile*()); - MOCK_METHOD0(GetDefaultProfileByPath, - Profile*()); + MOCK_METHOD0(GetDefaultProfile, Profile*()); + MOCK_METHOD0(GetDefaultProfileByPath, Profile*()); private: DISALLOW_COPY_AND_ASSIGN(MockProfileOperationsInterface); @@ -32,10 +30,8 @@ class MockBrowserOperationsInterface public: MockBrowserOperationsInterface() {} - MOCK_METHOD1(CreateBrowser, - Browser*(Profile* profile)); - MOCK_METHOD1(GetLoginBrowser, - Browser*(Profile* profile)); + MOCK_METHOD1(CreateBrowser, Browser*(Profile* profile)); + MOCK_METHOD1(GetLoginBrowser, Browser*(Profile* profile)); private: DISALLOW_COPY_AND_ASSIGN(MockBrowserOperationsInterface); @@ -46,8 +42,8 @@ class MockHTMLOperationsInterface public: MockHTMLOperationsInterface() {} - MOCK_METHOD0(GetLoginHTML, - base::StringPiece()); + MOCK_METHOD0(GetLoginHTML, base::StringPiece()); + MOCK_METHOD0(GetLoginContainerHTML, base::StringPiece()); MOCK_METHOD2(GetFullHTML, std::string(base::StringPiece login_html, DictionaryValue* localized_strings)); diff --git a/chrome/browser/resources/login_container.html b/chrome/browser/resources/login_container.html new file mode 100644 index 0000000..3158f9e --- /dev/null +++ b/chrome/browser/resources/login_container.html @@ -0,0 +1,23 @@ +<!DOCTYPE html> +<html> +<head> +<link rel="stylesheet" href="login_ui.css" > +</head> + +<body> + <div id="sign-in-div"> + <div id="sign-in-body"> + <button type="button" id="open-login-screen-button" + onclick="callOpenLoginScreen();"> + Open Login Screen + </button> + </div> + </div> +</body> + +<script> +function callOpenLoginScreen() { + chrome.send('OpenLoginScreen', []); +} +</script> +</html> diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 1b05b33..87d3c03 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -726,6 +726,8 @@ 'browser/chromeos/webui/login/authenticator_facade_cros_helpers.h', 'browser/chromeos/webui/login/login_ui.cc', 'browser/chromeos/webui/login/login_ui.h', + 'browser/chromeos/webui/login/login_container_ui.cc', + 'browser/chromeos/webui/login/login_container_ui.h', 'browser/chromeos/webui/login/login_ui_helpers.cc', 'browser/chromeos/webui/login/login_ui_helpers.h', 'browser/chromeos/webui/menu_ui.cc', @@ -3449,6 +3451,7 @@ ['touchui==1', { 'sources/': [ ['include', '^browser/ui/touch/*'], + ['include', '^browser/chromeos/dom_ui/login/'], ['exclude', '^browser/chromeos/frame/browser_non_client_frame_view_factory_chromeos.cc'], ['exclude', '^browser/renderer_host/gtk_im_context_wrapper.cc'], ['exclude', '^browser/renderer_host/gtk_im_context_wrapper.h'], diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 83b46df..299893f 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -1872,6 +1872,17 @@ ], }], ['chromeos==1', { + 'conditions': [ + ['touchui==1', { + 'sources/': [ + ['include', 'browser/chromeos/dom_ui/login/authenticator_facade_cros_unittest.cc'], + ['include', 'browser/chromeos/dom_ui/login/login_ui_unittest.cc'], + ['include', 'browser/chromeos/dom_ui/login/mock_authenticator_facade_cros.h'], + ['include', 'browser/chromeos/dom_ui/login/mock_authenticator_facade_cros_helpers.h'], + ['include', 'browser/chromeos/dom_ui/login/mock_login_ui_helpers.h'], + ], + }], + ], 'sources/': [ # TODO(thestig) Enable PrintPreviewUIHTMLSource tests on CrOS when # print preview is enabled on CrOS. diff --git a/chrome/common/url_constants.cc b/chrome/common/url_constants.cc index f876d03..4609ef7 100644 --- a/chrome/common/url_constants.cc +++ b/chrome/common/url_constants.cc @@ -129,7 +129,6 @@ const char kChromeUIHistoryHost[] = "history"; const char kChromeUIHistory2Host[] = "history2"; const char kChromeUIInspectorHost[] = "inspector"; const char kChromeUIKeyboardHost[] = "keyboard"; -const char kChromeUILoginHost[] = "login"; const char kChromeUINetInternalsHost[] = "net-internals"; const char kChromeUINewTabHost[] = "newtab"; const char kChromeUIPluginsHost[] = "plugins"; @@ -161,6 +160,11 @@ const char kChromeUINetworkMenu[] = "network-menu"; const char kChromeUIUserImageHost[] = "userimage"; #endif +#if defined(OS_CHROMEOS) && defined(TOUCH_UI) +const char kChromeUILoginContainerHost[] = "login-container"; +const char kChromeUILoginHost[] = "login"; +#endif + const char kUnreachableWebDataURL[] = "chrome://chromewebdata/"; const char kAppCacheViewInternalsURL[] = "chrome://appcache-internals/"; diff --git a/chrome/common/url_constants.h b/chrome/common/url_constants.h index cfd8080..563be8a 100644 --- a/chrome/common/url_constants.h +++ b/chrome/common/url_constants.h @@ -121,7 +121,6 @@ extern const char kChromeUIGpuInternalsHost[]; extern const char kChromeUIHistory2Host[]; extern const char kChromeUIHistoryHost[]; extern const char kChromeUIKeyboardHost[]; -extern const char kChromeUILoginHost[]; extern const char kChromeUINetInternalsHost[]; extern const char kChromeUINewTabHost[]; extern const char kChromeUIPluginsHost[]; @@ -153,6 +152,11 @@ extern const char kChromeUINetworkMenu[]; extern const char kChromeUIUserImageHost[]; #endif +#if defined(OS_CHROMEOS) && defined(TOUCH_UI) +extern const char kChromeUILoginContainerHost[]; +extern const char kChromeUILoginHost[]; +#endif + // Special URL used to start a navigation to an error page. extern const char kUnreachableWebDataURL[]; diff --git a/content/browser/webui/web_ui_factory.cc b/content/browser/webui/web_ui_factory.cc index c8ae401..e278fef 100644 --- a/content/browser/webui/web_ui_factory.cc +++ b/content/browser/webui/web_ui_factory.cc @@ -55,6 +55,7 @@ #endif #if defined(TOUCH_UI) && defined(OS_CHROMEOS) +#include "chrome/browser/chromeos/webui/login/login_container_ui.h" #include "chrome/browser/chromeos/webui/login/login_ui.h" #endif @@ -225,6 +226,8 @@ static WebUIFactoryFunction GetWebUIFactoryFunction(Profile* profile, #if defined(TOUCH_UI) && defined(OS_CHROMEOS) if (url.host() == chrome::kChromeUILoginHost) return &NewWebUI<chromeos::LoginUI>; + if (url.host() == chrome::kChromeUILoginContainerHost) + return &NewWebUI<chromeos::LoginContainerUI>; #endif if (url.spec() == chrome::kChromeUIConstrainedHTMLTestURL) |