ServiceWorker: Decompose SWRegistration::SetVersionInternal for readability
[chromium-blink-merge.git] / ui / oobe / oobe_md_ui.cc
blob07e91b59931d1ded0a1e93c3eaacce06526bfa37
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 "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"
13 namespace {
15 void SetUpDataSource(content::WebUIDataSource* source) {
16 source->SetJsonPath("strings.js");
17 source->AddResourcePath("", IDR_OOBE_UI_HTML);
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(StartsWithASCII(name, prefix, true));
25 source->AddResourcePath(name.substr(prefix_length),
26 kOobeResources[i].value);
30 } // namespace
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);
37 view_.reset(new gen::OobeWebUIView(web_ui));
38 view_->Init();
39 view_->SetUpDataSource(source);
41 content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(),
42 source);
45 OobeMdUI::~OobeMdUI() {}