Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: chrome/browser/chrome_content_browser_client.cc

Issue 1086283002: Track frame openers in FrameTreeNodes instead of WebContents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup in WebContentsImpl Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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.
505 if (!tab || tab->GetRenderViewHost() != render_view_host) 503 if (!tab ||
504 tab->GetRenderViewHost() != render_frame_host->GetRenderViewHost())
alexmos 2015/06/01 17:44:55 I guess this prevents the blocked popup UI from be
Charlie Reis 2015/06/03 20:01:36 Interesting. I don't think this new check works,
alexmos 2015/06/05 22:34:30 Ah, right, this check won't work for subframes --
Charlie Reis 2015/06/09 04:38:38 Hmm, you're right, but I wonder if we should chang
506 return; 505 return;
507 506
508 prerender::PrerenderContents* prerender_contents = 507 prerender::PrerenderContents* prerender_contents =
509 prerender::PrerenderContents::FromWebContents(tab); 508 prerender::PrerenderContents::FromWebContents(tab);
510 if (prerender_contents) { 509 if (prerender_contents) {
511 prerender_contents->Destroy(prerender::FINAL_STATUS_CREATE_NEW_WINDOW); 510 prerender_contents->Destroy(prerender::FINAL_STATUS_CREATE_NEW_WINDOW);
512 return; 511 return;
513 } 512 }
514 513
515 PopupBlockerTabHelper* popup_helper = 514 PopupBlockerTabHelper* popup_helper =
(...skipping 22 matching lines...) Expand all
538 } 537 }
539 } 538 }
540 539
541 private: 540 private:
542 const scoped_refptr<SafeBrowsingUIManager> safe_browsing_ui_manager_; 541 const scoped_refptr<SafeBrowsingUIManager> safe_browsing_ui_manager_;
543 }; 542 };
544 543
545 #if defined(OS_ANDROID) 544 #if defined(OS_ANDROID)
546 545
547 void HandleSingleTabModeBlockOnUIThread(const BlockedWindowParams& params) { 546 void HandleSingleTabModeBlockOnUIThread(const BlockedWindowParams& params) {
548 WebContents* web_contents = 547 WebContents* web_contents = tab_util::GetWebContentsByFrameID(
549 tab_util::GetWebContentsByID(params.render_process_id(), 548 params.render_process_id(), params.opener_render_frame_id());
550 params.opener_id());
551 if (!web_contents) 549 if (!web_contents)
552 return; 550 return;
553 551
554 SingleTabModeTabHelper::FromWebContents(web_contents)->HandleOpenUrl(params); 552 SingleTabModeTabHelper::FromWebContents(web_contents)->HandleOpenUrl(params);
555 } 553 }
556 554
557 float GetDeviceScaleAdjustment() { 555 float GetDeviceScaleAdjustment() {
558 static const float kMinFSM = 1.05f; 556 static const float kMinFSM = 1.05f;
559 static const int kWidthForMinFSM = 320; 557 static const int kWidthForMinFSM = 320;
560 static const float kMaxFSM = 1.3f; 558 static const float kMaxFSM = 1.3f;
(...skipping 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1844 const GURL& source_origin, 1842 const GURL& source_origin,
1845 WindowContainerType container_type, 1843 WindowContainerType container_type,
1846 const GURL& target_url, 1844 const GURL& target_url,
1847 const content::Referrer& referrer, 1845 const content::Referrer& referrer,
1848 WindowOpenDisposition disposition, 1846 WindowOpenDisposition disposition,
1849 const WebWindowFeatures& features, 1847 const WebWindowFeatures& features,
1850 bool user_gesture, 1848 bool user_gesture,
1851 bool opener_suppressed, 1849 bool opener_suppressed,
1852 content::ResourceContext* context, 1850 content::ResourceContext* context,
1853 int render_process_id, 1851 int render_process_id,
1854 int opener_id, 1852 int opener_render_view_id,
alexmos 2015/06/01 17:44:55 I didn't just convert opener_id to be opener_rende
Charlie Reis 2015/06/03 20:01:36 Yes, that approach sounds good.
1853 int opener_render_frame_id,
1855 bool* no_javascript_access) { 1854 bool* no_javascript_access) {
1856 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 1855 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1857 1856
1858 *no_javascript_access = false; 1857 *no_javascript_access = false;
1859 1858
1860 // If the opener is trying to create a background window but doesn't have 1859 // If the opener is trying to create a background window but doesn't have
1861 // the appropriate permission, fail the attempt. 1860 // the appropriate permission, fail the attempt.
1862 if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) { 1861 if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) {
1863 #if defined(ENABLE_EXTENSIONS) 1862 #if defined(ENABLE_EXTENSIONS)
1864 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); 1863 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
(...skipping 28 matching lines...) Expand all
1893 1892
1894 HostContentSettingsMap* content_settings = 1893 HostContentSettingsMap* content_settings =
1895 ProfileIOData::FromResourceContext(context)->GetHostContentSettingsMap(); 1894 ProfileIOData::FromResourceContext(context)->GetHostContentSettingsMap();
1896 BlockedWindowParams blocked_params(target_url, 1895 BlockedWindowParams blocked_params(target_url,
1897 referrer, 1896 referrer,
1898 disposition, 1897 disposition,
1899 features, 1898 features,
1900 user_gesture, 1899 user_gesture,
1901 opener_suppressed, 1900 opener_suppressed,
1902 render_process_id, 1901 render_process_id,
1903 opener_id); 1902 opener_render_frame_id);
1904 1903
1905 if (!user_gesture && 1904 if (!user_gesture &&
1906 !base::CommandLine::ForCurrentProcess()->HasSwitch( 1905 !base::CommandLine::ForCurrentProcess()->HasSwitch(
1907 switches::kDisablePopupBlocking)) { 1906 switches::kDisablePopupBlocking)) {
1908 if (content_settings->GetContentSetting(opener_top_level_frame_url, 1907 if (content_settings->GetContentSetting(opener_top_level_frame_url,
1909 opener_top_level_frame_url, 1908 opener_top_level_frame_url,
1910 CONTENT_SETTINGS_TYPE_POPUPS, 1909 CONTENT_SETTINGS_TYPE_POPUPS,
1911 std::string()) != 1910 std::string()) !=
1912 CONTENT_SETTING_ALLOW) { 1911 CONTENT_SETTING_ALLOW) {
1913 BrowserThread::PostTask(BrowserThread::UI, 1912 BrowserThread::PostTask(BrowserThread::UI,
1914 FROM_HERE, 1913 FROM_HERE,
1915 base::Bind(&HandleBlockedPopupOnUIThread, 1914 base::Bind(&HandleBlockedPopupOnUIThread,
1916 blocked_params)); 1915 blocked_params));
1917 return false; 1916 return false;
1918 } 1917 }
1919 } 1918 }
1920 1919
1921 #if defined(OS_ANDROID) 1920 #if defined(OS_ANDROID)
1922 if (SingleTabModeTabHelper::IsRegistered(render_process_id, opener_id)) { 1921 if (SingleTabModeTabHelper::IsRegistered(render_process_id,
1922 opener_render_view_id)) {
1923 BrowserThread::PostTask(BrowserThread::UI, 1923 BrowserThread::PostTask(BrowserThread::UI,
1924 FROM_HERE, 1924 FROM_HERE,
1925 base::Bind(&HandleSingleTabModeBlockOnUIThread, 1925 base::Bind(&HandleSingleTabModeBlockOnUIThread,
1926 blocked_params)); 1926 blocked_params));
1927 return false; 1927 return false;
1928 } 1928 }
1929 #endif 1929 #endif
1930 1930
1931 return true; 1931 return true;
1932 } 1932 }
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
2446 switches::kDisableWebRtcEncryption, 2446 switches::kDisableWebRtcEncryption,
2447 }; 2447 };
2448 to_command_line->CopySwitchesFrom(from_command_line, 2448 to_command_line->CopySwitchesFrom(from_command_line,
2449 kWebRtcDevSwitchNames, 2449 kWebRtcDevSwitchNames,
2450 arraysize(kWebRtcDevSwitchNames)); 2450 arraysize(kWebRtcDevSwitchNames));
2451 } 2451 }
2452 } 2452 }
2453 #endif // defined(ENABLE_WEBRTC) 2453 #endif // defined(ENABLE_WEBRTC)
2454 2454
2455 } // namespace chrome 2455 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698