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 "chrome/browser/chrome_content_browser_client.h" | 5 #include "chrome/browser/chrome_content_browser_client.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 return -1; | 487 return -1; |
488 } | 488 } |
489 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) | 489 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) |
490 | 490 |
491 void SetApplicationLocaleOnIOThread(const std::string& locale) { | 491 void SetApplicationLocaleOnIOThread(const std::string& locale) { |
492 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 492 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
493 g_io_thread_application_locale.Get() = locale; | 493 g_io_thread_application_locale.Get() = locale; |
494 } | 494 } |
495 | 495 |
496 void HandleBlockedPopupOnUIThread(const BlockedWindowParams& params) { | 496 void HandleBlockedPopupOnUIThread(const BlockedWindowParams& params) { |
497 // TODO(jochen): This code path should use RenderFrameHosts. See | 497 RenderFrameHost* render_frame_host = RenderFrameHost::FromID( |
498 // http://crbug.com/431769 for details. | 498 params.render_process_id(), params.opener_render_frame_id()); |
499 RenderViewHost* render_view_host = | 499 if (!render_frame_host) |
500 RenderViewHost::FromID(params.render_process_id(), params.opener_id()); | |
501 if (!render_view_host) | |
502 return; | 500 return; |
503 WebContents* tab = WebContents::FromRenderViewHost(render_view_host); | 501 WebContents* tab = WebContents::FromRenderFrameHost(render_frame_host); |
504 // The tab might already have navigated away. | 502 // The tab might already have navigated away. We only need to do this check |
505 if (!tab || tab->GetRenderViewHost() != render_view_host) | 503 // for main frames, since the RenderFrameHost for a subframe opener will have |
| 504 // already been deleted if the main frame navigates away. |
| 505 if (!tab || |
| 506 (!render_frame_host->GetParent() && |
| 507 tab->GetMainFrame() != render_frame_host)) |
506 return; | 508 return; |
507 | 509 |
508 prerender::PrerenderContents* prerender_contents = | 510 prerender::PrerenderContents* prerender_contents = |
509 prerender::PrerenderContents::FromWebContents(tab); | 511 prerender::PrerenderContents::FromWebContents(tab); |
510 if (prerender_contents) { | 512 if (prerender_contents) { |
511 prerender_contents->Destroy(prerender::FINAL_STATUS_CREATE_NEW_WINDOW); | 513 prerender_contents->Destroy(prerender::FINAL_STATUS_CREATE_NEW_WINDOW); |
512 return; | 514 return; |
513 } | 515 } |
514 | 516 |
515 PopupBlockerTabHelper* popup_helper = | 517 PopupBlockerTabHelper* popup_helper = |
(...skipping 22 matching lines...) Expand all Loading... |
538 } | 540 } |
539 } | 541 } |
540 | 542 |
541 private: | 543 private: |
542 const scoped_refptr<SafeBrowsingUIManager> safe_browsing_ui_manager_; | 544 const scoped_refptr<SafeBrowsingUIManager> safe_browsing_ui_manager_; |
543 }; | 545 }; |
544 | 546 |
545 #if defined(OS_ANDROID) | 547 #if defined(OS_ANDROID) |
546 | 548 |
547 void HandleSingleTabModeBlockOnUIThread(const BlockedWindowParams& params) { | 549 void HandleSingleTabModeBlockOnUIThread(const BlockedWindowParams& params) { |
548 WebContents* web_contents = | 550 WebContents* web_contents = tab_util::GetWebContentsByFrameID( |
549 tab_util::GetWebContentsByID(params.render_process_id(), | 551 params.render_process_id(), params.opener_render_frame_id()); |
550 params.opener_id()); | |
551 if (!web_contents) | 552 if (!web_contents) |
552 return; | 553 return; |
553 | 554 |
554 SingleTabModeTabHelper::FromWebContents(web_contents)->HandleOpenUrl(params); | 555 SingleTabModeTabHelper::FromWebContents(web_contents)->HandleOpenUrl(params); |
555 } | 556 } |
556 | 557 |
557 float GetDeviceScaleAdjustment() { | 558 float GetDeviceScaleAdjustment() { |
558 static const float kMinFSM = 1.05f; | 559 static const float kMinFSM = 1.05f; |
559 static const int kWidthForMinFSM = 320; | 560 static const int kWidthForMinFSM = 320; |
560 static const float kMaxFSM = 1.3f; | 561 static const float kMaxFSM = 1.3f; |
(...skipping 1279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1840 const GURL& source_origin, | 1841 const GURL& source_origin, |
1841 WindowContainerType container_type, | 1842 WindowContainerType container_type, |
1842 const GURL& target_url, | 1843 const GURL& target_url, |
1843 const content::Referrer& referrer, | 1844 const content::Referrer& referrer, |
1844 WindowOpenDisposition disposition, | 1845 WindowOpenDisposition disposition, |
1845 const WebWindowFeatures& features, | 1846 const WebWindowFeatures& features, |
1846 bool user_gesture, | 1847 bool user_gesture, |
1847 bool opener_suppressed, | 1848 bool opener_suppressed, |
1848 content::ResourceContext* context, | 1849 content::ResourceContext* context, |
1849 int render_process_id, | 1850 int render_process_id, |
1850 int opener_id, | 1851 int opener_render_view_id, |
| 1852 int opener_render_frame_id, |
1851 bool* no_javascript_access) { | 1853 bool* no_javascript_access) { |
1852 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1854 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
1853 | 1855 |
1854 *no_javascript_access = false; | 1856 *no_javascript_access = false; |
1855 | 1857 |
1856 // If the opener is trying to create a background window but doesn't have | 1858 // If the opener is trying to create a background window but doesn't have |
1857 // the appropriate permission, fail the attempt. | 1859 // the appropriate permission, fail the attempt. |
1858 if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) { | 1860 if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) { |
1859 #if defined(ENABLE_EXTENSIONS) | 1861 #if defined(ENABLE_EXTENSIONS) |
1860 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); | 1862 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
(...skipping 28 matching lines...) Expand all Loading... |
1889 | 1891 |
1890 HostContentSettingsMap* content_settings = | 1892 HostContentSettingsMap* content_settings = |
1891 ProfileIOData::FromResourceContext(context)->GetHostContentSettingsMap(); | 1893 ProfileIOData::FromResourceContext(context)->GetHostContentSettingsMap(); |
1892 BlockedWindowParams blocked_params(target_url, | 1894 BlockedWindowParams blocked_params(target_url, |
1893 referrer, | 1895 referrer, |
1894 disposition, | 1896 disposition, |
1895 features, | 1897 features, |
1896 user_gesture, | 1898 user_gesture, |
1897 opener_suppressed, | 1899 opener_suppressed, |
1898 render_process_id, | 1900 render_process_id, |
1899 opener_id); | 1901 opener_render_frame_id); |
1900 | 1902 |
1901 if (!user_gesture && | 1903 if (!user_gesture && |
1902 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 1904 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
1903 switches::kDisablePopupBlocking)) { | 1905 switches::kDisablePopupBlocking)) { |
1904 if (content_settings->GetContentSetting(opener_top_level_frame_url, | 1906 if (content_settings->GetContentSetting(opener_top_level_frame_url, |
1905 opener_top_level_frame_url, | 1907 opener_top_level_frame_url, |
1906 CONTENT_SETTINGS_TYPE_POPUPS, | 1908 CONTENT_SETTINGS_TYPE_POPUPS, |
1907 std::string()) != | 1909 std::string()) != |
1908 CONTENT_SETTING_ALLOW) { | 1910 CONTENT_SETTING_ALLOW) { |
1909 BrowserThread::PostTask(BrowserThread::UI, | 1911 BrowserThread::PostTask(BrowserThread::UI, |
1910 FROM_HERE, | 1912 FROM_HERE, |
1911 base::Bind(&HandleBlockedPopupOnUIThread, | 1913 base::Bind(&HandleBlockedPopupOnUIThread, |
1912 blocked_params)); | 1914 blocked_params)); |
1913 return false; | 1915 return false; |
1914 } | 1916 } |
1915 } | 1917 } |
1916 | 1918 |
1917 #if defined(OS_ANDROID) | 1919 #if defined(OS_ANDROID) |
1918 if (SingleTabModeTabHelper::IsRegistered(render_process_id, opener_id)) { | 1920 if (SingleTabModeTabHelper::IsRegistered(render_process_id, |
| 1921 opener_render_view_id)) { |
1919 BrowserThread::PostTask(BrowserThread::UI, | 1922 BrowserThread::PostTask(BrowserThread::UI, |
1920 FROM_HERE, | 1923 FROM_HERE, |
1921 base::Bind(&HandleSingleTabModeBlockOnUIThread, | 1924 base::Bind(&HandleSingleTabModeBlockOnUIThread, |
1922 blocked_params)); | 1925 blocked_params)); |
1923 return false; | 1926 return false; |
1924 } | 1927 } |
1925 #endif | 1928 #endif |
1926 | 1929 |
1927 return true; | 1930 return true; |
1928 } | 1931 } |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2442 switches::kDisableWebRtcEncryption, | 2445 switches::kDisableWebRtcEncryption, |
2443 }; | 2446 }; |
2444 to_command_line->CopySwitchesFrom(from_command_line, | 2447 to_command_line->CopySwitchesFrom(from_command_line, |
2445 kWebRtcDevSwitchNames, | 2448 kWebRtcDevSwitchNames, |
2446 arraysize(kWebRtcDevSwitchNames)); | 2449 arraysize(kWebRtcDevSwitchNames)); |
2447 } | 2450 } |
2448 } | 2451 } |
2449 #endif // defined(ENABLE_WEBRTC) | 2452 #endif // defined(ENABLE_WEBRTC) |
2450 | 2453 |
2451 } // namespace chrome | 2454 } // namespace chrome |
OLD | NEW |