| 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/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 1762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1773 transition_type, | 1773 transition_type, |
| 1774 source_frame_id)); | 1774 source_frame_id)); |
| 1775 } | 1775 } |
| 1776 } | 1776 } |
| 1777 | 1777 |
| 1778 void TabContents::RunJavaScriptMessage( | 1778 void TabContents::RunJavaScriptMessage( |
| 1779 const RenderViewHost* rvh, | 1779 const RenderViewHost* rvh, |
| 1780 const string16& message, | 1780 const string16& message, |
| 1781 const string16& default_prompt, | 1781 const string16& default_prompt, |
| 1782 const GURL& frame_url, | 1782 const GURL& frame_url, |
| 1783 const int flags, | 1783 ui::JavascriptMessageType javascript_message_type, |
| 1784 IPC::Message* reply_msg, | 1784 IPC::Message* reply_msg, |
| 1785 bool* did_suppress_message) { | 1785 bool* did_suppress_message) { |
| 1786 // Suppress JavaScript dialogs when requested. Also suppress messages when | 1786 // Suppress JavaScript dialogs when requested. Also suppress messages when |
| 1787 // showing an interstitial as it's shown over the previous page and we don't | 1787 // showing an interstitial as it's shown over the previous page and we don't |
| 1788 // want the hidden page's dialogs to interfere with the interstitial. | 1788 // want the hidden page's dialogs to interfere with the interstitial. |
| 1789 bool suppress_this_message = | 1789 bool suppress_this_message = |
| 1790 rvh->is_swapped_out() || | 1790 rvh->is_swapped_out() || |
| 1791 showing_interstitial_page() || | 1791 showing_interstitial_page() || |
| 1792 !delegate_ || | 1792 !delegate_ || |
| 1793 delegate_->ShouldSuppressDialogs(); | 1793 delegate_->ShouldSuppressDialogs(); |
| 1794 | 1794 |
| 1795 if (!suppress_this_message) { | 1795 if (!suppress_this_message) { |
| 1796 content::JavaScriptDialogCreator::TitleType title_type; | 1796 content::JavaScriptDialogCreator::TitleType title_type; |
| 1797 string16 title; | 1797 string16 title; |
| 1798 | 1798 |
| 1799 if (!frame_url.has_host()) { | 1799 if (!frame_url.has_host()) { |
| 1800 title_type = content::JavaScriptDialogCreator::DIALOG_TITLE_NONE; | 1800 title_type = content::JavaScriptDialogCreator::DIALOG_TITLE_NONE; |
| 1801 } else { | 1801 } else { |
| 1802 title_type = content::JavaScriptDialogCreator::DIALOG_TITLE_FORMATTED_URL; | 1802 title_type = content::JavaScriptDialogCreator::DIALOG_TITLE_FORMATTED_URL; |
| 1803 title = net::FormatUrl( | 1803 title = net::FormatUrl( |
| 1804 frame_url.GetOrigin(), | 1804 frame_url.GetOrigin(), |
| 1805 content::GetContentClient()->browser()->GetAcceptLangs( | 1805 content::GetContentClient()->browser()->GetAcceptLangs( |
| 1806 this->browser_context())); | 1806 this->browser_context())); |
| 1807 } | 1807 } |
| 1808 | 1808 |
| 1809 dialog_creator_ = delegate_->GetJavaScriptDialogCreator(); | 1809 dialog_creator_ = delegate_->GetJavaScriptDialogCreator(); |
| 1810 dialog_creator_->RunJavaScriptDialog(this, | 1810 dialog_creator_->RunJavaScriptDialog(this, |
| 1811 title_type, | 1811 title_type, |
| 1812 title, | 1812 title, |
| 1813 flags, | 1813 javascript_message_type, |
| 1814 message, | 1814 message, |
| 1815 default_prompt, | 1815 default_prompt, |
| 1816 reply_msg, | 1816 reply_msg, |
| 1817 &suppress_this_message); | 1817 &suppress_this_message); |
| 1818 } | 1818 } |
| 1819 | 1819 |
| 1820 if (suppress_this_message) { | 1820 if (suppress_this_message) { |
| 1821 // If we are suppressing messages, just reply as if the user immediately | 1821 // If we are suppressing messages, just reply as if the user immediately |
| 1822 // pressed "Cancel". | 1822 // pressed "Cancel". |
| 1823 OnDialogClosed(reply_msg, false, string16()); | 1823 OnDialogClosed(reply_msg, false, string16()); |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2051 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); | 2051 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); |
| 2052 // Can be NULL during tests. | 2052 // Can be NULL during tests. |
| 2053 if (rwh_view) | 2053 if (rwh_view) |
| 2054 rwh_view->SetSize(view()->GetContainerSize()); | 2054 rwh_view->SetSize(view()->GetContainerSize()); |
| 2055 } | 2055 } |
| 2056 | 2056 |
| 2057 bool TabContents::GotResponseToLockMouseRequest(bool allowed) { | 2057 bool TabContents::GotResponseToLockMouseRequest(bool allowed) { |
| 2058 return render_view_host() ? | 2058 return render_view_host() ? |
| 2059 render_view_host()->GotResponseToLockMouseRequest(allowed) : false; | 2059 render_view_host()->GotResponseToLockMouseRequest(allowed) : false; |
| 2060 } | 2060 } |
| OLD | NEW |