Commit 8358f765 authored by Pavel Feldman's avatar Pavel Feldman Committed by Commit Bot

DevTools: add experimental method for configuring the dock tile.

This is an experimental feature that allows trusted remote debugging
clients such as Carlo adjust the dock tile details.

Change-Id: I7b263a14f1632d867c8bd3cffdd0527b3f3c96c9
Reviewed-on: https://chromium-review.googlesource.com/c/1337295
Commit-Queue: Dmitry Gozman <dgozman@chromium.org>
Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608575}
parent c5baed4e
......@@ -149,6 +149,7 @@ static_library("devtools") {
"devtools_browser_context_manager.h",
"devtools_contents_resizing_strategy.cc",
"devtools_contents_resizing_strategy.h",
"devtools_dock_tile.h",
"devtools_embedder_message_dispatcher.cc",
"devtools_embedder_message_dispatcher.h",
"devtools_eye_dropper.cc",
......@@ -185,7 +186,11 @@ static_library("devtools") {
]
}
}
if (is_mac) {
sources += [ "devtools_dock_tile_mac.mm" ]
} else {
sources += [ "devtools_dock_tile.cc" ]
}
if (!is_android) {
deps += [ ":protocol_generated_sources" ]
sources += [
......
// Copyright 2018 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 "chrome/browser/devtools/devtools_dock_tile.h"
// static
void DevToolsDockTile::Update(const std::string& label, gfx::Image image) {}
// Copyright (c) 2018 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 CHROME_BROWSER_DEVTOOLS_DEVTOOLS_DOCK_TILE_H_
#define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_DOCK_TILE_H_
#include "base/macros.h"
#include "ui/gfx/image/image.h"
class DevToolsDockTile {
public:
static void Update(const std::string& label, gfx::Image image);
private:
DISALLOW_COPY_AND_ASSIGN(DevToolsDockTile);
};
#endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_DOCK_TILE_H_
// Copyright 2018 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 "base/mac/scoped_nsobject.h"
#include "base/strings/sys_string_conversions.h"
#include "chrome/browser/devtools/devtools_dock_tile.h"
#import <Cocoa/Cocoa.h>
// static
void DevToolsDockTile::Update(const std::string& label, gfx::Image image) {
NSDockTile* dockTile = [[NSApplication sharedApplication] dockTile];
if (!image.IsEmpty()) {
NSRect imageFrame = NSMakeRect(0, 0, 0, 0);
base::scoped_nsobject<NSImageView> imageView(
[[NSImageView alloc] initWithFrame:imageFrame]);
NSImage* nsImage = image.ToNSImage();
[imageView setImage:nsImage];
[dockTile setContentView:imageView];
}
if (!label.empty())
[dockTile setBadgeLabel:base::SysUTF8ToNSString(label)];
[dockTile display];
}
......@@ -13,7 +13,7 @@
},
{
"domain": "Browser",
"include": [ "getWindowForTarget", "getWindowBounds", "setWindowBounds", "close", "grantPermissions", "resetPermissions" ],
"include": [ "getWindowForTarget", "getWindowBounds", "setWindowBounds", "close", "grantPermissions", "resetPermissions", "setDockTile" ],
"include_events": []
},
{
......
......@@ -5,9 +5,12 @@
#include "chrome/browser/devtools/protocol/browser_handler.h"
#include <set>
#include <vector>
#include "base/memory/ref_counted_memory.h"
#include "base/task/post_task.h"
#include "chrome/browser/devtools/chrome_devtools_manager_delegate.h"
#include "chrome/browser/devtools/devtools_dock_tile.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/permissions/permission_manager.h"
#include "chrome/browser/profiles/profile.h"
......@@ -18,6 +21,8 @@
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/devtools_agent_host.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_png_rep.h"
using PermissionOverrides = std::set<content::PermissionType>;
using protocol::Maybe;
......@@ -275,6 +280,17 @@ Response BrowserHandler::ResetPermissions(
return Response::FallThrough();
}
protocol::Response BrowserHandler::SetDockTile(
protocol::Maybe<std::string> label,
protocol::Maybe<protocol::Binary> image) {
std::vector<gfx::ImagePNGRep> reps;
if (image.isJust())
reps.emplace_back(image.fromJust().bytes(), 1);
DevToolsDockTile::Update(label.fromMaybe(std::string()),
reps.size() ? gfx::Image(reps) : gfx::Image());
return Response::OK();
}
Response BrowserHandler::FindProfile(
const Maybe<std::string>& browser_context_id,
Profile** profile) {
......
......@@ -36,6 +36,9 @@ class BrowserHandler : public protocol::Browser::Backend {
protocol::Maybe<std::string> browser_context_id) override;
protocol::Response ResetPermissions(
protocol::Maybe<std::string> browser_context_id) override;
protocol::Response SetDockTile(
protocol::Maybe<std::string> label,
protocol::Maybe<protocol::Binary> image) override;
private:
protocol::Response FindProfile(
......
......@@ -112,5 +112,10 @@ Response BrowserHandler::SetWindowBounds(
return Response::OK();
}
protocol::Response BrowserHandler::SetDockTile(Maybe<std::string> label,
Maybe<protocol::Binary> image) {
return Response::OK();
}
} // namespace protocol
} // namespace headless
......@@ -31,6 +31,7 @@ class BrowserHandler : public DomainHandler, public Browser::Backend {
Response SetWindowBounds(
int window_id,
std::unique_ptr<Browser::Bounds> out_bounds) override;
Response SetDockTile(Maybe<std::string> label, Maybe<Binary> image) override;
private:
std::string target_id_;
......
......@@ -17,7 +17,7 @@
},
{
"domain": "Browser",
"include": ["close", "getWindowForTarget", "getWindowBounds", "setWindowBounds" ],
"include": ["close", "getWindowForTarget", "getWindowBounds", "setWindowBounds", "setDockTile" ],
"include_events": []
},
{
......
......@@ -635,6 +635,13 @@ domain Browser
# with 'left', 'top', 'width' or 'height'. Leaves unspecified fields unchanged.
Bounds bounds
# Set dock tile details, platform-specific.
experimental command setDockTile
parameters
optional string badgeLabel
# Png encoded image.
optional binary image
# This domain exposes CSS read/write operations. All CSS objects (stylesheets, rules, and styles)
# have an associated `id` used in subsequent operations on the related object. Each object type has
# a specific `id` structure, and those are not interchangeable between objects of different kinds.
......
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