| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #include "base/strings/string_util.h" | |
| 6 #include "content/public/browser/web_contents.h" | |
| 7 #include "content/public/browser/web_ui_data_source.h" | |
| 8 #include "grit/oobe_resources.h" | |
| 9 #include "grit/oobe_resources_map.h" | |
| 10 #include "ui/oobe/declarations/oobe_web_ui_view.h" | |
| 11 #include "ui/oobe/oobe_md_ui.h" | |
| 12 | |
| 13 namespace { | |
| 14 | |
| 15 void SetUpDataSource(content::WebUIDataSource* source) { | |
| 16 source->SetJsonPath("strings.js"); | |
| 17 source->AddResourcePath("", IDR_OOBE_UI_HTML); | |
| 18 | |
| 19 // Add all resources defined in "oobe_resources.grd" file at once. | |
| 20 const char prefix[] = "resources/"; | |
| 21 const size_t prefix_length = arraysize(prefix) - 1; | |
| 22 for (size_t i = 0; i < kOobeResourcesSize; ++i) { | |
| 23 std::string name = kOobeResources[i].name; | |
| 24 DCHECK(base::StartsWithASCII(name, prefix, true)); | |
| 25 source->AddResourcePath(name.substr(prefix_length), | |
| 26 kOobeResources[i].value); | |
| 27 } | |
| 28 } | |
| 29 | |
| 30 } // namespace | |
| 31 | |
| 32 OobeMdUI::OobeMdUI(content::WebUI* web_ui, const std::string& host) | |
| 33 : WebUIController(web_ui) { | |
| 34 content::WebUIDataSource* source = content::WebUIDataSource::Create(host); | |
| 35 SetUpDataSource(source); | |
| 36 | |
| 37 view_.reset(new gen::OobeWebUIView(web_ui)); | |
| 38 view_->Init(); | |
| 39 view_->SetUpDataSource(source); | |
| 40 | |
| 41 content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(), | |
| 42 source); | |
| 43 } | |
| 44 | |
| 45 OobeMdUI::~OobeMdUI() {} | |
| OLD | NEW |