OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chromeos/login/screen_observer.h" | 9 #include "chrome/browser/chromeos/login/screen_observer.h" |
10 #include "chrome/browser/profiles/profile_manager.h" | 10 #include "chrome/browser/profiles/profile_manager.h" |
11 #include "content/public/browser/render_view_host.h" | 11 #include "content/public/browser/render_view_host.h" |
12 #include "content/public/browser/site_instance.h" | 12 #include "content/public/browser/site_instance.h" |
13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
14 #include "ui/views/events/event.h" | 14 #include "ui/views/events/event.h" |
15 | 15 |
16 using content::SiteInstance; | 16 using content::SiteInstance; |
17 using content::WebContents; | 17 using content::WebContents; |
18 | 18 |
19 namespace chromeos { | 19 namespace chromeos { |
20 | 20 |
21 /////////////////////////////////////////////////////////////////////////////// | 21 /////////////////////////////////////////////////////////////////////////////// |
22 // HTMLPageView | 22 // HTMLPageView |
23 HTMLPageView::HTMLPageView() | 23 HTMLPageView::HTMLPageView(content::BrowserContext* browser_context) |
24 : dom_view_(new WebPageDomView()) { | 24 : dom_view_(new WebPageDomView(browser_context)) { |
25 } | 25 } |
26 | 26 |
27 WebPageDomView* HTMLPageView::dom_view() { | 27 WebPageDomView* HTMLPageView::dom_view() { |
28 return dom_view_; | 28 return dom_view_; |
29 } | 29 } |
30 | 30 |
31 /////////////////////////////////////////////////////////////////////////////// | 31 /////////////////////////////////////////////////////////////////////////////// |
32 // HTMLPageScreen, public: | 32 // HTMLPageScreen, public: |
33 HTMLPageScreen::HTMLPageScreen(ViewScreenDelegate* delegate, | 33 HTMLPageScreen::HTMLPageScreen(ViewScreenDelegate* delegate, |
34 const std::string& url) | 34 const std::string& url) |
35 : ViewScreen<HTMLPageView>(delegate), url_(url) { | 35 : ViewScreen<HTMLPageView>(delegate), url_(url) { |
36 } | 36 } |
37 | 37 |
38 HTMLPageScreen::~HTMLPageScreen() {} | 38 HTMLPageScreen::~HTMLPageScreen() {} |
39 | 39 |
40 /////////////////////////////////////////////////////////////////////////////// | 40 /////////////////////////////////////////////////////////////////////////////// |
41 // HTMLPageScreen, ViewScreen implementation: | 41 // HTMLPageScreen, ViewScreen implementation: |
42 void HTMLPageScreen::CreateView() { | 42 void HTMLPageScreen::CreateView() { |
43 ViewScreen<HTMLPageView>::CreateView(); | 43 ViewScreen<HTMLPageView>::CreateView(); |
44 } | 44 } |
45 | 45 |
46 void HTMLPageScreen::Refresh() { | 46 void HTMLPageScreen::Refresh() { |
47 VLOG(1) << "HTMLPageScreen::Refresh(): " << url_; | 47 VLOG(1) << "HTMLPageScreen::Refresh(): " << url_; |
48 StartTimeoutTimer(); | 48 StartTimeoutTimer(); |
49 GURL url(url_); | 49 GURL url(url_); |
50 Profile* profile = ProfileManager::GetDefaultProfile(); | 50 Profile* profile = ProfileManager::GetDefaultProfile(); |
51 view()->InitDOM(profile, SiteInstance::CreateForURL(profile, url)); | 51 view()->InitWebView(SiteInstance::CreateForURL(profile, url)); |
52 view()->SetWebContentsDelegate(this); | 52 view()->SetWebContentsDelegate(this); |
53 view()->LoadURL(url); | 53 view()->LoadURL(url); |
54 } | 54 } |
55 | 55 |
56 HTMLPageView* HTMLPageScreen::AllocateView() { | 56 HTMLPageView* HTMLPageScreen::AllocateView() { |
57 return new HTMLPageView(); | 57 return new HTMLPageView(ProfileManager::GetDefaultProfile()); |
58 } | 58 } |
59 | 59 |
60 void HTMLPageScreen::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { | 60 void HTMLPageScreen::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { |
61 unhandled_keyboard_handler_.HandleKeyboardEvent(event, | 61 unhandled_keyboard_handler_.HandleKeyboardEvent(event, |
62 view()->GetFocusManager()); | 62 view()->GetFocusManager()); |
63 } | 63 } |
64 | 64 |
65 /////////////////////////////////////////////////////////////////////////////// | 65 /////////////////////////////////////////////////////////////////////////////// |
66 // HTMLPageScreen, WebPageScreen implementation: | 66 // HTMLPageScreen, WebPageScreen implementation: |
67 void HTMLPageScreen::OnNetworkTimeout() { | 67 void HTMLPageScreen::OnNetworkTimeout() { |
68 VLOG(1) << "HTMLPageScreen::OnNetworkTimeout"; | 68 VLOG(1) << "HTMLPageScreen::OnNetworkTimeout"; |
69 // Just show what we have now. We shouldn't exit from the screen on timeout. | 69 // Just show what we have now. We shouldn't exit from the screen on timeout. |
70 StopTimeoutTimer(); | 70 StopTimeoutTimer(); |
71 view()->ShowPageContent(); | 71 view()->ShowPageContent(); |
72 } | 72 } |
73 | 73 |
74 /////////////////////////////////////////////////////////////////////////////// | 74 /////////////////////////////////////////////////////////////////////////////// |
75 // HTMLPageScreen, private: | 75 // HTMLPageScreen, private: |
76 void HTMLPageScreen::CloseScreen(ScreenObserver::ExitCodes code) { | 76 void HTMLPageScreen::CloseScreen(ScreenObserver::ExitCodes code) { |
77 StopTimeoutTimer(); | 77 StopTimeoutTimer(); |
78 delegate()->GetObserver()->OnExit(code); | 78 delegate()->GetObserver()->OnExit(code); |
79 } | 79 } |
80 | 80 |
81 } // namespace chromeos | 81 } // namespace chromeos |
OLD | NEW |