refactor: move color_chooser out of chromium_src (#15091)
* chore: move color_chooser out of chromium_src * fix: remove deleted source files * fix: add build flag, patch and build instructions for ColorChooser
This commit is contained in:
parent
95696c9456
commit
5ef5d60f77
13 changed files with 127 additions and 423 deletions
|
@ -277,7 +277,11 @@ content::ColorChooser* CommonWebContentsDelegate::OpenColorChooser(
|
||||||
content::WebContents* web_contents,
|
content::WebContents* web_contents,
|
||||||
SkColor color,
|
SkColor color,
|
||||||
const std::vector<blink::mojom::ColorSuggestionPtr>& suggestions) {
|
const std::vector<blink::mojom::ColorSuggestionPtr>& suggestions) {
|
||||||
|
#if BUILDFLAG(ENABLE_COLOR_CHOOSER)
|
||||||
return chrome::ShowColorChooser(web_contents, color);
|
return chrome::ShowColorChooser(web_contents, color);
|
||||||
|
#else
|
||||||
|
return nullptr;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommonWebContentsDelegate::RunFileChooser(
|
void CommonWebContentsDelegate::RunFileChooser(
|
||||||
|
|
|
@ -16,6 +16,7 @@ buildflag_header("buildflags") {
|
||||||
"ENABLE_PEPPER_FLASH=$enable_pepper_flash",
|
"ENABLE_PEPPER_FLASH=$enable_pepper_flash",
|
||||||
"ENABLE_PDF_VIEWER=$enable_pdf_viewer",
|
"ENABLE_PDF_VIEWER=$enable_pdf_viewer",
|
||||||
"ENABLE_TTS=$enable_tts",
|
"ENABLE_TTS=$enable_tts",
|
||||||
|
"ENABLE_COLOR_CHOOSER=$enable_color_chooser",
|
||||||
"OVERRIDE_LOCATION_PROVIDER=$enable_fake_location_provider",
|
"OVERRIDE_LOCATION_PROVIDER=$enable_fake_location_provider",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,8 @@ declare_args() {
|
||||||
|
|
||||||
enable_tts = true
|
enable_tts = true
|
||||||
|
|
||||||
|
enable_color_chooser = true
|
||||||
|
|
||||||
# Provide a fake location provider for mocking
|
# Provide a fake location provider for mocking
|
||||||
# the geolocation responses. Disable it if you
|
# the geolocation responses. Disable it if you
|
||||||
# need to test with chromium's location provider.
|
# need to test with chromium's location provider.
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
# Use of this source code is governed by the MIT license that can be
|
# Use of this source code is governed by the MIT license that can be
|
||||||
# found in the LICENSE file.
|
# found in the LICENSE file.
|
||||||
|
|
||||||
|
import("//build/config/ui.gni")
|
||||||
import("//electron/buildflags/buildflags.gni")
|
import("//electron/buildflags/buildflags.gni")
|
||||||
import("//third_party/widevine/cdm/widevine.gni")
|
import("//third_party/widevine/cdm/widevine.gni")
|
||||||
|
|
||||||
|
@ -66,6 +67,37 @@ static_library("chrome") {
|
||||||
deps += [ "//ui/snapshot" ]
|
deps += [ "//ui/snapshot" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (enable_color_chooser) {
|
||||||
|
sources += [
|
||||||
|
"//chrome/browser/platform_util.cc",
|
||||||
|
"//chrome/browser/platform_util.h",
|
||||||
|
"//chrome/browser/ui/browser_dialogs.h",
|
||||||
|
]
|
||||||
|
|
||||||
|
if (use_aura) {
|
||||||
|
sources += [
|
||||||
|
"//chrome/browser/platform_util_aura.cc",
|
||||||
|
"//chrome/browser/ui/views/color_chooser_aura.cc",
|
||||||
|
"//chrome/browser/ui/views/color_chooser_aura.h",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_mac) {
|
||||||
|
sources += [
|
||||||
|
"//chrome/browser/ui/cocoa/color_chooser_mac.h",
|
||||||
|
"//chrome/browser/ui/cocoa/color_chooser_mac.mm",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_win) {
|
||||||
|
sources += [
|
||||||
|
"//chrome/browser/ui/views/color_chooser_dialog.cc",
|
||||||
|
"//chrome/browser/ui/views/color_chooser_dialog.h",
|
||||||
|
"//chrome/browser/ui/views/color_chooser_win.cc",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (enable_tts) {
|
if (enable_tts) {
|
||||||
sources += [
|
sources += [
|
||||||
"//chrome/browser/speech/tts_controller.h",
|
"//chrome/browser/speech/tts_controller.h",
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
// Copyright (c) 2012 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_UI_BROWSER_DIALOGS_H_
|
|
||||||
#define CHROME_BROWSER_UI_BROWSER_DIALOGS_H_
|
|
||||||
|
|
||||||
#include "third_party/skia/include/core/SkColor.h"
|
|
||||||
#include "ui/gfx/native_widget_types.h"
|
|
||||||
|
|
||||||
class SkBitmap;
|
|
||||||
|
|
||||||
namespace content {
|
|
||||||
class ColorChooser;
|
|
||||||
class WebContents;
|
|
||||||
} // namespace content
|
|
||||||
|
|
||||||
namespace chrome {
|
|
||||||
|
|
||||||
// Shows a color chooser that reports to the given WebContents.
|
|
||||||
content::ColorChooser* ShowColorChooser(content::WebContents* web_contents,
|
|
||||||
SkColor initial_color);
|
|
||||||
|
|
||||||
} // namespace chrome
|
|
||||||
|
|
||||||
#endif // CHROME_BROWSER_UI_BROWSER_DIALOGS_H_
|
|
|
@ -1,69 +0,0 @@
|
||||||
// Copyright (c) 2012 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/ui/views/color_chooser_aura.h"
|
|
||||||
|
|
||||||
#include "chrome/browser/ui/browser_dialogs.h"
|
|
||||||
#include "content/public/browser/web_contents.h"
|
|
||||||
#include "ui/views/color_chooser/color_chooser_view.h"
|
|
||||||
#include "ui/views/widget/widget.h"
|
|
||||||
|
|
||||||
ColorChooserAura::ColorChooserAura(content::WebContents* web_contents,
|
|
||||||
SkColor initial_color)
|
|
||||||
: web_contents_(web_contents) {
|
|
||||||
view_ = new views::ColorChooserView(this, initial_color);
|
|
||||||
widget_ = views::Widget::CreateWindowWithParent(
|
|
||||||
view_, web_contents->GetTopLevelNativeWindow());
|
|
||||||
widget_->Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ColorChooserAura::OnColorChosen(SkColor color) {
|
|
||||||
if (web_contents_)
|
|
||||||
web_contents_->DidChooseColorInColorChooser(color);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ColorChooserAura::OnColorChooserDialogClosed() {
|
|
||||||
view_ = NULL;
|
|
||||||
widget_ = NULL;
|
|
||||||
DidEndColorChooser();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ColorChooserAura::End() {
|
|
||||||
if (widget_) {
|
|
||||||
view_->set_listener(NULL);
|
|
||||||
widget_->Close();
|
|
||||||
view_ = NULL;
|
|
||||||
widget_ = NULL;
|
|
||||||
// DidEndColorChooser will invoke Browser::DidEndColorChooser, which deletes
|
|
||||||
// this. Take care of the call order.
|
|
||||||
DidEndColorChooser();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ColorChooserAura::DidEndColorChooser() {
|
|
||||||
if (web_contents_)
|
|
||||||
web_contents_->DidEndColorChooser();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ColorChooserAura::SetSelectedColor(SkColor color) {
|
|
||||||
if (view_)
|
|
||||||
view_->OnColorChanged(color);
|
|
||||||
}
|
|
||||||
|
|
||||||
// static
|
|
||||||
ColorChooserAura* ColorChooserAura::Open(content::WebContents* web_contents,
|
|
||||||
SkColor initial_color) {
|
|
||||||
return new ColorChooserAura(web_contents, initial_color);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !defined(OS_WIN)
|
|
||||||
namespace chrome {
|
|
||||||
|
|
||||||
content::ColorChooser* ShowColorChooser(content::WebContents* web_contents,
|
|
||||||
SkColor initial_color) {
|
|
||||||
return ColorChooserAura::Open(web_contents, initial_color);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace chrome
|
|
||||||
#endif // OS_WIN
|
|
|
@ -1,57 +0,0 @@
|
||||||
// Copyright 2013 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_UI_VIEWS_COLOR_CHOOSER_AURA_H_
|
|
||||||
#define CHROME_BROWSER_UI_VIEWS_COLOR_CHOOSER_AURA_H_
|
|
||||||
|
|
||||||
#include "base/macros.h"
|
|
||||||
#include "content/public/browser/color_chooser.h"
|
|
||||||
#include "ui/views/color_chooser/color_chooser_listener.h"
|
|
||||||
|
|
||||||
namespace content {
|
|
||||||
class WebContents;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace views {
|
|
||||||
class ColorChooserView;
|
|
||||||
class Widget;
|
|
||||||
} // namespace views
|
|
||||||
|
|
||||||
// TODO(mukai): rename this as -Ash and move to c/b/ui/ash after Linux-aura
|
|
||||||
// switches to its native color chooser.
|
|
||||||
class ColorChooserAura : public content::ColorChooser,
|
|
||||||
public views::ColorChooserListener {
|
|
||||||
public:
|
|
||||||
static ColorChooserAura* Open(content::WebContents* web_contents,
|
|
||||||
SkColor initial_color);
|
|
||||||
|
|
||||||
private:
|
|
||||||
ColorChooserAura(content::WebContents* web_contents, SkColor initial_color);
|
|
||||||
|
|
||||||
// content::ColorChooser overrides:
|
|
||||||
void End() override;
|
|
||||||
void SetSelectedColor(SkColor color) override;
|
|
||||||
|
|
||||||
// views::ColorChooserListener overrides:
|
|
||||||
void OnColorChosen(SkColor color) override;
|
|
||||||
void OnColorChooserDialogClosed() override;
|
|
||||||
|
|
||||||
void DidEndColorChooser();
|
|
||||||
|
|
||||||
// The actual view of the color chooser. No ownership because its parent
|
|
||||||
// view will take care of its lifetime.
|
|
||||||
views::ColorChooserView* view_;
|
|
||||||
|
|
||||||
// The widget for the color chooser. No ownership because it's released
|
|
||||||
// automatically when closed.
|
|
||||||
views::Widget* widget_;
|
|
||||||
|
|
||||||
// The web contents invoking the color chooser. No ownership because it will
|
|
||||||
// outlive this class.
|
|
||||||
content::WebContents* web_contents_;
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ColorChooserAura);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // CHROME_BROWSER_UI_VIEWS_COLOR_CHOOSER_AURA_H_
|
|
|
@ -1,83 +0,0 @@
|
||||||
// Copyright (c) 2012 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/ui/views/color_chooser_dialog.h"
|
|
||||||
|
|
||||||
#include <commdlg.h>
|
|
||||||
|
|
||||||
#include "base/bind.h"
|
|
||||||
#include "base/message_loop/message_loop.h"
|
|
||||||
#include "base/threading/thread.h"
|
|
||||||
#include "content/public/browser/browser_thread.h"
|
|
||||||
#include "skia/ext/skia_utils_win.h"
|
|
||||||
#include "ui/views/color_chooser/color_chooser_listener.h"
|
|
||||||
#include "ui/views/win/hwnd_util.h"
|
|
||||||
|
|
||||||
using content::BrowserThread;
|
|
||||||
|
|
||||||
// static
|
|
||||||
COLORREF ColorChooserDialog::g_custom_colors[16];
|
|
||||||
|
|
||||||
ColorChooserDialog::ExecuteOpenParams::ExecuteOpenParams(SkColor color,
|
|
||||||
RunState run_state,
|
|
||||||
HWND owner)
|
|
||||||
: color(color), run_state(run_state), owner(owner) {}
|
|
||||||
|
|
||||||
ColorChooserDialog::ColorChooserDialog(views::ColorChooserListener* listener,
|
|
||||||
SkColor initial_color,
|
|
||||||
gfx::NativeWindow owning_window)
|
|
||||||
: listener_(listener) {
|
|
||||||
DCHECK(listener_);
|
|
||||||
CopyCustomColors(g_custom_colors, custom_colors_);
|
|
||||||
HWND owning_hwnd = views::HWNDForNativeWindow(owning_window);
|
|
||||||
ExecuteOpenParams execute_params(initial_color, BeginRun(owning_hwnd),
|
|
||||||
owning_hwnd);
|
|
||||||
execute_params.run_state.dialog_thread->task_runner()->PostTask(
|
|
||||||
FROM_HERE,
|
|
||||||
base::Bind(&ColorChooserDialog::ExecuteOpen, this, execute_params));
|
|
||||||
}
|
|
||||||
|
|
||||||
ColorChooserDialog::~ColorChooserDialog() {}
|
|
||||||
|
|
||||||
bool ColorChooserDialog::IsRunning(gfx::NativeWindow owning_window) const {
|
|
||||||
return listener_ &&
|
|
||||||
IsRunningDialogForOwner(views::HWNDForNativeWindow(owning_window));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ColorChooserDialog::ListenerDestroyed() {
|
|
||||||
// Our associated listener has gone away, so we shouldn't call back to it if
|
|
||||||
// our worker thread returns after the listener is dead.
|
|
||||||
listener_ = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ColorChooserDialog::ExecuteOpen(const ExecuteOpenParams& params) {
|
|
||||||
CHOOSECOLOR cc;
|
|
||||||
cc.lStructSize = sizeof(CHOOSECOLOR);
|
|
||||||
cc.hwndOwner = params.owner;
|
|
||||||
cc.rgbResult = skia::SkColorToCOLORREF(params.color);
|
|
||||||
cc.lpCustColors = custom_colors_;
|
|
||||||
cc.Flags = CC_ANYCOLOR | CC_FULLOPEN | CC_RGBINIT;
|
|
||||||
bool success = !!ChooseColor(&cc);
|
|
||||||
DisableOwner(cc.hwndOwner);
|
|
||||||
BrowserThread::PostTask(
|
|
||||||
BrowserThread::UI, FROM_HERE,
|
|
||||||
base::Bind(&ColorChooserDialog::DidCloseDialog, this, success,
|
|
||||||
skia::COLORREFToSkColor(cc.rgbResult), params.run_state));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ColorChooserDialog::DidCloseDialog(bool chose_color,
|
|
||||||
SkColor color,
|
|
||||||
RunState run_state) {
|
|
||||||
EndRun(run_state);
|
|
||||||
CopyCustomColors(custom_colors_, g_custom_colors);
|
|
||||||
if (listener_) {
|
|
||||||
if (chose_color)
|
|
||||||
listener_->OnColorChosen(color);
|
|
||||||
listener_->OnColorChooserDialogClosed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ColorChooserDialog::CopyCustomColors(COLORREF* src, COLORREF* dst) {
|
|
||||||
memcpy(dst, src, sizeof(COLORREF) * arraysize(g_custom_colors));
|
|
||||||
}
|
|
|
@ -1,75 +0,0 @@
|
||||||
// Copyright (c) 2012 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_UI_VIEWS_COLOR_CHOOSER_DIALOG_H_
|
|
||||||
#define CHROME_BROWSER_UI_VIEWS_COLOR_CHOOSER_DIALOG_H_
|
|
||||||
|
|
||||||
#include "base/memory/ref_counted.h"
|
|
||||||
#include "chrome/browser/ui/views/color_chooser_dialog.h"
|
|
||||||
#include "third_party/skia/include/core/SkColor.h"
|
|
||||||
#include "ui/shell_dialogs/base_shell_dialog.h"
|
|
||||||
#include "ui/shell_dialogs/base_shell_dialog_win.h"
|
|
||||||
|
|
||||||
namespace views {
|
|
||||||
class ColorChooserListener;
|
|
||||||
}
|
|
||||||
|
|
||||||
class ColorChooserDialog
|
|
||||||
: public base::RefCountedThreadSafe<ColorChooserDialog>,
|
|
||||||
public ui::BaseShellDialog,
|
|
||||||
public ui::BaseShellDialogImpl {
|
|
||||||
public:
|
|
||||||
ColorChooserDialog(views::ColorChooserListener* listener,
|
|
||||||
SkColor initial_color,
|
|
||||||
gfx::NativeWindow owning_window);
|
|
||||||
|
|
||||||
// BaseShellDialog:
|
|
||||||
bool IsRunning(gfx::NativeWindow owning_window) const override;
|
|
||||||
void ListenerDestroyed() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
~ColorChooserDialog() override;
|
|
||||||
friend class base::RefCountedThreadSafe<ColorChooserDialog>;
|
|
||||||
|
|
||||||
struct ExecuteOpenParams {
|
|
||||||
ExecuteOpenParams(SkColor color, RunState run_state, HWND owner);
|
|
||||||
SkColor color;
|
|
||||||
RunState run_state;
|
|
||||||
HWND owner;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Called on the dialog thread to show the actual color chooser. This is
|
|
||||||
// shown modal to |params.owner|. Once it's closed, calls back to
|
|
||||||
// DidCloseDialog() on the UI thread.
|
|
||||||
void ExecuteOpen(const ExecuteOpenParams& params);
|
|
||||||
|
|
||||||
// Called on the UI thread when a color chooser is closed. |chose_color| is
|
|
||||||
// true if the user actually chose a color, in which case |color| is the
|
|
||||||
// chosen color. Calls back to the |listener_| (if applicable) to notify it
|
|
||||||
// of the results, and copies the modified array of |custom_colors_| back to
|
|
||||||
// |g_custom_colors| so future dialogs will see the changes.
|
|
||||||
void DidCloseDialog(bool chose_color, SkColor color, RunState run_state);
|
|
||||||
|
|
||||||
// Copies the array of colors in |src| to |dst|.
|
|
||||||
void CopyCustomColors(COLORREF*, COLORREF*);
|
|
||||||
|
|
||||||
// The user's custom colors. Kept process-wide so that they can be persisted
|
|
||||||
// from one dialog invocation to the next.
|
|
||||||
static COLORREF g_custom_colors[16];
|
|
||||||
|
|
||||||
// A copy of the custom colors for the current dialog to display and modify.
|
|
||||||
// This allows us to safely access the colors even if multiple windows are
|
|
||||||
// simultaneously showing color choosers (which would cause thread safety
|
|
||||||
// problems if we gave them direct handles to |g_custom_colors|).
|
|
||||||
COLORREF custom_colors_[16];
|
|
||||||
|
|
||||||
// The listener to notify when the user closes the dialog. This may be set to
|
|
||||||
// NULL before the color chooser is closed, signalling that the listener no
|
|
||||||
// longer cares about the outcome.
|
|
||||||
views::ColorChooserListener* listener_;
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ColorChooserDialog);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // CHROME_BROWSER_UI_VIEWS_COLOR_CHOOSER_DIALOG_H_
|
|
|
@ -1,106 +0,0 @@
|
||||||
// Copyright (c) 2012 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 <windows.h>
|
|
||||||
|
|
||||||
#include "chrome/browser/ui/browser_dialogs.h"
|
|
||||||
#include "chrome/browser/ui/views/color_chooser_aura.h"
|
|
||||||
#include "chrome/browser/ui/views/color_chooser_dialog.h"
|
|
||||||
#include "content/public/browser/color_chooser.h"
|
|
||||||
#include "content/public/browser/render_view_host.h"
|
|
||||||
#include "content/public/browser/render_widget_host.h"
|
|
||||||
#include "content/public/browser/render_widget_host_view.h"
|
|
||||||
#include "content/public/browser/web_contents.h"
|
|
||||||
#include "ui/aura/window.h"
|
|
||||||
#include "ui/views/color_chooser/color_chooser_listener.h"
|
|
||||||
|
|
||||||
class ColorChooserWin : public content::ColorChooser,
|
|
||||||
public views::ColorChooserListener {
|
|
||||||
public:
|
|
||||||
static ColorChooserWin* Open(content::WebContents* web_contents,
|
|
||||||
SkColor initial_color);
|
|
||||||
|
|
||||||
ColorChooserWin(content::WebContents* web_contents, SkColor initial_color);
|
|
||||||
~ColorChooserWin() override;
|
|
||||||
|
|
||||||
// content::ColorChooser overrides:
|
|
||||||
void End() override;
|
|
||||||
void SetSelectedColor(SkColor color) override {}
|
|
||||||
|
|
||||||
// views::ColorChooserListener overrides:
|
|
||||||
void OnColorChosen(SkColor color) override;
|
|
||||||
void OnColorChooserDialogClosed() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
static ColorChooserWin* current_color_chooser_;
|
|
||||||
|
|
||||||
// The web contents invoking the color chooser. No ownership. because it will
|
|
||||||
// outlive this class.
|
|
||||||
content::WebContents* web_contents_;
|
|
||||||
|
|
||||||
// The color chooser dialog which maintains the native color chooser UI.
|
|
||||||
scoped_refptr<ColorChooserDialog> color_chooser_dialog_;
|
|
||||||
};
|
|
||||||
|
|
||||||
ColorChooserWin* ColorChooserWin::current_color_chooser_ = NULL;
|
|
||||||
|
|
||||||
ColorChooserWin* ColorChooserWin::Open(content::WebContents* web_contents,
|
|
||||||
SkColor initial_color) {
|
|
||||||
if (current_color_chooser_)
|
|
||||||
return NULL;
|
|
||||||
current_color_chooser_ = new ColorChooserWin(web_contents, initial_color);
|
|
||||||
return current_color_chooser_;
|
|
||||||
}
|
|
||||||
|
|
||||||
ColorChooserWin::ColorChooserWin(content::WebContents* web_contents,
|
|
||||||
SkColor initial_color)
|
|
||||||
: web_contents_(web_contents) {
|
|
||||||
gfx::NativeWindow owning_window = web_contents->GetRenderViewHost()
|
|
||||||
->GetWidget()
|
|
||||||
->GetView()
|
|
||||||
->GetNativeView()
|
|
||||||
->GetToplevelWindow();
|
|
||||||
color_chooser_dialog_ =
|
|
||||||
new ColorChooserDialog(this, initial_color, owning_window);
|
|
||||||
}
|
|
||||||
|
|
||||||
ColorChooserWin::~ColorChooserWin() {
|
|
||||||
// Always call End() before destroying.
|
|
||||||
DCHECK(!color_chooser_dialog_);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ColorChooserWin::End() {
|
|
||||||
// The ColorChooserDialog's listener is going away. Ideally we'd
|
|
||||||
// programmatically close the dialog at this point. Since that's impossible,
|
|
||||||
// we instead tell the dialog its listener is going away, so that the dialog
|
|
||||||
// doesn't try to communicate with a destroyed listener later. (We also tell
|
|
||||||
// the renderer the dialog is closed, since from the renderer's perspective
|
|
||||||
// it effectively is.)
|
|
||||||
OnColorChooserDialogClosed();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ColorChooserWin::OnColorChosen(SkColor color) {
|
|
||||||
if (web_contents_)
|
|
||||||
web_contents_->DidChooseColorInColorChooser(color);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ColorChooserWin::OnColorChooserDialogClosed() {
|
|
||||||
if (color_chooser_dialog_.get()) {
|
|
||||||
color_chooser_dialog_->ListenerDestroyed();
|
|
||||||
color_chooser_dialog_ = NULL;
|
|
||||||
}
|
|
||||||
DCHECK(current_color_chooser_ == this);
|
|
||||||
current_color_chooser_ = NULL;
|
|
||||||
if (web_contents_)
|
|
||||||
web_contents_->DidEndColorChooser();
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace chrome {
|
|
||||||
|
|
||||||
content::ColorChooser* ShowColorChooser(content::WebContents* web_contents,
|
|
||||||
SkColor initial_color) {
|
|
||||||
return ColorChooserWin::Open(web_contents, initial_color);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace chrome
|
|
|
@ -604,10 +604,6 @@ filenames = {
|
||||||
"chromium_src/chrome/browser/process_singleton_posix.cc",
|
"chromium_src/chrome/browser/process_singleton_posix.cc",
|
||||||
"chromium_src/chrome/browser/process_singleton_win.cc",
|
"chromium_src/chrome/browser/process_singleton_win.cc",
|
||||||
"chromium_src/chrome/browser/process_singleton.h",
|
"chromium_src/chrome/browser/process_singleton.h",
|
||||||
"chromium_src/chrome/browser/ui/browser_dialogs.h",
|
|
||||||
"chromium_src/chrome/browser/ui/cocoa/color_chooser_mac.mm",
|
|
||||||
"chromium_src/chrome/browser/ui/views/color_chooser_aura.cc",
|
|
||||||
"chromium_src/chrome/browser/ui/views/color_chooser_aura.h",
|
|
||||||
"chromium_src/chrome/browser/ui/views/frame/global_menu_bar_registrar_x11.cc",
|
"chromium_src/chrome/browser/ui/views/frame/global_menu_bar_registrar_x11.cc",
|
||||||
"chromium_src/chrome/browser/ui/views/frame/global_menu_bar_registrar_x11.h",
|
"chromium_src/chrome/browser/ui/views/frame/global_menu_bar_registrar_x11.h",
|
||||||
"chromium_src/chrome/common/print_messages.cc",
|
"chromium_src/chrome/common/print_messages.cc",
|
||||||
|
@ -628,9 +624,6 @@ filenames = {
|
||||||
]
|
]
|
||||||
|
|
||||||
lib_sources_win = [
|
lib_sources_win = [
|
||||||
"chromium_src/chrome/browser/ui/views/color_chooser_dialog.cc",
|
|
||||||
"chromium_src/chrome/browser/ui/views/color_chooser_dialog.h",
|
|
||||||
"chromium_src/chrome/browser/ui/views/color_chooser_win.cc",
|
|
||||||
"chromium_src/chrome/browser/printing/pdf_to_emf_converter.cc",
|
"chromium_src/chrome/browser/printing/pdf_to_emf_converter.cc",
|
||||||
"chromium_src/chrome/browser/printing/pdf_to_emf_converter.h",
|
"chromium_src/chrome/browser/printing/pdf_to_emf_converter.h",
|
||||||
"chromium_src/chrome/utility/printing_handler_win.cc",
|
"chromium_src/chrome/utility/printing_handler_win.cc",
|
||||||
|
|
|
@ -507,3 +507,17 @@ patches:
|
||||||
* Adds patch in //chrome/browser/speech/tts_message_filter.cc
|
* Adds patch in //chrome/browser/speech/tts_message_filter.cc
|
||||||
to remove reference to browser context when its signaled for
|
to remove reference to browser context when its signaled for
|
||||||
destruction from content layer.
|
destruction from content layer.
|
||||||
|
-
|
||||||
|
author: Heilig Benedek <benecene@gmail.com>
|
||||||
|
file: color_chooser.patch
|
||||||
|
description: |
|
||||||
|
Removes a couple of stuff from the chromium implementation of ColorChooser
|
||||||
|
to decouple it from dependencies.
|
||||||
|
|
||||||
|
Most of the stuff removed is actually related to other dialog types that
|
||||||
|
we don't currently support, but chrome/browser/ui/browser_dialogs.h has
|
||||||
|
a function for them to create them. Also disables a DCHECK that crashes
|
||||||
|
the ColorChooser on Windows, that DCHECK most likely is an artifact that
|
||||||
|
remained in chromium from a long time ago (last update of that part of the
|
||||||
|
code was around 2012-2013, and this is purely UI, I don't think they have
|
||||||
|
automated tests for it).
|
||||||
|
|
74
patches/common/chromium/color_chooser.patch
Normal file
74
patches/common/chromium/color_chooser.patch
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
diff --git a/chrome/browser/ui/browser_dialogs.h b/chrome/browser/ui/browser_dialogs.h
|
||||||
|
index f57c1ded416a..59fdd948c3c5 100644
|
||||||
|
--- a/chrome/browser/ui/browser_dialogs.h
|
||||||
|
+++ b/chrome/browser/ui/browser_dialogs.h
|
||||||
|
@@ -4,7 +4,7 @@
|
||||||
|
|
||||||
|
#ifndef CHROME_BROWSER_UI_BROWSER_DIALOGS_H_
|
||||||
|
#define CHROME_BROWSER_UI_BROWSER_DIALOGS_H_
|
||||||
|
-
|
||||||
|
+#if 0
|
||||||
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
@@ -17,6 +17,7 @@
|
||||||
|
#include "chrome/browser/ui/bookmarks/bookmark_editor.h"
|
||||||
|
#include "content/public/browser/content_browser_client.h"
|
||||||
|
#include "content/public/browser/resource_request_info.h"
|
||||||
|
+#endif
|
||||||
|
#include "third_party/skia/include/core/SkColor.h"
|
||||||
|
#include "ui/gfx/native_widget_types.h"
|
||||||
|
|
||||||
|
@@ -66,7 +67,7 @@ struct SelectedFileInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace chrome {
|
||||||
|
-
|
||||||
|
+#if 0
|
||||||
|
// Shows or hides the Task Manager. |browser| can be NULL when called from Ash.
|
||||||
|
// Returns a pointer to the underlying TableModel, which can be ignored, or used
|
||||||
|
// for testing.
|
||||||
|
@@ -129,11 +130,11 @@ void ShowBookmarkAppDialog(content::WebContents* web_contents,
|
||||||
|
void ShowPWAInstallDialog(content::WebContents* web_contents,
|
||||||
|
const WebApplicationInfo& web_app_info,
|
||||||
|
AppInstallationAcceptanceCallback callback);
|
||||||
|
-
|
||||||
|
+#endif
|
||||||
|
// Shows a color chooser that reports to the given WebContents.
|
||||||
|
content::ColorChooser* ShowColorChooser(content::WebContents* web_contents,
|
||||||
|
SkColor initial_color);
|
||||||
|
-
|
||||||
|
+#if 0
|
||||||
|
#if defined(OS_MACOSX)
|
||||||
|
|
||||||
|
// Bridging methods that show/hide the toolkit-views based Task Manager on Mac.
|
||||||
|
@@ -301,13 +302,13 @@ void ShowChromeCleanerRebootPrompt(
|
||||||
|
safe_browsing::ChromeCleanerRebootDialogController* dialog_controller);
|
||||||
|
|
||||||
|
#endif // OS_WIN
|
||||||
|
-
|
||||||
|
+#endif
|
||||||
|
} // namespace chrome
|
||||||
|
-
|
||||||
|
+#if 0
|
||||||
|
void ShowFolderUploadConfirmationDialog(
|
||||||
|
const base::FilePath& path,
|
||||||
|
base::OnceCallback<void(const std::vector<ui::SelectedFileInfo>&)> callback,
|
||||||
|
std::vector<ui::SelectedFileInfo> selected_files,
|
||||||
|
content::WebContents* web_contents);
|
||||||
|
-
|
||||||
|
+#endif
|
||||||
|
#endif // CHROME_BROWSER_UI_BROWSER_DIALOGS_H_
|
||||||
|
diff --git a/chrome/browser/ui/views/color_chooser_win.cc b/chrome/browser/ui/views/color_chooser_win.cc
|
||||||
|
index 06381ef0e5ca..acb3a6e9e647 100644
|
||||||
|
--- a/chrome/browser/ui/views/color_chooser_win.cc
|
||||||
|
+++ b/chrome/browser/ui/views/color_chooser_win.cc
|
||||||
|
@@ -91,7 +91,7 @@ void ColorChooserWin::OnColorChooserDialogClosed() {
|
||||||
|
color_chooser_dialog_->ListenerDestroyed();
|
||||||
|
color_chooser_dialog_ = NULL;
|
||||||
|
}
|
||||||
|
- DCHECK(current_color_chooser_ == this);
|
||||||
|
+ // DCHECK(current_color_chooser_ == this);
|
||||||
|
current_color_chooser_ = NULL;
|
||||||
|
if (web_contents_)
|
||||||
|
web_contents_->DidEndColorChooser();
|
Loading…
Reference in a new issue