Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / chrome / browser / ui / webui / signin / inline_login_ui.cc
blob2f285aff0428f22bea721e4f0687d2e46c07b007
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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/webui/signin/inline_login_ui.h"
7 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/sessions/session_tab_helper.h"
10 #include "chrome/common/url_constants.h"
11 #include "content/public/browser/web_ui.h"
12 #include "content/public/browser/web_ui_data_source.h"
13 #include "grit/browser_resources.h"
14 #include "grit/chromium_strings.h"
15 #if defined(OS_CHROMEOS)
16 #include "chrome/browser/ui/webui/chromeos/login/inline_login_handler_chromeos.h"
17 #else
18 #include "chrome/browser/ui/webui/signin/inline_login_handler_impl.h"
19 #endif
21 namespace {
23 content::WebUIDataSource* CreateWebUIDataSource() {
24 content::WebUIDataSource* source =
25 content::WebUIDataSource::Create(chrome::kChromeUIChromeSigninHost);
26 source->OverrideContentSecurityPolicyFrameSrc("frame-src chrome-extension:;");
27 source->SetUseJsonJSFormatV2();
28 source->SetJsonPath("strings.js");
30 source->SetDefaultResource(IDR_INLINE_LOGIN_HTML);
31 source->AddResourcePath("inline_login.css", IDR_INLINE_LOGIN_CSS);
32 source->AddResourcePath("inline_login.js", IDR_INLINE_LOGIN_JS);
34 source->AddLocalizedString("title", IDS_CHROME_SIGNIN_TITLE);
35 return source;
38 } // empty namespace
40 InlineLoginUI::InlineLoginUI(content::WebUI* web_ui)
41 : WebDialogUI(web_ui),
42 auth_extension_(Profile::FromWebUI(web_ui)) {
43 Profile* profile = Profile::FromWebUI(web_ui);
44 content::WebUIDataSource::Add(profile, CreateWebUIDataSource());
46 #if defined(OS_CHROMEOS)
47 web_ui->AddMessageHandler(new chromeos::InlineLoginHandlerChromeOS());
48 #else
49 web_ui->AddMessageHandler(new InlineLoginHandlerImpl());
50 #endif
51 content::WebContents* contents = web_ui->GetWebContents();
52 // Required for intercepting extension function calls when the page is loaded
53 // in a bubble (not a full tab, thus tab helpers are not registered
54 // automatically).
55 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents(
56 contents);
57 // Ensure that the login UI has a tab ID, which will allow the GAIA auth
58 // extension's background script to tell it apart from iframes injected by
59 // other extensions.
60 SessionTabHelper::CreateForWebContents(contents);
63 InlineLoginUI::~InlineLoginUI() {}