Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Side by Side Diff: chrome/browser/chromeos/webui/login/login_container_ui.cc

Issue 6579003: Add in chrome://login-container (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fix for build failure caused by header files moving Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
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 {
21 const char* kLoginURL = "chrome://login";
22 }
23 namespace chromeos {
24
25 // LoginContainerUIHTMLSource -------------------
Nikita (slow) 2011/03/02 12:13:18 nit: "-" should be filled till 80 chars limit
rharrison 2011/03/02 20:05:40 Done.
26
27 LoginContainerUIHTMLSource::LoginContainerUIHTMLSource(
28 MessageLoop* message_loop)
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,
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, (html_bytes.get()));
45 }
46
47 // LoginContainerUIHandler -------------------
48
49 LoginContainerUIHandler::LoginContainerUIHandler()
50 : browser_operations_(new BrowserOperationsInterface),
51 profile_operations_(new ProfileOperationsInterface) {
52 }
53
54 LoginContainerUIHandler::~LoginContainerUIHandler() {
55 }
56
57 WebUIMessageHandler* LoginContainerUIHandler::Attach(WebUI* web_ui) {
58 return WebUIMessageHandler::Attach(web_ui);
59 }
60
61 void LoginContainerUIHandler::RegisterMessages() {
62 web_ui_->RegisterMessageCallback(
63 "OpenLoginScreen",
64 NewCallback(this,
65 &LoginContainerUIHandler::HandleOpenLoginScreen));
66 }
67
68 void LoginContainerUIHandler::HandleOpenLoginScreen(const ListValue* args) {
69 Profile* profile = profile_operations_->GetDefaultProfileByPath();
70 Browser* current_browser = browser_operations_->GetLoginBrowser(profile);
71 Browser* login_screen = browser_operations_->CreateBrowser(profile);
72 login_screen->AddSelectedTabWithURL(GURL(kLoginURL), PageTransition::LINK);
73 login_screen->window()->Show();
74 current_browser->CloseWindow();
75 }
76
77 // LoginContainerUI -------------------
78
79 LoginContainerUI::LoginContainerUI(TabContents* contents)
80 : WebUI(contents) {
81 LoginContainerUIHandler* handler = new LoginContainerUIHandler();
82 AddMessageHandler(handler->Attach(this));
83 LoginContainerUIHTMLSource* html_source =
84 new LoginContainerUIHTMLSource(MessageLoop::current());
85
86 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source);
87 }
88
89 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/webui/login/login_container_ui.h ('k') | chrome/browser/chromeos/webui/login/login_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698