Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: chrome/browser/ui/webui/device_log_ui.cc

Issue 919183002: Move chromeos::device_event_log into components. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Shut down in PostDestroyThreads. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/webui/device_log_ui.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/chromeos/device_log_ui.h" 5 #include "chrome/browser/ui/webui/device_log_ui.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/common/url_constants.h" 12 #include "chrome/common/url_constants.h"
13 #include "chrome/grit/chromium_strings.h"
13 #include "chrome/grit/generated_resources.h" 14 #include "chrome/grit/generated_resources.h"
14 #include "chromeos/device_event_log.h" 15 #include "components/device_event_log/device_event_log.h"
15 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
16 #include "content/public/browser/web_ui.h" 17 #include "content/public/browser/web_ui.h"
17 #include "content/public/browser/web_ui_data_source.h" 18 #include "content/public/browser/web_ui_data_source.h"
18 #include "content/public/browser/web_ui_message_handler.h" 19 #include "content/public/browser/web_ui_message_handler.h"
19 #include "grit/browser_resources.h" 20 #include "grit/browser_resources.h"
20 21
21 namespace chromeos { 22 namespace chromeos {
22 23
23 namespace { 24 namespace {
24 25
25 class DeviceLogMessageHandler : public content::WebUIMessageHandler { 26 class DeviceLogMessageHandler : public content::WebUIMessageHandler {
26 public: 27 public:
27 DeviceLogMessageHandler() {} 28 DeviceLogMessageHandler() {}
28 ~DeviceLogMessageHandler() override {} 29 ~DeviceLogMessageHandler() override {}
29 30
30 // WebUIMessageHandler implementation. 31 // WebUIMessageHandler implementation.
31 void RegisterMessages() override { 32 void RegisterMessages() override {
32 web_ui()->RegisterMessageCallback( 33 web_ui()->RegisterMessageCallback(
33 "DeviceLog.getLog", 34 "DeviceLog.getLog",
34 base::Bind(&DeviceLogMessageHandler::GetLog, 35 base::Bind(&DeviceLogMessageHandler::GetLog, base::Unretained(this)));
35 base::Unretained(this)));
36 } 36 }
37 37
38 private: 38 private:
39 void GetLog(const base::ListValue* value) const { 39 void GetLog(const base::ListValue* value) const {
40 base::StringValue data(chromeos::device_event_log::GetAsString( 40 base::StringValue data(device_event_log::GetAsString(
41 chromeos::device_event_log::NEWEST_FIRST, "json", "", 41 device_event_log::NEWEST_FIRST, "json", "",
42 chromeos::device_event_log::LOG_LEVEL_DEBUG, 0)); 42 device_event_log::LOG_LEVEL_DEBUG, 0));
43 web_ui()->CallJavascriptFunction("DeviceLogUI.getLogCallback", data); 43 web_ui()->CallJavascriptFunction("DeviceLogUI.getLogCallback", data);
44 } 44 }
45 45
46 DISALLOW_COPY_AND_ASSIGN(DeviceLogMessageHandler); 46 DISALLOW_COPY_AND_ASSIGN(DeviceLogMessageHandler);
47 }; 47 };
48 48
49 } // namespace 49 } // namespace
50 50
51 DeviceLogUI::DeviceLogUI(content::WebUI* web_ui) 51 DeviceLogUI::DeviceLogUI(content::WebUI* web_ui)
52 : content::WebUIController(web_ui) { 52 : content::WebUIController(web_ui) {
(...skipping 18 matching lines...) Expand all
71 html->AddLocalizedString("logTypeLoginText", IDS_DEVICE_LOG_TYPE_LOGIN); 71 html->AddLocalizedString("logTypeLoginText", IDS_DEVICE_LOG_TYPE_LOGIN);
72 html->AddLocalizedString("logTypeNetworkText", IDS_DEVICE_LOG_TYPE_NETWORK); 72 html->AddLocalizedString("logTypeNetworkText", IDS_DEVICE_LOG_TYPE_NETWORK);
73 html->AddLocalizedString("logTypePowerText", IDS_DEVICE_LOG_TYPE_POWER); 73 html->AddLocalizedString("logTypePowerText", IDS_DEVICE_LOG_TYPE_POWER);
74 74
75 html->AddLocalizedString("logEntryFormat", IDS_DEVICE_LOG_ENTRY); 75 html->AddLocalizedString("logEntryFormat", IDS_DEVICE_LOG_ENTRY);
76 html->SetJsonPath("strings.js"); 76 html->SetJsonPath("strings.js");
77 html->AddResourcePath("device_log_ui.css", IDR_DEVICE_LOG_UI_CSS); 77 html->AddResourcePath("device_log_ui.css", IDR_DEVICE_LOG_UI_CSS);
78 html->AddResourcePath("device_log_ui.js", IDR_DEVICE_LOG_UI_JS); 78 html->AddResourcePath("device_log_ui.js", IDR_DEVICE_LOG_UI_JS);
79 html->SetDefaultResource(IDR_DEVICE_LOG_UI_HTML); 79 html->SetDefaultResource(IDR_DEVICE_LOG_UI_HTML);
80 80
81 content::WebUIDataSource::Add( 81 content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(),
82 web_ui->GetWebContents()->GetBrowserContext(), html); 82 html);
83 } 83 }
84 84
85 DeviceLogUI::~DeviceLogUI() { 85 DeviceLogUI::~DeviceLogUI() {
86 } 86 }
87 87
88 } // namespace chromeos 88 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/device_log_ui.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698