Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 287093002: Remove ViewMsg_SetZoomLevel (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Revised as per comments. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "content/browser/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 capturer_count_(0), 331 capturer_count_(0),
332 should_normally_be_visible_(true), 332 should_normally_be_visible_(true),
333 is_being_destroyed_(false), 333 is_being_destroyed_(false),
334 notify_disconnection_(false), 334 notify_disconnection_(false),
335 dialog_manager_(NULL), 335 dialog_manager_(NULL),
336 is_showing_before_unload_dialog_(false), 336 is_showing_before_unload_dialog_(false),
337 last_active_time_(base::TimeTicks::Now()), 337 last_active_time_(base::TimeTicks::Now()),
338 closed_by_user_gesture_(false), 338 closed_by_user_gesture_(false),
339 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)), 339 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)),
340 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), 340 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)),
341 temporary_zoom_settings_(false),
342 totalPinchGestureAmount_(0), 341 totalPinchGestureAmount_(0),
343 currentPinchZoomStepDelta_(0), 342 currentPinchZoomStepDelta_(0),
344 render_view_message_source_(NULL), 343 render_view_message_source_(NULL),
345 fullscreen_widget_routing_id_(MSG_ROUTING_NONE), 344 fullscreen_widget_routing_id_(MSG_ROUTING_NONE),
346 is_subframe_(false), 345 is_subframe_(false),
347 last_dialog_suppressed_(false) { 346 last_dialog_suppressed_(false) {
348 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++) 347 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++)
349 g_created_callbacks.Get().at(i).Run(this); 348 g_created_callbacks.Get().at(i).Run(this);
350 frame_tree_.SetFrameRemoveListener( 349 frame_tree_.SetFrameRemoveListener(
351 base::Bind(&WebContentsImpl::OnFrameRemoved, 350 base::Bind(&WebContentsImpl::OnFrameRemoved,
(...skipping 1781 matching lines...) Expand 10 before | Expand all | Expand 10 after
2133 } 2132 }
2134 2133
2135 void WebContentsImpl::SetClosedByUserGesture(bool value) { 2134 void WebContentsImpl::SetClosedByUserGesture(bool value) {
2136 closed_by_user_gesture_ = value; 2135 closed_by_user_gesture_ = value;
2137 } 2136 }
2138 2137
2139 bool WebContentsImpl::GetClosedByUserGesture() const { 2138 bool WebContentsImpl::GetClosedByUserGesture() const {
2140 return closed_by_user_gesture_; 2139 return closed_by_user_gesture_;
2141 } 2140 }
2142 2141
2143 double WebContentsImpl::GetZoomLevel() const {
2144 HostZoomMapImpl* zoom_map = static_cast<HostZoomMapImpl*>(
2145 HostZoomMap::GetForBrowserContext(GetBrowserContext()));
2146 if (!zoom_map)
2147 return 0;
2148
2149 double zoom_level;
2150 if (temporary_zoom_settings_) {
2151 zoom_level = zoom_map->GetTemporaryZoomLevel(
2152 GetRenderProcessHost()->GetID(), GetRenderViewHost()->GetRoutingID());
2153 } else {
2154 GURL url;
2155 NavigationEntry* entry = GetController().GetLastCommittedEntry();
2156 // Since zoom map is updated using rewritten URL, use rewritten URL
2157 // to get the zoom level.
2158 url = entry ? entry->GetURL() : GURL::EmptyGURL();
2159 zoom_level = zoom_map->GetZoomLevelForHostAndScheme(url.scheme(),
2160 net::GetHostOrSpecFromURL(url));
2161 }
2162 return zoom_level;
2163 }
2164
2165 int WebContentsImpl::GetZoomPercent(bool* enable_increment, 2142 int WebContentsImpl::GetZoomPercent(bool* enable_increment,
2166 bool* enable_decrement) const { 2143 bool* enable_decrement) const {
2167 *enable_decrement = *enable_increment = false; 2144 *enable_decrement = *enable_increment = false;
2168 // Calculate the zoom percent from the factor. Round up to the nearest whole 2145 // Calculate the zoom percent from the factor. Round up to the nearest whole
2169 // number. 2146 // number.
2170 int percent = static_cast<int>( 2147 int percent = static_cast<int>(
2171 ZoomLevelToZoomFactor(GetZoomLevel()) * 100 + 0.5); 2148 ZoomLevelToZoomFactor(HostZoomMap::GetZoomLevel(this)) * 100 + 0.5);
2172 *enable_decrement = percent > minimum_zoom_percent_; 2149 *enable_decrement = percent > minimum_zoom_percent_;
2173 *enable_increment = percent < maximum_zoom_percent_; 2150 *enable_increment = percent < maximum_zoom_percent_;
2174 return percent; 2151 return percent;
2175 } 2152 }
2176 2153
2177 void WebContentsImpl::ViewSource() { 2154 void WebContentsImpl::ViewSource() {
2178 if (!delegate_) 2155 if (!delegate_)
2179 return; 2156 return;
2180 2157
2181 NavigationEntry* entry = GetController().GetLastCommittedEntry(); 2158 NavigationEntry* entry = GetController().GetLastCommittedEntry();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
2250 const ImageDownloadCallback& callback) { 2227 const ImageDownloadCallback& callback) {
2251 int id = StartDownload(GetMainFrame(), url, is_favicon, max_bitmap_size); 2228 int id = StartDownload(GetMainFrame(), url, is_favicon, max_bitmap_size);
2252 image_download_map_[id] = callback; 2229 image_download_map_[id] = callback;
2253 return id; 2230 return id;
2254 } 2231 }
2255 2232
2256 bool WebContentsImpl::IsSubframe() const { 2233 bool WebContentsImpl::IsSubframe() const {
2257 return is_subframe_; 2234 return is_subframe_;
2258 } 2235 }
2259 2236
2260 void WebContentsImpl::SetZoomLevel(double level) {
2261 Send(new ViewMsg_SetZoomLevel(GetRoutingID(), level));
2262 BrowserPluginEmbedder* embedder = GetBrowserPluginEmbedder();
2263 if (embedder)
2264 embedder->SetZoomLevel(level);
2265 }
2266
2267 void WebContentsImpl::Find(int request_id, 2237 void WebContentsImpl::Find(int request_id,
2268 const base::string16& search_text, 2238 const base::string16& search_text,
2269 const blink::WebFindOptions& options) { 2239 const blink::WebFindOptions& options) {
2270 Send(new ViewMsg_Find(GetRoutingID(), request_id, search_text, options)); 2240 Send(new ViewMsg_Find(GetRoutingID(), request_id, search_text, options));
2271 } 2241 }
2272 2242
2273 void WebContentsImpl::StopFinding(StopFindAction action) { 2243 void WebContentsImpl::StopFinding(StopFindAction action) {
2274 Send(new ViewMsg_StopFinding(GetRoutingID(), action)); 2244 Send(new ViewMsg_StopFinding(GetRoutingID(), action));
2275 } 2245 }
2276 2246
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
2686 loading_weak_factory_.GetWeakPtr()), 2656 loading_weak_factory_.GetWeakPtr()),
2687 min_delay); 2657 min_delay);
2688 } 2658 }
2689 2659
2690 void WebContentsImpl::OnGoToEntryAtOffset(int offset) { 2660 void WebContentsImpl::OnGoToEntryAtOffset(int offset) {
2691 if (!delegate_ || delegate_->OnGoToEntryOffset(offset)) 2661 if (!delegate_ || delegate_->OnGoToEntryOffset(offset))
2692 controller_.GoToOffset(offset); 2662 controller_.GoToOffset(offset);
2693 } 2663 }
2694 2664
2695 void WebContentsImpl::OnUpdateZoomLimits(int minimum_percent, 2665 void WebContentsImpl::OnUpdateZoomLimits(int minimum_percent,
2696 int maximum_percent, 2666 int maximum_percent) {
2697 bool remember) {
2698 minimum_zoom_percent_ = minimum_percent; 2667 minimum_zoom_percent_ = minimum_percent;
2699 maximum_zoom_percent_ = maximum_percent; 2668 maximum_zoom_percent_ = maximum_percent;
2700 temporary_zoom_settings_ = !remember;
2701 } 2669 }
2702 2670
2703 void WebContentsImpl::OnEnumerateDirectory(int request_id, 2671 void WebContentsImpl::OnEnumerateDirectory(int request_id,
2704 const base::FilePath& path) { 2672 const base::FilePath& path) {
2705 if (!delegate_) 2673 if (!delegate_)
2706 return; 2674 return;
2707 2675
2708 ChildProcessSecurityPolicyImpl* policy = 2676 ChildProcessSecurityPolicyImpl* policy =
2709 ChildProcessSecurityPolicyImpl::GetInstance(); 2677 ChildProcessSecurityPolicyImpl::GetInstance();
2710 if (policy->CanReadFile(GetRenderProcessHost()->GetID(), path)) 2678 if (policy->CanReadFile(GetRenderProcessHost()->GetID(), path))
(...skipping 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after
4071 4039
4072 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { 4040 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) {
4073 if (!delegate_) 4041 if (!delegate_)
4074 return; 4042 return;
4075 const gfx::Size new_size = GetPreferredSize(); 4043 const gfx::Size new_size = GetPreferredSize();
4076 if (new_size != old_size) 4044 if (new_size != old_size)
4077 delegate_->UpdatePreferredSize(this, new_size); 4045 delegate_->UpdatePreferredSize(this, new_size);
4078 } 4046 }
4079 4047
4080 } // namespace content 4048 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698