| 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/browser/prerender/prerender_contents.h" | 5 #include "chrome/browser/prerender/prerender_contents.h" |
| 6 | 6 |
| 7 #include "base/process_util.h" | 7 #include "base/process_util.h" |
| 8 #include "base/task.h" | 8 #include "base/task.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/background_contents_service.h" | 10 #include "chrome/browser/background_contents_service.h" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/prerender/prerender_final_status.h" | 12 #include "chrome/browser/prerender/prerender_final_status.h" |
| 13 #include "chrome/browser/prerender/prerender_manager.h" | 13 #include "chrome/browser/prerender/prerender_manager.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/renderer_preferences_util.h" | 15 #include "chrome/browser/renderer_preferences_util.h" |
| 16 #include "chrome/browser/ui/login/login_prompt.h" | 16 #include "chrome/browser/ui/login/login_prompt.h" |
| 17 #include "chrome/common/extensions/extension_constants.h" | 17 #include "chrome/common/extensions/extension_constants.h" |
| 18 #include "chrome/common/icon_messages.h" |
| 18 #include "chrome/common/render_messages.h" | 19 #include "chrome/common/render_messages.h" |
| 19 #include "chrome/common/extensions/extension_messages.h" | 20 #include "chrome/common/extensions/extension_messages.h" |
| 20 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
| 21 #include "chrome/common/view_types.h" | 22 #include "chrome/common/view_types.h" |
| 22 #include "content/browser/browsing_instance.h" | 23 #include "content/browser/browsing_instance.h" |
| 23 #include "content/browser/renderer_host/render_view_host.h" | 24 #include "content/browser/renderer_host/render_view_host.h" |
| 24 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 25 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 25 #include "content/browser/renderer_host/resource_request_details.h" | 26 #include "content/browser/renderer_host/resource_request_details.h" |
| 26 #include "content/browser/site_instance.h" | 27 #include "content/browser/site_instance.h" |
| 27 #include "content/common/notification_service.h" | 28 #include "content/common/notification_service.h" |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 void PrerenderContents::ShowCreatedFullscreenWidget(int route_id) { | 431 void PrerenderContents::ShowCreatedFullscreenWidget(int route_id) { |
| 431 NOTIMPLEMENTED(); | 432 NOTIMPLEMENTED(); |
| 432 } | 433 } |
| 433 | 434 |
| 434 bool PrerenderContents::OnMessageReceived(const IPC::Message& message) { | 435 bool PrerenderContents::OnMessageReceived(const IPC::Message& message) { |
| 435 bool handled = true; | 436 bool handled = true; |
| 436 bool message_is_ok = true; | 437 bool message_is_ok = true; |
| 437 IPC_BEGIN_MESSAGE_MAP_EX(PrerenderContents, message, message_is_ok) | 438 IPC_BEGIN_MESSAGE_MAP_EX(PrerenderContents, message, message_is_ok) |
| 438 IPC_MESSAGE_HANDLER(ViewHostMsg_DidStartProvisionalLoadForFrame, | 439 IPC_MESSAGE_HANDLER(ViewHostMsg_DidStartProvisionalLoadForFrame, |
| 439 OnDidStartProvisionalLoadForFrame) | 440 OnDidStartProvisionalLoadForFrame) |
| 440 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) | 441 IPC_MESSAGE_HANDLER(IconHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) |
| 441 IPC_MESSAGE_HANDLER(ViewHostMsg_MaybeCancelPrerenderForHTML5Media, | 442 IPC_MESSAGE_HANDLER(ViewHostMsg_MaybeCancelPrerenderForHTML5Media, |
| 442 OnMaybeCancelPrerenderForHTML5Media) | 443 OnMaybeCancelPrerenderForHTML5Media) |
| 443 IPC_MESSAGE_UNHANDLED(handled = false) | 444 IPC_MESSAGE_UNHANDLED(handled = false) |
| 444 IPC_END_MESSAGE_MAP_EX() | 445 IPC_END_MESSAGE_MAP_EX() |
| 445 | 446 |
| 446 return handled; | 447 return handled; |
| 447 } | 448 } |
| 448 | 449 |
| 449 void PrerenderContents::OnDidStartProvisionalLoadForFrame(int64 frame_id, | 450 void PrerenderContents::OnDidStartProvisionalLoadForFrame(int64 frame_id, |
| 450 bool is_main_frame, | 451 bool is_main_frame, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 463 has_stopped_loading_ = false; | 464 has_stopped_loading_ = false; |
| 464 } | 465 } |
| 465 } | 466 } |
| 466 | 467 |
| 467 void PrerenderContents::OnUpdateFaviconURL( | 468 void PrerenderContents::OnUpdateFaviconURL( |
| 468 int32 page_id, | 469 int32 page_id, |
| 469 const std::vector<FaviconURL>& urls) { | 470 const std::vector<FaviconURL>& urls) { |
| 470 LOG(INFO) << "PrerenderContents::OnUpdateFaviconURL" << icon_url_; | 471 LOG(INFO) << "PrerenderContents::OnUpdateFaviconURL" << icon_url_; |
| 471 for (std::vector<FaviconURL>::const_iterator i = urls.begin(); | 472 for (std::vector<FaviconURL>::const_iterator i = urls.begin(); |
| 472 i != urls.end(); ++i) { | 473 i != urls.end(); ++i) { |
| 473 if (i->icon_type == FAVICON) { | 474 if (i->icon_type == FaviconURL::FAVICON) { |
| 474 icon_url_ = i->icon_url; | 475 icon_url_ = i->icon_url; |
| 475 LOG(INFO) << icon_url_; | 476 LOG(INFO) << icon_url_; |
| 476 return; | 477 return; |
| 477 } | 478 } |
| 478 } | 479 } |
| 479 } | 480 } |
| 480 | 481 |
| 481 void PrerenderContents::OnMaybeCancelPrerenderForHTML5Media() { | 482 void PrerenderContents::OnMaybeCancelPrerenderForHTML5Media() { |
| 482 Destroy(FINAL_STATUS_HTML5_MEDIA); | 483 Destroy(FINAL_STATUS_HTML5_MEDIA); |
| 483 } | 484 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 return; | 541 return; |
| 541 | 542 |
| 542 size_t private_bytes, shared_bytes; | 543 size_t private_bytes, shared_bytes; |
| 543 if (metrics->GetMemoryBytes(&private_bytes, &shared_bytes)) { | 544 if (metrics->GetMemoryBytes(&private_bytes, &shared_bytes)) { |
| 544 if (private_bytes > kMaxPrerenderPrivateMB * 1024 * 1024) | 545 if (private_bytes > kMaxPrerenderPrivateMB * 1024 * 1024) |
| 545 Destroy(FINAL_STATUS_MEMORY_LIMIT_EXCEEDED); | 546 Destroy(FINAL_STATUS_MEMORY_LIMIT_EXCEEDED); |
| 546 } | 547 } |
| 547 } | 548 } |
| 548 | 549 |
| 549 } // namespace prerender | 550 } // namespace prerender |
| OLD | NEW |