Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / chrome / browser / ui / webui / media_router / media_router_ui.cc
blob893dc733c1a379b0c38d8c86110519efa20d23c4
1 // Copyright 2015 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/media_router/media_router_ui.h"
7 #include <string>
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/webui/media_router/media_router_localized_strings_provider.h"
11 #include "chrome/browser/ui/webui/media_router/media_router_resources_provider.h"
12 #include "chrome/browser/ui/webui/media_router/media_router_webui_message_handler.h"
13 #include "chrome/common/url_constants.h"
14 #include "content/public/browser/web_ui.h"
15 #include "content/public/browser/web_ui_data_source.h"
16 #include "ui/web_dialogs/web_dialog_delegate.h"
18 namespace media_router {
20 MediaRouterUI::MediaRouterUI(content::WebUI* web_ui)
21 : ConstrainedWebDialogUI(web_ui),
22 handler_(new MediaRouterWebUIMessageHandler()) {
23 // Create a WebUIDataSource containing the chrome://media-router page's
24 // content.
25 scoped_ptr<content::WebUIDataSource> html_source(
26 content::WebUIDataSource::Create(chrome::kChromeUIMediaRouterHost));
27 AddLocalizedStrings(html_source.get());
28 AddMediaRouterUIResources(html_source.get());
29 Profile* profile = Profile::FromWebUI(web_ui);
30 // Ownership of |html_source| is transferred to the BrowserContext.
31 content::WebUIDataSource::Add(profile, html_source.release());
32 // Ownership of |handler_| is transferred to |web_ui|.
33 web_ui->AddMessageHandler(handler_);
36 MediaRouterUI::~MediaRouterUI() {
39 void MediaRouterUI::Close() {
40 ConstrainedWebDialogDelegate* delegate = GetConstrainedDelegate();
41 if (delegate) {
42 delegate->GetWebDialogDelegate()->OnDialogClosed(std::string());
43 delegate->OnDialogCloseFromWebUI();
47 } // namespace media_router