OLD | NEW |
---|---|
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_render_view_observer.h" | 5 #include "chrome/renderer/chrome_render_view_observer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
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" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "chrome/common/chrome_constants.h" | 14 #include "chrome/common/chrome_constants.h" |
15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
16 #include "chrome/common/icon_messages.h" | 16 #include "chrome/common/icon_messages.h" |
17 #include "chrome/common/render_messages.h" | 17 #include "chrome/common/render_messages.h" |
18 #include "chrome/common/thumbnail_score.h" | 18 #include "chrome/common/thumbnail_score.h" |
19 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
20 #include "chrome/renderer/about_handler.h" | 20 #include "chrome/renderer/about_handler.h" |
21 #include "chrome/renderer/automation/dom_automation_controller.h" | 21 #include "chrome/renderer/automation/dom_automation_controller.h" |
22 #include "chrome/renderer/chrome_render_process_observer.h" | 22 #include "chrome/renderer/chrome_render_process_observer.h" |
23 #include "chrome/renderer/content_settings_observer.h" | 23 #include "chrome/renderer/content_settings_observer.h" |
24 #include "chrome/renderer/extensions/extension_dispatcher.h" | 24 #include "chrome/renderer/extensions/extension_dispatcher.h" |
25 #include "chrome/renderer/extensions/extension_helper.h" | |
25 #include "chrome/renderer/external_host_bindings.h" | 26 #include "chrome/renderer/external_host_bindings.h" |
26 #include "chrome/renderer/frame_sniffer.h" | 27 #include "chrome/renderer/frame_sniffer.h" |
27 #include "chrome/renderer/prerender/prerender_helper.h" | 28 #include "chrome/renderer/prerender/prerender_helper.h" |
28 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" | 29 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" |
29 #include "chrome/renderer/translate_helper.h" | 30 #include "chrome/renderer/translate_helper.h" |
30 #include "chrome/renderer/webview_color_overlay.h" | 31 #include "chrome/renderer/webview_color_overlay.h" |
31 #include "content/public/common/bindings_policy.h" | 32 #include "content/public/common/bindings_policy.h" |
33 #include "content/public/common/view_type.h" | |
32 #include "content/public/renderer/render_view.h" | 34 #include "content/public/renderer/render_view.h" |
33 #include "content/public/renderer/content_renderer_client.h" | 35 #include "content/public/renderer/content_renderer_client.h" |
34 #include "net/base/data_url.h" | 36 #include "net/base/data_url.h" |
35 #include "skia/ext/image_operations.h" | 37 #include "skia/ext/image_operations.h" |
36 #include "skia/ext/platform_canvas.h" | 38 #include "skia/ext/platform_canvas.h" |
37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObjec t.h" | 39 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObjec t.h" |
38 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h " | 40 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h " |
39 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" | 41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" |
40 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 // #define TIME_TEXT_RETRIEVAL | 88 // #define TIME_TEXT_RETRIEVAL |
87 | 89 |
88 // maximum number of characters in the document to index, any text beyond this | 90 // maximum number of characters in the document to index, any text beyond this |
89 // point will be clipped | 91 // point will be clipped |
90 static const size_t kMaxIndexChars = 65535; | 92 static const size_t kMaxIndexChars = 65535; |
91 | 93 |
92 // Size of the thumbnails that we'll generate | 94 // Size of the thumbnails that we'll generate |
93 static const int kThumbnailWidth = 212; | 95 static const int kThumbnailWidth = 212; |
94 static const int kThumbnailHeight = 132; | 96 static const int kThumbnailHeight = 132; |
95 | 97 |
98 // The default layout width for pages when fixed layout is enabled. | |
99 static const int kDefaultLayoutWidth = 980; | |
100 static const int kDefaultLayoutHeight = 640; | |
101 | |
96 // Constants for UMA statistic collection. | 102 // Constants for UMA statistic collection. |
97 static const char kWWWDotGoogleDotCom[] = "www.google.com"; | 103 static const char kWWWDotGoogleDotCom[] = "www.google.com"; |
98 static const char kMailDotGoogleDotCom[] = "mail.google.com"; | 104 static const char kMailDotGoogleDotCom[] = "mail.google.com"; |
99 static const char kPlusDotGoogleDotCom[] = "plus.google.com"; | 105 static const char kPlusDotGoogleDotCom[] = "plus.google.com"; |
100 static const char kDocsDotGoogleDotCom[] = "docs.google.com"; | 106 static const char kDocsDotGoogleDotCom[] = "docs.google.com"; |
101 static const char kSitesDotGoogleDotCom[] = "sites.google.com"; | 107 static const char kSitesDotGoogleDotCom[] = "sites.google.com"; |
102 static const char kPicasawebDotGoogleDotCom[] = "picasaweb.google.com"; | 108 static const char kPicasawebDotGoogleDotCom[] = "picasaweb.google.com"; |
103 static const char kCodeDotGoogleDotCom[] = "code.google.com"; | 109 static const char kCodeDotGoogleDotCom[] = "code.google.com"; |
104 static const char kGroupsDotGoogleDotCom[] = "groups.google.com"; | 110 static const char kGroupsDotGoogleDotCom[] = "groups.google.com"; |
105 static const char kMapsDotGoogleDotCom[] = "maps.google.com"; | 111 static const char kMapsDotGoogleDotCom[] = "maps.google.com"; |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
365 void ChromeRenderViewObserver::OnAddStrictSecurityHost( | 371 void ChromeRenderViewObserver::OnAddStrictSecurityHost( |
366 const std::string& host) { | 372 const std::string& host) { |
367 strict_security_hosts_.insert(host); | 373 strict_security_hosts_.insert(host); |
368 } | 374 } |
369 | 375 |
370 void ChromeRenderViewObserver::OnSetAsInterstitial() { | 376 void ChromeRenderViewObserver::OnSetAsInterstitial() { |
371 content_settings_->SetAsInterstitial(); | 377 content_settings_->SetAsInterstitial(); |
372 } | 378 } |
373 | 379 |
374 void ChromeRenderViewObserver::Navigate(const GURL& url) { | 380 void ChromeRenderViewObserver::Navigate(const GURL& url) { |
381 ExtensionHelper* extension_helper = ExtensionHelper::Get(render_view()); | |
Aaron Boodman
2012/01/20 18:49:23
What are you trying to do here? It looks to me lik
| |
382 bool is_tab_contents = extension_helper && | |
383 extension_helper->view_type() == content::VIEW_TYPE_TAB_CONTENTS; | |
darin (slow to review)
2012/01/20 19:10:20
it seems a little hacky to be using something from
Fady Samuel
2012/01/20 21:05:04
I don't know what the answer to that question is..
jam
2012/01/20 21:08:05
code in the renderer doesn't generally know about
| |
384 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | |
385 // Only use fixed layout on tab contents. | |
386 if (is_tab_contents && cmd_line->HasSwitch(switches::kEnableFixedLayout)) { | |
387 WebSize viewSize = render_view()->GetWebView()->size(); | |
darin (slow to review)
2012/01/20 19:10:20
nit: view_size
Fady Samuel
2012/01/20 21:05:04
Done.
| |
388 int layoutHeight = | |
darin (slow to review)
2012/01/20 19:10:20
nit: layout_height
Fady Samuel
2012/01/20 21:05:04
Done.
| |
389 viewSize.height ? | |
390 viewSize.height * kDefaultLayoutWidth / viewSize.width : | |
391 kDefaultLayoutHeight; | |
392 WebSize layout_size(kDefaultLayoutWidth, layoutHeight); | |
393 render_view()->GetWebView()->enableFixedLayoutMode(true); | |
394 render_view()->GetWebView()->setFixedLayoutSize(layout_size); | |
395 render_view()->GetWebView()-> | |
396 setShouldLayoutFixedElementsRelativeToFrame(true); | |
darin (slow to review)
2012/01/20 19:10:20
isn't this done through WebSettings now?
Fady Samuel
2012/01/20 21:05:04
Patch hasn't landed yet. Will fix now. But once i
| |
397 } else { | |
398 render_view()->GetWebView()->enableFixedLayoutMode(false); | |
399 render_view()->GetWebView()-> | |
400 setShouldLayoutFixedElementsRelativeToFrame(false); | |
401 } | |
375 // Execute cache clear operations that were postponed until a navigation | 402 // Execute cache clear operations that were postponed until a navigation |
376 // event (including tab reload). | 403 // event (including tab reload). |
377 if (chrome_render_process_observer_) | 404 if (chrome_render_process_observer_) |
378 chrome_render_process_observer_->ExecutePendingClearCache(); | 405 chrome_render_process_observer_->ExecutePendingClearCache(); |
379 AboutHandler::MaybeHandle(url); | 406 AboutHandler::MaybeHandle(url); |
380 } | 407 } |
381 | 408 |
382 void ChromeRenderViewObserver::OnSetClientSidePhishingDetection( | 409 void ChromeRenderViewObserver::OnSetClientSidePhishingDetection( |
383 bool enable_phishing_detection) { | 410 bool enable_phishing_detection) { |
384 #if defined(ENABLE_SAFE_BROWSING) && !defined(OS_CHROMEOS) | 411 #if defined(ENABLE_SAFE_BROWSING) && !defined(OS_CHROMEOS) |
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1075 reinterpret_cast<const unsigned char*>(&data[0]); | 1102 reinterpret_cast<const unsigned char*>(&data[0]); |
1076 | 1103 |
1077 return decoder.Decode(src_data, data.size()); | 1104 return decoder.Decode(src_data, data.size()); |
1078 } | 1105 } |
1079 return SkBitmap(); | 1106 return SkBitmap(); |
1080 } | 1107 } |
1081 | 1108 |
1082 bool ChromeRenderViewObserver::IsStrictSecurityHost(const std::string& host) { | 1109 bool ChromeRenderViewObserver::IsStrictSecurityHost(const std::string& host) { |
1083 return (strict_security_hosts_.find(host) != strict_security_hosts_.end()); | 1110 return (strict_security_hosts_.find(host) != strict_security_hosts_.end()); |
1084 } | 1111 } |
OLD | NEW |