| Index: content/browser/web_contents/web_contents_impl.cc
|
| diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
|
| index a19fcd9921d563c334e361a83b4689aad1dc658e..2cc3f4ad846d5b0cd8bf7c21fdaba052fc4d8e80 100644
|
| --- a/content/browser/web_contents/web_contents_impl.cc
|
| +++ b/content/browser/web_contents/web_contents_impl.cc
|
| @@ -338,7 +338,9 @@ WebContentsImpl::WebContentsImpl(
|
| color_chooser_identifier_(0),
|
| render_view_message_source_(NULL),
|
| fullscreen_widget_routing_id_(MSG_ROUTING_NONE),
|
| - is_subframe_(false) {
|
| + is_subframe_(false),
|
| + current_zoom_mode_(kZoomModeDefault),
|
| + current_zoom_id_(0) {
|
| for (size_t i = 0; i < g_created_callbacks.Get().size(); i++)
|
| g_created_callbacks.Get().at(i).Run(this);
|
| frame_tree_.SetFrameRemoveListener(
|
| @@ -1986,7 +1988,14 @@ bool WebContentsImpl::GetClosedByUserGesture() const {
|
| return closed_by_user_gesture_;
|
| }
|
|
|
| +content::ZoomMode WebContentsImpl::GetZoomMode() const {
|
| + return current_zoom_mode_;
|
| +}
|
| +
|
| double WebContentsImpl::GetZoomLevel() const {
|
| + if (current_zoom_mode_ == kZoomModeDisabled)
|
| + return 0;
|
| +
|
| HostZoomMapImpl* zoom_map = static_cast<HostZoomMapImpl*>(
|
| HostZoomMap::GetForBrowserContext(GetBrowserContext()));
|
| if (!zoom_map)
|
| @@ -2085,11 +2094,65 @@ bool WebContentsImpl::IsSubframe() const {
|
| return is_subframe_;
|
| }
|
|
|
| -void WebContentsImpl::SetZoomLevel(double level) {
|
| - Send(new ViewMsg_SetZoomLevel(GetRoutingID(), level));
|
| +int WebContentsImpl::SetZoomLevel(double level) {
|
| + if (current_zoom_mode_ == kZoomModeDisabled)
|
| + return 0;
|
| +
|
| + ++current_zoom_id_;
|
| +
|
| + ZoomChangeDetails zoom_change_details;
|
| + zoom_change_details.old_zoom_level = GetZoomLevel();
|
| + zoom_change_details.new_zoom_level = level;
|
| + zoom_change_details.zoom_mode = current_zoom_mode_;
|
| + NotificationService::current()->Notify(
|
| + content::NOTIFICATION_WEB_CONTENTS_ZOOM_CHANGE,
|
| + Source<WebContents>(this),
|
| + content::Details<ZoomChangeDetails>(
|
| + &zoom_change_details));
|
| +
|
| + Send(new ViewMsg_SetZoomLevel(GetRoutingID(), current_zoom_id_, level,
|
| + current_zoom_mode_));
|
| BrowserPluginEmbedder* embedder = GetBrowserPluginEmbedder();
|
| if (embedder)
|
| embedder->SetZoomLevel(level);
|
| +
|
| + return current_zoom_id_;
|
| +}
|
| +
|
| +void WebContentsImpl::SetZoomMode(ZoomMode mode) {
|
| + if (mode == current_zoom_mode_)
|
| + return;
|
| +
|
| + double original_zoom_level = GetZoomLevel();
|
| +
|
| + if (mode == kZoomModeDefault) {
|
| + Send(new ViewMsg_SetZoomLevel(GetRoutingID(), 0, original_zoom_level,
|
| + kZoomModeDefault));
|
| + NotificationService::current()->Notify(
|
| + NOTIFICATION_WEB_CONTENTS_NO_TEMPORARY_ZOOM_LEVEL,
|
| + Source<WebContents>(this),
|
| + NotificationService::NoDetails());
|
| + } else if (mode == kZoomModeIsolated) {
|
| + if (current_zoom_mode_ != kZoomModeDisabled) {
|
| + Send(new ViewMsg_SetZoomLevel(GetRoutingID(), 0, original_zoom_level,
|
| + kZoomModeIsolated));
|
| + }
|
| + } else if (mode == kZoomModeManual) {
|
| + if (current_zoom_mode_ != kZoomModeDisabled) {
|
| + Send(new ViewMsg_SetZoomLevel(GetRoutingID(), 0, 0, kZoomModeIsolated));
|
| + current_zoom_mode_ = mode;
|
| + SetZoomLevel(original_zoom_level);
|
| + }
|
| + } else if (mode == kZoomModeDisabled) {
|
| + if (current_zoom_mode_ != kZoomModeManual) {
|
| + Send(new ViewMsg_SetZoomLevel(GetRoutingID(), 0, 0, kZoomModeIsolated));
|
| + }
|
| + } else {
|
| + NOTREACHED();
|
| + }
|
| +
|
| + current_zoom_mode_ = mode;
|
| + temporary_zoom_settings_ = mode != kZoomModeDefault;
|
| }
|
|
|
| void WebContentsImpl::Find(int request_id,
|
| @@ -2426,7 +2489,8 @@ void WebContentsImpl::OnUpdateZoomLimits(int minimum_percent,
|
| bool remember) {
|
| minimum_zoom_percent_ = minimum_percent;
|
| maximum_zoom_percent_ = maximum_percent;
|
| - temporary_zoom_settings_ = !remember;
|
| + temporary_zoom_settings_ = !remember ||
|
| + current_zoom_mode_ != kZoomModeDefault;
|
| }
|
|
|
| void WebContentsImpl::OnEnumerateDirectory(int request_id,
|
| @@ -2826,6 +2890,11 @@ void WebContentsImpl::NotifyDisconnected() {
|
|
|
| void WebContentsImpl::NotifyNavigationEntryCommitted(
|
| const LoadCommittedDetails& load_details) {
|
| + if (load_details.is_navigation_to_different_page()) {
|
| + temporary_zoom_settings_ = false;
|
| + SetZoomMode(kZoomModeDefault);
|
| + }
|
| +
|
| FOR_EACH_OBSERVER(
|
| WebContentsObserver, observers_, NavigationEntryCommitted(load_details));
|
| }
|
|
|