| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/login/html_page_screen.h" | 5 #include "chrome/browser/chromeos/login/html_page_screen.h" |
| 6 | 6 |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 10 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 } | 43 } |
| 44 | 44 |
| 45 /////////////////////////////////////////////////////////////////////////////// | 45 /////////////////////////////////////////////////////////////////////////////// |
| 46 // HTMLPageScreen, ViewScreen implementation: | 46 // HTMLPageScreen, ViewScreen implementation: |
| 47 void HTMLPageScreen::CreateView() { | 47 void HTMLPageScreen::CreateView() { |
| 48 ViewScreen<HTMLPageView>::CreateView(); | 48 ViewScreen<HTMLPageView>::CreateView(); |
| 49 view()->SetWebPageDelegate(this); | 49 view()->SetWebPageDelegate(this); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void HTMLPageScreen::Refresh() { | 52 void HTMLPageScreen::Refresh() { |
| 53 LOG(INFO) << "HTMLPageScreen::Refresh(): " << url_; | 53 VLOG(1) << "HTMLPageScreen::Refresh(): " << url_; |
| 54 StartTimeoutTimer(); | 54 StartTimeoutTimer(); |
| 55 GURL url(url_); | 55 GURL url(url_); |
| 56 Profile* profile = ProfileManager::GetDefaultProfile(); | 56 Profile* profile = ProfileManager::GetDefaultProfile(); |
| 57 view()->InitDOM(profile, | 57 view()->InitDOM(profile, |
| 58 SiteInstance::CreateSiteInstanceForURL(profile, url)); | 58 SiteInstance::CreateSiteInstanceForURL(profile, url)); |
| 59 view()->SetTabContentsDelegate(this); | 59 view()->SetTabContentsDelegate(this); |
| 60 view()->LoadURL(url); | 60 view()->LoadURL(url); |
| 61 } | 61 } |
| 62 | 62 |
| 63 HTMLPageView* HTMLPageScreen::AllocateView() { | 63 HTMLPageView* HTMLPageScreen::AllocateView() { |
| 64 return new HTMLPageView(); | 64 return new HTMLPageView(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 /////////////////////////////////////////////////////////////////////////////// | 67 /////////////////////////////////////////////////////////////////////////////// |
| 68 // HTMLPageScreen, TabContentsDelegate implementation: | 68 // HTMLPageScreen, TabContentsDelegate implementation: |
| 69 void HTMLPageScreen::LoadingStateChanged(TabContents* source) { | 69 void HTMLPageScreen::LoadingStateChanged(TabContents* source) { |
| 70 std::string url = source->GetURL().spec(); | 70 std::string url = source->GetURL().spec(); |
| 71 if (url == kHTMLPageDoneUrl) { | 71 if (url == kHTMLPageDoneUrl) { |
| 72 source->Stop(); | 72 source->Stop(); |
| 73 // TODO(dpolukhin): use special code for this case but now | 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. | 74 // ACCOUNT_CREATE_BACK works as we would like, i.e. get to login page. |
| 75 LOG(INFO) << "HTMLPageScreen::LoadingStateChanged: " << url; | 75 VLOG(1) << "HTMLPageScreen::LoadingStateChanged: " << url; |
| 76 CloseScreen(ScreenObserver::ACCOUNT_CREATE_BACK); | 76 CloseScreen(ScreenObserver::ACCOUNT_CREATE_BACK); |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 | 79 |
| 80 void HTMLPageScreen::NavigationStateChanged(const TabContents* source, | 80 void HTMLPageScreen::NavigationStateChanged(const TabContents* source, |
| 81 unsigned changed_flags) { | 81 unsigned changed_flags) { |
| 82 } | 82 } |
| 83 | 83 |
| 84 void HTMLPageScreen::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { | 84 void HTMLPageScreen::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { |
| 85 views::Widget* widget = view()->GetWidget(); | 85 views::Widget* widget = view()->GetWidget(); |
| 86 if (widget && event.os_event && !event.skip_in_browser) | 86 if (widget && event.os_event && !event.skip_in_browser) |
| 87 static_cast<views::WidgetGtk*>(widget)->HandleKeyboardEvent(event.os_event); | 87 static_cast<views::WidgetGtk*>(widget)->HandleKeyboardEvent(event.os_event); |
| 88 } | 88 } |
| 89 | 89 |
| 90 /////////////////////////////////////////////////////////////////////////////// | 90 /////////////////////////////////////////////////////////////////////////////// |
| 91 // HTMLPageScreen, WebPageDelegate implementation: | 91 // HTMLPageScreen, WebPageDelegate implementation: |
| 92 void HTMLPageScreen::OnPageLoaded() { | 92 void HTMLPageScreen::OnPageLoaded() { |
| 93 StopTimeoutTimer(); | 93 StopTimeoutTimer(); |
| 94 // Enable input methods (e.g. Chinese, Japanese) so that users could input | 94 // Enable input methods (e.g. Chinese, Japanese) so that users could input |
| 95 // their first and last names. | 95 // their first and last names. |
| 96 if (g_browser_process) { | 96 if (g_browser_process) { |
| 97 const std::string locale = g_browser_process->GetApplicationLocale(); | 97 const std::string locale = g_browser_process->GetApplicationLocale(); |
| 98 input_method::EnableInputMethods( | 98 input_method::EnableInputMethods( |
| 99 locale, input_method::kAllInputMethods, ""); | 99 locale, input_method::kAllInputMethods, ""); |
| 100 } | 100 } |
| 101 view()->ShowPageContent(); | 101 view()->ShowPageContent(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 void HTMLPageScreen::OnPageLoadFailed(const std::string& url) { | 104 void HTMLPageScreen::OnPageLoadFailed(const std::string& url) { |
| 105 LOG(INFO) << "HTMLPageScreen::OnPageLoadFailed: " << url; | 105 VLOG(1) << "HTMLPageScreen::OnPageLoadFailed: " << url; |
| 106 CloseScreen(ScreenObserver::CONNECTION_FAILED); | 106 CloseScreen(ScreenObserver::CONNECTION_FAILED); |
| 107 } | 107 } |
| 108 | 108 |
| 109 /////////////////////////////////////////////////////////////////////////////// | 109 /////////////////////////////////////////////////////////////////////////////// |
| 110 // HTMLPageScreen, WebPageScreen implementation: | 110 // HTMLPageScreen, WebPageScreen implementation: |
| 111 void HTMLPageScreen::OnNetworkTimeout() { | 111 void HTMLPageScreen::OnNetworkTimeout() { |
| 112 LOG(INFO) << "HTMLPageScreen::OnNetworkTimeout"; | 112 VLOG(1) << "HTMLPageScreen::OnNetworkTimeout"; |
| 113 // Just show what we have now. We shouldn't exit from the screen on timeout. | 113 // Just show what we have now. We shouldn't exit from the screen on timeout. |
| 114 OnPageLoaded(); | 114 OnPageLoaded(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 /////////////////////////////////////////////////////////////////////////////// | 117 /////////////////////////////////////////////////////////////////////////////// |
| 118 // HTMLPageScreen, private: | 118 // HTMLPageScreen, private: |
| 119 void HTMLPageScreen::CloseScreen(ScreenObserver::ExitCodes code) { | 119 void HTMLPageScreen::CloseScreen(ScreenObserver::ExitCodes code) { |
| 120 StopTimeoutTimer(); | 120 StopTimeoutTimer(); |
| 121 // Disable input methods since they are not necessary to input username and | 121 // Disable input methods since they are not necessary to input username and |
| 122 // password. | 122 // password. |
| 123 if (g_browser_process) { | 123 if (g_browser_process) { |
| 124 const std::string locale = g_browser_process->GetApplicationLocale(); | 124 const std::string locale = g_browser_process->GetApplicationLocale(); |
| 125 input_method::EnableInputMethods( | 125 input_method::EnableInputMethods( |
| 126 locale, input_method::kKeyboardLayoutsOnly, ""); | 126 locale, input_method::kKeyboardLayoutsOnly, ""); |
| 127 } | 127 } |
| 128 delegate()->GetObserver(this)->OnExit(code); | 128 delegate()->GetObserver(this)->OnExit(code); |
| 129 } | 129 } |
| 130 | 130 |
| 131 } // namespace chromeos | 131 } // namespace chromeos |
| OLD | NEW |