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 "content/browser/media/media_internals_ui.h" | 5 #include "content/browser/media/media_internals_ui.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "content/browser/media/media_internals_handler.h" | 8 #include "content/browser/media/media_internals_handler.h" |
9 #include "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
10 #include "content/public/browser/web_ui.h" | 10 #include "content/public/browser/web_ui.h" |
11 #include "content/public/browser/web_ui_data_source.h" | 11 #include "content/public/browser/web_ui_data_source.h" |
12 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
13 #include "content/public/common/url_constants.h" | 13 #include "content/public/common/url_constants.h" |
14 #include "grit/content_resources.h" | 14 #include "grit/content_resources.h" |
15 | 15 |
16 namespace content { | 16 namespace content { |
17 namespace { | 17 namespace { |
18 | 18 |
19 WebUIDataSource* CreateMediaInternalsHTMLSource() { | 19 WebUIDataSource* CreateMediaInternalsHTMLSource() { |
20 WebUIDataSource* source = | 20 WebUIDataSource* source = |
21 WebUIDataSource::Create(kChromeUIMediaInternalsHost); | 21 WebUIDataSource::Create(kChromeUIMediaInternalsHost); |
22 | 22 |
23 source->SetJsonPath("strings.js"); | 23 source->SetJsonPath("strings.js"); |
24 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
25 switches::kEnableNewMediaInternals)) { | |
26 source->AddResourcePath("media_internals.js", IDR_MEDIA_INTERNALS_NEW_JS); | |
27 source->SetDefaultResource(IDR_MEDIA_INTERNALS_NEW_HTML); | |
28 return source; | |
29 } | |
30 | 24 |
31 source->AddResourcePath("media_internals.js", IDR_MEDIA_INTERNALS_JS); | 25 source->AddResourcePath("media_internals.js", IDR_MEDIA_INTERNALS_JS); |
32 source->SetDefaultResource(IDR_MEDIA_INTERNALS_HTML); | 26 source->SetDefaultResource(IDR_MEDIA_INTERNALS_HTML); |
33 return source; | 27 return source; |
34 } | 28 } |
35 | 29 |
36 } // namespace | 30 } // namespace |
37 | 31 |
38 //////////////////////////////////////////////////////////////////////////////// | 32 //////////////////////////////////////////////////////////////////////////////// |
39 // | 33 // |
40 // MediaInternalsUI | 34 // MediaInternalsUI |
41 // | 35 // |
42 //////////////////////////////////////////////////////////////////////////////// | 36 //////////////////////////////////////////////////////////////////////////////// |
43 | 37 |
44 MediaInternalsUI::MediaInternalsUI(WebUI* web_ui) | 38 MediaInternalsUI::MediaInternalsUI(WebUI* web_ui) |
45 : WebUIController(web_ui) { | 39 : WebUIController(web_ui) { |
46 web_ui->AddMessageHandler(new MediaInternalsMessageHandler()); | 40 web_ui->AddMessageHandler(new MediaInternalsMessageHandler()); |
47 | 41 |
48 BrowserContext* browser_context = | 42 BrowserContext* browser_context = |
49 web_ui->GetWebContents()->GetBrowserContext(); | 43 web_ui->GetWebContents()->GetBrowserContext(); |
50 WebUIDataSource::Add(browser_context, CreateMediaInternalsHTMLSource()); | 44 WebUIDataSource::Add(browser_context, CreateMediaInternalsHTMLSource()); |
51 } | 45 } |
52 | 46 |
53 } // namespace content | 47 } // namespace content |
OLD | NEW |