| 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" |
| 11 #include "base/format_macros.h" | 11 #include "base/format_macros.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/services/gcm/gcm_profile_service.h" | |
| 19 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" | 18 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" |
| 20 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
| 21 #include "components/gcm_driver/gcm_client.h" | 20 #include "components/gcm_driver/gcm_client.h" |
| 22 #include "components/gcm_driver/gcm_driver.h" | 21 #include "components/gcm_driver/gcm_driver.h" |
| 23 #include "components/gcm_driver/gcm_internals_constants.h" | 22 #include "components/gcm_driver/gcm_internals_constants.h" |
| 23 #include "components/gcm_driver/gcm_profile_service.h" |
| 24 #include "content/public/browser/web_ui.h" | 24 #include "content/public/browser/web_ui.h" |
| 25 #include "content/public/browser/web_ui_controller.h" | 25 #include "content/public/browser/web_ui_controller.h" |
| 26 #include "content/public/browser/web_ui_data_source.h" | 26 #include "content/public/browser/web_ui_data_source.h" |
| 27 #include "content/public/browser/web_ui_message_handler.h" | 27 #include "content/public/browser/web_ui_message_handler.h" |
| 28 #include "grit/components_resources.h" | 28 #include "grit/components_resources.h" |
| 29 | 29 |
| 30 namespace { | 30 namespace { |
| 31 | 31 |
| 32 void SetCheckinInfo( | 32 void SetCheckinInfo( |
| 33 const std::vector<gcm::CheckinActivity>& checkins, | 33 const std::vector<gcm::CheckinActivity>& checkins, |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 void GcmInternalsUIMessageHandler::ReturnResults( | 148 void GcmInternalsUIMessageHandler::ReturnResults( |
| 149 Profile* profile, | 149 Profile* profile, |
| 150 gcm::GCMProfileService* profile_service, | 150 gcm::GCMProfileService* profile_service, |
| 151 const gcm::GCMClient::GCMStatistics* stats) const { | 151 const gcm::GCMClient::GCMStatistics* stats) const { |
| 152 base::DictionaryValue results; | 152 base::DictionaryValue results; |
| 153 base::DictionaryValue* device_info = new base::DictionaryValue(); | 153 base::DictionaryValue* device_info = new base::DictionaryValue(); |
| 154 results.Set(gcm_driver::kDeviceInfo, device_info); | 154 results.Set(gcm_driver::kDeviceInfo, device_info); |
| 155 | 155 |
| 156 device_info->SetBoolean(gcm_driver::kProfileServiceCreated, | 156 device_info->SetBoolean(gcm_driver::kProfileServiceCreated, |
| 157 profile_service != NULL); | 157 profile_service != NULL); |
| 158 device_info->SetBoolean(gcm_driver::kGcmEnabled, | 158 device_info->SetBoolean( |
| 159 gcm::GCMProfileService::IsGCMEnabled(profile)); | 159 gcm_driver::kGcmEnabled, |
| 160 gcm::GCMProfileService::IsGCMEnabled(profile->GetPrefs())); |
| 160 if (stats) { | 161 if (stats) { |
| 161 results.SetBoolean(gcm_driver::kIsRecording, stats->is_recording); | 162 results.SetBoolean(gcm_driver::kIsRecording, stats->is_recording); |
| 162 device_info->SetBoolean(gcm_driver::kGcmClientCreated, | 163 device_info->SetBoolean(gcm_driver::kGcmClientCreated, |
| 163 stats->gcm_client_created); | 164 stats->gcm_client_created); |
| 164 device_info->SetString(gcm_driver::kGcmClientState, | 165 device_info->SetString(gcm_driver::kGcmClientState, |
| 165 stats->gcm_client_state); | 166 stats->gcm_client_state); |
| 166 device_info->SetBoolean(gcm_driver::kConnectionClientCreated, | 167 device_info->SetBoolean(gcm_driver::kConnectionClientCreated, |
| 167 stats->connection_client_created); | 168 stats->connection_client_created); |
| 168 device_info->SetString(gcm_driver::kRegisteredAppIds, | 169 device_info->SetString(gcm_driver::kRegisteredAppIds, |
| 169 base::JoinString(stats->registered_app_ids, ",")); | 170 base::JoinString(stats->registered_app_ids, ",")); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 IDR_GCM_DRIVER_GCM_INTERNALS_JS); | 304 IDR_GCM_DRIVER_GCM_INTERNALS_JS); |
| 304 html_source->SetDefaultResource(IDR_GCM_DRIVER_GCM_INTERNALS_HTML); | 305 html_source->SetDefaultResource(IDR_GCM_DRIVER_GCM_INTERNALS_HTML); |
| 305 | 306 |
| 306 Profile* profile = Profile::FromWebUI(web_ui); | 307 Profile* profile = Profile::FromWebUI(web_ui); |
| 307 content::WebUIDataSource::Add(profile, html_source); | 308 content::WebUIDataSource::Add(profile, html_source); |
| 308 | 309 |
| 309 web_ui->AddMessageHandler(new GcmInternalsUIMessageHandler()); | 310 web_ui->AddMessageHandler(new GcmInternalsUIMessageHandler()); |
| 310 } | 311 } |
| 311 | 312 |
| 312 GCMInternalsUI::~GCMInternalsUI() {} | 313 GCMInternalsUI::~GCMInternalsUI() {} |
| OLD | NEW |