Index: chrome/browser/chromeos/login/html_page_screen.cc |
diff --git a/chrome/browser/chromeos/login/html_page_screen.cc b/chrome/browser/chromeos/login/html_page_screen.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..17bcaf0bdad71594a66b705128de7b6cfd8c851c |
--- /dev/null |
+++ b/chrome/browser/chromeos/login/html_page_screen.cc |
@@ -0,0 +1,123 @@ |
+// Copyright (c) 2010 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/login/html_page_screen.h" |
+ |
+#include "base/string_util.h" |
+#include "base/utf_string_conversions.h" |
+#include "chrome/browser/browser_process.h" |
+#include "chrome/browser/chromeos/input_method/input_method_util.h" |
+#include "chrome/browser/chromeos/login/screen_observer.h" |
+#include "chrome/browser/profile_manager.h" |
+#include "chrome/browser/renderer_host/render_view_host.h" |
+#include "chrome/browser/renderer_host/site_instance.h" |
+#include "chrome/browser/tab_contents/tab_contents.h" |
+#include "googleurl/src/gurl.h" |
+#include "views/widget/widget_gtk.h" |
+ |
+namespace chromeos { |
+ |
+static const char kHTMLPageDoneUrl[] = "about:blank"; |
+ |
+/////////////////////////////////////////////////////////////////////////////// |
+// HTMLPageDomView |
+TabContents* HTMLPageDomView::CreateTabContents(Profile* profile, |
+ SiteInstance* instance) { |
+ return new WizardWebPageViewTabContents(profile, |
+ instance, |
+ page_delegate_); |
+} |
+ |
+/////////////////////////////////////////////////////////////////////////////// |
+// HTMLPageView |
+HTMLPageView::HTMLPageView() |
+ : dom_view_(new HTMLPageDomView()) { |
+} |
+ |
+/////////////////////////////////////////////////////////////////////////////// |
+// HTMLPageScreen, public: |
+HTMLPageScreen::HTMLPageScreen(WizardScreenDelegate* delegate, |
+ const std::string& url) |
+ : ViewScreen<HTMLPageView>(delegate), url_(url) { |
+} |
+ |
+/////////////////////////////////////////////////////////////////////////////// |
+// HTMLPageScreen, ViewScreen implementation: |
+void HTMLPageScreen::CreateView() { |
+ ViewScreen<HTMLPageView>::CreateView(); |
+ view()->SetWebPageDelegate(this); |
+} |
+ |
+void HTMLPageScreen::Refresh() { |
+ LOG(INFO) << "HTMLPageScreen::Refresh(): " << url_; |
+ StartTimeoutTimer(); |
+ GURL url(url_); |
+ Profile* profile = ProfileManager::GetDefaultProfile(); |
+ view()->InitDOM(profile, |
+ SiteInstance::CreateSiteInstanceForURL(profile, url)); |
+ view()->SetTabContentsDelegate(this); |
+ view()->LoadURL(url); |
+} |
+ |
+HTMLPageView* HTMLPageScreen::AllocateView() { |
+ return new HTMLPageView(); |
+} |
+ |
+/////////////////////////////////////////////////////////////////////////////// |
+// HTMLPageScreen, TabContentsDelegate implementation: |
+void HTMLPageScreen::LoadingStateChanged(TabContents* source) { |
+ std::string url = source->GetURL().spec(); |
+ if (url == kHTMLPageDoneUrl) { |
+ source->Stop(); |
+ // TODO(dpolukhin): use special code for this case but now |
+ // ACCOUNT_CREATE_BACK works as we would like, i.e. get to login page. |
+ LOG(INFO) << "HTMLPageScreen::LoadingStateChanged: " << url; |
+ CloseScreen(ScreenObserver::ACCOUNT_CREATE_BACK); |
+ } |
+} |
+ |
+void HTMLPageScreen::NavigationStateChanged(const TabContents* source, |
+ unsigned changed_flags) { |
+} |
+ |
+void HTMLPageScreen::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { |
+ views::Widget* widget = view()->GetWidget(); |
+ if (widget && event.os_event && !event.skip_in_browser) |
+ static_cast<views::WidgetGtk*>(widget)->HandleKeyboardEvent(event.os_event); |
+} |
+ |
+/////////////////////////////////////////////////////////////////////////////// |
+// HTMLPageScreen, WebPageDelegate implementation: |
+void HTMLPageScreen::OnPageLoaded() { |
+ StopTimeoutTimer(); |
+ // Enable input methods (e.g. Chinese, Japanese) so that users could input |
+ // their first and last names. |
+ if (g_browser_process) { |
+ const std::string locale = g_browser_process->GetApplicationLocale(); |
+ input_method::EnableInputMethods( |
+ locale, input_method::kAllInputMethods, ""); |
+ } |
+ view()->ShowPageContent(); |
+} |
+ |
+void HTMLPageScreen::OnPageLoadFailed(const std::string& url) { |
+ LOG(INFO) << "HTMLPageScreen::OnPageLoadFailed: " << url; |
+ CloseScreen(ScreenObserver::CONNECTION_FAILED); |
+} |
+ |
+/////////////////////////////////////////////////////////////////////////////// |
+// HTMLPageScreen, private: |
+void HTMLPageScreen::CloseScreen(ScreenObserver::ExitCodes code) { |
+ StopTimeoutTimer(); |
+ // Disable input methods since they are not necessary to input username and |
+ // password. |
+ if (g_browser_process) { |
+ const std::string locale = g_browser_process->GetApplicationLocale(); |
+ input_method::EnableInputMethods( |
+ locale, input_method::kKeyboardLayoutsOnly, ""); |
+ } |
+ delegate()->GetObserver(this)->OnExit(code); |
+} |
+ |
+} // namespace chromeos |