Commit 37a164f1 authored by Tom Anderson's avatar Tom Anderson Committed by Commit Bot

Remove GTK deps on chrome, content, and prefs

BUG=None
R=sky

Change-Id: I46c44a85089ed1f2dd226c1e3df00991fad95864
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2097463
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Auto-Submit: Thomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#751341}
parent ca7266da
...@@ -62,7 +62,9 @@ bool SystemThemeX11::GetTint(int id, color_utils::HSL* hsl) const { ...@@ -62,7 +62,9 @@ bool SystemThemeX11::GetTint(int id, color_utils::HSL* hsl) const {
} }
bool SystemThemeX11::GetColor(int id, SkColor* color) const { bool SystemThemeX11::GetColor(int id, SkColor* color) const {
return linux_ui_ && linux_ui_->GetColor(id, color, pref_service_); return linux_ui_ && linux_ui_->GetColor(id, color,
pref_service_->GetBoolean(
prefs::kUseCustomChromeFrame));
} }
bool SystemThemeX11::GetDisplayProperty(int id, int* result) const { bool SystemThemeX11::GetDisplayProperty(int id, int* result) const {
......
...@@ -58,9 +58,6 @@ jumbo_component("gtk") { ...@@ -58,9 +58,6 @@ jumbo_component("gtk") {
"//base", "//base",
"//build/config/linux/gtk", "//build/config/linux/gtk",
"//build/config/linux/gtk:gtkprint", "//build/config/linux/gtk:gtkprint",
"//chrome/common:constants",
"//components/prefs",
"//content/public/browser",
"//printing", "//printing",
"//skia", "//skia",
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/browser/ui/gtk/gtk_util.h"
#include "content/public/browser/native_web_keyboard_event.h"
#include "ui/base/ime/text_edit_commands.h" #include "ui/base/ime/text_edit_commands.h"
#include "ui/events/event.h" #include "ui/events/event.h"
......
...@@ -32,8 +32,6 @@ ...@@ -32,8 +32,6 @@
#include "chrome/browser/ui/gtk/printing_gtk_util.h" #include "chrome/browser/ui/gtk/printing_gtk_util.h"
#include "chrome/browser/ui/gtk/select_file_dialog_impl.h" #include "chrome/browser/ui/gtk/select_file_dialog_impl.h"
#include "chrome/browser/ui/gtk/settings_provider_gtk.h" #include "chrome/browser/ui/gtk/settings_provider_gtk.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h"
#include "printing/buildflags/buildflags.h" #include "printing/buildflags/buildflags.h"
#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkCanvas.h"
...@@ -491,11 +489,10 @@ bool GtkUi::GetTint(int id, color_utils::HSL* tint) const { ...@@ -491,11 +489,10 @@ bool GtkUi::GetTint(int id, color_utils::HSL* tint) const {
return false; return false;
} }
bool GtkUi::GetColor(int id, SkColor* color, PrefService* pref_service) const { bool GtkUi::GetColor(int id, SkColor* color, bool use_custom_frame) const {
for (const ColorMap& color_map : for (const ColorMap& color_map :
{colors_, pref_service->GetBoolean(prefs::kUseCustomChromeFrame) {colors_,
? custom_frame_colors_ use_custom_frame ? custom_frame_colors_ : native_frame_colors_}) {
: native_frame_colors_}) {
auto it = color_map.find(id); auto it = color_map.find(id);
if (it != color_map.end()) { if (it != color_map.end()) {
*color = it->second; *color = it->second;
......
...@@ -68,9 +68,7 @@ class GtkUi : public views::LinuxUI { ...@@ -68,9 +68,7 @@ class GtkUi : public views::LinuxUI {
// views::LinuxUI: // views::LinuxUI:
void Initialize() override; void Initialize() override;
bool GetTint(int id, color_utils::HSL* tint) const override; bool GetTint(int id, color_utils::HSL* tint) const override;
bool GetColor(int id, bool GetColor(int id, SkColor* color, bool use_custom_frame) const override;
SkColor* color,
PrefService* pref_service) const override;
bool GetDisplayProperty(int id, int* result) const override; bool GetDisplayProperty(int id, int* result) const override;
SkColor GetFocusRingColor() const override; SkColor GetFocusRingColor() const override;
SkColor GetActiveSelectionBgColor() const override; SkColor GetActiveSelectionBgColor() const override;
......
...@@ -18,13 +18,14 @@ ...@@ -18,13 +18,14 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/no_destructor.h" #include "base/no_destructor.h"
#include "base/sequence_checker.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "base/task/thread_pool.h" #include "base/task/thread_pool.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/browser/ui/gtk/gtk_util.h"
#include "chrome/browser/ui/gtk/printing_gtk_util.h" #include "chrome/browser/ui/gtk/printing_gtk_util.h"
#include "content/public/browser/browser_task_traits.h"
#include "printing/metafile.h" #include "printing/metafile.h"
#include "printing/print_job_constants.h" #include "printing/print_job_constants.h"
#include "printing/print_settings.h" #include "printing/print_settings.h"
...@@ -34,7 +35,6 @@ ...@@ -34,7 +35,6 @@
#include "ui/events/platform/x11/x11_event_source.h" // nogncheck #include "ui/events/platform/x11/x11_event_source.h" // nogncheck
#endif #endif
using content::BrowserThread;
using printing::PageRanges; using printing::PageRanges;
using printing::PrintSettings; using printing::PrintSettings;
...@@ -173,15 +173,16 @@ class GtkPrinterList { ...@@ -173,15 +173,16 @@ class GtkPrinterList {
// static // static
printing::PrintDialogGtkInterface* PrintDialogGtk::CreatePrintDialog( printing::PrintDialogGtkInterface* PrintDialogGtk::CreatePrintDialog(
PrintingContextLinux* context) { PrintingContextLinux* context) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
return new PrintDialogGtk(context); return new PrintDialogGtk(context);
} }
PrintDialogGtk::PrintDialogGtk(PrintingContextLinux* context) PrintDialogGtk::PrintDialogGtk(PrintingContextLinux* context)
: context_(context) {} : base::RefCountedDeleteOnSequence<PrintDialogGtk>(
base::SequencedTaskRunnerHandle::Get()),
context_(context) {}
PrintDialogGtk::~PrintDialogGtk() { PrintDialogGtk::~PrintDialogGtk() {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (dialog_) { if (dialog_) {
aura::Window* parent = gtk::GetAuraTransientParent(dialog_); aura::Window* parent = gtk::GetAuraTransientParent(dialog_);
...@@ -366,7 +367,7 @@ void PrintDialogGtk::ShowDialog( ...@@ -366,7 +367,7 @@ void PrintDialogGtk::ShowDialog(
void PrintDialogGtk::PrintDocument(const printing::MetafilePlayer& metafile, void PrintDialogGtk::PrintDocument(const printing::MetafilePlayer& metafile,
const base::string16& document_name) { const base::string16& document_name) {
// This runs on the print worker thread, does not block the UI thread. // This runs on the print worker thread, does not block the UI thread.
DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// The document printing tasks can outlive the PrintingContext that created // The document printing tasks can outlive the PrintingContext that created
// this dialog. // this dialog.
...@@ -392,8 +393,8 @@ void PrintDialogGtk::PrintDocument(const printing::MetafilePlayer& metafile, ...@@ -392,8 +393,8 @@ void PrintDialogGtk::PrintDocument(const printing::MetafilePlayer& metafile,
} }
// No errors, continue printing. // No errors, continue printing.
base::PostTask(FROM_HERE, {BrowserThread::UI}, base::SequencedTaskRunnerHandle::Get()->PostTask(
base::BindOnce(&PrintDialogGtk::SendDocumentToPrinter, this, FROM_HERE, base::BindOnce(&PrintDialogGtk::SendDocumentToPrinter, this,
document_name)); document_name));
} }
...@@ -490,7 +491,7 @@ static void OnJobCompletedThunk(GtkPrintJob* print_job, ...@@ -490,7 +491,7 @@ static void OnJobCompletedThunk(GtkPrintJob* print_job,
} }
void PrintDialogGtk::SendDocumentToPrinter( void PrintDialogGtk::SendDocumentToPrinter(
const base::string16& document_name) { const base::string16& document_name) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// If |printer_| is nullptr then somehow the GTK printer list changed out // If |printer_| is nullptr then somehow the GTK printer list changed out
// under us. In which case, just bail out. // under us. In which case, just bail out.
......
...@@ -12,9 +12,8 @@ ...@@ -12,9 +12,8 @@
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted_delete_on_sequence.h"
#include "base/sequenced_task_runner_helpers.h" #include "base/sequenced_task_runner_helpers.h"
#include "content/public/browser/browser_thread.h"
#include "printing/print_dialog_gtk_interface.h" #include "printing/print_dialog_gtk_interface.h"
#include "printing/printing_context_linux.h" #include "printing/printing_context_linux.h"
#include "ui/aura/window_observer.h" #include "ui/aura/window_observer.h"
...@@ -29,9 +28,7 @@ using printing::PrintingContextLinux; ...@@ -29,9 +28,7 @@ using printing::PrintingContextLinux;
// Needs to be freed on the UI thread to clean up its GTK members variables. // Needs to be freed on the UI thread to clean up its GTK members variables.
class PrintDialogGtk : public printing::PrintDialogGtkInterface, class PrintDialogGtk : public printing::PrintDialogGtkInterface,
public base::RefCountedThreadSafe< public base::RefCountedDeleteOnSequence<PrintDialogGtk>,
PrintDialogGtk,
content::BrowserThread::DeleteOnUIThread>,
public aura::WindowObserver { public aura::WindowObserver {
public: public:
// Creates and returns a print dialog. // Creates and returns a print dialog.
...@@ -55,8 +52,7 @@ class PrintDialogGtk : public printing::PrintDialogGtkInterface, ...@@ -55,8 +52,7 @@ class PrintDialogGtk : public printing::PrintDialogGtkInterface,
void OnJobCompleted(GtkPrintJob* print_job, const GError* error); void OnJobCompleted(GtkPrintJob* print_job, const GError* error);
private: private:
friend struct content::BrowserThread::DeleteOnThread< friend class base::RefCountedDeleteOnSequence<PrintDialogGtk>;
content::BrowserThread::UI>;
friend class base::DeleteHelper<PrintDialogGtk>; friend class base::DeleteHelper<PrintDialogGtk>;
explicit PrintDialogGtk(PrintingContextLinux* context); explicit PrintDialogGtk(PrintingContextLinux* context);
...@@ -88,6 +84,8 @@ class PrintDialogGtk : public printing::PrintDialogGtkInterface, ...@@ -88,6 +84,8 @@ class PrintDialogGtk : public printing::PrintDialogGtkInterface,
base::FilePath path_to_pdf_; base::FilePath path_to_pdf_;
SEQUENCE_CHECKER(sequence_checker_);
DISALLOW_COPY_AND_ASSIGN(PrintDialogGtk); DISALLOW_COPY_AND_ASSIGN(PrintDialogGtk);
}; };
......
...@@ -10,9 +10,6 @@ ...@@ -10,9 +10,6 @@
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/nix/xdg_util.h" #include "base/nix/xdg_util.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "content/public/browser/browser_thread.h"
using content::BrowserThread;
namespace { namespace {
...@@ -31,7 +28,6 @@ base::FilePath* SelectFileDialogImpl::last_opened_path_ = nullptr; ...@@ -31,7 +28,6 @@ base::FilePath* SelectFileDialogImpl::last_opened_path_ = nullptr;
ui::SelectFileDialog* SelectFileDialogImpl::Create( ui::SelectFileDialog* SelectFileDialogImpl::Create(
ui::SelectFileDialog::Listener* listener, ui::SelectFileDialog::Listener* listener,
std::unique_ptr<ui::SelectFilePolicy> policy) { std::unique_ptr<ui::SelectFilePolicy> policy) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (use_kde_ == UNKNOWN) { if (use_kde_ == UNKNOWN) {
// Start out assumimg we are not going to use KDE. // Start out assumimg we are not going to use KDE.
use_kde_ = NO_KDE; use_kde_ = NO_KDE;
......
...@@ -26,14 +26,11 @@ ...@@ -26,14 +26,11 @@
#include "base/task/thread_pool.h" #include "base/task/thread_pool.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "chrome/browser/ui/gtk/select_file_dialog_impl.h" #include "chrome/browser/ui/gtk/select_file_dialog_impl.h"
#include "content/public/browser/browser_thread.h"
#include "ui/aura/window_tree_host.h" #include "ui/aura/window_tree_host.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/x/x11.h" #include "ui/gfx/x/x11.h"
#include "ui/strings/grit/ui_strings.h" #include "ui/strings/grit/ui_strings.h"
using content::BrowserThread;
namespace { namespace {
std::string GetTitle(const std::string& title, int message_id) { std::string GetTitle(const std::string& title, int message_id) {
...@@ -180,6 +177,8 @@ class SelectFileDialogImplKDE : public SelectFileDialogImpl { ...@@ -180,6 +177,8 @@ class SelectFileDialogImplKDE : public SelectFileDialogImpl {
// A task runner for blocking pipe reads. // A task runner for blocking pipe reads.
scoped_refptr<base::SequencedTaskRunner> pipe_task_runner_; scoped_refptr<base::SequencedTaskRunner> pipe_task_runner_;
SEQUENCE_CHECKER(sequence_checker_);
DISALLOW_COPY_AND_ASSIGN(SelectFileDialogImplKDE); DISALLOW_COPY_AND_ASSIGN(SelectFileDialogImplKDE);
}; };
...@@ -222,7 +221,7 @@ SelectFileDialogImplKDE::SelectFileDialogImplKDE( ...@@ -222,7 +221,7 @@ SelectFileDialogImplKDE::SelectFileDialogImplKDE(
SelectFileDialogImplKDE::~SelectFileDialogImplKDE() {} SelectFileDialogImplKDE::~SelectFileDialogImplKDE() {}
bool SelectFileDialogImplKDE::IsRunning(gfx::NativeWindow parent_window) const { bool SelectFileDialogImplKDE::IsRunning(gfx::NativeWindow parent_window) const {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (parent_window && parent_window->GetHost()) { if (parent_window && parent_window->GetHost()) {
XID xid = parent_window->GetHost()->GetAcceleratedWidget(); XID xid = parent_window->GetHost()->GetAcceleratedWidget();
return parents_.find(xid) != parents_.end(); return parents_.find(xid) != parents_.end();
...@@ -241,7 +240,7 @@ void SelectFileDialogImplKDE::SelectFileImpl( ...@@ -241,7 +240,7 @@ void SelectFileDialogImplKDE::SelectFileImpl(
const base::FilePath::StringType& default_extension, const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window, gfx::NativeWindow owning_window,
void* params) { void* params) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
type_ = type; type_ = type;
XID window_xid = x11::None; XID window_xid = x11::None;
...@@ -410,8 +409,8 @@ void SelectFileDialogImplKDE::CreateSelectFolderDialog( ...@@ -410,8 +409,8 @@ void SelectFileDialogImplKDE::CreateSelectFolderDialog(
int title_message_id = (type == SELECT_UPLOAD_FOLDER) int title_message_id = (type == SELECT_UPLOAD_FOLDER)
? IDS_SELECT_UPLOAD_FOLDER_DIALOG_TITLE ? IDS_SELECT_UPLOAD_FOLDER_DIALOG_TITLE
: IDS_SELECT_FOLDER_DIALOG_TITLE; : IDS_SELECT_FOLDER_DIALOG_TITLE;
base::PostTaskAndReplyWithResult( pipe_task_runner_->PostTaskAndReplyWithResult(
pipe_task_runner_.get(), FROM_HERE, FROM_HERE,
base::BindOnce( base::BindOnce(
&SelectFileDialogImplKDE::CallKDialogOutput, this, &SelectFileDialogImplKDE::CallKDialogOutput, this,
KDialogParams( KDialogParams(
...@@ -428,8 +427,8 @@ void SelectFileDialogImplKDE::CreateFileOpenDialog( ...@@ -428,8 +427,8 @@ void SelectFileDialogImplKDE::CreateFileOpenDialog(
const base::FilePath& default_path, const base::FilePath& default_path,
XID parent, XID parent,
void* params) { void* params) {
base::PostTaskAndReplyWithResult( pipe_task_runner_->PostTaskAndReplyWithResult(
pipe_task_runner_.get(), FROM_HERE, FROM_HERE,
base::BindOnce( base::BindOnce(
&SelectFileDialogImplKDE::CallKDialogOutput, this, &SelectFileDialogImplKDE::CallKDialogOutput, this,
KDialogParams( KDialogParams(
...@@ -445,8 +444,8 @@ void SelectFileDialogImplKDE::CreateMultiFileOpenDialog( ...@@ -445,8 +444,8 @@ void SelectFileDialogImplKDE::CreateMultiFileOpenDialog(
const base::FilePath& default_path, const base::FilePath& default_path,
XID parent, XID parent,
void* params) { void* params) {
base::PostTaskAndReplyWithResult( pipe_task_runner_->PostTaskAndReplyWithResult(
pipe_task_runner_.get(), FROM_HERE, FROM_HERE,
base::BindOnce( base::BindOnce(
&SelectFileDialogImplKDE::CallKDialogOutput, this, &SelectFileDialogImplKDE::CallKDialogOutput, this,
KDialogParams( KDialogParams(
...@@ -462,8 +461,8 @@ void SelectFileDialogImplKDE::CreateSaveAsDialog( ...@@ -462,8 +461,8 @@ void SelectFileDialogImplKDE::CreateSaveAsDialog(
const base::FilePath& default_path, const base::FilePath& default_path,
XID parent, XID parent,
void* params) { void* params) {
base::PostTaskAndReplyWithResult( pipe_task_runner_->PostTaskAndReplyWithResult(
pipe_task_runner_.get(), FROM_HERE, FROM_HERE,
base::BindOnce( base::BindOnce(
&SelectFileDialogImplKDE::CallKDialogOutput, this, &SelectFileDialogImplKDE::CallKDialogOutput, this,
KDialogParams("--getsavefilename", KDialogParams("--getsavefilename",
...@@ -500,7 +499,7 @@ void SelectFileDialogImplKDE::OnSelectSingleFileDialogResponse( ...@@ -500,7 +499,7 @@ void SelectFileDialogImplKDE::OnSelectSingleFileDialogResponse(
XID parent, XID parent,
void* params, void* params,
std::unique_ptr<KDialogOutputParams> results) { std::unique_ptr<KDialogOutputParams> results) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
parents_.erase(parent); parents_.erase(parent);
SelectSingleFileHelper(params, false, std::move(results)); SelectSingleFileHelper(params, false, std::move(results));
} }
...@@ -509,7 +508,7 @@ void SelectFileDialogImplKDE::OnSelectSingleFolderDialogResponse( ...@@ -509,7 +508,7 @@ void SelectFileDialogImplKDE::OnSelectSingleFolderDialogResponse(
XID parent, XID parent,
void* params, void* params,
std::unique_ptr<KDialogOutputParams> results) { std::unique_ptr<KDialogOutputParams> results) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
parents_.erase(parent); parents_.erase(parent);
SelectSingleFileHelper(params, true, std::move(results)); SelectSingleFileHelper(params, true, std::move(results));
} }
...@@ -518,7 +517,7 @@ void SelectFileDialogImplKDE::OnSelectMultiFileDialogResponse( ...@@ -518,7 +517,7 @@ void SelectFileDialogImplKDE::OnSelectMultiFileDialogResponse(
XID parent, XID parent,
void* params, void* params,
std::unique_ptr<KDialogOutputParams> results) { std::unique_ptr<KDialogOutputParams> results) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
VLOG(1) << "[kdialog] MultiFileResponse: " << results->output; VLOG(1) << "[kdialog] MultiFileResponse: " << results->output;
parents_.erase(parent); parents_.erase(parent);
......
...@@ -25,8 +25,6 @@ ...@@ -25,8 +25,6 @@
// The main entrypoint into Linux toolkit specific code. GTK code should only // The main entrypoint into Linux toolkit specific code. GTK code should only
// be executed behind this interface. // be executed behind this interface.
class PrefService;
namespace aura { namespace aura {
class Window; class Window;
} }
...@@ -96,7 +94,7 @@ class VIEWS_EXPORT LinuxUI : public ui::LinuxInputMethodContextFactory, ...@@ -96,7 +94,7 @@ class VIEWS_EXPORT LinuxUI : public ui::LinuxInputMethodContextFactory,
virtual bool GetTint(int id, color_utils::HSL* tint) const = 0; virtual bool GetTint(int id, color_utils::HSL* tint) const = 0;
virtual bool GetColor(int id, virtual bool GetColor(int id,
SkColor* color, SkColor* color,
PrefService* pref_service) const = 0; bool use_custom_frame) const = 0;
virtual bool GetDisplayProperty(int id, int* result) const = 0; virtual bool GetDisplayProperty(int id, int* result) const = 0;
// Returns the preferences that we pass to Blink. // Returns the preferences that we pass to Blink.
......
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