Commit 22fb8788 authored by sangwoo.ko's avatar sangwoo.ko Committed by Commit Bot

Use TabStripModelObserver's new API in chrome/browser/extensions

Replace old API with new API. This CL is a refactor
ans has no intended behavior change.

Bug: 842194
Change-Id: I46e242b51c99ef720ee6700ab6bf0fdc8c2a4720
Reviewed-on: https://chromium-review.googlesource.com/1174582Reviewed-by: default avatarErik Chen <erikchen@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Sang Woo Ko <sangwoo108@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583318}
parent 2065e9fc
......@@ -88,25 +88,32 @@ bool WebNavigationEventRouter::ShouldTrackBrowser(Browser* browser) {
return profile_->IsSameProfile(browser->profile());
}
void WebNavigationEventRouter::TabReplacedAt(
void WebNavigationEventRouter::OnTabStripModelChanged(
TabStripModel* tab_strip_model,
content::WebContents* old_contents,
content::WebContents* new_contents,
int index) {
WebNavigationTabObserver* tab_observer =
WebNavigationTabObserver::Get(old_contents);
if (!tab_observer) {
// If you hit this DCHECK(), please add reproduction steps to
// http://crbug.com/109464.
DCHECK(GetViewType(old_contents) != VIEW_TYPE_TAB_CONTENTS);
return;
}
if (!FrameNavigationState::IsValidUrl(old_contents->GetURL()) ||
!FrameNavigationState::IsValidUrl(new_contents->GetURL()))
const TabStripModelChange& change,
const TabStripSelectionChange& selection) {
if (change.type() != TabStripModelChange::kReplaced)
return;
web_navigation_api_helpers::DispatchOnTabReplaced(old_contents, profile_,
new_contents);
for (const auto& delta : change.deltas()) {
content::WebContents* old_contents = delta.replace.old_contents;
content::WebContents* new_contents = delta.replace.new_contents;
WebNavigationTabObserver* tab_observer =
WebNavigationTabObserver::Get(old_contents);
if (!tab_observer) {
// If you hit this DCHECK(), please add reproduction steps to
// http://crbug.com/109464.
DCHECK(GetViewType(old_contents) != VIEW_TYPE_TAB_CONTENTS);
continue;
}
if (!FrameNavigationState::IsValidUrl(old_contents->GetURL()) ||
!FrameNavigationState::IsValidUrl(new_contents->GetURL()))
continue;
web_navigation_api_helpers::DispatchOnTabReplaced(old_contents, profile_,
new_contents);
}
}
void WebNavigationEventRouter::Observe(
......
......@@ -148,10 +148,10 @@ class WebNavigationEventRouter : public TabStripModelObserver,
bool ShouldTrackBrowser(Browser* browser) override;
// TabStripModelObserver implementation.
void TabReplacedAt(TabStripModel* tab_strip_model,
content::WebContents* old_contents,
content::WebContents* new_contents,
int index) override;
void OnTabStripModelChanged(
TabStripModel* tab_strip_model,
const TabStripModelChange& change,
const TabStripSelectionChange& selection) override;
// content::NotificationObserver implementation.
void Observe(int type,
......
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