| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/ui/webui/physical_web/physical_web_ui.h" | 5 #include "chrome/browser/ui/webui/physical_web/physical_web_ui.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/metrics/user_metrics.h" | 8 #include "base/metrics/user_metrics.h" |
| 9 #include "chrome/browser/browser_process_impl.h" | 9 #include "chrome/browser/browser_process_impl.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/common/url_constants.h" | 11 #include "chrome/common/url_constants.h" |
| 12 #include "components/grit/components_resources.h" | 12 #include "components/grit/components_resources.h" |
| 13 #include "components/physical_web/data_source/physical_web_data_source.h" | 13 #include "components/physical_web/data_source/physical_web_data_source.h" |
| 14 #include "components/physical_web/webui/physical_web_base_message_handler.h" | 14 #include "components/physical_web/webui/physical_web_base_message_handler.h" |
| 15 #include "components/physical_web/webui/physical_web_ui_constants.h" | 15 #include "components/physical_web/webui/physical_web_ui_constants.h" |
| 16 #include "components/strings/grit/components_strings.h" | 16 #include "components/strings/grit/components_strings.h" |
| 17 #include "content/public/browser/web_ui_data_source.h" | 17 #include "content/public/browser/web_ui_data_source.h" |
| 18 #include "content/public/browser/web_ui_message_handler.h" | 18 #include "content/public/browser/web_ui_message_handler.h" |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 content::WebUIDataSource* CreatePhysicalWebHTMLSource() { | 22 content::WebUIDataSource* CreatePhysicalWebHTMLSource() { |
| 23 content::WebUIDataSource* source = content::WebUIDataSource::Create( | 23 content::WebUIDataSource* source = content::WebUIDataSource::Create( |
| 24 chrome::kChromeUIPhysicalWebHost); | 24 chrome::kChromeUIPhysicalWebHost); |
| 25 | 25 |
| 26 source->AddLocalizedString(physical_web_ui::kTitle, | 26 source->AddLocalizedString(physical_web_ui::kTitle, |
| 27 IDS_PHYSICAL_WEB_UI_TITLE); | 27 IDS_PHYSICAL_WEB_UI_TITLE); |
| 28 source->AddLocalizedString(physical_web_ui::kEmptyMessage, |
| 29 IDS_PHYSICAL_WEB_UI_EMPTY_MESSAGE); |
| 28 source->SetJsonPath("strings.js"); | 30 source->SetJsonPath("strings.js"); |
| 29 source->AddResourcePath(physical_web_ui::kPhysicalWebJS, | 31 source->AddResourcePath(physical_web_ui::kPhysicalWebJS, |
| 30 IDR_PHYSICAL_WEB_UI_JS); | 32 IDR_PHYSICAL_WEB_UI_JS); |
| 31 source->AddResourcePath(physical_web_ui::kPhysicalWebCSS, | 33 source->AddResourcePath(physical_web_ui::kPhysicalWebCSS, |
| 32 IDR_PHYSICAL_WEB_UI_CSS); | 34 IDR_PHYSICAL_WEB_UI_CSS); |
| 33 source->SetDefaultResource(IDR_PHYSICAL_WEB_UI_HTML); | 35 source->SetDefaultResource(IDR_PHYSICAL_WEB_UI_HTML); |
| 34 return source; | 36 return source; |
| 35 } | 37 } |
| 36 | 38 |
| 37 // Implements all MessageHandler core functionality. This is extends the | 39 // Implements all MessageHandler core functionality. This is extends the |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 82 |
| 81 PhysicalWebUI::PhysicalWebUI(content::WebUI* web_ui) | 83 PhysicalWebUI::PhysicalWebUI(content::WebUI* web_ui) |
| 82 : WebUIController(web_ui) { | 84 : WebUIController(web_ui) { |
| 83 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), | 85 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), |
| 84 CreatePhysicalWebHTMLSource()); | 86 CreatePhysicalWebHTMLSource()); |
| 85 web_ui->AddMessageHandler(base::MakeUnique<PhysicalWebMessageHandler>()); | 87 web_ui->AddMessageHandler(base::MakeUnique<PhysicalWebMessageHandler>()); |
| 86 base::RecordAction(base::UserMetricsAction("PhysicalWeb.WebUI.Open")); | 88 base::RecordAction(base::UserMetricsAction("PhysicalWeb.WebUI.Open")); |
| 87 } | 89 } |
| 88 | 90 |
| 89 PhysicalWebUI::~PhysicalWebUI() = default; | 91 PhysicalWebUI::~PhysicalWebUI() = default; |
| OLD | NEW |