| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_frame_observer.h" | 5 #include "chrome/renderer/chrome_render_frame_observer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "chrome/common/render_messages.h" | 23 #include "chrome/common/render_messages.h" |
| 24 #include "chrome/renderer/prerender/prerender_helper.h" | 24 #include "chrome/renderer/prerender/prerender_helper.h" |
| 25 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" | 25 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" |
| 26 #include "components/translate/content/renderer/translate_helper.h" | 26 #include "components/translate/content/renderer/translate_helper.h" |
| 27 #include "content/public/renderer/render_frame.h" | 27 #include "content/public/renderer/render_frame.h" |
| 28 #include "content/public/renderer/render_view.h" | 28 #include "content/public/renderer/render_view.h" |
| 29 #include "extensions/common/constants.h" | 29 #include "extensions/common/constants.h" |
| 30 #include "skia/ext/image_operations.h" | 30 #include "skia/ext/image_operations.h" |
| 31 #include "third_party/WebKit/public/platform/WebImage.h" | 31 #include "third_party/WebKit/public/platform/WebImage.h" |
| 32 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 32 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 33 #include "third_party/WebKit/public/platform/modules/app_banner/WebAppBannerProm
ptReply.h" | |
| 34 #include "third_party/WebKit/public/web/WebDataSource.h" | 33 #include "third_party/WebKit/public/web/WebDataSource.h" |
| 35 #include "third_party/WebKit/public/web/WebDocument.h" | 34 #include "third_party/WebKit/public/web/WebDocument.h" |
| 36 #include "third_party/WebKit/public/web/WebElement.h" | 35 #include "third_party/WebKit/public/web/WebElement.h" |
| 37 #include "third_party/WebKit/public/web/WebFrameContentDumper.h" | 36 #include "third_party/WebKit/public/web/WebFrameContentDumper.h" |
| 38 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 37 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 39 #include "third_party/WebKit/public/web/WebNode.h" | 38 #include "third_party/WebKit/public/web/WebNode.h" |
| 40 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 39 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
| 41 #include "third_party/skia/include/core/SkBitmap.h" | 40 #include "third_party/skia/include/core/SkBitmap.h" |
| 42 #include "ui/gfx/codec/jpeg_codec.h" | 41 #include "ui/gfx/codec/jpeg_codec.h" |
| 43 #include "ui/gfx/geometry/size_f.h" | 42 #include "ui/gfx/geometry/size_f.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 IPC_MESSAGE_HANDLER(ChromeViewMsg_RequestReloadImageForContextNode, | 141 IPC_MESSAGE_HANDLER(ChromeViewMsg_RequestReloadImageForContextNode, |
| 143 OnRequestReloadImageForContextNode) | 142 OnRequestReloadImageForContextNode) |
| 144 IPC_MESSAGE_HANDLER(ChromeViewMsg_RequestThumbnailForContextNode, | 143 IPC_MESSAGE_HANDLER(ChromeViewMsg_RequestThumbnailForContextNode, |
| 145 OnRequestThumbnailForContextNode) | 144 OnRequestThumbnailForContextNode) |
| 146 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetClientSidePhishingDetection, | 145 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetClientSidePhishingDetection, |
| 147 OnSetClientSidePhishingDetection) | 146 OnSetClientSidePhishingDetection) |
| 148 #if defined(ENABLE_PRINTING) | 147 #if defined(ENABLE_PRINTING) |
| 149 IPC_MESSAGE_HANDLER(PrintMsg_PrintNodeUnderContextMenu, | 148 IPC_MESSAGE_HANDLER(PrintMsg_PrintNodeUnderContextMenu, |
| 150 OnPrintNodeUnderContextMenu) | 149 OnPrintNodeUnderContextMenu) |
| 151 #endif | 150 #endif |
| 152 IPC_MESSAGE_HANDLER(ChromeViewMsg_AppBannerPromptRequest, | |
| 153 OnAppBannerPromptRequest) | |
| 154 IPC_MESSAGE_UNHANDLED(handled = false) | 151 IPC_MESSAGE_UNHANDLED(handled = false) |
| 155 IPC_END_MESSAGE_MAP() | 152 IPC_END_MESSAGE_MAP() |
| 156 | 153 |
| 157 return handled; | 154 return handled; |
| 158 } | 155 } |
| 159 | 156 |
| 160 void ChromeRenderFrameObserver::OnSetIsPrerendering( | 157 void ChromeRenderFrameObserver::OnSetIsPrerendering( |
| 161 prerender::PrerenderMode mode) { | 158 prerender::PrerenderMode mode) { |
| 162 if (mode != prerender::NO_PRERENDER) { | 159 if (mode != prerender::NO_PRERENDER) { |
| 163 // If the PrerenderHelper for this frame already exists, don't create it. It | 160 // If the PrerenderHelper for this frame already exists, don't create it. It |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 bool enable_phishing_detection) { | 230 bool enable_phishing_detection) { |
| 234 #if defined(SAFE_BROWSING_CSD) | 231 #if defined(SAFE_BROWSING_CSD) |
| 235 phishing_classifier_ = | 232 phishing_classifier_ = |
| 236 enable_phishing_detection | 233 enable_phishing_detection |
| 237 ? safe_browsing::PhishingClassifierDelegate::Create(render_frame(), | 234 ? safe_browsing::PhishingClassifierDelegate::Create(render_frame(), |
| 238 nullptr) | 235 nullptr) |
| 239 : nullptr; | 236 : nullptr; |
| 240 #endif | 237 #endif |
| 241 } | 238 } |
| 242 | 239 |
| 243 void ChromeRenderFrameObserver::OnAppBannerPromptRequest( | |
| 244 int request_id, | |
| 245 const std::string& platform) { | |
| 246 // App banner prompt requests are handled in the general chrome render frame | |
| 247 // observer, not the AppBannerClient, as the AppBannerClient is created lazily | |
| 248 // by blink and may not exist when the request is sent. | |
| 249 blink::WebAppBannerPromptReply reply = blink::WebAppBannerPromptReply::None; | |
| 250 blink::WebString web_platform(base::UTF8ToUTF16(platform)); | |
| 251 blink::WebVector<blink::WebString> web_platforms(&web_platform, 1); | |
| 252 | |
| 253 blink::WebLocalFrame* frame = render_frame()->GetWebFrame(); | |
| 254 frame->willShowInstallBannerPrompt(request_id, web_platforms, &reply); | |
| 255 | |
| 256 // Extract the referrer header for this site according to its referrer policy. | |
| 257 // Pass in an empty URL as the destination so that it is always treated | |
| 258 // as a cross-origin request. | |
| 259 std::string referrer = blink::WebSecurityPolicy::generateReferrerHeader( | |
| 260 frame->document().referrerPolicy(), GURL(), | |
| 261 frame->document().outgoingReferrer()).utf8(); | |
| 262 | |
| 263 Send(new ChromeViewHostMsg_AppBannerPromptReply( | |
| 264 routing_id(), request_id, reply, referrer)); | |
| 265 } | |
| 266 | |
| 267 void ChromeRenderFrameObserver::DidFinishLoad() { | 240 void ChromeRenderFrameObserver::DidFinishLoad() { |
| 268 WebLocalFrame* frame = render_frame()->GetWebFrame(); | 241 WebLocalFrame* frame = render_frame()->GetWebFrame(); |
| 269 // Don't do anything for subframes. | 242 // Don't do anything for subframes. |
| 270 if (frame->parent()) | 243 if (frame->parent()) |
| 271 return; | 244 return; |
| 272 | 245 |
| 273 GURL osdd_url = frame->document().openSearchDescriptionURL(); | 246 GURL osdd_url = frame->document().openSearchDescriptionURL(); |
| 274 if (!osdd_url.is_empty()) { | 247 if (!osdd_url.is_empty()) { |
| 275 Send(new ChromeViewHostMsg_PageHasOSDD( | 248 Send(new ChromeViewHostMsg_PageHasOSDD( |
| 276 routing_id(), frame->document().url(), osdd_url)); | 249 routing_id(), frame->document().url(), osdd_url)); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 CapturePageText(FINAL_CAPTURE); | 337 CapturePageText(FINAL_CAPTURE); |
| 365 break; | 338 break; |
| 366 default: | 339 default: |
| 367 break; | 340 break; |
| 368 } | 341 } |
| 369 } | 342 } |
| 370 | 343 |
| 371 void ChromeRenderFrameObserver::OnDestruct() { | 344 void ChromeRenderFrameObserver::OnDestruct() { |
| 372 delete this; | 345 delete this; |
| 373 } | 346 } |
| OLD | NEW |