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

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

Powered by Google App Engine
This is Rietveld 408576698