Skip to content

Commit

Permalink
Move color_change_listener to ui/webui
Browse files Browse the repository at this point in the history
This enables webuis in //ash to be able to hook into the color
change listener.

LOW_COVERAGE_REASON=Migration of existing code only, no new code added.

BUG= b:244116796

Change-Id: Iae535cccbca7e634b7c7e3129b10a74103abb342
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3861651
Reviewed-by: Giovanni Ortuno Urquidi <ortuno@chromium.org>
Commit-Queue: Meredith Lane <meredithl@chromium.org>
Reviewed-by: Thomas Lukaszewicz <tluk@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1042447}
  • Loading branch information
Meredith Lane authored and Chromium LUCI CQ committed Sep 2, 2022
1 parent 3dc27e1 commit dce700c
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 14 deletions.
2 changes: 0 additions & 2 deletions chrome/browser/ui/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1475,8 +1475,6 @@ static_library("ui") {
"webui/browser_command/browser_command_handler.h",
"webui/chrome_web_contents_handler.cc",
"webui/chrome_web_contents_handler.h",
"webui/color_change_listener/color_change_handler.cc",
"webui/color_change_listener/color_change_handler.h",
"webui/commander/commander_handler.cc",
"webui/commander/commander_handler.h",
"webui/commander/commander_ui.cc",
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include "chrome/browser/ui/color/chrome_color_id.h"
#include "chrome/browser/ui/side_panel/customize_chrome/customize_chrome_tab_helper.h"
#include "chrome/browser/ui/webui/browser_command/browser_command_handler.h"
#include "chrome/browser/ui/webui/color_change_listener/color_change_handler.h"
#include "chrome/browser/ui/webui/cr_components/most_visited/most_visited_handler.h"
#include "chrome/browser/ui/webui/customize_themes/chrome_customize_themes_handler.h"
#include "chrome/browser/ui/webui/favicon_source.h"
Expand Down Expand Up @@ -81,6 +80,7 @@
#include "ui/color/color_provider.h"
#include "ui/native_theme/native_theme.h"
#include "ui/resources/grit/webui_generated_resources.h"
#include "ui/webui/color_change_listener/color_change_handler.h"
#include "url/url_util.h"

#if !defined(OFFICIAL_BUILD)
Expand Down Expand Up @@ -647,7 +647,7 @@ void NewTabPageUI::BindInterface(
void NewTabPageUI::BindInterface(
mojo::PendingReceiver<color_change_listener::mojom::PageHandler>
pending_receiver) {
color_provider_handler_ = std::make_unique<ColorChangeHandler>(
color_provider_handler_ = std::make_unique<ui::ColorChangeHandler>(
web_ui()->GetWebContents(), std::move(pending_receiver));
}

Expand Down
7 changes: 5 additions & 2 deletions chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ class WebContents;
class WebUI;
} // namespace content

class ChromeCustomizeThemesHandler;
namespace ui {
class ColorChangeHandler;
} // namespace ui

class ChromeCustomizeThemesHandler;
#if !defined(OFFICIAL_BUILD)
class FooHandler;
#endif
Expand Down Expand Up @@ -218,7 +221,7 @@ class NewTabPageUI
mojo::Receiver<new_tab_page::mojom::PageHandlerFactory>
page_factory_receiver_;
std::unique_ptr<ChromeCustomizeThemesHandler> customize_themes_handler_;
std::unique_ptr<ColorChangeHandler> color_provider_handler_;
std::unique_ptr<ui::ColorChangeHandler> color_provider_handler_;
mojo::Receiver<customize_themes::mojom::CustomizeThemesHandlerFactory>
customize_themes_factory_receiver_;
std::unique_ptr<MostVisitedHandler> most_visited_page_handler_;
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/webui/tab_strip/tab_strip_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "chrome/browser/ui/color/chrome_color_id.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/webui/color_change_listener/color_change_handler.h"
#include "chrome/browser/ui/webui/favicon_source.h"
#include "chrome/browser/ui/webui/tab_strip/tab_strip_page_handler.h"
#include "chrome/browser/ui/webui/tab_strip/tab_strip_ui_embedder.h"
Expand All @@ -34,6 +33,7 @@
#include "ui/base/theme_provider.h"
#include "ui/base/webui/web_ui_util.h"
#include "ui/gfx/color_utils.h"
#include "ui/webui/color_change_listener/color_change_handler.h"

// These data types must be in all lowercase.
const char kWebUITabIdDataType[] = "application/vnd.chromium.tab";
Expand Down Expand Up @@ -102,7 +102,7 @@ void TabStripUI::BindInterface(

void TabStripUI::BindInterface(
mojo::PendingReceiver<color_change_listener::mojom::PageHandler> receiver) {
color_provider_handler_ = std::make_unique<ColorChangeHandler>(
color_provider_handler_ = std::make_unique<ui::ColorChangeHandler>(
web_ui()->GetWebContents(), std::move(receiver));
}

Expand Down
7 changes: 5 additions & 2 deletions chrome/browser/ui/webui/tab_strip/tab_strip_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
#include "ui/webui/mojo_web_ui_controller.h"
#include "ui/webui/resources/cr_components/color_change_listener/color_change_listener.mojom.h"

class Browser;
namespace ui {
class ColorChangeHandler;
} // namespace ui

class Browser;
class TabStripPageHandler;
class TabStripUIEmbedder;

Expand Down Expand Up @@ -74,7 +77,7 @@ class TabStripUI : public ui::MojoWebUIController,

std::unique_ptr<TabStripPageHandler> page_handler_;

std::unique_ptr<ColorChangeHandler> color_provider_handler_;
std::unique_ptr<ui::ColorChangeHandler> color_provider_handler_;

mojo::Receiver<tab_strip::mojom::PageHandlerFactory> page_factory_receiver_{
this};
Expand Down
4 changes: 4 additions & 0 deletions ui/webui/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ static_library("webui") {
"//ui/webui/resources/cr_components/history_clusters:mojo_bindings",
"//ui/webui/resources/cr_components/most_visited:mojom",
]
sources += [
"color_change_listener/color_change_handler.cc",
"color_change_listener/color_change_handler.h",
]
}
}

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/webui/color_change_listener/color_change_handler.h"
#include "ui/webui/color_change_listener/color_change_handler.h"

#include "content/public/browser/web_ui_data_source.h"
#include "ui/base/webui/resource_path.h"
#include "ui/resources/grit/webui_generated_resources.h"

namespace ui {

ColorChangeHandler::ColorChangeHandler(
content::WebContents* web_contents,
Expand All @@ -26,3 +27,5 @@ void ColorChangeHandler::OnColorProviderChanged() {
if (page_)
page_->OnColorProviderChanged();
}

} // namespace ui
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_UI_WEBUI_COLOR_CHANGE_LISTENER_COLOR_CHANGE_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_COLOR_CHANGE_LISTENER_COLOR_CHANGE_HANDLER_H_
#ifndef UI_WEBUI_COLOR_CHANGE_LISTENER_COLOR_CHANGE_HANDLER_H_
#define UI_WEBUI_COLOR_CHANGE_LISTENER_COLOR_CHANGE_HANDLER_H_

#include "content/public/browser/web_contents_observer.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "ui/webui/resources/cr_components/color_change_listener/color_change_listener.mojom.h"

namespace ui {

// Handles ColorProvider related communication between C++ and WebUI in the
// renderer.
class ColorChangeHandler : public content::WebContentsObserver,
Expand All @@ -36,4 +38,6 @@ class ColorChangeHandler : public content::WebContentsObserver,
mojo::Receiver<color_change_listener::mojom::PageHandler> page_handler_;
};

} // namespace ui

#endif // CHROME_BROWSER_UI_WEBUI_COLOR_CHANGE_LISTENER_COLOR_CHANGE_HANDLER_H_

0 comments on commit dce700c

Please sign in to comment.