Chromium Code Reviews| 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 "content/browser/media/media_internals_handler.h" | 8 #include "content/browser/media/media_internals_handler.h" |
| 8 #include "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
| 9 #include "content/public/browser/web_ui.h" | 10 #include "content/public/browser/web_ui.h" |
| 10 #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" | |
| 11 #include "content/public/common/url_constants.h" | 13 #include "content/public/common/url_constants.h" |
| 12 #include "grit/content_resources.h" | 14 #include "grit/content_resources.h" |
| 13 | 15 |
| 14 namespace content { | 16 namespace content { |
| 15 namespace { | 17 namespace { |
| 16 | 18 |
| 17 WebUIDataSource* CreateMediaInternalsHTMLSource() { | 19 WebUIDataSource* CreateMediaInternalsHTMLSource() { |
| 18 WebUIDataSource* source = | 20 WebUIDataSource* source = |
| 19 WebUIDataSource::Create(kChromeUIMediaInternalsHost); | 21 WebUIDataSource::Create(kChromeUIMediaInternalsHost); |
| 20 | 22 |
| 21 source->SetJsonPath("strings.js"); | 23 source->SetJsonPath("strings.js"); |
| 22 source->AddResourcePath("media_internals.js", IDR_MEDIA_INTERNALS_JS); | 24 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 23 source->SetDefaultResource(IDR_MEDIA_INTERNALS_HTML); | 25 switches::kEnableNewMediaInternals)) { |
| 26 source->AddResourcePath("media_internals.js", IDR_MEDIA_INTERNALS_NEW_JS); | |
| 27 source->SetDefaultResource(IDR_MEDIA_INTERNALS_NEW_HTML); | |
|
scherkus (not reviewing)
2013/07/19 01:58:49
nit: return early here instead of sticking the oth
Ty Overby
2013/07/19 17:48:00
Done.
| |
| 28 } else { | |
| 29 source->AddResourcePath("media_internals.js", IDR_MEDIA_INTERNALS_JS); | |
| 30 source->SetDefaultResource(IDR_MEDIA_INTERNALS_HTML); | |
| 31 } | |
| 24 return source; | 32 return source; |
| 25 } | 33 } |
| 26 | 34 |
| 27 } // namespace | 35 } // namespace |
| 28 | 36 |
| 29 //////////////////////////////////////////////////////////////////////////////// | 37 //////////////////////////////////////////////////////////////////////////////// |
| 30 // | 38 // |
| 31 // MediaInternalsUI | 39 // MediaInternalsUI |
| 32 // | 40 // |
| 33 //////////////////////////////////////////////////////////////////////////////// | 41 //////////////////////////////////////////////////////////////////////////////// |
| 34 | 42 |
| 35 MediaInternalsUI::MediaInternalsUI(WebUI* web_ui) | 43 MediaInternalsUI::MediaInternalsUI(WebUI* web_ui) |
| 36 : WebUIController(web_ui) { | 44 : WebUIController(web_ui) { |
| 37 web_ui->AddMessageHandler(new MediaInternalsMessageHandler()); | 45 web_ui->AddMessageHandler(new MediaInternalsMessageHandler()); |
| 38 | 46 |
| 39 BrowserContext* browser_context = | 47 BrowserContext* browser_context = |
| 40 web_ui->GetWebContents()->GetBrowserContext(); | 48 web_ui->GetWebContents()->GetBrowserContext(); |
| 41 WebUIDataSource::Add(browser_context, CreateMediaInternalsHTMLSource()); | 49 WebUIDataSource::Add(browser_context, CreateMediaInternalsHTMLSource()); |
| 42 } | 50 } |
| 43 | 51 |
| 44 } // namespace content | 52 } // namespace content |
| OLD | NEW |