| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/zoom/zoom_controller.h" | 5 #include "components/zoom/zoom_controller.h" |
| 6 | 6 |
| 7 #include "components/zoom/zoom_event_manager.h" | 7 #include "components/zoom/zoom_event_manager.h" |
| 8 #include "components/zoom/zoom_observer.h" | 8 #include "components/zoom/zoom_observer.h" |
| 9 #include "content/public/browser/host_zoom_map.h" | 9 #include "content/public/browser/host_zoom_map.h" |
| 10 #include "content/public/browser/navigation_details.h" | 10 #include "content/public/browser/navigation_details.h" |
| 11 #include "content/public/browser/navigation_entry.h" | 11 #include "content/public/browser/navigation_entry.h" |
| 12 #include "content/public/browser/navigation_handle.h" |
| 12 #include "content/public/browser/render_process_host.h" | 13 #include "content/public/browser/render_process_host.h" |
| 13 #include "content/public/browser/render_view_host.h" | 14 #include "content/public/browser/render_view_host.h" |
| 14 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
| 15 #include "content/public/common/page_type.h" | 16 #include "content/public/common/page_type.h" |
| 16 #include "content/public/common/page_zoom.h" | 17 #include "content/public/common/page_zoom.h" |
| 17 #include "net/base/url_util.h" | 18 #include "net/base/url_util.h" |
| 18 | 19 |
| 19 DEFINE_WEB_CONTENTS_USER_DATA_KEY(zoom::ZoomController); | 20 DEFINE_WEB_CONTENTS_USER_DATA_KEY(zoom::ZoomController); |
| 20 | 21 |
| 21 namespace zoom { | 22 namespace zoom { |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 // The call to ClearTemporaryZoomLevel() doesn't generate any events from | 278 // The call to ClearTemporaryZoomLevel() doesn't generate any events from |
| 278 // HostZoomMap, but the call to UpdateState() at the end of this function | 279 // HostZoomMap, but the call to UpdateState() at the end of this function |
| 279 // will notify our observers. | 280 // will notify our observers. |
| 280 // Note: it's possible the render_process/view ids have disappeared (e.g. | 281 // Note: it's possible the render_process/view ids have disappeared (e.g. |
| 281 // if we navigated to a new origin), but this won't cause a problem in the | 282 // if we navigated to a new origin), but this won't cause a problem in the |
| 282 // call below. | 283 // call below. |
| 283 zoom_map->ClearTemporaryZoomLevel(render_process_id, render_view_id); | 284 zoom_map->ClearTemporaryZoomLevel(render_process_id, render_view_id); |
| 284 zoom_mode_ = ZOOM_MODE_DEFAULT; | 285 zoom_mode_ = ZOOM_MODE_DEFAULT; |
| 285 } | 286 } |
| 286 | 287 |
| 287 void ZoomController::DidNavigateMainFrame( | 288 void ZoomController::DidFinishNavigation( |
| 288 const content::LoadCommittedDetails& details, | 289 content::NavigationHandle* navigation_handle) { |
| 289 const content::FrameNavigateParams& params) { | 290 if (!navigation_handle->IsInMainFrame() || !navigation_handle->HasCommitted()) |
| 290 if (details.entry && details.entry->GetPageType() == content::PAGE_TYPE_ERROR) | 291 return; |
| 292 |
| 293 if (navigation_handle->IsErrorPage()) |
| 291 content::HostZoomMap::SendErrorPageZoomLevelRefresh(web_contents()); | 294 content::HostZoomMap::SendErrorPageZoomLevelRefresh(web_contents()); |
| 292 | 295 |
| 293 if (!details.is_in_page) | 296 if (!navigation_handle->IsSamePage()) |
| 294 ResetZoomModeOnNavigationIfNeeded(params.url); | 297 ResetZoomModeOnNavigationIfNeeded(navigation_handle->GetURL()); |
| 295 | 298 |
| 296 // If the main frame's content has changed, the new page may have a different | 299 // If the main frame's content has changed, the new page may have a different |
| 297 // zoom level from the old one. | 300 // zoom level from the old one. |
| 298 UpdateState(std::string()); | 301 UpdateState(std::string()); |
| 299 DCHECK(!event_data_); | 302 DCHECK(!event_data_); |
| 300 } | 303 } |
| 301 | 304 |
| 302 void ZoomController::WebContentsDestroyed() { | 305 void ZoomController::WebContentsDestroyed() { |
| 303 // At this point we should no longer be sending any zoom events with this | 306 // At this point we should no longer be sending any zoom events with this |
| 304 // WebContents. | 307 // WebContents. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 int render_view_id = web_contents()->GetRenderViewHost()->GetRoutingID(); | 369 int render_view_id = web_contents()->GetRenderViewHost()->GetRoutingID(); |
| 367 host_zoom_map_->SetPageScaleFactorIsOneForView(render_process_id, | 370 host_zoom_map_->SetPageScaleFactorIsOneForView(render_process_id, |
| 368 render_view_id, is_one); | 371 render_view_id, is_one); |
| 369 } | 372 } |
| 370 | 373 |
| 371 bool ZoomController::PageScaleFactorIsOne() const { | 374 bool ZoomController::PageScaleFactorIsOne() const { |
| 372 return content::HostZoomMap::PageScaleFactorIsOne(web_contents()); | 375 return content::HostZoomMap::PageScaleFactorIsOne(web_contents()); |
| 373 } | 376 } |
| 374 | 377 |
| 375 } // namespace zoom | 378 } // namespace zoom |
| OLD | NEW |