| 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/snippets_internals_ui.h" | 5 #include "chrome/browser/ui/webui/snippets_internals_ui.h" |
| 6 | 6 |
| 7 #include "chrome/browser/ntp_snippets/content_suggestions_service_factory.h" |
| 7 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/ui/webui/snippets_internals_message_handler.h" | 9 #include "chrome/browser/ui/webui/snippets_internals_message_handler.h" |
| 9 #include "chrome/common/url_constants.h" | 10 #include "chrome/common/url_constants.h" |
| 10 #include "chrome/grit/browser_resources.h" | 11 #include "chrome/grit/browser_resources.h" |
| 11 #include "content/public/browser/web_ui.h" | 12 #include "content/public/browser/web_ui.h" |
| 12 #include "content/public/browser/web_ui_data_source.h" | 13 #include "content/public/browser/web_ui_data_source.h" |
| 13 | 14 |
| 14 namespace { | 15 namespace { |
| 15 | 16 |
| 16 content::WebUIDataSource* CreateSnippetsInternalsHTMLSource() { | 17 content::WebUIDataSource* CreateSnippetsInternalsHTMLSource() { |
| 17 content::WebUIDataSource* source = | 18 content::WebUIDataSource* source = |
| 18 content::WebUIDataSource::Create(chrome::kChromeUISnippetsInternalsHost); | 19 content::WebUIDataSource::Create(chrome::kChromeUISnippetsInternalsHost); |
| 19 | 20 |
| 20 source->AddResourcePath("snippets_internals.js", IDR_SNIPPETS_INTERNALS_JS); | 21 source->AddResourcePath("snippets_internals.js", IDR_SNIPPETS_INTERNALS_JS); |
| 21 source->AddResourcePath("snippets_internals.css", IDR_SNIPPETS_INTERNALS_CSS); | 22 source->AddResourcePath("snippets_internals.css", IDR_SNIPPETS_INTERNALS_CSS); |
| 22 source->SetDefaultResource(IDR_SNIPPETS_INTERNALS_HTML); | 23 source->SetDefaultResource(IDR_SNIPPETS_INTERNALS_HTML); |
| 23 source->DisableI18nAndUseGzipForAllPaths(); | 24 source->DisableI18nAndUseGzipForAllPaths(); |
| 24 return source; | 25 return source; |
| 25 } | 26 } |
| 26 | 27 |
| 27 } // namespace | 28 } // namespace |
| 28 | 29 |
| 29 SnippetsInternalsUI::SnippetsInternalsUI(content::WebUI* web_ui) | 30 SnippetsInternalsUI::SnippetsInternalsUI(content::WebUI* web_ui) |
| 30 : WebUIController(web_ui) { | 31 : WebUIController(web_ui) { |
| 31 Profile* profile = Profile::FromWebUI(web_ui); | 32 Profile* profile = Profile::FromWebUI(web_ui); |
| 32 content::WebUIDataSource::Add(profile, CreateSnippetsInternalsHTMLSource()); | 33 content::WebUIDataSource::Add(profile, CreateSnippetsInternalsHTMLSource()); |
| 33 | 34 |
| 34 web_ui->AddMessageHandler(new SnippetsInternalsMessageHandler); | 35 web_ui->AddMessageHandler(new SnippetsInternalsMessageHandler( |
| 36 ContentSuggestionsServiceFactory::GetInstance()->GetForProfile(profile), |
| 37 profile->GetPrefs())); |
| 35 } | 38 } |
| 36 | 39 |
| 37 SnippetsInternalsUI::~SnippetsInternalsUI() {} | 40 SnippetsInternalsUI::~SnippetsInternalsUI() {} |
| OLD | NEW |