| 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 <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" | 160 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" |
| 161 #include "chrome/browser/chromeos/fileapi/mtp_file_system_backend_delegate.h" | 161 #include "chrome/browser/chromeos/fileapi/mtp_file_system_backend_delegate.h" |
| 162 #include "chrome/browser/chromeos/login/startup_utils.h" | 162 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 163 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 163 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 164 #include "chrome/browser/chromeos/system/input_device_settings.h" | 164 #include "chrome/browser/chromeos/system/input_device_settings.h" |
| 165 #include "chromeos/chromeos_switches.h" | 165 #include "chromeos/chromeos_switches.h" |
| 166 #include "components/user_manager/user_manager.h" | 166 #include "components/user_manager/user_manager.h" |
| 167 #elif defined(OS_LINUX) | 167 #elif defined(OS_LINUX) |
| 168 #include "chrome/browser/chrome_browser_main_linux.h" | 168 #include "chrome/browser/chrome_browser_main_linux.h" |
| 169 #elif defined(OS_ANDROID) | 169 #elif defined(OS_ANDROID) |
| 170 #if !defined(USE_AURA) |
| 170 #include "chrome/browser/android/new_tab_page_url_handler.h" | 171 #include "chrome/browser/android/new_tab_page_url_handler.h" |
| 171 #include "chrome/browser/android/webapps/single_tab_mode_tab_helper.h" | 172 #include "chrome/browser/android/webapps/single_tab_mode_tab_helper.h" |
| 173 #include "components/service_tab_launcher/browser/android/service_tab_launcher.h
" |
| 174 #endif // USE_AURA |
| 172 #include "chrome/browser/chrome_browser_main_android.h" | 175 #include "chrome/browser/chrome_browser_main_android.h" |
| 173 #include "chrome/common/descriptors_android.h" | 176 #include "chrome/common/descriptors_android.h" |
| 174 #include "components/crash/browser/crash_dump_manager_android.h" | 177 #include "components/crash/browser/crash_dump_manager_android.h" |
| 175 #include "components/service_tab_launcher/browser/android/service_tab_launcher.h
" | |
| 176 #include "ui/base/resource/resource_bundle_android.h" | 178 #include "ui/base/resource/resource_bundle_android.h" |
| 177 #elif defined(OS_POSIX) | 179 #elif defined(OS_POSIX) |
| 178 #include "chrome/browser/chrome_browser_main_posix.h" | 180 #include "chrome/browser/chrome_browser_main_posix.h" |
| 179 #endif | 181 #endif |
| 180 | 182 |
| 181 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 183 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 182 #include "base/debug/leak_annotations.h" | 184 #include "base/debug/leak_annotations.h" |
| 183 #include "components/crash/app/breakpad_linux.h" | 185 #include "components/crash/app/breakpad_linux.h" |
| 184 #include "components/crash/browser/crash_handler_host_linux.h" | 186 #include "components/crash/browser/crash_handler_host_linux.h" |
| 185 #endif | 187 #endif |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 safe_browsing_ui_manager_->ReportInvalidCertificateChain( | 559 safe_browsing_ui_manager_->ReportInvalidCertificateChain( |
| 558 serialized_report, base::Bind(&base::DoNothing)); | 560 serialized_report, base::Bind(&base::DoNothing)); |
| 559 } | 561 } |
| 560 } | 562 } |
| 561 | 563 |
| 562 private: | 564 private: |
| 563 const scoped_refptr<SafeBrowsingUIManager> safe_browsing_ui_manager_; | 565 const scoped_refptr<SafeBrowsingUIManager> safe_browsing_ui_manager_; |
| 564 }; | 566 }; |
| 565 | 567 |
| 566 #if defined(OS_ANDROID) | 568 #if defined(OS_ANDROID) |
| 567 | 569 #if !defined(USE_AURA) |
| 568 void HandleSingleTabModeBlockOnUIThread(const BlockedWindowParams& params) { | 570 void HandleSingleTabModeBlockOnUIThread(const BlockedWindowParams& params) { |
| 569 WebContents* web_contents = tab_util::GetWebContentsByFrameID( | 571 WebContents* web_contents = tab_util::GetWebContentsByFrameID( |
| 570 params.render_process_id(), params.opener_render_frame_id()); | 572 params.render_process_id(), params.opener_render_frame_id()); |
| 571 if (!web_contents) | 573 if (!web_contents) |
| 572 return; | 574 return; |
| 573 | 575 |
| 574 SingleTabModeTabHelper::FromWebContents(web_contents)->HandleOpenUrl(params); | 576 SingleTabModeTabHelper::FromWebContents(web_contents)->HandleOpenUrl(params); |
| 575 } | 577 } |
| 578 #endif // !defined(USE_AURA |
| 576 | 579 |
| 577 float GetDeviceScaleAdjustment() { | 580 float GetDeviceScaleAdjustment() { |
| 578 static const float kMinFSM = 1.05f; | 581 static const float kMinFSM = 1.05f; |
| 579 static const int kWidthForMinFSM = 320; | 582 static const int kWidthForMinFSM = 320; |
| 580 static const float kMaxFSM = 1.3f; | 583 static const float kMaxFSM = 1.3f; |
| 581 static const int kWidthForMaxFSM = 800; | 584 static const int kWidthForMaxFSM = 800; |
| 582 | 585 |
| 583 gfx::DeviceDisplayInfo info; | 586 gfx::DeviceDisplayInfo info; |
| 584 int minWidth = info.GetSmallestDIPWidth(); | 587 int minWidth = info.GetSmallestDIPWidth(); |
| 585 | 588 |
| 586 if (minWidth <= kWidthForMinFSM) | 589 if (minWidth <= kWidthForMinFSM) |
| 587 return kMinFSM; | 590 return kMinFSM; |
| 588 if (minWidth >= kWidthForMaxFSM) | 591 if (minWidth >= kWidthForMaxFSM) |
| 589 return kMaxFSM; | 592 return kMaxFSM; |
| 590 | 593 |
| 591 // The font scale multiplier varies linearly between kMinFSM and kMaxFSM. | 594 // The font scale multiplier varies linearly between kMinFSM and kMaxFSM. |
| 592 float ratio = static_cast<float>(minWidth - kWidthForMinFSM) / | 595 float ratio = static_cast<float>(minWidth - kWidthForMinFSM) / |
| 593 (kWidthForMaxFSM - kWidthForMinFSM); | 596 (kWidthForMaxFSM - kWidthForMinFSM); |
| 594 return ratio * (kMaxFSM - kMinFSM) + kMinFSM; | 597 return ratio * (kMaxFSM - kMinFSM) + kMinFSM; |
| 595 } | 598 } |
| 596 | |
| 597 #endif // defined(OS_ANDROID) | 599 #endif // defined(OS_ANDROID) |
| 598 | 600 |
| 599 #if defined(ENABLE_EXTENSIONS) | 601 #if defined(ENABLE_EXTENSIONS) |
| 600 // By default, JavaScript and images are enabled in guest content. | 602 // By default, JavaScript and images are enabled in guest content. |
| 601 void GetGuestViewDefaultContentSettingRules( | 603 void GetGuestViewDefaultContentSettingRules( |
| 602 bool incognito, | 604 bool incognito, |
| 603 RendererContentSettingRules* rules) { | 605 RendererContentSettingRules* rules) { |
| 604 rules->image_rules.push_back( | 606 rules->image_rules.push_back( |
| 605 ContentSettingPatternSource(ContentSettingsPattern::Wildcard(), | 607 ContentSettingPatternSource(ContentSettingsPattern::Wildcard(), |
| 606 ContentSettingsPattern::Wildcard(), | 608 ContentSettingsPattern::Wildcard(), |
| (...skipping 1386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1993 std::string()) != | 1995 std::string()) != |
| 1994 CONTENT_SETTING_ALLOW) { | 1996 CONTENT_SETTING_ALLOW) { |
| 1995 BrowserThread::PostTask(BrowserThread::UI, | 1997 BrowserThread::PostTask(BrowserThread::UI, |
| 1996 FROM_HERE, | 1998 FROM_HERE, |
| 1997 base::Bind(&HandleBlockedPopupOnUIThread, | 1999 base::Bind(&HandleBlockedPopupOnUIThread, |
| 1998 blocked_params)); | 2000 blocked_params)); |
| 1999 return false; | 2001 return false; |
| 2000 } | 2002 } |
| 2001 } | 2003 } |
| 2002 | 2004 |
| 2003 #if defined(OS_ANDROID) | 2005 #if defined(OS_ANDROID) && !defined(USE_AURA) |
| 2004 if (SingleTabModeTabHelper::IsRegistered(render_process_id, | 2006 if (SingleTabModeTabHelper::IsRegistered(render_process_id, |
| 2005 opener_render_view_id)) { | 2007 opener_render_view_id)) { |
| 2006 BrowserThread::PostTask(BrowserThread::UI, | 2008 BrowserThread::PostTask(BrowserThread::UI, |
| 2007 FROM_HERE, | 2009 FROM_HERE, |
| 2008 base::Bind(&HandleSingleTabModeBlockOnUIThread, | 2010 base::Bind(&HandleSingleTabModeBlockOnUIThread, |
| 2009 blocked_params)); | 2011 blocked_params)); |
| 2010 return false; | 2012 return false; |
| 2011 } | 2013 } |
| 2012 #endif | 2014 #endif |
| 2013 | 2015 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2166 for (size_t i = 0; i < extra_parts_.size(); ++i) | 2168 for (size_t i = 0; i < extra_parts_.size(); ++i) |
| 2167 extra_parts_[i]->BrowserURLHandlerCreated(handler); | 2169 extra_parts_[i]->BrowserURLHandlerCreated(handler); |
| 2168 | 2170 |
| 2169 // about: handler. Must come before chrome: handler, since it will | 2171 // about: handler. Must come before chrome: handler, since it will |
| 2170 // rewrite about: urls to chrome: URLs and then expect chrome: to | 2172 // rewrite about: urls to chrome: URLs and then expect chrome: to |
| 2171 // actually handle them. Also relies on a preliminary fixup phase. | 2173 // actually handle them. Also relies on a preliminary fixup phase. |
| 2172 handler->SetFixupHandler(&FixupBrowserAboutURL); | 2174 handler->SetFixupHandler(&FixupBrowserAboutURL); |
| 2173 handler->AddHandlerPair(&WillHandleBrowserAboutURL, | 2175 handler->AddHandlerPair(&WillHandleBrowserAboutURL, |
| 2174 BrowserURLHandler::null_handler()); | 2176 BrowserURLHandler::null_handler()); |
| 2175 | 2177 |
| 2176 #if defined(OS_ANDROID) | 2178 #if defined(OS_ANDROID) && !defined(USE_AURA) |
| 2177 // Handler to rewrite chrome://newtab on Android. | 2179 // Handler to rewrite chrome://newtab on Android. |
| 2178 handler->AddHandlerPair(&chrome::android::HandleAndroidNativePageURL, | 2180 handler->AddHandlerPair(&chrome::android::HandleAndroidNativePageURL, |
| 2179 BrowserURLHandler::null_handler()); | 2181 BrowserURLHandler::null_handler()); |
| 2180 #else | 2182 #else |
| 2181 // Handler to rewrite chrome://newtab for InstantExtended. | 2183 // Handler to rewrite chrome://newtab for InstantExtended. |
| 2182 handler->AddHandlerPair(&search::HandleNewTabURLRewrite, | 2184 handler->AddHandlerPair(&search::HandleNewTabURLRewrite, |
| 2183 &search::HandleNewTabURLReverseRewrite); | 2185 &search::HandleNewTabURLReverseRewrite); |
| 2184 #endif | 2186 #endif |
| 2185 | 2187 |
| 2186 // chrome: & friends. | 2188 // chrome: & friends. |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2446 base::ThreadTaskRunnerHandle::Get()))); | 2448 base::ThreadTaskRunnerHandle::Get()))); |
| 2447 #endif | 2449 #endif |
| 2448 } | 2450 } |
| 2449 | 2451 |
| 2450 void ChromeContentBrowserClient::OpenURL( | 2452 void ChromeContentBrowserClient::OpenURL( |
| 2451 content::BrowserContext* browser_context, | 2453 content::BrowserContext* browser_context, |
| 2452 const content::OpenURLParams& params, | 2454 const content::OpenURLParams& params, |
| 2453 const base::Callback<void(content::WebContents*)>& callback) { | 2455 const base::Callback<void(content::WebContents*)>& callback) { |
| 2454 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2456 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 2455 | 2457 |
| 2456 #if !defined(OS_ANDROID) && !defined(OS_IOS) | 2458 #if (!defined(OS_ANDROID) || defined(USE_AURA)) && !defined(OS_IOS) |
| 2457 NavigateParams nav_params(Profile::FromBrowserContext(browser_context), | 2459 NavigateParams nav_params(Profile::FromBrowserContext(browser_context), |
| 2458 params.url, | 2460 params.url, |
| 2459 params.transition); | 2461 params.transition); |
| 2460 FillNavigateParamsFromOpenURLParams(&nav_params, params); | 2462 FillNavigateParamsFromOpenURLParams(&nav_params, params); |
| 2461 nav_params.user_gesture = params.user_gesture; | 2463 nav_params.user_gesture = params.user_gesture; |
| 2462 | 2464 |
| 2463 Navigate(&nav_params); | 2465 Navigate(&nav_params); |
| 2464 callback.Run(nav_params.target_contents); | 2466 callback.Run(nav_params.target_contents); |
| 2465 #elif defined(OS_ANDROID) | 2467 #elif defined(OS_ANDROID) |
| 2466 service_tab_launcher::ServiceTabLauncher::GetInstance()->LaunchTab( | 2468 service_tab_launcher::ServiceTabLauncher::GetInstance()->LaunchTab( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2489 metric, url); | 2491 metric, url); |
| 2490 } | 2492 } |
| 2491 } | 2493 } |
| 2492 | 2494 |
| 2493 content::DevToolsManagerDelegate* | 2495 content::DevToolsManagerDelegate* |
| 2494 ChromeContentBrowserClient::GetDevToolsManagerDelegate() { | 2496 ChromeContentBrowserClient::GetDevToolsManagerDelegate() { |
| 2495 return new ChromeDevToolsManagerDelegate(); | 2497 return new ChromeDevToolsManagerDelegate(); |
| 2496 } | 2498 } |
| 2497 | 2499 |
| 2498 content::TracingDelegate* ChromeContentBrowserClient::GetTracingDelegate() { | 2500 content::TracingDelegate* ChromeContentBrowserClient::GetTracingDelegate() { |
| 2499 #if !defined(OS_ANDROID) | 2501 #if !defined(OS_ANDROID) && !defined(USE_AURA) |
| 2500 return new ChromeTracingDelegate(); | 2502 return new ChromeTracingDelegate(); |
| 2501 #else | 2503 #else |
| 2502 return nullptr; | 2504 return nullptr; |
| 2503 #endif | 2505 #endif |
| 2504 } | 2506 } |
| 2505 | 2507 |
| 2506 bool ChromeContentBrowserClient::IsPluginAllowedToCallRequestOSFileHandle( | 2508 bool ChromeContentBrowserClient::IsPluginAllowedToCallRequestOSFileHandle( |
| 2507 content::BrowserContext* browser_context, | 2509 content::BrowserContext* browser_context, |
| 2508 const GURL& url) { | 2510 const GURL& url) { |
| 2509 #if defined(ENABLE_PLUGINS) && defined(ENABLE_EXTENSIONS) | 2511 #if defined(ENABLE_PLUGINS) && defined(ENABLE_EXTENSIONS) |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2563 switches::kDisableWebRtcEncryption, | 2565 switches::kDisableWebRtcEncryption, |
| 2564 }; | 2566 }; |
| 2565 to_command_line->CopySwitchesFrom(from_command_line, | 2567 to_command_line->CopySwitchesFrom(from_command_line, |
| 2566 kWebRtcDevSwitchNames, | 2568 kWebRtcDevSwitchNames, |
| 2567 arraysize(kWebRtcDevSwitchNames)); | 2569 arraysize(kWebRtcDevSwitchNames)); |
| 2568 } | 2570 } |
| 2569 } | 2571 } |
| 2570 #endif // defined(ENABLE_WEBRTC) | 2572 #endif // defined(ENABLE_WEBRTC) |
| 2571 | 2573 |
| 2572 } // namespace chrome | 2574 } // namespace chrome |
| OLD | NEW |