| 
									
										
										
										
											2017-01-30 16:48:40 +05:30
										 |  |  | // Copyright (c) 2017 GitHub, Inc.
 | 
					
						
							|  |  |  | // Use of this source code is governed by the MIT license that can be
 | 
					
						
							|  |  |  | // found in the LICENSE file.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "atom/browser/web_contents_zoom_controller.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "content/public/browser/navigation_details.h"
 | 
					
						
							|  |  |  | #include "content/public/browser/navigation_entry.h"
 | 
					
						
							|  |  |  | #include "content/public/browser/navigation_handle.h"
 | 
					
						
							| 
									
										
										
										
											2017-12-18 13:46:23 +11:00
										 |  |  | #include "content/public/browser/render_frame_host.h"
 | 
					
						
							| 
									
										
										
										
											2017-01-30 16:48:40 +05:30
										 |  |  | #include "content/public/browser/render_process_host.h"
 | 
					
						
							|  |  |  | #include "content/public/browser/render_view_host.h"
 | 
					
						
							|  |  |  | #include "content/public/browser/web_contents.h"
 | 
					
						
							|  |  |  | #include "content/public/common/page_type.h"
 | 
					
						
							|  |  |  | #include "content/public/common/page_zoom.h"
 | 
					
						
							|  |  |  | #include "net/base/url_util.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace atom { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | WebContentsZoomController::WebContentsZoomController( | 
					
						
							|  |  |  |     content::WebContents* web_contents) | 
					
						
							| 
									
										
										
										
											2018-05-22 00:18:38 +02:00
										 |  |  |     : content::WebContentsObserver(web_contents) { | 
					
						
							| 
									
										
										
										
											2017-01-30 16:48:40 +05:30
										 |  |  |   default_zoom_factor_ = content::kEpsilon; | 
					
						
							|  |  |  |   host_zoom_map_ = content::HostZoomMap::GetForWebContents(web_contents); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-31 14:55:48 +05:30
										 |  |  | WebContentsZoomController::~WebContentsZoomController() {} | 
					
						
							| 
									
										
										
										
											2017-01-30 16:48:40 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | void WebContentsZoomController::AddObserver( | 
					
						
							|  |  |  |     WebContentsZoomController::Observer* observer) { | 
					
						
							|  |  |  |   observers_.AddObserver(observer); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WebContentsZoomController::RemoveObserver( | 
					
						
							|  |  |  |     WebContentsZoomController::Observer* observer) { | 
					
						
							|  |  |  |   observers_.RemoveObserver(observer); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-31 14:45:45 +05:30
										 |  |  | void WebContentsZoomController::SetEmbedderZoomController( | 
					
						
							|  |  |  |     WebContentsZoomController* controller) { | 
					
						
							|  |  |  |   embedder_zoom_controller_ = controller; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-30 16:48:40 +05:30
										 |  |  | void WebContentsZoomController::SetZoomLevel(double level) { | 
					
						
							|  |  |  |   if (!web_contents()->GetRenderViewHost()->IsRenderViewLive() || | 
					
						
							| 
									
										
										
										
											2017-06-08 02:13:49 +02:00
										 |  |  |       content::ZoomValuesEqual(GetZoomLevel(), level) || | 
					
						
							| 
									
										
										
										
											2019-05-03 20:11:41 +02:00
										 |  |  |       zoom_mode_ == ZoomMode::DISABLED) | 
					
						
							| 
									
										
										
										
											2017-01-30 16:48:40 +05:30
										 |  |  |     return; | 
					
						
							| 
									
										
										
										
											2017-01-30 22:36:50 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-18 13:46:23 +11:00
										 |  |  |   int render_process_id = | 
					
						
							|  |  |  |       web_contents()->GetRenderViewHost()->GetProcess()->GetID(); | 
					
						
							| 
									
										
										
										
											2017-01-31 14:45:45 +05:30
										 |  |  |   int render_view_id = web_contents()->GetRenderViewHost()->GetRoutingID(); | 
					
						
							| 
									
										
										
										
											2017-06-08 02:13:49 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-03 20:11:41 +02:00
										 |  |  |   if (zoom_mode_ == ZoomMode::MANUAL) { | 
					
						
							| 
									
										
										
										
											2017-06-08 02:13:49 +02:00
										 |  |  |     zoom_level_ = level; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (Observer& observer : observers_) | 
					
						
							|  |  |  |       observer.OnZoomLevelChanged(web_contents(), level, true); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return; | 
					
						
							| 
									
										
										
										
											2017-01-30 22:36:50 +05:30
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-08 02:13:49 +02:00
										 |  |  |   content::HostZoomMap* zoom_map = | 
					
						
							|  |  |  |       content::HostZoomMap::GetForWebContents(web_contents()); | 
					
						
							| 
									
										
										
										
											2019-05-03 20:11:41 +02:00
										 |  |  |   if (zoom_mode_ == ZoomMode::ISOLATED || | 
					
						
							| 
									
										
										
										
											2017-06-08 02:13:49 +02:00
										 |  |  |       zoom_map->UsesTemporaryZoomLevel(render_process_id, render_view_id)) { | 
					
						
							| 
									
										
										
										
											2018-04-17 21:55:30 -04:00
										 |  |  |     zoom_map->SetTemporaryZoomLevel(render_process_id, render_view_id, level); | 
					
						
							| 
									
										
										
										
											2017-06-08 02:13:49 +02:00
										 |  |  |     // Notify observers of zoom level changes.
 | 
					
						
							|  |  |  |     for (Observer& observer : observers_) | 
					
						
							|  |  |  |       observer.OnZoomLevelChanged(web_contents(), level, true); | 
					
						
							|  |  |  |   } else { | 
					
						
							|  |  |  |     content::HostZoomMap::SetZoomLevel(web_contents(), level); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Notify observers of zoom level changes.
 | 
					
						
							|  |  |  |     for (Observer& observer : observers_) | 
					
						
							|  |  |  |       observer.OnZoomLevelChanged(web_contents(), level, false); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2017-01-30 16:48:40 +05:30
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | double WebContentsZoomController::GetZoomLevel() { | 
					
						
							| 
									
										
										
										
											2019-05-03 20:11:41 +02:00
										 |  |  |   return zoom_mode_ == ZoomMode::MANUAL | 
					
						
							| 
									
										
										
										
											2017-06-08 02:13:49 +02:00
										 |  |  |              ? zoom_level_ | 
					
						
							|  |  |  |              : content::HostZoomMap::GetZoomLevel(web_contents()); | 
					
						
							| 
									
										
										
										
											2017-01-30 16:48:40 +05:30
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WebContentsZoomController::SetDefaultZoomFactor(double factor) { | 
					
						
							|  |  |  |   default_zoom_factor_ = factor; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | double WebContentsZoomController::GetDefaultZoomFactor() { | 
					
						
							|  |  |  |   return default_zoom_factor_; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-30 22:36:50 +05:30
										 |  |  | void WebContentsZoomController::SetTemporaryZoomLevel(double level) { | 
					
						
							| 
									
										
										
										
											2017-12-18 13:46:23 +11:00
										 |  |  |   old_process_id_ = web_contents()->GetRenderViewHost()->GetProcess()->GetID(); | 
					
						
							| 
									
										
										
										
											2017-01-31 14:45:45 +05:30
										 |  |  |   old_view_id_ = web_contents()->GetRenderViewHost()->GetRoutingID(); | 
					
						
							|  |  |  |   host_zoom_map_->SetTemporaryZoomLevel(old_process_id_, old_view_id_, level); | 
					
						
							| 
									
										
										
										
											2017-01-30 22:36:50 +05:30
										 |  |  |   // Notify observers of zoom level changes.
 | 
					
						
							| 
									
										
										
										
											2017-01-31 14:55:48 +05:30
										 |  |  |   for (Observer& observer : observers_) | 
					
						
							|  |  |  |     observer.OnZoomLevelChanged(web_contents(), level, true); | 
					
						
							| 
									
										
										
										
											2017-01-30 22:36:50 +05:30
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-31 14:45:45 +05:30
										 |  |  | bool WebContentsZoomController::UsesTemporaryZoomLevel() { | 
					
						
							| 
									
										
										
										
											2017-12-18 13:46:23 +11:00
										 |  |  |   int render_process_id = | 
					
						
							|  |  |  |       web_contents()->GetRenderViewHost()->GetProcess()->GetID(); | 
					
						
							| 
									
										
										
										
											2017-01-30 22:36:50 +05:30
										 |  |  |   int render_view_id = web_contents()->GetRenderViewHost()->GetRoutingID(); | 
					
						
							| 
									
										
										
										
											2017-01-31 14:45:45 +05:30
										 |  |  |   return host_zoom_map_->UsesTemporaryZoomLevel(render_process_id, | 
					
						
							|  |  |  |                                                 render_view_id); | 
					
						
							| 
									
										
										
										
											2017-01-30 22:36:50 +05:30
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-08 02:13:49 +02:00
										 |  |  | void WebContentsZoomController::SetZoomMode(ZoomMode new_mode) { | 
					
						
							|  |  |  |   if (new_mode == zoom_mode_) | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   content::HostZoomMap* zoom_map = | 
					
						
							|  |  |  |       content::HostZoomMap::GetForWebContents(web_contents()); | 
					
						
							| 
									
										
										
										
											2017-12-18 13:46:23 +11:00
										 |  |  |   int render_process_id = | 
					
						
							|  |  |  |       web_contents()->GetRenderViewHost()->GetProcess()->GetID(); | 
					
						
							| 
									
										
										
										
											2017-06-08 02:13:49 +02:00
										 |  |  |   int render_view_id = web_contents()->GetRenderViewHost()->GetRoutingID(); | 
					
						
							|  |  |  |   double original_zoom_level = GetZoomLevel(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   switch (new_mode) { | 
					
						
							| 
									
										
										
										
											2019-05-03 20:11:41 +02:00
										 |  |  |     case ZoomMode::DEFAULT: { | 
					
						
							| 
									
										
										
										
											2017-06-08 02:13:49 +02:00
										 |  |  |       content::NavigationEntry* entry = | 
					
						
							|  |  |  |           web_contents()->GetController().GetLastCommittedEntry(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       if (entry) { | 
					
						
							|  |  |  |         GURL url = content::HostZoomMap::GetURLFromEntry(entry); | 
					
						
							|  |  |  |         std::string host = net::GetHostOrSpecFromURL(url); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (zoom_map->HasZoomLevel(url.scheme(), host)) { | 
					
						
							|  |  |  |           // If there are other tabs with the same origin, then set this tab's
 | 
					
						
							|  |  |  |           // zoom level to match theirs. The temporary zoom level will be
 | 
					
						
							|  |  |  |           // cleared below, but this call will make sure this tab re-draws at
 | 
					
						
							|  |  |  |           // the correct zoom level.
 | 
					
						
							|  |  |  |           double origin_zoom_level = | 
					
						
							|  |  |  |               zoom_map->GetZoomLevelForHostAndScheme(url.scheme(), host); | 
					
						
							|  |  |  |           zoom_map->SetTemporaryZoomLevel(render_process_id, render_view_id, | 
					
						
							|  |  |  |                                           origin_zoom_level); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |           // The host will need a level prior to removing the temporary level.
 | 
					
						
							|  |  |  |           // We don't want the zoom level to change just because we entered
 | 
					
						
							|  |  |  |           // default mode.
 | 
					
						
							|  |  |  |           zoom_map->SetZoomLevelForHost(host, original_zoom_level); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       // Remove per-tab zoom data for this tab. No event callback expected.
 | 
					
						
							|  |  |  |       zoom_map->ClearTemporaryZoomLevel(render_process_id, render_view_id); | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-05-03 20:11:41 +02:00
										 |  |  |     case ZoomMode::ISOLATED: { | 
					
						
							|  |  |  |       // Unless the zoom mode was |ZoomMode::DISABLED| before this call, the
 | 
					
						
							| 
									
										
										
										
											2017-06-08 02:13:49 +02:00
										 |  |  |       // page needs an initial isolated zoom back to the same level it was at
 | 
					
						
							|  |  |  |       // in the other mode.
 | 
					
						
							| 
									
										
										
										
											2019-05-03 20:11:41 +02:00
										 |  |  |       if (zoom_mode_ != ZoomMode::DISABLED) { | 
					
						
							| 
									
										
										
										
											2017-06-08 02:13:49 +02:00
										 |  |  |         zoom_map->SetTemporaryZoomLevel(render_process_id, render_view_id, | 
					
						
							|  |  |  |                                         original_zoom_level); | 
					
						
							|  |  |  |       } else { | 
					
						
							|  |  |  |         // When we don't call any HostZoomMap set functions, we send the event
 | 
					
						
							|  |  |  |         // manually.
 | 
					
						
							|  |  |  |         for (Observer& observer : observers_) | 
					
						
							| 
									
										
										
										
											2017-06-08 09:57:24 +02:00
										 |  |  |           observer.OnZoomLevelChanged(web_contents(), original_zoom_level, | 
					
						
							| 
									
										
										
										
											2018-04-17 21:55:30 -04:00
										 |  |  |                                       false); | 
					
						
							| 
									
										
										
										
											2017-06-08 02:13:49 +02:00
										 |  |  |       } | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-05-03 20:11:41 +02:00
										 |  |  |     case ZoomMode::MANUAL: { | 
					
						
							|  |  |  |       // Unless the zoom mode was |ZoomMode::DISABLED| before this call, the
 | 
					
						
							| 
									
										
										
										
											2017-06-08 02:13:49 +02:00
										 |  |  |       // page needs to be resized to the default zoom. While in manual mode,
 | 
					
						
							|  |  |  |       // the zoom level is handled independently.
 | 
					
						
							| 
									
										
										
										
											2019-05-03 20:11:41 +02:00
										 |  |  |       if (zoom_mode_ != ZoomMode::DISABLED) { | 
					
						
							| 
									
										
										
										
											2018-04-17 21:55:30 -04:00
										 |  |  |         zoom_map->SetTemporaryZoomLevel(render_process_id, render_view_id, | 
					
						
							|  |  |  |                                         GetDefaultZoomLevel()); | 
					
						
							| 
									
										
										
										
											2017-06-08 02:13:49 +02:00
										 |  |  |         zoom_level_ = original_zoom_level; | 
					
						
							|  |  |  |       } else { | 
					
						
							|  |  |  |         // When we don't call any HostZoomMap set functions, we send the event
 | 
					
						
							|  |  |  |         // manually.
 | 
					
						
							|  |  |  |         for (Observer& observer : observers_) | 
					
						
							| 
									
										
										
										
											2017-06-08 09:57:24 +02:00
										 |  |  |           observer.OnZoomLevelChanged(web_contents(), original_zoom_level, | 
					
						
							| 
									
										
										
										
											2018-04-17 21:55:30 -04:00
										 |  |  |                                       false); | 
					
						
							| 
									
										
										
										
											2017-06-08 02:13:49 +02:00
										 |  |  |       } | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-05-03 20:11:41 +02:00
										 |  |  |     case ZoomMode::DISABLED: { | 
					
						
							| 
									
										
										
										
											2017-06-08 02:13:49 +02:00
										 |  |  |       // The page needs to be zoomed back to default before disabling the zoom
 | 
					
						
							| 
									
										
										
										
											2018-04-17 21:55:30 -04:00
										 |  |  |       zoom_map->SetTemporaryZoomLevel(render_process_id, render_view_id, | 
					
						
							|  |  |  |                                       GetDefaultZoomLevel()); | 
					
						
							| 
									
										
										
										
											2017-06-08 02:13:49 +02:00
										 |  |  |       break; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   zoom_mode_ = new_mode; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WebContentsZoomController::ResetZoomModeOnNavigationIfNeeded( | 
					
						
							|  |  |  |     const GURL& url) { | 
					
						
							| 
									
										
										
										
											2019-05-03 20:11:41 +02:00
										 |  |  |   if (zoom_mode_ != ZoomMode::ISOLATED && zoom_mode_ != ZoomMode::MANUAL) | 
					
						
							| 
									
										
										
										
											2017-06-08 02:13:49 +02:00
										 |  |  |     return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-18 13:46:23 +11:00
										 |  |  |   int render_process_id = | 
					
						
							|  |  |  |       web_contents()->GetRenderViewHost()->GetProcess()->GetID(); | 
					
						
							| 
									
										
										
										
											2017-06-08 02:13:49 +02:00
										 |  |  |   int render_view_id = web_contents()->GetRenderViewHost()->GetRoutingID(); | 
					
						
							|  |  |  |   content::HostZoomMap* zoom_map = | 
					
						
							|  |  |  |       content::HostZoomMap::GetForWebContents(web_contents()); | 
					
						
							|  |  |  |   zoom_level_ = zoom_map->GetDefaultZoomLevel(); | 
					
						
							|  |  |  |   double new_zoom_level = zoom_map->GetZoomLevelForHostAndScheme( | 
					
						
							|  |  |  |       url.scheme(), net::GetHostOrSpecFromURL(url)); | 
					
						
							|  |  |  |   for (Observer& observer : observers_) | 
					
						
							| 
									
										
										
										
											2018-04-17 21:55:30 -04:00
										 |  |  |     observer.OnZoomLevelChanged(web_contents(), new_zoom_level, false); | 
					
						
							| 
									
										
										
										
											2017-06-08 02:13:49 +02:00
										 |  |  |   zoom_map->ClearTemporaryZoomLevel(render_process_id, render_view_id); | 
					
						
							| 
									
										
										
										
											2019-05-03 20:11:41 +02:00
										 |  |  |   zoom_mode_ = ZoomMode::DEFAULT; | 
					
						
							| 
									
										
										
										
											2017-06-08 02:13:49 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-30 16:48:40 +05:30
										 |  |  | void WebContentsZoomController::DidFinishNavigation( | 
					
						
							|  |  |  |     content::NavigationHandle* navigation_handle) { | 
					
						
							|  |  |  |   if (!navigation_handle->IsInMainFrame() || !navigation_handle->HasCommitted()) | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (navigation_handle->IsErrorPage()) { | 
					
						
							|  |  |  |     content::HostZoomMap::SendErrorPageZoomLevelRefresh(web_contents()); | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-08 02:13:49 +02:00
										 |  |  |   ResetZoomModeOnNavigationIfNeeded(navigation_handle->GetURL()); | 
					
						
							| 
									
										
										
										
											2017-02-17 23:24:24 +05:30
										 |  |  |   SetZoomFactorOnNavigationIfNeeded(navigation_handle->GetURL()); | 
					
						
							| 
									
										
										
										
											2017-01-30 16:48:40 +05:30
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WebContentsZoomController::WebContentsDestroyed() { | 
					
						
							| 
									
										
										
										
											2018-08-16 15:57:40 -07:00
										 |  |  |   for (Observer& observer : observers_) | 
					
						
							|  |  |  |     observer.OnZoomControllerWebContentsDestroyed(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-30 16:48:40 +05:30
										 |  |  |   observers_.Clear(); | 
					
						
							| 
									
										
										
										
											2017-01-31 14:55:48 +05:30
										 |  |  |   embedder_zoom_controller_ = nullptr; | 
					
						
							| 
									
										
										
										
											2017-01-30 16:48:40 +05:30
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WebContentsZoomController::RenderFrameHostChanged( | 
					
						
							|  |  |  |     content::RenderFrameHost* old_host, | 
					
						
							|  |  |  |     content::RenderFrameHost* new_host) { | 
					
						
							|  |  |  |   // If our associated HostZoomMap changes, update our event subscription.
 | 
					
						
							|  |  |  |   content::HostZoomMap* new_host_zoom_map = | 
					
						
							|  |  |  |       content::HostZoomMap::GetForWebContents(web_contents()); | 
					
						
							|  |  |  |   if (new_host_zoom_map == host_zoom_map_) | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   host_zoom_map_ = new_host_zoom_map; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WebContentsZoomController::SetZoomFactorOnNavigationIfNeeded( | 
					
						
							|  |  |  |     const GURL& url) { | 
					
						
							|  |  |  |   if (content::ZoomValuesEqual(GetDefaultZoomFactor(), content::kEpsilon)) | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-31 14:45:45 +05:30
										 |  |  |   if (host_zoom_map_->UsesTemporaryZoomLevel(old_process_id_, old_view_id_)) { | 
					
						
							|  |  |  |     host_zoom_map_->ClearTemporaryZoomLevel(old_process_id_, old_view_id_); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (embedder_zoom_controller_ && | 
					
						
							|  |  |  |       embedder_zoom_controller_->UsesTemporaryZoomLevel()) { | 
					
						
							|  |  |  |     double level = embedder_zoom_controller_->GetZoomLevel(); | 
					
						
							|  |  |  |     SetTemporaryZoomLevel(level); | 
					
						
							| 
									
										
										
										
											2017-01-30 22:36:50 +05:30
										 |  |  |     return; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-30 16:48:40 +05:30
										 |  |  |   // When kZoomFactor is available, it takes precedence over
 | 
					
						
							|  |  |  |   // pref store values but if the host has zoom factor set explicitly
 | 
					
						
							|  |  |  |   // then it takes precendence.
 | 
					
						
							|  |  |  |   // pref store < kZoomFactor < setZoomLevel
 | 
					
						
							|  |  |  |   std::string host = net::GetHostOrSpecFromURL(url); | 
					
						
							| 
									
										
										
										
											2017-03-08 19:03:43 +05:30
										 |  |  |   std::string scheme = url.scheme(); | 
					
						
							| 
									
										
										
										
											2017-01-30 16:48:40 +05:30
										 |  |  |   double zoom_factor = GetDefaultZoomFactor(); | 
					
						
							| 
									
										
										
										
											2017-03-08 19:03:43 +05:30
										 |  |  |   double zoom_level = content::ZoomFactorToZoomLevel(zoom_factor); | 
					
						
							|  |  |  |   if (host_zoom_map_->HasZoomLevel(scheme, host)) { | 
					
						
							|  |  |  |     zoom_level = host_zoom_map_->GetZoomLevelForHostAndScheme(scheme, host); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   if (content::ZoomValuesEqual(zoom_level, GetZoomLevel())) | 
					
						
							| 
									
										
										
										
											2017-01-30 16:48:40 +05:30
										 |  |  |     return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-08 19:03:43 +05:30
										 |  |  |   SetZoomLevel(zoom_level); | 
					
						
							| 
									
										
										
										
											2017-01-30 16:48:40 +05:30
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-21 22:26:54 +05:30
										 |  |  | WEB_CONTENTS_USER_DATA_KEY_IMPL(WebContentsZoomController) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-30 16:48:40 +05:30
										 |  |  | }  // namespace atom
 |