OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 #include "chrome/renderer/visitedlink_slave.h" | 59 #include "chrome/renderer/visitedlink_slave.h" |
60 #include "content/common/resource_dispatcher.h" | 60 #include "content/common/resource_dispatcher.h" |
61 #include "content/common/view_messages.h" | 61 #include "content/common/view_messages.h" |
62 #include "content/renderer/render_thread.h" | 62 #include "content/renderer/render_thread.h" |
63 #include "content/renderer/render_view.h" | 63 #include "content/renderer/render_view.h" |
64 #include "grit/generated_resources.h" | 64 #include "grit/generated_resources.h" |
65 #include "grit/locale_settings.h" | 65 #include "grit/locale_settings.h" |
66 #include "grit/renderer_resources.h" | 66 #include "grit/renderer_resources.h" |
67 #include "net/base/net_errors.h" | 67 #include "net/base/net_errors.h" |
68 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h" | 68 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h" |
| 69 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" |
69 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 70 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
70 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" | 71 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" |
71 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" | 72 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" |
72 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" | 73 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" |
73 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h" | 74 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h" |
74 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" | 75 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" |
75 #include "ui/base/l10n/l10n_util.h" | 76 #include "ui/base/l10n/l10n_util.h" |
76 #include "ui/base/resource/resource_bundle.h" | 77 #include "ui/base/resource/resource_bundle.h" |
77 #include "webkit/plugins/npapi/plugin_list.h" | 78 #include "webkit/plugins/npapi/plugin_list.h" |
78 #include "webkit/plugins/ppapi/plugin_module.h" | 79 #include "webkit/plugins/ppapi/plugin_module.h" |
79 | 80 |
80 #if defined(OS_MACOSX) | 81 #if defined(OS_MACOSX) |
81 #include "chrome/app/breakpad_mac.h" | 82 #include "chrome/app/breakpad_mac.h" |
82 #endif | 83 #endif |
83 | 84 |
84 using autofill::AutofillAgent; | 85 using autofill::AutofillAgent; |
85 using autofill::FormManager; | 86 using autofill::FormManager; |
86 using autofill::PasswordAutofillManager; | 87 using autofill::PasswordAutofillManager; |
87 using WebKit::WebCache; | 88 using WebKit::WebCache; |
| 89 using WebKit::WebDataSource; |
88 using WebKit::WebFrame; | 90 using WebKit::WebFrame; |
89 using WebKit::WebPlugin; | 91 using WebKit::WebPlugin; |
90 using WebKit::WebPluginParams; | 92 using WebKit::WebPluginParams; |
91 using WebKit::WebSecurityPolicy; | 93 using WebKit::WebSecurityPolicy; |
92 using WebKit::WebString; | 94 using WebKit::WebString; |
93 using WebKit::WebURLError; | 95 using WebKit::WebURLError; |
94 using WebKit::WebURLRequest; | 96 using WebKit::WebURLRequest; |
95 using WebKit::WebURLResponse; | 97 using WebKit::WebURLResponse; |
96 using WebKit::WebVector; | 98 using WebKit::WebVector; |
97 | 99 |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 render_view->routing_id(), group->GetGroupName(), GURL())); | 393 render_view->routing_id(), group->GetGroupName(), GURL())); |
392 return CreatePluginPlaceholder( | 394 return CreatePluginPlaceholder( |
393 render_view, frame, params, *group, IDR_BLOCKED_PLUGIN_HTML, | 395 render_view, frame, params, *group, IDR_BLOCKED_PLUGIN_HTML, |
394 IDS_PLUGIN_NOT_AUTHORIZED, false, true); | 396 IDS_PLUGIN_NOT_AUTHORIZED, false, true); |
395 } | 397 } |
396 | 398 |
397 if (info.path.value() == webkit::npapi::kDefaultPluginLibraryName || | 399 if (info.path.value() == webkit::npapi::kDefaultPluginLibraryName || |
398 plugin_setting == CONTENT_SETTING_ALLOW || | 400 plugin_setting == CONTENT_SETTING_ALLOW || |
399 host_setting == CONTENT_SETTING_ALLOW) { | 401 host_setting == CONTENT_SETTING_ALLOW) { |
400 // Delay loading plugins if prerendering. | 402 // Delay loading plugins if prerendering. |
401 if (render_view->is_prerendering_) { | 403 if (render_view->is_prerendering()) { |
402 return CreatePluginPlaceholder( | 404 return CreatePluginPlaceholder( |
403 render_view, frame, params, *group, IDR_CLICK_TO_PLAY_PLUGIN_HTML, | 405 render_view, frame, params, *group, IDR_CLICK_TO_PLAY_PLUGIN_HTML, |
404 IDS_PLUGIN_LOAD, true, true); | 406 IDS_PLUGIN_LOAD, true, true); |
405 } | 407 } |
406 | 408 |
407 bool pepper_plugin_was_registered = false; | 409 bool pepper_plugin_was_registered = false; |
408 scoped_refptr<webkit::ppapi::PluginModule> pepper_module( | 410 scoped_refptr<webkit::ppapi::PluginModule> pepper_module( |
409 render_view->pepper_delegate_.CreatePepperPlugin( | 411 render_view->pepper_delegate()->CreatePepperPlugin( |
410 info.path, | 412 info.path, &pepper_plugin_was_registered)); |
411 &pepper_plugin_was_registered)); | |
412 if (pepper_plugin_was_registered) { | 413 if (pepper_plugin_was_registered) { |
413 if (pepper_module) { | 414 if (pepper_module) { |
414 return render_view->CreatePepperPlugin( | 415 return render_view->CreatePepperPlugin( |
415 frame, params, info.path, pepper_module.get()); | 416 frame, params, info.path, pepper_module.get()); |
416 } | 417 } |
417 return NULL; | 418 return NULL; |
418 } | 419 } |
419 | 420 |
420 return render_view->CreateNPAPIPlugin( | 421 return render_view->CreateNPAPIPlugin( |
421 frame, params, info.path, actual_mime_type); | 422 frame, params, info.path, actual_mime_type); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 params, | 455 params, |
455 render_view->webkit_preferences(), | 456 render_view->webkit_preferences(), |
456 resource_id, | 457 resource_id, |
457 l10n_util::GetStringFUTF16(message_id, | 458 l10n_util::GetStringFUTF16(message_id, |
458 group.GetGroupName()), | 459 group.GetGroupName()), |
459 is_blocked_for_prerendering, | 460 is_blocked_for_prerendering, |
460 allow_loading); | 461 allow_loading); |
461 return blocked_plugin->plugin(); | 462 return blocked_plugin->plugin(); |
462 } | 463 } |
463 | 464 |
| 465 void ChromeContentRendererClient::ShowErrorPage(RenderView* render_view, |
| 466 WebKit::WebFrame* frame, |
| 467 int http_status_code) { |
| 468 // Use an internal error page, if we have one for the status code. |
| 469 if (LocalizedError::HasStrings(LocalizedError::kHttpErrorDomain, |
| 470 http_status_code)) { |
| 471 WebURLError error; |
| 472 error.unreachableURL = frame->url(); |
| 473 error.domain = WebString::fromUTF8(LocalizedError::kHttpErrorDomain); |
| 474 error.reason = http_status_code; |
| 475 |
| 476 render_view->LoadNavigationErrorPage( |
| 477 frame, frame->dataSource()->request(), error, std::string(), true); |
| 478 } |
| 479 } |
| 480 |
464 std::string ChromeContentRendererClient::GetNavigationErrorHtml( | 481 std::string ChromeContentRendererClient::GetNavigationErrorHtml( |
465 const WebURLRequest& failed_request, | 482 const WebURLRequest& failed_request, |
466 const WebURLError& error) { | 483 const WebURLError& error) { |
467 GURL failed_url = error.unreachableURL; | 484 GURL failed_url = error.unreachableURL; |
468 std::string html; | 485 std::string html; |
469 const Extension* extension = NULL; | 486 const Extension* extension = NULL; |
470 | 487 |
471 // Use a local error page. | 488 // Use a local error page. |
472 int resource_id; | 489 int resource_id; |
473 DictionaryValue error_strings; | 490 DictionaryValue error_strings; |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 if (old_url.is_empty() && frame->opener()) | 639 if (old_url.is_empty() && frame->opener()) |
623 old_url = frame->opener()->url(); | 640 old_url = frame->opener()->url(); |
624 | 641 |
625 bool old_url_is_hosted_app = extensions->GetByURL(old_url) && | 642 bool old_url_is_hosted_app = extensions->GetByURL(old_url) && |
626 !extensions->GetByURL(old_url)->web_extent().is_empty(); | 643 !extensions->GetByURL(old_url)->web_extent().is_empty(); |
627 return !extensions->InSameExtent(old_url, new_url) && | 644 return !extensions->InSameExtent(old_url, new_url) && |
628 !old_url_is_hosted_app; | 645 !old_url_is_hosted_app; |
629 } | 646 } |
630 | 647 |
631 } // namespace chrome | 648 } // namespace chrome |
OLD | NEW |