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) { ...@@ -88,25 +88,32 @@ bool WebNavigationEventRouter::ShouldTrackBrowser(Browser* browser) {
return profile_->IsSameProfile(browser->profile()); return profile_->IsSameProfile(browser->profile());
} }
void WebNavigationEventRouter::TabReplacedAt( void WebNavigationEventRouter::OnTabStripModelChanged(
TabStripModel* tab_strip_model, TabStripModel* tab_strip_model,
content::WebContents* old_contents, const TabStripModelChange& change,
content::WebContents* new_contents, const TabStripSelectionChange& selection) {
int index) { if (change.type() != TabStripModelChange::kReplaced)
return;
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* tab_observer =
WebNavigationTabObserver::Get(old_contents); WebNavigationTabObserver::Get(old_contents);
if (!tab_observer) { if (!tab_observer) {
// If you hit this DCHECK(), please add reproduction steps to // If you hit this DCHECK(), please add reproduction steps to
// http://crbug.com/109464. // http://crbug.com/109464.
DCHECK(GetViewType(old_contents) != VIEW_TYPE_TAB_CONTENTS); DCHECK(GetViewType(old_contents) != VIEW_TYPE_TAB_CONTENTS);
return; continue;
} }
if (!FrameNavigationState::IsValidUrl(old_contents->GetURL()) || if (!FrameNavigationState::IsValidUrl(old_contents->GetURL()) ||
!FrameNavigationState::IsValidUrl(new_contents->GetURL())) !FrameNavigationState::IsValidUrl(new_contents->GetURL()))
return; continue;
web_navigation_api_helpers::DispatchOnTabReplaced(old_contents, profile_, web_navigation_api_helpers::DispatchOnTabReplaced(old_contents, profile_,
new_contents); new_contents);
}
} }
void WebNavigationEventRouter::Observe( void WebNavigationEventRouter::Observe(
......
...@@ -148,10 +148,10 @@ class WebNavigationEventRouter : public TabStripModelObserver, ...@@ -148,10 +148,10 @@ class WebNavigationEventRouter : public TabStripModelObserver,
bool ShouldTrackBrowser(Browser* browser) override; bool ShouldTrackBrowser(Browser* browser) override;
// TabStripModelObserver implementation. // TabStripModelObserver implementation.
void TabReplacedAt(TabStripModel* tab_strip_model, void OnTabStripModelChanged(
content::WebContents* old_contents, TabStripModel* tab_strip_model,
content::WebContents* new_contents, const TabStripModelChange& change,
int index) override; const TabStripSelectionChange& selection) override;
// content::NotificationObserver implementation. // content::NotificationObserver implementation.
void Observe(int type, 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