| OLD | NEW |
| 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/gcm_internals_ui.h" | 5 #include "chrome/browser/ui/webui/gcm_internals_ui.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 if (args->GetSize() != 1) { | 78 if (args->GetSize() != 1) { |
| 79 NOTREACHED(); | 79 NOTREACHED(); |
| 80 return; | 80 return; |
| 81 } | 81 } |
| 82 bool clear_logs = false; | 82 bool clear_logs = false; |
| 83 if (!args->GetBoolean(0, &clear_logs)) { | 83 if (!args->GetBoolean(0, &clear_logs)) { |
| 84 NOTREACHED(); | 84 NOTREACHED(); |
| 85 return; | 85 return; |
| 86 } | 86 } |
| 87 | 87 |
| 88 gcm::GCMDriver::ClearActivityLogs clear_activity_logs = |
| 89 clear_logs ? gcm::GCMDriver::CLEAR_LOGS : gcm::GCMDriver::KEEP_LOGS; |
| 90 |
| 88 Profile* profile = Profile::FromWebUI(web_ui()); | 91 Profile* profile = Profile::FromWebUI(web_ui()); |
| 89 gcm::GCMProfileService* profile_service = | 92 gcm::GCMProfileService* profile_service = |
| 90 gcm::GCMProfileServiceFactory::GetForProfile(profile); | 93 gcm::GCMProfileServiceFactory::GetForProfile(profile); |
| 91 | 94 |
| 92 if (!profile_service || !profile_service->driver()) { | 95 if (!profile_service || !profile_service->driver()) { |
| 93 ReturnResults(profile, NULL, NULL); | 96 ReturnResults(profile, NULL, NULL); |
| 94 } else { | 97 } else { |
| 95 profile_service->driver()->GetGCMStatistics( | 98 profile_service->driver()->GetGCMStatistics( |
| 96 base::Bind(&GcmInternalsUIMessageHandler::RequestGCMStatisticsFinished, | 99 base::Bind(&GcmInternalsUIMessageHandler::RequestGCMStatisticsFinished, |
| 97 weak_ptr_factory_.GetWeakPtr()), | 100 weak_ptr_factory_.GetWeakPtr()), |
| 98 clear_logs); | 101 clear_activity_logs); |
| 99 } | 102 } |
| 100 } | 103 } |
| 101 | 104 |
| 102 void GcmInternalsUIMessageHandler::SetRecording(const base::ListValue* args) { | 105 void GcmInternalsUIMessageHandler::SetRecording(const base::ListValue* args) { |
| 103 if (args->GetSize() != 1) { | 106 if (args->GetSize() != 1) { |
| 104 NOTREACHED(); | 107 NOTREACHED(); |
| 105 return; | 108 return; |
| 106 } | 109 } |
| 107 bool recording = false; | 110 bool recording = false; |
| 108 if (!args->GetBoolean(0, &recording)) { | 111 if (!args->GetBoolean(0, &recording)) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 IDR_GCM_DRIVER_GCM_INTERNALS_JS); | 167 IDR_GCM_DRIVER_GCM_INTERNALS_JS); |
| 165 html_source->SetDefaultResource(IDR_GCM_DRIVER_GCM_INTERNALS_HTML); | 168 html_source->SetDefaultResource(IDR_GCM_DRIVER_GCM_INTERNALS_HTML); |
| 166 | 169 |
| 167 Profile* profile = Profile::FromWebUI(web_ui); | 170 Profile* profile = Profile::FromWebUI(web_ui); |
| 168 content::WebUIDataSource::Add(profile, html_source); | 171 content::WebUIDataSource::Add(profile, html_source); |
| 169 | 172 |
| 170 web_ui->AddMessageHandler(new GcmInternalsUIMessageHandler()); | 173 web_ui->AddMessageHandler(new GcmInternalsUIMessageHandler()); |
| 171 } | 174 } |
| 172 | 175 |
| 173 GCMInternalsUI::~GCMInternalsUI() {} | 176 GCMInternalsUI::~GCMInternalsUI() {} |
| OLD | NEW |