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

Side by Side Diff: chrome/browser/chromeos/login/html_page_screen.cc

Issue 3158023: OOBE screen with HTML page specified from command line it is going to be used for recovery screen. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Removed useless explicit Created 10 years, 4 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
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 "chrome/browser/chromeos/login/html_page_screen.h"
6
7 #include "base/string_util.h"
8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/chromeos/input_method/input_method_util.h"
11 #include "chrome/browser/chromeos/login/screen_observer.h"
12 #include "chrome/browser/profile_manager.h"
13 #include "chrome/browser/renderer_host/render_view_host.h"
14 #include "chrome/browser/renderer_host/site_instance.h"
15 #include "chrome/browser/tab_contents/tab_contents.h"
16 #include "googleurl/src/gurl.h"
17 #include "views/widget/widget_gtk.h"
18
19 namespace chromeos {
20
21 static const char kHTMLPageDoneUrl[] = "about:blank";
22
23 ///////////////////////////////////////////////////////////////////////////////
24 // HTMLPageDomView
25 TabContents* HTMLPageDomView::CreateTabContents(Profile* profile,
26 SiteInstance* instance) {
27 return new WizardWebPageViewTabContents(profile,
28 instance,
29 page_delegate_);
30 }
31
32 ///////////////////////////////////////////////////////////////////////////////
33 // HTMLPageView
34 HTMLPageView::HTMLPageView()
35 : dom_view_(new HTMLPageDomView()) {
36 }
37
38 ///////////////////////////////////////////////////////////////////////////////
39 // HTMLPageScreen, public:
40 HTMLPageScreen::HTMLPageScreen(WizardScreenDelegate* delegate,
41 const std::string& url)
42 : ViewScreen<HTMLPageView>(delegate), url_(url) {
43 }
44
45 ///////////////////////////////////////////////////////////////////////////////
46 // HTMLPageScreen, ViewScreen implementation:
47 void HTMLPageScreen::CreateView() {
48 ViewScreen<HTMLPageView>::CreateView();
49 view()->SetWebPageDelegate(this);
50 }
51
52 void HTMLPageScreen::Refresh() {
53 LOG(INFO) << "HTMLPageScreen::Refresh(): " << url_;
54 StartTimeoutTimer();
55 GURL url(url_);
56 Profile* profile = ProfileManager::GetDefaultProfile();
57 view()->InitDOM(profile,
58 SiteInstance::CreateSiteInstanceForURL(profile, url));
59 view()->SetTabContentsDelegate(this);
60 view()->LoadURL(url);
61 }
62
63 HTMLPageView* HTMLPageScreen::AllocateView() {
64 return new HTMLPageView();
65 }
66
67 ///////////////////////////////////////////////////////////////////////////////
68 // HTMLPageScreen, TabContentsDelegate implementation:
69 void HTMLPageScreen::LoadingStateChanged(TabContents* source) {
70 std::string url = source->GetURL().spec();
71 if (url == kHTMLPageDoneUrl) {
72 source->Stop();
73 // TODO(dpolukhin): use special code for this case but now
74 // ACCOUNT_CREATE_BACK works as we would like, i.e. get to login page.
75 LOG(INFO) << "HTMLPageScreen::LoadingStateChanged: " << url;
76 CloseScreen(ScreenObserver::ACCOUNT_CREATE_BACK);
77 }
78 }
79
80 void HTMLPageScreen::NavigationStateChanged(const TabContents* source,
81 unsigned changed_flags) {
82 }
83
84 void HTMLPageScreen::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) {
85 views::Widget* widget = view()->GetWidget();
86 if (widget && event.os_event && !event.skip_in_browser)
87 static_cast<views::WidgetGtk*>(widget)->HandleKeyboardEvent(event.os_event);
88 }
89
90 ///////////////////////////////////////////////////////////////////////////////
91 // HTMLPageScreen, WebPageDelegate implementation:
92 void HTMLPageScreen::OnPageLoaded() {
93 StopTimeoutTimer();
94 // Enable input methods (e.g. Chinese, Japanese) so that users could input
95 // their first and last names.
96 if (g_browser_process) {
97 const std::string locale = g_browser_process->GetApplicationLocale();
98 input_method::EnableInputMethods(
99 locale, input_method::kAllInputMethods, "");
100 }
101 view()->ShowPageContent();
102 }
103
104 void HTMLPageScreen::OnPageLoadFailed(const std::string& url) {
105 LOG(INFO) << "HTMLPageScreen::OnPageLoadFailed: " << url;
106 CloseScreen(ScreenObserver::CONNECTION_FAILED);
107 }
108
109 ///////////////////////////////////////////////////////////////////////////////
110 // HTMLPageScreen, private:
111 void HTMLPageScreen::CloseScreen(ScreenObserver::ExitCodes code) {
112 StopTimeoutTimer();
113 // Disable input methods since they are not necessary to input username and
114 // password.
115 if (g_browser_process) {
116 const std::string locale = g_browser_process->GetApplicationLocale();
117 input_method::EnableInputMethods(
118 locale, input_method::kKeyboardLayoutsOnly, "");
119 }
120 delegate()->GetObserver(this)->OnExit(code);
121 }
122
123 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/html_page_screen.h ('k') | chrome/browser/chromeos/login/wizard_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698