|
@@ -74,6 +74,7 @@ bool WebContentsZoomController::SetZoomLevel(double level) {
|
|
|
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
|
|
content::NavigationEntry* entry =
|
|
|
web_contents()->GetController().GetLastCommittedEntry();
|
|
|
+
|
|
|
// Cannot zoom in disabled mode. Also, don't allow changing zoom level on
|
|
|
// a crashed tab, an error page or an interstitial page.
|
|
|
if (zoom_mode_ == ZOOM_MODE_DISABLED ||
|
|
@@ -90,7 +91,7 @@ bool WebContentsZoomController::SetZoomLevel(double level) {
|
|
|
zoom_level_ = level;
|
|
|
|
|
|
ZoomChangedEventData zoom_change_data(web_contents(), old_zoom_level,
|
|
|
- zoom_level_, false /* temporary */,
|
|
|
+ zoom_level_, true /* temporary */,
|
|
|
zoom_mode_);
|
|
|
for (auto& observer : observers_)
|
|
|
observer.OnZoomChanged(zoom_change_data);
|
|
@@ -154,7 +155,7 @@ void WebContentsZoomController::SetTemporaryZoomLevel(double level) {
|
|
|
// Notify observers of zoom level changes.
|
|
|
ZoomChangedEventData zoom_change_data(web_contents(), zoom_level_, level,
|
|
|
true /* temporary */, zoom_mode_);
|
|
|
- for (WebContentsZoomObserver& observer : observers_)
|
|
|
+ for (auto& observer : observers_)
|
|
|
observer.OnZoomChanged(zoom_change_data);
|
|
|
}
|
|
|
|
|
@@ -268,8 +269,10 @@ void WebContentsZoomController::ResetZoomModeOnNavigationIfNeeded(
|
|
|
double old_zoom_level = zoom_map->GetZoomLevel(web_contents());
|
|
|
double new_zoom_level = zoom_map->GetZoomLevelForHostAndScheme(
|
|
|
url.scheme(), net::GetHostOrSpecFromURL(url));
|
|
|
+
|
|
|
event_data_ = std::make_unique<ZoomChangedEventData>(
|
|
|
web_contents(), old_zoom_level, new_zoom_level, false, ZOOM_MODE_DEFAULT);
|
|
|
+
|
|
|
// The call to ClearTemporaryZoomLevel() doesn't generate any events from
|
|
|
// HostZoomMap, but the call to UpdateState() at the end of
|
|
|
// DidFinishNavigation will notify our observers.
|
|
@@ -295,11 +298,12 @@ void WebContentsZoomController::DidFinishNavigation(
|
|
|
if (!navigation_handle->IsSameDocument()) {
|
|
|
ResetZoomModeOnNavigationIfNeeded(navigation_handle->GetURL());
|
|
|
SetZoomFactorOnNavigationIfNeeded(navigation_handle->GetURL());
|
|
|
+
|
|
|
+ // If the main frame's content has changed, the new page may have a
|
|
|
+ // different zoom level from the old one.
|
|
|
+ UpdateState(std::string());
|
|
|
}
|
|
|
|
|
|
- // If the main frame's content has changed, the new page may have a different
|
|
|
- // zoom level from the old one.
|
|
|
- UpdateState(std::string());
|
|
|
DCHECK(!event_data_);
|
|
|
}
|
|
|
|