Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
|
oshima
2011/02/28 18:38:07
2011
rharrison
2011/02/28 19:28:24
Done.
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/chromeos/webui/login/login_container_ui.h" | |
| 6 | |
| 7 #include "base/ref_counted_memory.h" | |
| 8 #include "base/singleton.h" | |
| 9 #include "base/string_piece.h" | |
| 10 #include "base/values.h" | |
| 11 #include "chrome/browser/browser_thread.h" | |
| 12 #include "chrome/browser/chromeos/webui/login/login_ui_helpers.h" | |
| 13 #include "chrome/browser/profiles/profile.h" | |
| 14 #include "chrome/browser/tab_contents/tab_contents.h" | |
| 15 #include "chrome/browser/ui/browser.h" | |
| 16 #include "chrome/browser/ui/browser_window.h" | |
| 17 #include "chrome/common/url_constants.h" | |
| 18 #include "views/screen.h" | |
| 19 | |
| 20 namespace chromeos { | |
| 21 | |
| 22 //////////////////////////////////////////////////////////////////////////////// | |
| 23 // | |
| 24 // LoginContainerUIHTMLSource | |
|
oshima
2011/02/28 18:38:07
// LoginContainerUIHTMLSource -------------------
rharrison
2011/02/28 19:28:24
Done.
| |
| 25 // | |
| 26 //////////////////////////////////////////////////////////////////////////////// | |
| 27 | |
| 28 LoginContainerUIHTMLSource::LoginContainerUIHTMLSource(MessageLoop* message_loop ) | |
|
Nikita (slow)
2011/02/28 14:26:17
not fitting on a single line
rharrison
2011/02/28 19:28:24
Done.
| |
| 29 : DataSource(chrome::kChromeUILoginContainerHost, message_loop), | |
| 30 html_operations_(new HTMLOperationsInterface()) { | |
| 31 } | |
| 32 | |
| 33 void LoginContainerUIHTMLSource::StartDataRequest(const std::string& path, | |
| 34 bool is_off_the_record, | |
|
Nikita (slow)
2011/02/28 14:26:17
please align params
rharrison
2011/02/28 19:28:24
Done.
| |
| 35 int request_id) { | |
| 36 DictionaryValue localized_strings; | |
| 37 SetFontAndTextDirection(&localized_strings); | |
| 38 | |
| 39 base::StringPiece login_html = html_operations_->GetLoginContainerHTML(); | |
| 40 std::string full_html = html_operations_->GetFullHTML(login_html, | |
| 41 &localized_strings); | |
| 42 scoped_refptr<RefCountedBytes> html_bytes( | |
| 43 html_operations_->CreateHTMLBytes(full_html)); | |
| 44 SendResponse(request_id, | |
| 45 (html_bytes.get())); | |
|
oshima
2011/02/28 18:38:07
fits to single line.
rharrison
2011/02/28 19:28:24
Done.
| |
| 46 } | |
| 47 | |
| 48 //////////////////////////////////////////////////////////////////////////////// | |
| 49 // | |
| 50 // LoginContainerUIHandler | |
| 51 // | |
| 52 //////////////////////////////////////////////////////////////////////////////// | |
| 53 | |
| 54 LoginContainerUIHandler::LoginContainerUIHandler() | |
| 55 : browser_operations_(new BrowserOperationsInterface), | |
| 56 profile_operations_(new ProfileOperationsInterface) { | |
| 57 } | |
| 58 | |
| 59 LoginContainerUIHandler::~LoginContainerUIHandler() { | |
| 60 } | |
| 61 | |
| 62 WebUIMessageHandler* LoginContainerUIHandler::Attach(WebUI* web_ui) { | |
| 63 return WebUIMessageHandler::Attach(web_ui); | |
| 64 } | |
| 65 | |
| 66 void LoginContainerUIHandler::RegisterMessages() { | |
| 67 web_ui_->RegisterMessageCallback( | |
| 68 "OpenLoginScreen", | |
| 69 NewCallback(this, | |
| 70 &LoginContainerUIHandler::HandleOpenLoginScreen)); | |
| 71 } | |
| 72 | |
| 73 void LoginContainerUIHandler::HandleOpenLoginScreen(const ListValue* args) { | |
| 74 Profile* profile = profile_operations_->GetDefaultProfileByPath(); | |
| 75 Browser* current_browser = browser_operations_->GetLoginBrowser(profile); | |
| 76 Browser* login_screen = browser_operations_->CreateBrowser(profile); | |
| 77 login_screen->AddSelectedTabWithURL(GURL("chrome://login"), | |
|
Nikita (slow)
2011/02/28 14:26:17
Use constant.
rharrison
2011/02/28 19:28:24
Done.
| |
| 78 PageTransition::LINK); | |
| 79 login_screen->window()->Show(); | |
| 80 current_browser->CloseWindow(); | |
| 81 } | |
| 82 | |
| 83 //////////////////////////////////////////////////////////////////////////////// | |
| 84 // | |
| 85 // LoginContainerUI | |
| 86 // | |
| 87 //////////////////////////////////////////////////////////////////////////////// | |
| 88 LoginContainerUI::LoginContainerUI(TabContents* contents) | |
| 89 : WebUI(contents) { | |
| 90 LoginContainerUIHandler* handler = new LoginContainerUIHandler(); | |
| 91 AddMessageHandler(handler->Attach(this)); | |
| 92 LoginContainerUIHTMLSource* html_source = | |
| 93 new LoginContainerUIHTMLSource(MessageLoop::current()); | |
| 94 | |
| 95 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); | |
| 96 } | |
| 97 | |
| 98 } // namespace chromeos | |
| OLD | NEW |