OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/render_view.h" | 5 #include "chrome/renderer/render_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 | 787 |
788 WebFrame* main_frame = webview()->GetMainFrame(); | 788 WebFrame* main_frame = webview()->GetMainFrame(); |
789 if (is_reload && !main_frame->HasCurrentHistoryState()) { | 789 if (is_reload && !main_frame->HasCurrentHistoryState()) { |
790 // We cannot reload if we do not have any history state. This happens, for | 790 // We cannot reload if we do not have any history state. This happens, for |
791 // example, when recovering from a crash. Our workaround here is a bit of | 791 // example, when recovering from a crash. Our workaround here is a bit of |
792 // a hack since it means that reload after a crashed tab does not cause an | 792 // a hack since it means that reload after a crashed tab does not cause an |
793 // end-to-end cache validation. | 793 // end-to-end cache validation. |
794 is_reload = false; | 794 is_reload = false; |
795 } | 795 } |
796 | 796 |
797 WebRequestCachePolicy cache_policy; | |
798 if (is_reload) { | |
799 cache_policy = WebRequestReloadIgnoringCacheData; | |
800 } else if (params.page_id != -1 || main_frame->GetInViewSourceMode()) { | |
801 cache_policy = WebRequestReturnCacheDataElseLoad; | |
802 } else { | |
803 cache_policy = WebRequestUseProtocolCachePolicy; | |
804 } | |
805 | |
806 scoped_ptr<WebRequest> request(WebRequest::Create(params.url)); | |
807 request->SetCachePolicy(cache_policy); | |
808 | |
809 // A navigation resulting from loading a javascript URL should not be treated | 797 // A navigation resulting from loading a javascript URL should not be treated |
810 // as a browser initiated event. Instead, we want it to look as if the page | 798 // as a browser initiated event. Instead, we want it to look as if the page |
811 // initiated any load resulting from JS execution. | 799 // initiated any load resulting from JS execution. |
812 if (!params.url.SchemeIs(chrome::kJavaScriptScheme)) { | 800 if (!params.url.SchemeIs(chrome::kJavaScriptScheme)) { |
813 pending_navigation_state_.reset(new NavigationState( | 801 pending_navigation_state_.reset(new NavigationState( |
814 params.page_id, params.transition, params.request_time)); | 802 params.page_id, params.transition, params.request_time)); |
815 } | 803 } |
816 | 804 |
817 // If we are reloading, then WebKit will use the state of the current page. | 805 // If we are reloading, then WebKit will use the history state of the current |
818 // Otherwise, we give it the state to navigate to. | 806 // page, so we should just ignore any given history state. Otherwise, if we |
819 if (!is_reload) | 807 // have history state, then we need to navigate to it, which corresponds to a |
820 request->SetHistoryState(params.state); | 808 // back/forward navigation event. |
| 809 if (!is_reload && !params.state.empty()) { |
| 810 // We must know the page ID of the page we are navigating back to. |
| 811 DCHECK(params.page_id != -1); |
| 812 main_frame->LoadHistoryState(params.state); |
| 813 } else { |
| 814 // Navigate to the given URL. |
| 815 scoped_ptr<WebRequest> request(WebRequest::Create(params.url)); |
821 | 816 |
822 if (params.referrer.is_valid()) { | 817 // TODO(darin): WebFrame should just have a Reload method. |
823 request->SetHttpHeaderValue("Referer", | 818 |
824 params.referrer.spec()); | 819 WebRequestCachePolicy cache_policy; |
| 820 if (is_reload) { |
| 821 cache_policy = WebRequestReloadIgnoringCacheData; |
| 822 } else { |
| 823 // A session history navigation should have been accompanied by state. |
| 824 DCHECK(params.page_id == -1); |
| 825 if (main_frame->GetInViewSourceMode()) { |
| 826 cache_policy = WebRequestReturnCacheDataElseLoad; |
| 827 } else { |
| 828 cache_policy = WebRequestUseProtocolCachePolicy; |
| 829 } |
| 830 } |
| 831 request->SetCachePolicy(cache_policy); |
| 832 |
| 833 if (params.referrer.is_valid()) |
| 834 request->SetHttpHeaderValue("Referer", params.referrer.spec()); |
| 835 |
| 836 main_frame->LoadRequest(request.get()); |
825 } | 837 } |
826 | 838 |
827 main_frame->LoadRequest(request.get()); | |
828 | |
829 // In case LoadRequest failed before DidCreateDataSource was called. | 839 // In case LoadRequest failed before DidCreateDataSource was called. |
830 pending_navigation_state_.reset(); | 840 pending_navigation_state_.reset(); |
831 } | 841 } |
832 | 842 |
833 // Stop loading the current page | 843 // Stop loading the current page |
834 void RenderView::OnStop() { | 844 void RenderView::OnStop() { |
835 if (webview()) | 845 if (webview()) |
836 webview()->StopLoading(); | 846 webview()->StopLoading(); |
837 } | 847 } |
838 | 848 |
(...skipping 2230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3069 // If id is valid, alert the browser side that an accessibility focus change | 3079 // If id is valid, alert the browser side that an accessibility focus change |
3070 // occurred. | 3080 // occurred. |
3071 if (acc_obj_id >= 0) | 3081 if (acc_obj_id >= 0) |
3072 Send(new ViewHostMsg_AccessibilityFocusChange(routing_id_, acc_obj_id)); | 3082 Send(new ViewHostMsg_AccessibilityFocusChange(routing_id_, acc_obj_id)); |
3073 | 3083 |
3074 #else // defined(OS_WIN) | 3084 #else // defined(OS_WIN) |
3075 // TODO(port): accessibility not yet implemented | 3085 // TODO(port): accessibility not yet implemented |
3076 NOTIMPLEMENTED(); | 3086 NOTIMPLEMENTED(); |
3077 #endif | 3087 #endif |
3078 } | 3088 } |
OLD | NEW |