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

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: Re-order functions, add comments and DCHECK(). Created 6 years, 7 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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 capturer_count_(0), 349 capturer_count_(0),
350 should_normally_be_visible_(true), 350 should_normally_be_visible_(true),
351 is_being_destroyed_(false), 351 is_being_destroyed_(false),
352 notify_disconnection_(false), 352 notify_disconnection_(false),
353 dialog_manager_(NULL), 353 dialog_manager_(NULL),
354 is_showing_before_unload_dialog_(false), 354 is_showing_before_unload_dialog_(false),
355 last_active_time_(base::TimeTicks::Now()), 355 last_active_time_(base::TimeTicks::Now()),
356 closed_by_user_gesture_(false), 356 closed_by_user_gesture_(false),
357 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)), 357 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)),
358 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), 358 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)),
359 temporary_zoom_settings_(false),
360 totalPinchGestureAmount_(0), 359 totalPinchGestureAmount_(0),
361 currentPinchZoomStepDelta_(0), 360 currentPinchZoomStepDelta_(0),
362 render_view_message_source_(NULL), 361 render_view_message_source_(NULL),
363 fullscreen_widget_routing_id_(MSG_ROUTING_NONE), 362 fullscreen_widget_routing_id_(MSG_ROUTING_NONE),
364 is_subframe_(false), 363 is_subframe_(false),
365 last_dialog_suppressed_(false) { 364 last_dialog_suppressed_(false) {
366 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++) 365 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++)
367 g_created_callbacks.Get().at(i).Run(this); 366 g_created_callbacks.Get().at(i).Run(this);
368 frame_tree_.SetFrameRemoveListener( 367 frame_tree_.SetFrameRemoveListener(
369 base::Bind(&WebContentsImpl::OnFrameRemoved, 368 base::Bind(&WebContentsImpl::OnFrameRemoved,
(...skipping 1774 matching lines...) Expand 10 before | Expand all | Expand 10 after
2144 } 2143 }
2145 2144
2146 void WebContentsImpl::SetClosedByUserGesture(bool value) { 2145 void WebContentsImpl::SetClosedByUserGesture(bool value) {
2147 closed_by_user_gesture_ = value; 2146 closed_by_user_gesture_ = value;
2148 } 2147 }
2149 2148
2150 bool WebContentsImpl::GetClosedByUserGesture() const { 2149 bool WebContentsImpl::GetClosedByUserGesture() const {
2151 return closed_by_user_gesture_; 2150 return closed_by_user_gesture_;
2152 } 2151 }
2153 2152
2154 double WebContentsImpl::GetZoomLevel() const {
2155 HostZoomMapImpl* zoom_map = static_cast<HostZoomMapImpl*>(
2156 HostZoomMap::GetForBrowserContext(GetBrowserContext()));
2157 if (!zoom_map)
2158 return 0;
2159
2160 double zoom_level;
2161 if (temporary_zoom_settings_) {
2162 zoom_level = zoom_map->GetTemporaryZoomLevel(
2163 GetRenderProcessHost()->GetID(), GetRenderViewHost()->GetRoutingID());
2164 } else {
2165 GURL url;
2166 NavigationEntry* entry = GetController().GetLastCommittedEntry();
2167 // Since zoom map is updated using rewritten URL, use rewritten URL
2168 // to get the zoom level.
2169 url = entry ? entry->GetURL() : GURL::EmptyGURL();
2170 zoom_level = zoom_map->GetZoomLevelForHostAndScheme(url.scheme(),
2171 net::GetHostOrSpecFromURL(url));
2172 }
2173 return zoom_level;
2174 }
2175
2176 int WebContentsImpl::GetZoomPercent(bool* enable_increment, 2153 int WebContentsImpl::GetZoomPercent(bool* enable_increment,
2177 bool* enable_decrement) const { 2154 bool* enable_decrement) const {
2178 *enable_decrement = *enable_increment = false; 2155 *enable_decrement = *enable_increment = false;
2179 // Calculate the zoom percent from the factor. Round up to the nearest whole 2156 // Calculate the zoom percent from the factor. Round up to the nearest whole
2180 // number. 2157 // number.
2181 int percent = static_cast<int>( 2158 int percent = static_cast<int>(
2182 ZoomLevelToZoomFactor(GetZoomLevel()) * 100 + 0.5); 2159 ZoomLevelToZoomFactor(HostZoomMap::GetZoomLevel(this)) * 100 + 0.5);
2183 *enable_decrement = percent > minimum_zoom_percent_; 2160 *enable_decrement = percent > minimum_zoom_percent_;
2184 *enable_increment = percent < maximum_zoom_percent_; 2161 *enable_increment = percent < maximum_zoom_percent_;
2185 return percent; 2162 return percent;
2186 } 2163 }
2187 2164
2188 void WebContentsImpl::ViewSource() { 2165 void WebContentsImpl::ViewSource() {
2189 if (!delegate_) 2166 if (!delegate_)
2190 return; 2167 return;
2191 2168
2192 NavigationEntry* entry = GetController().GetLastCommittedEntry(); 2169 NavigationEntry* entry = GetController().GetLastCommittedEntry();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
2261 const ImageDownloadCallback& callback) { 2238 const ImageDownloadCallback& callback) {
2262 int id = StartDownload(GetMainFrame(), url, is_favicon, max_bitmap_size); 2239 int id = StartDownload(GetMainFrame(), url, is_favicon, max_bitmap_size);
2263 image_download_map_[id] = callback; 2240 image_download_map_[id] = callback;
2264 return id; 2241 return id;
2265 } 2242 }
2266 2243
2267 bool WebContentsImpl::IsSubframe() const { 2244 bool WebContentsImpl::IsSubframe() const {
2268 return is_subframe_; 2245 return is_subframe_;
2269 } 2246 }
2270 2247
2271 void WebContentsImpl::SetZoomLevel(double level) {
2272 Send(new ViewMsg_SetZoomLevel(GetRoutingID(), level));
2273 BrowserPluginEmbedder* embedder = GetBrowserPluginEmbedder();
2274 if (embedder)
2275 embedder->SetZoomLevel(level);
2276 }
2277
2278 void WebContentsImpl::Find(int request_id, 2248 void WebContentsImpl::Find(int request_id,
2279 const base::string16& search_text, 2249 const base::string16& search_text,
2280 const blink::WebFindOptions& options) { 2250 const blink::WebFindOptions& options) {
2281 Send(new ViewMsg_Find(GetRoutingID(), request_id, search_text, options)); 2251 Send(new ViewMsg_Find(GetRoutingID(), request_id, search_text, options));
2282 } 2252 }
2283 2253
2284 void WebContentsImpl::StopFinding(StopFindAction action) { 2254 void WebContentsImpl::StopFinding(StopFindAction action) {
2285 Send(new ViewMsg_StopFinding(GetRoutingID(), action)); 2255 Send(new ViewMsg_StopFinding(GetRoutingID(), action));
2286 } 2256 }
2287 2257
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
2697 loading_weak_factory_.GetWeakPtr()), 2667 loading_weak_factory_.GetWeakPtr()),
2698 min_delay); 2668 min_delay);
2699 } 2669 }
2700 2670
2701 void WebContentsImpl::OnGoToEntryAtOffset(int offset) { 2671 void WebContentsImpl::OnGoToEntryAtOffset(int offset) {
2702 if (!delegate_ || delegate_->OnGoToEntryOffset(offset)) 2672 if (!delegate_ || delegate_->OnGoToEntryOffset(offset))
2703 controller_.GoToOffset(offset); 2673 controller_.GoToOffset(offset);
2704 } 2674 }
2705 2675
2706 void WebContentsImpl::OnUpdateZoomLimits(int minimum_percent, 2676 void WebContentsImpl::OnUpdateZoomLimits(int minimum_percent,
2707 int maximum_percent, 2677 int maximum_percent) {
2708 bool remember) {
2709 minimum_zoom_percent_ = minimum_percent; 2678 minimum_zoom_percent_ = minimum_percent;
2710 maximum_zoom_percent_ = maximum_percent; 2679 maximum_zoom_percent_ = maximum_percent;
2711 temporary_zoom_settings_ = !remember;
2712 } 2680 }
2713 2681
2714 void WebContentsImpl::OnEnumerateDirectory(int request_id, 2682 void WebContentsImpl::OnEnumerateDirectory(int request_id,
2715 const base::FilePath& path) { 2683 const base::FilePath& path) {
2716 if (!delegate_) 2684 if (!delegate_)
2717 return; 2685 return;
2718 2686
2719 ChildProcessSecurityPolicyImpl* policy = 2687 ChildProcessSecurityPolicyImpl* policy =
2720 ChildProcessSecurityPolicyImpl::GetInstance(); 2688 ChildProcessSecurityPolicyImpl::GetInstance();
2721 if (policy->CanReadFile(GetRenderProcessHost()->GetID(), path)) 2689 if (policy->CanReadFile(GetRenderProcessHost()->GetID(), path))
(...skipping 1353 matching lines...) Expand 10 before | Expand all | Expand 10 after
4075 4043
4076 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { 4044 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) {
4077 if (!delegate_) 4045 if (!delegate_)
4078 return; 4046 return;
4079 const gfx::Size new_size = GetPreferredSize(); 4047 const gfx::Size new_size = GetPreferredSize();
4080 if (new_size != old_size) 4048 if (new_size != old_size)
4081 delegate_->UpdatePreferredSize(this, new_size); 4049 delegate_->UpdatePreferredSize(this, new_size);
4082 } 4050 }
4083 4051
4084 } // namespace content 4052 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698