Skip to content

Commit

Permalink
Move gcm_internals resources and constants to //components.
Browse files Browse the repository at this point in the history
These are moved in order to be shared on iOS.

resource_ids are updated as follows:
generated_resources.grd: -100
components_strings.grd : +70
components_chromium_strings.grd: +10
components_resources.grd: +20

Review URL: https://codereview.chromium.org/1339803003

Cr-Commit-Position: refs/heads/master@{#348949}
  • Loading branch information
droger authored and Commit bot committed Sep 15, 2015
1 parent d24a029 commit e89640c
Show file tree
Hide file tree
Showing 13 changed files with 183 additions and 87 deletions.
6 changes: 3 additions & 3 deletions build/ios/grit_whitelist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ IDR_EXTRACT_PAGE_FEATURES_JS
IDR_FLAGS_FAVICON
IDR_FLAGS_HTML
IDR_FLAGS_JS
IDR_GCM_INTERNALS_CSS
IDR_GCM_INTERNALS_HTML
IDR_GCM_INTERNALS_JS
IDR_GCM_DRIVER_GCM_INTERNALS_CSS
IDR_GCM_DRIVER_GCM_INTERNALS_HTML
IDR_GCM_DRIVER_GCM_INTERNALS_JS
IDR_HISTORY_FAVICON
IDR_HISTORY_HTML
IDR_HISTORY_JS
Expand Down
3 changes: 0 additions & 3 deletions chrome/browser/browser_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,6 @@
<include name="IDR_BLUETOOTH_SETTINGS_JS" file="resources\chromeos\emulator\bluetooth_settings.js" type="BINDATA" />
<include name="IDR_BLUETOOTH_SETTINGS_CSS" file="resources\chromeos\emulator\bluetooth_settings.css" type="BINDATA" />
</if>
<include name="IDR_GCM_INTERNALS_HTML" file="resources\gcm_internals.html" type="BINDATA" />
<include name="IDR_GCM_INTERNALS_CSS" file="resources\gcm_internals.css" type="BINDATA" />
<include name="IDR_GCM_INTERNALS_JS" file="resources\gcm_internals.js" type="BINDATA" />
<include name="IDR_EASY_UNLOCK_MANIFEST" file="resources\easy_unlock\manifest.json" type="BINDATA" />
<include name="IDR_EASY_UNLOCK_MANIFEST_SIGNIN" file="resources\easy_unlock\manifest_signin.json" type="BINDATA" />
<if expr="chromeos">
Expand Down
58 changes: 33 additions & 25 deletions chrome/browser/ui/webui/gcm_internals_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
#include "chrome/common/url_constants.h"
#include "components/gcm_driver/gcm_client.h"
#include "components/gcm_driver/gcm_driver.h"
#include "components/gcm_driver/gcm_internals_constants.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_controller.h"
#include "content/public/browser/web_ui_data_source.h"
#include "content/public/browser/web_ui_message_handler.h"
#include "grit/browser_resources.h"
#include "grit/components_resources.h"

namespace {

Expand Down Expand Up @@ -150,60 +151,65 @@ void GcmInternalsUIMessageHandler::ReturnResults(
const gcm::GCMClient::GCMStatistics* stats) const {
base::DictionaryValue results;
base::DictionaryValue* device_info = new base::DictionaryValue();
results.Set("deviceInfo", device_info);
results.Set(gcm_driver::kDeviceInfo, device_info);

device_info->SetBoolean("profileServiceCreated", profile_service != NULL);
device_info->SetBoolean("gcmEnabled",
device_info->SetBoolean(gcm_driver::kProfileServiceCreated,
profile_service != NULL);
device_info->SetBoolean(gcm_driver::kGcmEnabled,
gcm::GCMProfileService::IsGCMEnabled(profile));
if (stats) {
results.SetBoolean("isRecording", stats->is_recording);
device_info->SetBoolean("gcmClientCreated", stats->gcm_client_created);
device_info->SetString("gcmClientState", stats->gcm_client_state);
device_info->SetBoolean("connectionClientCreated",
results.SetBoolean(gcm_driver::kIsRecording, stats->is_recording);
device_info->SetBoolean(gcm_driver::kGcmClientCreated,
stats->gcm_client_created);
device_info->SetString(gcm_driver::kGcmClientState,
stats->gcm_client_state);
device_info->SetBoolean(gcm_driver::kConnectionClientCreated,
stats->connection_client_created);
device_info->SetString("registeredAppIds",
device_info->SetString(gcm_driver::kRegisteredAppIds,
base::JoinString(stats->registered_app_ids, ","));
if (stats->connection_client_created)
device_info->SetString("connectionState", stats->connection_state);
device_info->SetString(gcm_driver::kConnectionState,
stats->connection_state);
if (stats->android_id > 0) {
device_info->SetString("androidId",
device_info->SetString(
gcm_driver::kAndroidId,
base::StringPrintf("0x%" PRIx64, stats->android_id));
}
device_info->SetInteger("sendQueueSize", stats->send_queue_size);
device_info->SetInteger("resendQueueSize", stats->resend_queue_size);
device_info->SetInteger(gcm_driver::kSendQueueSize, stats->send_queue_size);
device_info->SetInteger(gcm_driver::kResendQueueSize,
stats->resend_queue_size);

if (stats->recorded_activities.checkin_activities.size() > 0) {
base::ListValue* checkin_info = new base::ListValue();
results.Set("checkinInfo", checkin_info);
results.Set(gcm_driver::kCheckinInfo, checkin_info);
SetCheckinInfo(stats->recorded_activities.checkin_activities,
checkin_info);
}
if (stats->recorded_activities.connection_activities.size() > 0) {
base::ListValue* connection_info = new base::ListValue();
results.Set("connectionInfo", connection_info);
results.Set(gcm_driver::kConnectionInfo, connection_info);
SetConnectionInfo(stats->recorded_activities.connection_activities,
connection_info);
}
if (stats->recorded_activities.registration_activities.size() > 0) {
base::ListValue* registration_info = new base::ListValue();
results.Set("registrationInfo", registration_info);
results.Set(gcm_driver::kRegistrationInfo, registration_info);
SetRegistrationInfo(stats->recorded_activities.registration_activities,
registration_info);
}
if (stats->recorded_activities.receiving_activities.size() > 0) {
base::ListValue* receive_info = new base::ListValue();
results.Set("receiveInfo", receive_info);
results.Set(gcm_driver::kReceiveInfo, receive_info);
SetReceivingInfo(stats->recorded_activities.receiving_activities,
receive_info);
}
if (stats->recorded_activities.sending_activities.size() > 0) {
base::ListValue* send_info = new base::ListValue();
results.Set("sendInfo", send_info);
results.Set(gcm_driver::kSendInfo, send_info);
SetSendingInfo(stats->recorded_activities.sending_activities, send_info);
}
}
web_ui()->CallJavascriptFunction("gcmInternals.setGcmInternalsInfo",
results);
web_ui()->CallJavascriptFunction(gcm_driver::kSetGcmInternalsInfo, results);
}

void GcmInternalsUIMessageHandler::RequestAllInfo(
Expand Down Expand Up @@ -271,11 +277,11 @@ void GcmInternalsUIMessageHandler::RequestGCMStatisticsFinished(

void GcmInternalsUIMessageHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
"getGcmInternalsInfo",
gcm_driver::kGetGcmInternalsInfo,
base::Bind(&GcmInternalsUIMessageHandler::RequestAllInfo,
weak_ptr_factory_.GetWeakPtr()));
web_ui()->RegisterMessageCallback(
"setGcmInternalsRecording",
gcm_driver::kSetGcmInternalsRecording,
base::Bind(&GcmInternalsUIMessageHandler::SetRecording,
weak_ptr_factory_.GetWeakPtr()));
}
Expand All @@ -291,9 +297,11 @@ GCMInternalsUI::GCMInternalsUI(content::WebUI* web_ui)
html_source->SetJsonPath("strings.js");

// Add required resources.
html_source->AddResourcePath("gcm_internals.css", IDR_GCM_INTERNALS_CSS);
html_source->AddResourcePath("gcm_internals.js", IDR_GCM_INTERNALS_JS);
html_source->SetDefaultResource(IDR_GCM_INTERNALS_HTML);
html_source->AddResourcePath(gcm_driver::kGcmInternalsCSS,
IDR_GCM_DRIVER_GCM_INTERNALS_CSS);
html_source->AddResourcePath(gcm_driver::kGcmInternalsJS,
IDR_GCM_DRIVER_GCM_INTERNALS_JS);
html_source->SetDefaultResource(IDR_GCM_DRIVER_GCM_INTERNALS_HTML);

Profile* profile = Profile::FromWebUI(web_ui);
content::WebUIDataSource::Add(profile, html_source);
Expand Down
2 changes: 2 additions & 0 deletions components/gcm_driver.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@
'gcm_driver/gcm_driver_android.h',
'gcm_driver/gcm_driver_desktop.cc',
'gcm_driver/gcm_driver_desktop.h',
'gcm_driver/gcm_internals_constants.cc',
'gcm_driver/gcm_internals_constants.h',
'gcm_driver/gcm_stats_recorder_impl.cc',
'gcm_driver/gcm_stats_recorder_impl.h',
'gcm_driver/registration_info.cc',
Expand Down
2 changes: 2 additions & 0 deletions components/gcm_driver/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ static_library("gcm_driver") {
"gcm_driver_android.h",
"gcm_driver_desktop.cc",
"gcm_driver_desktop.h",
"gcm_internals_constants.cc",
"gcm_internals_constants.h",
"gcm_stats_recorder_impl.cc",
"gcm_stats_recorder_impl.h",
"registration_info.cc",
Expand Down
37 changes: 37 additions & 0 deletions components/gcm_driver/gcm_internals_constants.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/gcm_driver/gcm_internals_constants.h"

namespace gcm_driver {

// Resource paths.
const char kGcmInternalsCSS[] = "gcm_internals.css";
const char kGcmInternalsJS[] = "gcm_internals.js";

// Message handlers.
const char kGetGcmInternalsInfo[] = "getGcmInternalsInfo";
const char kSetGcmInternalsInfo[] = "gcmInternals.setGcmInternalsInfo";
const char kSetGcmInternalsRecording[] = "setGcmInternalsRecording";

// GCM internal info.
const char kAndroidId[] = "androidId";
const char kCheckinInfo[] = "checkinInfo";
const char kConnectionClientCreated[] = "connectionClientCreated";
const char kConnectionInfo[] = "connectionInfo";
const char kConnectionState[] = "connectionState";
const char kDeviceInfo[] = "deviceInfo";
const char kGcmClientCreated[] = "gcmClientCreated";
const char kGcmClientState[] = "gcmClientState";
const char kGcmEnabled[] = "gcmEnabled";
const char kIsRecording[] = "isRecording";
const char kProfileServiceCreated[] = "profileServiceCreated";
const char kReceiveInfo[] = "receiveInfo";
const char kRegisteredAppIds[] = "registeredAppIds";
const char kRegistrationInfo[] = "registrationInfo";
const char kResendQueueSize[] = "resendQueueSize";
const char kSendInfo[] = "sendInfo";
const char kSendQueueSize[] = "sendQueueSize";

} // namespace gcm_driver
43 changes: 43 additions & 0 deletions components/gcm_driver/gcm_internals_constants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_GCM_DRIVER_GCM_INTERNALS_CONSTANTS_H_
#define COMPONENTS_GCM_DRIVER_GCM_INTERNALS_CONSTANTS_H_

namespace gcm_driver {

// Resource paths.
// Must match the resource file names.
extern const char kGcmInternalsCSS[];
extern const char kGcmInternalsJS[];

// Message handlers.
// Must match the constants used in the resource files.
extern const char kGetGcmInternalsInfo[];
extern const char kSetGcmInternalsInfo[];
extern const char kSetGcmInternalsRecording[];

// GCM internal info.
// Must match the constants used in the resource files.
extern const char kAndroidId[];
extern const char kCheckinInfo[];
extern const char kConnectionClientCreated[];
extern const char kConnectionInfo[];
extern const char kConnectionState[];
extern const char kDeviceInfo[];
extern const char kGcmClientCreated[];
extern const char kGcmClientState[];
extern const char kGcmEnabled[];
extern const char kIsRecording[];
extern const char kProfileServiceCreated[];
extern const char kReceiveInfo[];
extern const char kRegisteredAppIds[];
extern const char kRegistrationInfo[];
extern const char kResendQueueSize[];
extern const char kSendInfo[];
extern const char kSendQueueSize[];

} // namespace gcm_driver

#endif // COMPONENTS_GCM_DRIVER_GCM_INTERNALS_CONSTANTS_H_
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions components/resources/components_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<includes>
<part file="data_reduction_proxy_resources.grdp" />
<part file="dom_distiller_resources.grdp" />
<part file="gcm_driver_resources.grdp" />
<part file="printing_resources.grdp" />
<part file="proximity_auth_resources.grdp" />
<part file="security_interstitials_resources.grdp" />
Expand Down
6 changes: 6 additions & 0 deletions components/resources/gcm_driver_resources.grdp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<grit-part>
<include name="IDR_GCM_DRIVER_GCM_INTERNALS_HTML" file="../gcm_driver/resources/gcm_internals.html" type="BINDATA" />
<include name="IDR_GCM_DRIVER_GCM_INTERNALS_CSS" file="../gcm_driver/resources/gcm_internals.css" type="BINDATA" />
<include name="IDR_GCM_DRIVER_GCM_INTERNALS_JS" file="../gcm_driver/resources/gcm_internals.js" type="BINDATA" />
</grit-part>
Loading

0 comments on commit e89640c

Please sign in to comment.