Commit 54c3c6ef authored by Julie Jeongeun Kim's avatar Julie Jeongeun Kim Committed by Commit Bot

Convert ExtensionMsg_SetSessionInfo to mojo

This CL converts ExtensionMsg_SetSessionInfo to mojo
and introduces channel_mojom_traits.h to convert
version_info::Channel to extensions.mojom.Channel.

Bug: 1146103
Change-Id: Iacc3d116bf08a7f32eadb5066cd9690b3aec89ba
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2548943
Commit-Queue: Julie Kim <jkim@igalia.com>
Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#829934}
parent 733cb400
......@@ -80,6 +80,9 @@ class InterceptingRendererStartupHelper : public RendererStartupHelper,
void ActivateExtension(const std::string& extension_id) override {}
void SetActivityLoggingEnabled(bool enabled) override {}
void UnloadExtension(const std::string& extension_id) override {}
void SetSessionInfo(version_info::Channel channel,
mojom::FeatureSessionType session,
bool is_lock_screen_context) override {}
mojo::AssociatedReceiverSet<mojom::Renderer> receivers_;
};
......
......@@ -122,9 +122,8 @@ void RendererStartupHelper::InitializeProcess(
// renderers may have content scripts.
bool is_lock_screen_context =
client->IsLockScreenContext(process->GetBrowserContext());
process->Send(new ExtensionMsg_SetSessionInfo(GetCurrentChannel(),
GetCurrentFeatureSessionType(),
is_lock_screen_context));
renderer->SetSessionInfo(GetCurrentChannel(), GetCurrentFeatureSessionType(),
is_lock_screen_context);
// Platform apps need to know the system font.
// TODO(dbeam): this is not the system font in all cases.
......
......@@ -51,6 +51,10 @@ class InterceptingRendererStartupHelper : public RendererStartupHelper,
unloaded_extensions_.push_back(extension_id);
}
void SetSessionInfo(version_info::Channel channel,
mojom::FeatureSessionType session,
bool is_lock_screen_context) override {}
std::vector<std::string> activated_extensions_;
std::vector<std::string> unloaded_extensions_;
mojo::AssociatedReceiverSet<mojom::Renderer> receivers_;
......
......@@ -40,6 +40,7 @@ if (enable_extensions) {
sources = [
"mojom/app_window.mojom",
"mojom/channel.mojom",
"mojom/feature_session_type.mojom",
"mojom/guest_view.mojom",
"mojom/keep_alive.mojom",
......@@ -58,6 +59,18 @@ if (enable_extensions) {
"//url/mojom:url_mojom_gurl",
]
cpp_typemaps = [
{
types = [
{
mojom = "extensions.mojom.Channel"
cpp = "version_info::Channel"
},
]
traits_headers = [ "//extensions/common/mojom/channel_mojom_traits.h" ]
traits_public_deps = [ "//components/version_info:channel" ]
},
]
overridden_deps = [ "//content/public/common:interfaces" ]
component_deps = [ "//content/public/common" ]
......
......@@ -703,13 +703,6 @@ IPC_MESSAGE_ROUTED3(ExtensionMsg_DispatchOnDisconnect,
extensions::PortId /* port_id */,
std::string /* error_message */)
// Informs the renderer what channel (dev, beta, stable, etc) and user session
// type is running.
IPC_MESSAGE_CONTROL3(ExtensionMsg_SetSessionInfo,
version_info::Channel /* channel */,
extensions::mojom::FeatureSessionType /* session_type */,
bool /* is_lock_screen_context */)
// Notify the renderer that its window has closed.
IPC_MESSAGE_ROUTED1(ExtensionMsg_AppWindowClosed, bool /* send_onclosed */)
......
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
per-file *_mojom_traits*.*=set noparent
per-file *_mojom_traits*.*=file://ipc/SECURITY_OWNERS
// Copyright 2020 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.
module extensions.mojom;
// The possible channels for an installation. Refer to version_info::Channel.
enum Channel {
kUnknown = 0,
kCanary = 1,
kDev = 2,
kBeta = 3,
kStable = 4,
};
// Copyright 2020 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 EXTENSIONS_COMMON_MOJOM_CHANNEL_MOJOM_TRAITS_H_
#define EXTENSIONS_COMMON_MOJOM_CHANNEL_MOJOM_TRAITS_H_
#include "components/version_info/channel.h"
#include "extensions/common/mojom/channel.mojom-shared.h"
#include "mojo/public/cpp/bindings/enum_traits.h"
namespace mojo {
template <>
struct EnumTraits<extensions::mojom::Channel, version_info::Channel> {
static extensions::mojom::Channel ToMojom(version_info::Channel input) {
switch (input) {
case version_info::Channel::UNKNOWN:
return extensions::mojom::Channel::kUnknown;
case version_info::Channel::CANARY:
return extensions::mojom::Channel::kCanary;
case version_info::Channel::DEV:
return extensions::mojom::Channel::kDev;
case version_info::Channel::BETA:
return extensions::mojom::Channel::kBeta;
case version_info::Channel::STABLE:
return extensions::mojom::Channel::kStable;
}
NOTREACHED();
return extensions::mojom::Channel::kUnknown;
}
static bool FromMojom(extensions::mojom::Channel input,
version_info::Channel* out) {
switch (input) {
case extensions::mojom::Channel::kUnknown:
*out = version_info::Channel::UNKNOWN;
return true;
case extensions::mojom::Channel::kCanary:
*out = version_info::Channel::CANARY;
return true;
case extensions::mojom::Channel::kDev:
*out = version_info::Channel::DEV;
return true;
case extensions::mojom::Channel::kBeta:
*out = version_info::Channel::BETA;
return true;
case extensions::mojom::Channel::kStable:
*out = version_info::Channel::STABLE;
return true;
}
NOTREACHED();
*out = version_info::Channel::UNKNOWN;
return false;
}
};
} // namespace mojo
#endif // EXTENSIONS_COMMON_MOJOM_CHANNEL_MOJOM_TRAITS_H_
......@@ -4,6 +4,9 @@
module extensions.mojom;
import "extensions/common/mojom/channel.mojom";
import "extensions/common/mojom/feature_session_type.mojom";
// This should be used for implementing browser-to-renderer control messages
// which need to retain FIFO with respect to other mojo interfaces like
// content.mojom.Renderer.
......@@ -20,4 +23,11 @@ interface Renderer {
// Notifies the renderer that an extension was unloaded in the browser.
UnloadExtension(string extension_id);
// Informs the renderer what channel (dev, beta, stable, etc) and user session
// type is running. |is_lock_screen_context| represents whether the browser
// context is associated with Chrome OS lock screen.
SetSessionInfo(Channel channel,
FeatureSessionType session,
bool is_lock_screen_context);
};
......@@ -872,7 +872,6 @@ bool Dispatcher::OnControlMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(ExtensionMsg_Loaded, OnLoaded)
IPC_MESSAGE_HANDLER(ExtensionMsg_MessageInvoke, OnMessageInvoke)
IPC_MESSAGE_HANDLER(ExtensionMsg_DispatchEvent, OnDispatchEvent)
IPC_MESSAGE_HANDLER(ExtensionMsg_SetSessionInfo, OnSetSessionInfo)
IPC_MESSAGE_HANDLER(ExtensionMsg_SetScriptingAllowlist,
OnSetScriptingAllowlist)
IPC_MESSAGE_HANDLER(ExtensionMsg_SetSystemFont, OnSetSystemFont)
......@@ -1158,9 +1157,9 @@ void Dispatcher::OnDispatchEvent(
}
}
void Dispatcher::OnSetSessionInfo(version_info::Channel channel,
mojom::FeatureSessionType session_type,
bool is_lock_screen_context) {
void Dispatcher::SetSessionInfo(version_info::Channel channel,
mojom::FeatureSessionType session_type,
bool is_lock_screen_context) {
SetCurrentChannel(channel);
SetCurrentFeatureSessionType(session_type);
script_context_set_->set_is_lock_screen_context(is_lock_screen_context);
......
......@@ -217,6 +217,9 @@ class Dispatcher : public content::RenderThreadObserver,
void ActivateExtension(const std::string& extension_id) override;
void SetActivityLoggingEnabled(bool enabled) override;
void UnloadExtension(const std::string& extension_id) override;
void SetSessionInfo(version_info::Channel channel,
mojom::FeatureSessionType session_type,
bool lock_screen_context) override;
void OnRendererAssociatedRequest(
mojo::PendingAssociatedReceiver<mojom::Renderer> receiver);
......@@ -240,9 +243,6 @@ class Dispatcher : public content::RenderThreadObserver,
const base::ListValue& args);
void OnDispatchEvent(const ExtensionMsg_DispatchEvent_Params& params,
const base::ListValue& event_args);
void OnSetSessionInfo(version_info::Channel channel,
mojom::FeatureSessionType session_type,
bool lock_screen_context);
void OnSetScriptingAllowlist(
const ExtensionsClient::ScriptingAllowlist& extension_ids);
void OnSetSystemFont(const std::string& font_family,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment