| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 scoped_ptr<WebRequest> request(WebRequest::Create(params.url)); | 833 scoped_ptr<WebRequest> request(WebRequest::Create(params.url)); |
| 834 request->SetCachePolicy(cache_policy); | 834 request->SetCachePolicy(cache_policy); |
| 835 request->SetExtraData(new RenderViewExtraRequestData( | 835 request->SetExtraData(new RenderViewExtraRequestData( |
| 836 params.page_id, params.transition, params.url)); | 836 params.page_id, params.transition, params.url)); |
| 837 | 837 |
| 838 // If we are reloading, then WebKit will use the state of the current page. | 838 // If we are reloading, then WebKit will use the state of the current page. |
| 839 // Otherwise, we give it the state to navigate to. | 839 // Otherwise, we give it the state to navigate to. |
| 840 if (!is_reload) | 840 if (!is_reload) |
| 841 request->SetHistoryState(params.state); | 841 request->SetHistoryState(params.state); |
| 842 | 842 |
| 843 if (!params.referrer.is_empty()) { |
| 844 request->SetHttpHeaderValue(L"Referer", |
| 845 UTF8ToWide(params.referrer.spec())); |
| 846 } |
| 847 |
| 843 main_frame->LoadRequest(request.get()); | 848 main_frame->LoadRequest(request.get()); |
| 844 } | 849 } |
| 845 | 850 |
| 846 // Stop loading the current page | 851 // Stop loading the current page |
| 847 void RenderView::OnStop() { | 852 void RenderView::OnStop() { |
| 848 if (webview()) | 853 if (webview()) |
| 849 webview()->StopLoading(); | 854 webview()->StopLoading(); |
| 850 } | 855 } |
| 851 | 856 |
| 852 void RenderView::OnLoadAlternateHTMLText(const std::string& html_contents, | 857 void RenderView::OnLoadAlternateHTMLText(const std::string& html_contents, |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1514 if (disposition == CURRENT_TAB && !(url.SchemeIs("about"))) { | 1519 if (disposition == CURRENT_TAB && !(url.SchemeIs("about"))) { |
| 1515 // GetExtraData is NULL when we did not issue the request ourselves (see | 1520 // GetExtraData is NULL when we did not issue the request ourselves (see |
| 1516 // OnNavigate), and so such a request may correspond to a link-click, | 1521 // OnNavigate), and so such a request may correspond to a link-click, |
| 1517 // script, or drag-n-drop initiated navigation. | 1522 // script, or drag-n-drop initiated navigation. |
| 1518 if (frame == webview->GetMainFrame() && !request->GetExtraData()) { | 1523 if (frame == webview->GetMainFrame() && !request->GetExtraData()) { |
| 1519 // When we received such unsolicited navigations, we sometimes want to | 1524 // When we received such unsolicited navigations, we sometimes want to |
| 1520 // punt them up to the browser to handle. | 1525 // punt them up to the browser to handle. |
| 1521 if (enable_dom_ui_bindings_ || | 1526 if (enable_dom_ui_bindings_ || |
| 1522 frame->GetInViewSourceMode() || | 1527 frame->GetInViewSourceMode() || |
| 1523 url.SchemeIs("view-source")) { | 1528 url.SchemeIs("view-source")) { |
| 1524 OpenURL(webview, url, disposition); | 1529 OpenURL(webview, url, GURL(), disposition); |
| 1525 return IGNORE_ACTION; // Suppress the load here. | 1530 return IGNORE_ACTION; // Suppress the load here. |
| 1526 } | 1531 } |
| 1527 } | 1532 } |
| 1528 } | 1533 } |
| 1529 | 1534 |
| 1530 // Detect when a page is "forking" a new tab that can be safely rendered in | 1535 // Detect when a page is "forking" a new tab that can be safely rendered in |
| 1531 // its own process. This is done by sites like Gmail that try to open links | 1536 // its own process. This is done by sites like Gmail that try to open links |
| 1532 // in new windows without script connections back to the original page. We | 1537 // in new windows without script connections back to the original page. We |
| 1533 // treat such cases as browser navigations (in which we will create a new | 1538 // treat such cases as browser navigations (in which we will create a new |
| 1534 // renderer for a cross-site navigation), rather than WebKit navigations. | 1539 // renderer for a cross-site navigation), rather than WebKit navigations. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1551 frame->GetParent() == NULL && | 1556 frame->GetParent() == NULL && |
| 1552 // Must not have issued the request from this page. GetExtraData is NULL | 1557 // Must not have issued the request from this page. GetExtraData is NULL |
| 1553 // when the navigation is being done by something outside the page. | 1558 // when the navigation is being done by something outside the page. |
| 1554 !request->GetExtraData() && | 1559 !request->GetExtraData() && |
| 1555 // Must be targeted at the current tab. | 1560 // Must be targeted at the current tab. |
| 1556 disposition == CURRENT_TAB && | 1561 disposition == CURRENT_TAB && |
| 1557 // Must be a JavaScript navigation, which appears as "other". | 1562 // Must be a JavaScript navigation, which appears as "other". |
| 1558 type == WebNavigationTypeOther; | 1563 type == WebNavigationTypeOther; |
| 1559 if (is_fork) { | 1564 if (is_fork) { |
| 1560 // Open the URL via the browser, not via WebKit. | 1565 // Open the URL via the browser, not via WebKit. |
| 1561 OpenURL(webview, url, disposition); | 1566 OpenURL(webview, url, GURL(), disposition); |
| 1562 return IGNORE_ACTION; | 1567 return IGNORE_ACTION; |
| 1563 } | 1568 } |
| 1564 | 1569 |
| 1565 return disposition; | 1570 return disposition; |
| 1566 } | 1571 } |
| 1567 | 1572 |
| 1568 void RenderView::RunJavaScriptAlert(WebView* webview, | 1573 void RenderView::RunJavaScriptAlert(WebView* webview, |
| 1569 const std::wstring& message) { | 1574 const std::wstring& message) { |
| 1570 RunJavaScriptMessage(MessageBoxView::kIsJavascriptAlert, | 1575 RunJavaScriptMessage(MessageBoxView::kIsJavascriptAlert, |
| 1571 message, | 1576 message, |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1816 } else { | 1821 } else { |
| 1817 // Closes the InfoBar if user clicks on the plugin (instead of the InfoBar) | 1822 // Closes the InfoBar if user clicks on the plugin (instead of the InfoBar) |
| 1818 // to start the download/install. | 1823 // to start the download/install. |
| 1819 if (status == default_plugin::MISSING_PLUGIN_USER_STARTED_DOWNLOAD) { | 1824 if (status == default_plugin::MISSING_PLUGIN_USER_STARTED_DOWNLOAD) { |
| 1820 Send(new ViewHostMsg_MissingPluginStatus(routing_id_, status)); | 1825 Send(new ViewHostMsg_MissingPluginStatus(routing_id_, status)); |
| 1821 } | 1826 } |
| 1822 } | 1827 } |
| 1823 } | 1828 } |
| 1824 | 1829 |
| 1825 void RenderView::OpenURL(WebView* webview, const GURL& url, | 1830 void RenderView::OpenURL(WebView* webview, const GURL& url, |
| 1831 const GURL& referrer, |
| 1826 WindowOpenDisposition disposition) { | 1832 WindowOpenDisposition disposition) { |
| 1827 Send(new ViewHostMsg_OpenURL(routing_id_, url, disposition)); | 1833 Send(new ViewHostMsg_OpenURL(routing_id_, url, referrer, disposition)); |
| 1828 } | 1834 } |
| 1829 | 1835 |
| 1830 // We are supposed to get a single call to Show for a newly created RenderView | 1836 // We are supposed to get a single call to Show for a newly created RenderView |
| 1831 // that was created via RenderView::CreateWebView. So, we wait until this | 1837 // that was created via RenderView::CreateWebView. So, we wait until this |
| 1832 // point to dispatch the ShowView message. | 1838 // point to dispatch the ShowView message. |
| 1833 // | 1839 // |
| 1834 // This method provides us with the information about how to display the newly | 1840 // This method provides us with the information about how to display the newly |
| 1835 // created RenderView (i.e., as a constrained popup or as a new tab). | 1841 // created RenderView (i.e., as a constrained popup or as a new tab). |
| 1836 // | 1842 // |
| 1837 void RenderView::Show(WebWidget* webwidget, WindowOpenDisposition disposition) { | 1843 void RenderView::Show(WebWidget* webwidget, WindowOpenDisposition disposition) { |
| (...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2660 template_resource_id)); | 2666 template_resource_id)); |
| 2661 | 2667 |
| 2662 if (template_html.empty()) { | 2668 if (template_html.empty()) { |
| 2663 NOTREACHED() << "unable to load template. ID: " << template_resource_id; | 2669 NOTREACHED() << "unable to load template. ID: " << template_resource_id; |
| 2664 return ""; | 2670 return ""; |
| 2665 } | 2671 } |
| 2666 // "t" is the id of the templates root node. | 2672 // "t" is the id of the templates root node. |
| 2667 return jstemplate_builder::GetTemplateHtml( | 2673 return jstemplate_builder::GetTemplateHtml( |
| 2668 template_html, &error_strings, "t"); | 2674 template_html, &error_strings, "t"); |
| 2669 } | 2675 } |
| OLD | NEW |