Commit 673f4711 authored by Alexander Timin's avatar Alexander Timin Committed by Commit Bot

Remove ThumbnailPageEventAdapter.

ThumbnailPageEventAdapter is unused at the moment and there is no active
development in the directory.

Remove it to reduce the number of users of WebContentsObservers and
other content/public APIs and make changes to them (a little bit)
easier.

R=dfried@chromium.org

Change-Id: Ibba50f017a1ebf3b90eacf4392ea72413a97a113
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2085311Reviewed-by: default avatarDana Fried <dfried@chromium.org>
Commit-Queue: Alexander Timin <altimin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747458}
parent a168145a
......@@ -1211,9 +1211,6 @@ jumbo_static_library("ui") {
"task_manager/task_manager_table_model.h",
"thumbnails/thumbnail_image.cc",
"thumbnails/thumbnail_image.h",
"thumbnails/thumbnail_page_event_adapter.cc",
"thumbnails/thumbnail_page_event_adapter.h",
"thumbnails/thumbnail_page_observer.h",
"thumbnails/thumbnail_tab_helper.cc",
"thumbnails/thumbnail_tab_helper.h",
"toolbar/app_menu_icon_controller.cc",
......
// Copyright 2019 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/thumbnails/thumbnail_page_event_adapter.h"
#include "content/public/browser/navigation_handle.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"
namespace thumbnails {
namespace {
bool IsMainFrame(content::RenderFrameHost* render_frame_host) {
return !render_frame_host->GetParent();
}
} // namespace
ThumbnailPageEventAdapter::ThumbnailPageEventAdapter(
content::WebContents* contents)
: content::WebContentsObserver(contents) {}
ThumbnailPageEventAdapter::~ThumbnailPageEventAdapter() = default;
void ThumbnailPageEventAdapter::AddObserver(ThumbnailPageObserver* observer) {
observers_.AddObserver(observer);
}
void ThumbnailPageEventAdapter::RemoveObserver(
ThumbnailPageObserver* observer) {
if (observers_.HasObserver(observer))
observers_.RemoveObserver(observer);
}
void ThumbnailPageEventAdapter::OnVisibilityChanged(
content::Visibility visibility) {
const bool visible = visibility == content::Visibility::VISIBLE;
for (auto& observer : observers_)
observer.VisibilityChanged(visible);
}
void ThumbnailPageEventAdapter::DidStartNavigation(
content::NavigationHandle* navigation_handle) {
if (navigation_handle->IsInMainFrame() &&
!navigation_handle->IsSameDocument()) {
const GURL& url = navigation_handle->GetWebContents()->GetVisibleURL();
for (auto& observer : observers_)
observer.TopLevelNavigationStarted(url);
}
}
void ThumbnailPageEventAdapter::DidRedirectNavigation(
content::NavigationHandle* navigation_handle) {
if (navigation_handle->IsInMainFrame() &&
!navigation_handle->IsSameDocument()) {
const GURL& url = navigation_handle->GetWebContents()->GetVisibleURL();
for (auto& observer : observers_)
observer.TopLevelNavigationStarted(url);
}
}
void ThumbnailPageEventAdapter::DidFinishNavigation(
content::NavigationHandle* navigation_handle) {
if (navigation_handle->IsInMainFrame()) {
const GURL& url = navigation_handle->GetWebContents()->GetVisibleURL();
for (auto& observer : observers_)
observer.TopLevelNavigationEnded(url);
}
}
void ThumbnailPageEventAdapter::DocumentAvailableInMainFrame() {
for (auto& observer : observers_)
observer.PageLoadStarted();
}
void ThumbnailPageEventAdapter::DidFirstVisuallyNonEmptyPaint() {
for (auto& observer : observers_)
observer.PagePainted();
}
void ThumbnailPageEventAdapter::DidFinishLoad(
content::RenderFrameHost* render_frame_host,
const GURL& validated_url) {
if (IsMainFrame(render_frame_host)) {
for (auto& observer : observers_)
observer.PageLoadFinished();
}
}
void ThumbnailPageEventAdapter::DidFailLoad(
content::RenderFrameHost* render_frame_host,
const GURL& validated_url,
int error_code) {
if (IsMainFrame(render_frame_host)) {
for (auto& observer : observers_)
observer.PageLoadFinished();
}
}
void ThumbnailPageEventAdapter::NavigationStopped() {
const GURL& url = web_contents()->GetVisibleURL();
for (auto& observer : observers_) {
observer.TopLevelNavigationEnded(url);
observer.PageLoadFinished();
}
}
void ThumbnailPageEventAdapter::BeforeUnloadFired(
bool proceed,
const base::TimeTicks& proceed_time) {
is_unloading_ = true;
}
void ThumbnailPageEventAdapter::BeforeUnloadDialogCancelled() {
is_unloading_ = false;
}
} // namespace thumbnails
// Copyright 2019 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_THUMBNAILS_THUMBNAIL_PAGE_EVENT_ADAPTER_H_
#define CHROME_BROWSER_UI_THUMBNAILS_THUMBNAIL_PAGE_EVENT_ADAPTER_H_
#include "base/macros.h"
#include "base/scoped_observer.h"
#include "chrome/browser/ui/thumbnails/thumbnail_page_observer.h"
#include "content/public/browser/web_contents_observer.h"
#include "url/gurl.h"
namespace content {
class NavigationHandle;
class RenderFrameHost;
} // namespace content
namespace thumbnails {
// Base class for thumbnail tab helper; processes specific web contents events
// into a filtered-down set of navigation and loading events for ease of
// processing.
class ThumbnailPageEventAdapter : public content::WebContentsObserver {
public:
explicit ThumbnailPageEventAdapter(content::WebContents* contents);
~ThumbnailPageEventAdapter() override;
bool is_unloading() const { return is_unloading_; }
void AddObserver(ThumbnailPageObserver* observer);
void RemoveObserver(ThumbnailPageObserver* observer);
protected:
// WebContentsObserver:
void OnVisibilityChanged(content::Visibility visibility) override;
void DidStartNavigation(
content::NavigationHandle* navigation_handle) override;
void DidRedirectNavigation(
content::NavigationHandle* navigation_handle) override;
void DidFinishNavigation(
content::NavigationHandle* navigation_handle) override;
void DocumentAvailableInMainFrame() override;
void DidFirstVisuallyNonEmptyPaint() override;
void DidFinishLoad(content::RenderFrameHost* render_frame_host,
const GURL& validated_url) override;
void DidFailLoad(content::RenderFrameHost* render_frame_host,
const GURL& validated_url,
int error_code) override;
void NavigationStopped() override;
void BeforeUnloadFired(bool proceed,
const base::TimeTicks& proceed_time) override;
void BeforeUnloadDialogCancelled() override;
private:
base::ObserverList<ThumbnailPageObserver> observers_;
// True if the current page is in the process of being unloaded from the
// browser (e.g. on a tab or window close).
bool is_unloading_ = false;
DISALLOW_COPY_AND_ASSIGN(ThumbnailPageEventAdapter);
};
} // namespace thumbnails
#endif // CHROME_BROWSER_UI_THUMBNAILS_THUMBNAIL_PAGE_EVENT_ADAPTER_H_
// Copyright 2019 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_THUMBNAILS_THUMBNAIL_PAGE_OBSERVER_H_
#define CHROME_BROWSER_UI_THUMBNAILS_THUMBNAIL_PAGE_OBSERVER_H_
#include "base/observer_list_types.h"
#include "url/gurl.h"
namespace thumbnails {
// Observer of navigation and loading events relevant to thumbnail processing.
//
// Note that while most page loads receive the following signals in order:
// - Navigation Started
// - Navigation Ended
// - Page Load Started
// - Page Load Finished
//
// Not all page transitions will receive all of these or in that order.
// Classes implementing this interface should be able to handle a navigation end
// without a start, or a frame load without a prior navigation.
class ThumbnailPageObserver : public base::CheckedObserver {
public:
// Called when navigation in the top-level browser window starts.
virtual void TopLevelNavigationStarted(const GURL& url) = 0;
// Called when navigation in the top-level browser window completes.
virtual void TopLevelNavigationEnded(const GURL& url) = 0;
// Called when the page/tab's visibility changes.
virtual void VisibilityChanged(bool visible) = 0;
// Called when the page is painted for the first time.
virtual void PagePainted() = 0;
// Called when a page begins to load.
virtual void PageLoadStarted() = 0;
// Called when a page finishes loading.
virtual void PageLoadFinished() = 0;
};
} // namespace thumbnails
#endif // CHROME_BROWSER_UI_THUMBNAILS_THUMBNAIL_PAGE_OBSERVER_H_
......@@ -12,8 +12,6 @@
#include "base/scoped_observer.h"
#include "base/time/time.h"
#include "chrome/browser/ui/thumbnails/thumbnail_image.h"
#include "chrome/browser/ui/thumbnails/thumbnail_page_event_adapter.h"
#include "chrome/browser/ui/thumbnails/thumbnail_page_observer.h"
#include "components/viz/host/client_frame_sink_video_capturer.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/web_contents_observer.h"
......
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