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 "content/browser/tab_contents/tab_contents.h" | 5 #include "content/browser/tab_contents/tab_contents.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 20 matching lines...) Expand all Loading... | |
31 #include "content/browser/tab_contents/interstitial_page_impl.h" | 31 #include "content/browser/tab_contents/interstitial_page_impl.h" |
32 #include "content/browser/tab_contents/navigation_entry_impl.h" | 32 #include "content/browser/tab_contents/navigation_entry_impl.h" |
33 #include "content/browser/tab_contents/provisional_load_details.h" | 33 #include "content/browser/tab_contents/provisional_load_details.h" |
34 #include "content/browser/tab_contents/title_updated_details.h" | 34 #include "content/browser/tab_contents/title_updated_details.h" |
35 #include "content/browser/webui/web_ui_impl.h" | 35 #include "content/browser/webui/web_ui_impl.h" |
36 #include "content/common/intents_messages.h" | 36 #include "content/common/intents_messages.h" |
37 #include "content/common/ssl_status_serialization.h" | 37 #include "content/common/ssl_status_serialization.h" |
38 #include "content/common/view_messages.h" | 38 #include "content/common/view_messages.h" |
39 #include "content/port/browser/render_widget_host_view_port.h" | 39 #include "content/port/browser/render_widget_host_view_port.h" |
40 #include "content/public/browser/browser_context.h" | 40 #include "content/public/browser/browser_context.h" |
41 #include "content/public/browser/color_chooser.h" | |
41 #include "content/public/browser/content_browser_client.h" | 42 #include "content/public/browser/content_browser_client.h" |
42 #include "content/public/browser/devtools_agent_host_registry.h" | 43 #include "content/public/browser/devtools_agent_host_registry.h" |
43 #include "content/public/browser/download_manager.h" | 44 #include "content/public/browser/download_manager.h" |
44 #include "content/public/browser/invalidate_type.h" | 45 #include "content/public/browser/invalidate_type.h" |
45 #include "content/public/browser/javascript_dialogs.h" | 46 #include "content/public/browser/javascript_dialogs.h" |
46 #include "content/public/browser/navigation_details.h" | 47 #include "content/public/browser/navigation_details.h" |
47 #include "content/public/browser/notification_service.h" | 48 #include "content/public/browser/notification_service.h" |
48 #include "content/public/browser/user_metrics.h" | 49 #include "content/public/browser/user_metrics.h" |
49 #include "content/public/browser/web_contents_delegate.h" | 50 #include "content/public/browser/web_contents_delegate.h" |
50 #include "content/public/browser/web_contents_observer.h" | 51 #include "content/public/browser/web_contents_observer.h" |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
509 IPC_MESSAGE_HANDLER(ViewHostMsg_GoToEntryAtOffset, OnGoToEntryAtOffset) | 510 IPC_MESSAGE_HANDLER(ViewHostMsg_GoToEntryAtOffset, OnGoToEntryAtOffset) |
510 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits) | 511 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits) |
511 IPC_MESSAGE_HANDLER(ViewHostMsg_SaveURLAs, OnSaveURL) | 512 IPC_MESSAGE_HANDLER(ViewHostMsg_SaveURLAs, OnSaveURL) |
512 IPC_MESSAGE_HANDLER(ViewHostMsg_EnumerateDirectory, OnEnumerateDirectory) | 513 IPC_MESSAGE_HANDLER(ViewHostMsg_EnumerateDirectory, OnEnumerateDirectory) |
513 IPC_MESSAGE_HANDLER(ViewHostMsg_JSOutOfMemory, OnJSOutOfMemory) | 514 IPC_MESSAGE_HANDLER(ViewHostMsg_JSOutOfMemory, OnJSOutOfMemory) |
514 IPC_MESSAGE_HANDLER(ViewHostMsg_RegisterProtocolHandler, | 515 IPC_MESSAGE_HANDLER(ViewHostMsg_RegisterProtocolHandler, |
515 OnRegisterProtocolHandler) | 516 OnRegisterProtocolHandler) |
516 IPC_MESSAGE_HANDLER(ViewHostMsg_Find_Reply, OnFindReply) | 517 IPC_MESSAGE_HANDLER(ViewHostMsg_Find_Reply, OnFindReply) |
517 IPC_MESSAGE_HANDLER(ViewHostMsg_CrashedPlugin, OnCrashedPlugin) | 518 IPC_MESSAGE_HANDLER(ViewHostMsg_CrashedPlugin, OnCrashedPlugin) |
518 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) | 519 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) |
520 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenColorChooser, OnOpenColorChooser) | |
521 IPC_MESSAGE_HANDLER(ViewHostMsg_EndColorChooser, OnEndColorChooser) | |
522 IPC_MESSAGE_HANDLER(ViewHostMsg_SetSelectedColorInColorChooser, | |
523 OnSetSelectedColorInColorChooser) | |
519 IPC_MESSAGE_UNHANDLED(handled = false) | 524 IPC_MESSAGE_UNHANDLED(handled = false) |
520 IPC_END_MESSAGE_MAP_EX() | 525 IPC_END_MESSAGE_MAP_EX() |
521 | 526 |
522 if (!message_is_ok) { | 527 if (!message_is_ok) { |
523 content::RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); | 528 content::RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); |
524 GetRenderProcessHost()->ReceivedBadMessage(); | 529 GetRenderProcessHost()->ReceivedBadMessage(); |
525 } | 530 } |
526 | 531 |
527 return handled; | 532 return handled; |
528 } | 533 } |
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1314 render_manager_.pending_web_ui())) | 1319 render_manager_.pending_web_ui())) |
1315 return render_manager_.pending_web_ui(); | 1320 return render_manager_.pending_web_ui(); |
1316 return render_manager_.web_ui(); | 1321 return render_manager_.web_ui(); |
1317 } | 1322 } |
1318 | 1323 |
1319 bool TabContents::GotResponseToLockMouseRequest(bool allowed) { | 1324 bool TabContents::GotResponseToLockMouseRequest(bool allowed) { |
1320 return GetRenderViewHost() ? | 1325 return GetRenderViewHost() ? |
1321 GetRenderViewHost()->GotResponseToLockMouseRequest(allowed) : false; | 1326 GetRenderViewHost()->GotResponseToLockMouseRequest(allowed) : false; |
1322 } | 1327 } |
1323 | 1328 |
1329 void TabContents::DidChooseColorInColorChooser(int color_chooser_id, | |
1330 const SkColor& color) { | |
1331 GetRenderViewHost()->Send(new ViewMsg_DidChooseColorResponse( | |
1332 GetRenderViewHost()->routing_id(), color_chooser_id, color)); | |
1333 } | |
1334 | |
1335 void TabContents::DidEndColorChooser(int color_chooser_id) { | |
1336 GetRenderViewHost()->Send(new ViewMsg_DidEndColorChooser( | |
1337 GetRenderViewHost()->routing_id(), color_chooser_id)); | |
1338 delegate_->DidEndColorChooser(); | |
1339 color_chooser_ = NULL; | |
1340 } | |
1341 | |
1324 bool TabContents::FocusLocationBarByDefault() { | 1342 bool TabContents::FocusLocationBarByDefault() { |
1325 content::WebUI* web_ui = GetWebUIForCurrentState(); | 1343 content::WebUI* web_ui = GetWebUIForCurrentState(); |
1326 if (web_ui) | 1344 if (web_ui) |
1327 return web_ui->ShouldFocusLocationBarByDefault(); | 1345 return web_ui->ShouldFocusLocationBarByDefault(); |
1328 NavigationEntry* entry = controller_.GetActiveEntry(); | 1346 NavigationEntry* entry = controller_.GetActiveEntry(); |
1329 if (entry && entry->GetURL() == GURL(chrome::kAboutBlankURL)) | 1347 if (entry && entry->GetURL() == GURL(chrome::kAboutBlankURL)) |
1330 return true; | 1348 return true; |
1331 return false; | 1349 return false; |
1332 } | 1350 } |
1333 | 1351 |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1634 delegate_->CrashedPlugin(this, plugin_path); | 1652 delegate_->CrashedPlugin(this, plugin_path); |
1635 } | 1653 } |
1636 | 1654 |
1637 void TabContents::OnAppCacheAccessed(const GURL& manifest_url, | 1655 void TabContents::OnAppCacheAccessed(const GURL& manifest_url, |
1638 bool blocked_by_policy) { | 1656 bool blocked_by_policy) { |
1639 // Notify observers about navigation. | 1657 // Notify observers about navigation. |
1640 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 1658 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
1641 AppCacheAccessed(manifest_url, blocked_by_policy)); | 1659 AppCacheAccessed(manifest_url, blocked_by_policy)); |
1642 } | 1660 } |
1643 | 1661 |
1662 void TabContents::OnOpenColorChooser(int color_chooser_id, | |
1663 const SkColor& color) { | |
1664 color_chooser_ = delegate_->OpenColorChooser(this, color_chooser_id, color); | |
1665 } | |
1666 | |
1667 void TabContents::OnEndColorChooser(int color_chooser_id) { | |
1668 if (color_chooser_ && | |
1669 color_chooser_id == color_chooser_->GetIdentifier()) | |
1670 color_chooser_->End(); | |
1671 } | |
1672 | |
1673 void TabContents::OnSetSelectedColorInColorChooser( | |
1674 int color_chooser_id, const SkColor& color) { | |
Peter Kasting
2012/03/01 20:44:18
Nit: One arg per line. First arg on above line if
keishi
2012/03/02 06:12:13
Done.
| |
1675 if (color_chooser_ && | |
1676 color_chooser_id == color_chooser_->GetIdentifier()) | |
1677 color_chooser_->SetSelectedColor(color); | |
1678 } | |
1679 | |
1644 // Notifies the RenderWidgetHost instance about the fact that the page is | 1680 // Notifies the RenderWidgetHost instance about the fact that the page is |
1645 // loading, or done loading and calls the base implementation. | 1681 // loading, or done loading and calls the base implementation. |
1646 void TabContents::SetIsLoading(bool is_loading, | 1682 void TabContents::SetIsLoading(bool is_loading, |
1647 LoadNotificationDetails* details) { | 1683 LoadNotificationDetails* details) { |
1648 if (is_loading == is_loading_) | 1684 if (is_loading == is_loading_) |
1649 return; | 1685 return; |
1650 | 1686 |
1651 if (!is_loading) { | 1687 if (!is_loading) { |
1652 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE, string16()); | 1688 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE, string16()); |
1653 load_state_host_.clear(); | 1689 load_state_host_.clear(); |
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2471 save_info, | 2507 save_info, |
2472 this); | 2508 this); |
2473 } | 2509 } |
2474 | 2510 |
2475 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 2511 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
2476 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); | 2512 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); |
2477 // Can be NULL during tests. | 2513 // Can be NULL during tests. |
2478 if (rwh_view) | 2514 if (rwh_view) |
2479 rwh_view->SetSize(GetView()->GetContainerSize()); | 2515 rwh_view->SetSize(GetView()->GetContainerSize()); |
2480 } | 2516 } |
OLD | NEW |