OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui/webui/signin/inline_login_ui.h" | 5 #include "chrome/browser/ui/webui/signin/inline_login_ui.h" |
6 | 6 |
7 #include "chrome/browser/extensions/extension_web_contents_observer.h" | |
8 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/common/url_constants.h" | 8 #include "chrome/common/url_constants.h" |
10 #include "content/public/browser/web_ui.h" | 9 #include "content/public/browser/web_ui.h" |
11 #include "content/public/browser/web_ui_data_source.h" | 10 #include "content/public/browser/web_ui_data_source.h" |
12 #include "grit/browser_resources.h" | 11 #include "grit/browser_resources.h" |
13 #include "grit/chromium_strings.h" | 12 #include "grit/chromium_strings.h" |
14 #if defined(OS_CHROMEOS) | 13 #if defined(OS_CHROMEOS) |
15 #include "chrome/browser/ui/webui/chromeos/login/inline_login_handler_chromeos.h
" | 14 #include "chrome/browser/ui/webui/chromeos/login/inline_login_handler_chromeos.h
" |
16 #else | 15 #else |
17 #include "chrome/browser/extensions/tab_helper.h" | 16 #include "chrome/browser/extensions/tab_helper.h" |
18 #include "chrome/browser/ui/webui/signin/inline_login_handler_impl.h" | 17 #include "chrome/browser/ui/webui/signin/inline_login_handler_impl.h" |
19 #endif | 18 #endif |
20 | 19 |
21 namespace { | 20 namespace { |
22 | 21 |
23 content::WebUIDataSource* CreateWebUIDataSource() { | 22 content::WebUIDataSource* CreateWebUIDataSource() { |
24 content::WebUIDataSource* source = | 23 content::WebUIDataSource* source = |
25 content::WebUIDataSource::Create(chrome::kChromeUIChromeSigninHost); | 24 content::WebUIDataSource::Create(chrome::kChromeUIChromeSigninHost); |
26 source->OverrideContentSecurityPolicyFrameSrc("frame-src chrome-extension:;"); | |
27 source->SetUseJsonJSFormatV2(); | 25 source->SetUseJsonJSFormatV2(); |
28 source->SetJsonPath("strings.js"); | 26 source->SetJsonPath("strings.js"); |
29 | 27 |
30 source->SetDefaultResource(IDR_INLINE_LOGIN_HTML); | 28 source->SetDefaultResource(IDR_INLINE_LOGIN_HTML); |
31 source->AddResourcePath("inline_login.css", IDR_INLINE_LOGIN_CSS); | 29 source->AddResourcePath("inline_login.css", IDR_INLINE_LOGIN_CSS); |
32 source->AddResourcePath("inline_login.js", IDR_INLINE_LOGIN_JS); | 30 source->AddResourcePath("inline_login.js", IDR_INLINE_LOGIN_JS); |
33 | 31 |
34 source->AddLocalizedString("title", IDS_CHROME_SIGNIN_TITLE); | 32 source->AddLocalizedString("title", IDS_CHROME_SIGNIN_TITLE); |
35 return source; | 33 return source; |
36 }; | 34 }; |
37 | 35 |
38 } // empty namespace | 36 } // empty namespace |
39 | 37 |
40 InlineLoginUI::InlineLoginUI(content::WebUI* web_ui) | 38 InlineLoginUI::InlineLoginUI(content::WebUI* web_ui) |
41 : WebDialogUI(web_ui), | 39 : WebDialogUI(web_ui), |
42 auth_extension_(Profile::FromWebUI(web_ui)) { | 40 auth_extension_(Profile::FromWebUI(web_ui)) { |
43 Profile* profile = Profile::FromWebUI(web_ui); | 41 Profile* profile = Profile::FromWebUI(web_ui); |
44 content::WebUIDataSource::Add(profile, CreateWebUIDataSource()); | 42 content::WebUIDataSource::Add(profile, CreateWebUIDataSource()); |
45 | 43 |
46 #if defined(OS_CHROMEOS) | 44 #if defined(OS_CHROMEOS) |
47 web_ui->AddMessageHandler(new chromeos::InlineLoginHandlerChromeOS()); | 45 web_ui->AddMessageHandler(new chromeos::InlineLoginHandlerChromeOS()); |
48 #else | 46 #else |
49 web_ui->AddMessageHandler(new InlineLoginHandlerImpl()); | 47 web_ui->AddMessageHandler(new InlineLoginHandlerImpl()); |
50 // Required for intercepting extension function calls when the page is loaded | 48 // Required for intercepting extension function calls when the page is loaded |
51 // in a bubble (not a full tab, thus tab helpers are not registered | 49 // in a bubble (not a full tab, thus tab helpers are not registered |
52 // automatically). | 50 // automatically). |
53 extensions::ExtensionWebContentsObserver::CreateForWebContents( | 51 extensions::TabHelper::CreateForWebContents(web_ui->GetWebContents()); |
54 web_ui->GetWebContents()); | |
55 #endif | 52 #endif |
56 } | 53 } |
57 | 54 |
58 InlineLoginUI::~InlineLoginUI() {} | 55 InlineLoginUI::~InlineLoginUI() {} |
OLD | NEW |