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 "content/renderer/render_view.h" | 5 #include "content/renderer/render_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
710 | 710 |
711 WebFrame* main_frame = webview()->mainFrame(); | 711 WebFrame* main_frame = webview()->mainFrame(); |
712 if (is_reload && main_frame->currentHistoryItem().isNull()) { | 712 if (is_reload && main_frame->currentHistoryItem().isNull()) { |
713 // We cannot reload if we do not have any history state. This happens, for | 713 // We cannot reload if we do not have any history state. This happens, for |
714 // example, when recovering from a crash. Our workaround here is a bit of | 714 // example, when recovering from a crash. Our workaround here is a bit of |
715 // a hack since it means that reload after a crashed tab does not cause an | 715 // a hack since it means that reload after a crashed tab does not cause an |
716 // end-to-end cache validation. | 716 // end-to-end cache validation. |
717 is_reload = false; | 717 is_reload = false; |
718 } | 718 } |
719 | 719 |
720 // Correct the visible state of the webview before loading a document. | |
721 if (params.is_hidden) { | |
brettw
2011/05/18 22:11:38
Prefer no {} for single-line conditionals (prevail
Shishir
2011/05/20 03:48:19
Removed {} around condition.
At this point the is
| |
722 webview()->setVisibilityState(WebKit::WebPageVisibilityStateHidden, true); | |
723 } else { | |
724 webview()->setVisibilityState(WebKit::WebPageVisibilityStateVisible, true); | |
725 } | |
726 | |
720 // A navigation resulting from loading a javascript URL should not be treated | 727 // A navigation resulting from loading a javascript URL should not be treated |
721 // as a browser initiated event. Instead, we want it to look as if the page | 728 // as a browser initiated event. Instead, we want it to look as if the page |
722 // initiated any load resulting from JS execution. | 729 // initiated any load resulting from JS execution. |
723 if (!params.url.SchemeIs(chrome::kJavaScriptScheme)) { | 730 if (!params.url.SchemeIs(chrome::kJavaScriptScheme)) { |
724 NavigationState* state = NavigationState::CreateBrowserInitiated( | 731 NavigationState* state = NavigationState::CreateBrowserInitiated( |
725 params.page_id, | 732 params.page_id, |
726 params.pending_history_list_offset, | 733 params.pending_history_list_offset, |
727 params.transition, | 734 params.transition, |
728 params.request_time); | 735 params.request_time); |
729 if (params.navigation_type == ViewMsg_Navigate_Type::RESTORE) { | 736 if (params.navigation_type == ViewMsg_Navigate_Type::RESTORE) { |
(...skipping 3142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3872 void RenderView::DidHandleMouseEvent(const WebKit::WebMouseEvent& event) { | 3879 void RenderView::DidHandleMouseEvent(const WebKit::WebMouseEvent& event) { |
3873 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidHandleMouseEvent(event)); | 3880 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidHandleMouseEvent(event)); |
3874 } | 3881 } |
3875 | 3882 |
3876 void RenderView::OnWasHidden() { | 3883 void RenderView::OnWasHidden() { |
3877 RenderWidget::OnWasHidden(); | 3884 RenderWidget::OnWasHidden(); |
3878 | 3885 |
3879 if (webview()) { | 3886 if (webview()) { |
3880 webview()->settings()->setMinimumTimerInterval( | 3887 webview()->settings()->setMinimumTimerInterval( |
3881 webkit_glue::kBackgroundTabTimerInterval); | 3888 webkit_glue::kBackgroundTabTimerInterval); |
3889 webview()->setVisibilityState(WebKit::WebPageVisibilityStateHidden, false); | |
3882 } | 3890 } |
3883 | 3891 |
3884 #if defined(OS_MACOSX) | 3892 #if defined(OS_MACOSX) |
3885 // Inform plugins that their container is no longer visible. | 3893 // Inform plugins that their container is no longer visible. |
3886 std::set<WebPluginDelegateProxy*>::iterator plugin_it; | 3894 std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
3887 for (plugin_it = plugin_delegates_.begin(); | 3895 for (plugin_it = plugin_delegates_.begin(); |
3888 plugin_it != plugin_delegates_.end(); ++plugin_it) { | 3896 plugin_it != plugin_delegates_.end(); ++plugin_it) { |
3889 (*plugin_it)->SetContainerVisibility(false); | 3897 (*plugin_it)->SetContainerVisibility(false); |
3890 } | 3898 } |
3891 #endif // OS_MACOSX | 3899 #endif // OS_MACOSX |
3892 } | 3900 } |
3893 | 3901 |
3894 void RenderView::OnWasRestored(bool needs_repainting) { | 3902 void RenderView::OnWasRestored(bool needs_repainting) { |
3895 RenderWidget::OnWasRestored(needs_repainting); | 3903 RenderWidget::OnWasRestored(needs_repainting); |
3896 | 3904 |
3897 if (webview()) { | 3905 if (webview()) { |
3898 webview()->settings()->setMinimumTimerInterval( | 3906 webview()->settings()->setMinimumTimerInterval( |
3899 webkit_glue::kForegroundTabTimerInterval); | 3907 webkit_glue::kForegroundTabTimerInterval); |
3908 webview()->setVisibilityState(WebKit::WebPageVisibilityStateVisible, false); | |
3900 } | 3909 } |
3901 | 3910 |
3902 #if defined(OS_MACOSX) | 3911 #if defined(OS_MACOSX) |
3903 // Inform plugins that their container is now visible. | 3912 // Inform plugins that their container is now visible. |
3904 std::set<WebPluginDelegateProxy*>::iterator plugin_it; | 3913 std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
3905 for (plugin_it = plugin_delegates_.begin(); | 3914 for (plugin_it = plugin_delegates_.begin(); |
3906 plugin_it != plugin_delegates_.end(); ++plugin_it) { | 3915 plugin_it != plugin_delegates_.end(); ++plugin_it) { |
3907 (*plugin_it)->SetContainerVisibility(true); | 3916 (*plugin_it)->SetContainerVisibility(true); |
3908 } | 3917 } |
3909 #endif // OS_MACOSX | 3918 #endif // OS_MACOSX |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4090 if (base.GetOrigin() != absolute_url.GetOrigin()) { | 4099 if (base.GetOrigin() != absolute_url.GetOrigin()) { |
4091 return; | 4100 return; |
4092 } | 4101 } |
4093 RenderThread::current()->Send( | 4102 RenderThread::current()->Send( |
4094 new ViewHostMsg_RegisterProtocolHandler(routing_id_, | 4103 new ViewHostMsg_RegisterProtocolHandler(routing_id_, |
4095 UTF16ToUTF8(scheme), | 4104 UTF16ToUTF8(scheme), |
4096 absolute_url, | 4105 absolute_url, |
4097 title)); | 4106 title)); |
4098 } | 4107 } |
4099 | 4108 |
4109 WebKit::WebPageVisibilityState RenderView::visibilityState() const { | |
4110 if (is_hidden()) { | |
brettw
2011/05/18 22:11:38
Ditto remove the {}
Shishir
2011/05/20 03:48:19
Done.
| |
4111 return WebKit::WebPageVisibilityStateHidden; | |
4112 } else { | |
4113 return WebKit::WebPageVisibilityStateVisible; | |
4114 } | |
4115 } | |
4116 | |
4100 bool RenderView::IsNonLocalTopLevelNavigation( | 4117 bool RenderView::IsNonLocalTopLevelNavigation( |
4101 const GURL& url, WebKit::WebFrame* frame, WebKit::WebNavigationType type) { | 4118 const GURL& url, WebKit::WebFrame* frame, WebKit::WebNavigationType type) { |
4102 // Must be a top level frame. | 4119 // Must be a top level frame. |
4103 if (frame->parent() != NULL) | 4120 if (frame->parent() != NULL) |
4104 return false; | 4121 return false; |
4105 | 4122 |
4106 // Navigations initiated within Webkit are not sent out to the external host | 4123 // Navigations initiated within Webkit are not sent out to the external host |
4107 // in the following cases. | 4124 // in the following cases. |
4108 // 1. The url scheme is not http/https | 4125 // 1. The url scheme is not http/https |
4109 // 2. The origin of the url and the opener is the same in which case the | 4126 // 2. The origin of the url and the opener is the same in which case the |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4183 const webkit_glue::CustomContextMenuContext& custom_context) { | 4200 const webkit_glue::CustomContextMenuContext& custom_context) { |
4184 if (custom_context.is_pepper_menu) | 4201 if (custom_context.is_pepper_menu) |
4185 pepper_delegate_.OnContextMenuClosed(custom_context); | 4202 pepper_delegate_.OnContextMenuClosed(custom_context); |
4186 else | 4203 else |
4187 context_menu_node_.reset(); | 4204 context_menu_node_.reset(); |
4188 } | 4205 } |
4189 | 4206 |
4190 void RenderView::OnNetworkStateChanged(bool online) { | 4207 void RenderView::OnNetworkStateChanged(bool online) { |
4191 WebNetworkStateNotifier::setOnLine(online); | 4208 WebNetworkStateNotifier::setOnLine(online); |
4192 } | 4209 } |
OLD | NEW |