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