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

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

Issue 6577003: Entire DOMBrowser stack (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 10 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) 2010 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 "base/ref_counted_memory.h"
6 #include "base/singleton.h"
7 #include "base/string_piece.h"
8 #include "base/values.h"
9 #include "chrome/browser/browser_thread.h"
10 #include "chrome/browser/chromeos/webui/login/browser/dom_browser.h"
11 #include "chrome/browser/chromeos/webui/login/login_container_ui.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
25 //
26 ////////////////////////////////////////////////////////////////////////////////
27
28 LoginContainerUIHTMLSource::LoginContainerUIHTMLSource(
29 MessageLoop* message_loop)
30 : DataSource(chrome::kChromeUILoginContainerHost, message_loop),
31 html_operations_(new HTMLOperationsInterface()) {
32 }
33
34 void LoginContainerUIHTMLSource::StartDataRequest(const std::string& path,
35 bool is_off_the_record,
36 int request_id) {
37 DictionaryValue localized_strings;
38 SetFontAndTextDirection(&localized_strings);
39
40 base::StringPiece login_html = html_operations_->GetLoginContainerHTML();
41 std::string full_html = html_operations_->GetFullHTML(login_html,
42 &localized_strings);
43 scoped_refptr<RefCountedBytes> html_bytes(
44 html_operations_->CreateHTMLBytes(full_html));
45 SendResponse(request_id,
46 (html_bytes.get()));
47 }
48
49 ////////////////////////////////////////////////////////////////////////////////
50 //
51 // LoginContainerUIHandler
52 //
53 ////////////////////////////////////////////////////////////////////////////////
54
55 LoginContainerUIHandler::LoginContainerUIHandler()
56 : browser_operations_(new BrowserOperationsInterface),
57 profile_operations_(new ProfileOperationsInterface) {
58 }
59
60 LoginContainerUIHandler::~LoginContainerUIHandler() {
61 }
62
63 WebUIMessageHandler* LoginContainerUIHandler::Attach(WebUI* web_ui) {
64 return WebUIMessageHandler::Attach(web_ui);
65 }
66
67 void LoginContainerUIHandler::RegisterMessages() {
68 web_ui_->RegisterMessageCallback(
69 "OpenLoginScreen",
70 NewCallback(this,
71 &LoginContainerUIHandler::HandleOpenLoginScreen));
72 }
73
74 void LoginContainerUIHandler::HandleOpenLoginScreen(const ListValue* args) {
75 Profile* profile = profile_operations_->GetDefaultProfileByPath();
76 Browser* current_browser = browser_operations_->GetLoginBrowser(profile);
77 Browser* login_screen = DOMBrowser::CreateForDOM(profile);
78 login_screen->AddSelectedTabWithURL(GURL("chrome://login"),
79 PageTransition::LINK);
80 login_screen->window()->Show();
81 current_browser->CloseWindow();
82 }
83
84 ////////////////////////////////////////////////////////////////////////////////
85 //
86 // LoginContainerUI
87 //
88 ////////////////////////////////////////////////////////////////////////////////
89 LoginContainerUI::LoginContainerUI(TabContents* contents)
90 : WebUI(contents) {
91 LoginContainerUIHandler* handler = new LoginContainerUIHandler();
92 AddMessageHandler(handler->Attach(this));
93 LoginContainerUIHTMLSource* html_source =
94 new LoginContainerUIHTMLSource(MessageLoop::current());
95
96 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source);
97 }
98
99 } // 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