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

Side by Side Diff: chrome/renderer/chrome_content_renderer_client.cc

Issue 7831028: Compute pageScaleFactor on page so that fixed layout page fits width of window. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Minimizes render_view_impl changes and introduces a defaultDeviceScaleFactor argument Created 8 years, 10 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 "chrome/renderer/chrome_content_renderer_client.h" 5 #include "chrome/renderer/chrome_content_renderer_client.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/string_number_conversions.h"
13 #include "base/string_tokenizer.h" 14 #include "base/string_tokenizer.h"
14 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
15 #include "base/values.h" 16 #include "base/values.h"
16 #include "chrome/common/child_process_logging.h" 17 #include "chrome/common/child_process_logging.h"
17 #include "chrome/common/chrome_content_client.h" 18 #include "chrome/common/chrome_content_client.h"
18 #include "chrome/common/chrome_paths.h" 19 #include "chrome/common/chrome_paths.h"
19 #include "chrome/common/chrome_switches.h" 20 #include "chrome/common/chrome_switches.h"
20 #include "chrome/common/content_settings_pattern.h" 21 #include "chrome/common/content_settings_pattern.h"
21 #include "chrome/common/external_ipc_fuzzer.h" 22 #include "chrome/common/external_ipc_fuzzer.h"
22 #include "chrome/common/extensions/extension.h" 23 #include "chrome/common/extensions/extension.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 #include "grit/renderer_resources.h" 70 #include "grit/renderer_resources.h"
70 #include "ipc/ipc_sync_channel.h" 71 #include "ipc/ipc_sync_channel.h"
71 #include "net/base/net_errors.h" 72 #include "net/base/net_errors.h"
72 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h" 73 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h"
73 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" 74 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h"
74 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 75 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
75 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 76 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
76 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" 77 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h"
77 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" 78 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
78 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" 79 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h"
80 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h"
81 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
79 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" 82 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h"
80 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLError. h" 83 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLError. h"
81 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLReques t.h" 84 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLReques t.h"
82 #include "ui/base/l10n/l10n_util.h" 85 #include "ui/base/l10n/l10n_util.h"
83 #include "ui/base/resource/resource_bundle.h" 86 #include "ui/base/resource/resource_bundle.h"
84 #include "webkit/plugins/npapi/plugin_list.h" 87 #include "webkit/plugins/npapi/plugin_list.h"
85 #include "webkit/plugins/ppapi/plugin_module.h" 88 #include "webkit/plugins/ppapi/plugin_module.h"
86 #include "webkit/plugins/ppapi/ppapi_interface_factory.h" 89 #include "webkit/plugins/ppapi/ppapi_interface_factory.h"
87 90
88 using WebKit::WebCache; 91 using WebKit::WebCache;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 // notification and can stop the propagation. 257 // notification and can stop the propagation.
255 page_click_tracker->AddListener(password_autofill_manager); 258 page_click_tracker->AddListener(password_autofill_manager);
256 page_click_tracker->AddListener(autofill_agent); 259 page_click_tracker->AddListener(autofill_agent);
257 260
258 TranslateHelper* translate = new TranslateHelper(render_view); 261 TranslateHelper* translate = new TranslateHelper(render_view);
259 new ChromeRenderViewObserver( 262 new ChromeRenderViewObserver(
260 render_view, content_settings, chrome_observer_.get(), 263 render_view, content_settings, chrome_observer_.get(),
261 extension_dispatcher_.get(), translate); 264 extension_dispatcher_.get(), translate);
262 265
263 // Used only for testing/automation. 266 // Used only for testing/automation.
264 if (CommandLine::ForCurrentProcess()->HasSwitch( 267 if (CommandLine::ForCurrentProcess()->HasSwitch(
darin (slow to review) 2012/02/15 06:13:23 nit: probably should cache a pointer to the Comman
265 switches::kDomAutomationController)) { 268 switches::kDomAutomationController)) {
266 new AutomationRendererHelper(render_view); 269 new AutomationRendererHelper(render_view);
267 } 270 }
271
272 const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
273 render_view->GetWebView()->enableFixedLayoutMode(
274 cmd_line->HasSwitch(switches::kEnableFixedLayout));
275 }
276
277 void ChromeContentRendererClient::RenderViewResized(
278 content::RenderView* render_view, int new_width, int new_height) {
279 if (!render_view->GetWebView())
280 return;
281
282 const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
283 int defaultDeviceScaleFactor = 0;
darin (slow to review) 2012/02/15 06:13:23 nit: use google_style_for_variable_names
Fady Samuel 2012/02/15 17:46:05 Done. I always forget when switching between chrom
284 base::StringToInt(cmd_line->GetSwitchValueASCII(
285 switches::kDefaultDeviceScaleFactor),
darin (slow to review) 2012/02/15 06:13:23 nit: indentation
Fady Samuel 2012/02/15 17:46:05 I think I have matched the style guide now.
286 &defaultDeviceScaleFactor);
287 // This setting has no effect if fixed layout is not enabled.
288 if (defaultDeviceScaleFactor)
289 render_view->GetWebView()->settings()->setLayoutFallbackWidth(
darin (slow to review) 2012/02/15 06:13:23 it seems a bit unusual to update WebSettings on re
Fady Samuel 2012/02/15 17:46:05 In my humble opinion, no. The default device scale
290 new_width / defaultDeviceScaleFactor);
268 } 291 }
269 292
270 void ChromeContentRendererClient::SetNumberOfViews(int number_of_views) { 293 void ChromeContentRendererClient::SetNumberOfViews(int number_of_views) {
271 child_process_logging::SetNumberOfViews(number_of_views); 294 child_process_logging::SetNumberOfViews(number_of_views);
272 } 295 }
273 296
274 SkBitmap* ChromeContentRendererClient::GetSadPluginBitmap() { 297 SkBitmap* ChromeContentRendererClient::GetSadPluginBitmap() {
275 return ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_SAD_PLUGIN); 298 return ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_SAD_PLUGIN);
276 } 299 }
277 300
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 webkit::ppapi::PpapiInterfaceFactoryManager* factory_manager) { 883 webkit::ppapi::PpapiInterfaceFactoryManager* factory_manager) {
861 factory_manager->RegisterFactory(ChromePPAPIInterfaceFactory); 884 factory_manager->RegisterFactory(ChromePPAPIInterfaceFactory);
862 } 885 }
863 886
864 bool ChromeContentRendererClient::AllowSocketAPI(const GURL& url) { 887 bool ChromeContentRendererClient::AllowSocketAPI(const GURL& url) {
865 return allowed_socket_origins_.find(url.host()) != 888 return allowed_socket_origins_.find(url.host()) !=
866 allowed_socket_origins_.end(); 889 allowed_socket_origins_.end();
867 } 890 }
868 891
869 } // namespace chrome 892 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698