| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 #include "chrome/browser/ui/sync/sync_promo_ui.h" | 86 #include "chrome/browser/ui/sync/sync_promo_ui.h" |
| 87 #include "chrome/browser/ui/tab_contents/chrome_web_contents_view_delegate.h" | 87 #include "chrome/browser/ui/tab_contents/chrome_web_contents_view_delegate.h" |
| 88 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" | 88 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" |
| 89 #include "chrome/browser/ui/webui/log_web_ui_url.h" | 89 #include "chrome/browser/ui/webui/log_web_ui_url.h" |
| 90 #include "chrome/browser/usb/usb_tab_helper.h" | 90 #include "chrome/browser/usb/usb_tab_helper.h" |
| 91 #include "chrome/common/channel_info.h" | 91 #include "chrome/common/channel_info.h" |
| 92 #include "chrome/common/chrome_constants.h" | 92 #include "chrome/common/chrome_constants.h" |
| 93 #include "chrome/common/chrome_paths.h" | 93 #include "chrome/common/chrome_paths.h" |
| 94 #include "chrome/common/chrome_switches.h" | 94 #include "chrome/common/chrome_switches.h" |
| 95 #include "chrome/common/env_vars.h" | 95 #include "chrome/common/env_vars.h" |
| 96 #include "chrome/common/features.h" |
| 96 #include "chrome/common/logging_chrome.h" | 97 #include "chrome/common/logging_chrome.h" |
| 97 #include "chrome/common/pepper_permission_util.h" | 98 #include "chrome/common/pepper_permission_util.h" |
| 98 #include "chrome/common/pref_names.h" | 99 #include "chrome/common/pref_names.h" |
| 99 #include "chrome/common/render_messages.h" | 100 #include "chrome/common/render_messages.h" |
| 100 #include "chrome/common/url_constants.h" | 101 #include "chrome/common/url_constants.h" |
| 101 #include "chrome/grit/generated_resources.h" | 102 #include "chrome/grit/generated_resources.h" |
| 102 #include "chrome/installer/util/google_update_settings.h" | 103 #include "chrome/installer/util/google_update_settings.h" |
| 103 #include "chromeos/chromeos_constants.h" | 104 #include "chromeos/chromeos_constants.h" |
| 104 #include "components/autofill/core/common/autofill_switches.h" | 105 #include "components/autofill/core/common/autofill_switches.h" |
| 105 #include "components/cdm/browser/cdm_message_filter_android.h" | 106 #include "components/cdm/browser/cdm_message_filter_android.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 #elif defined(OS_POSIX) | 191 #elif defined(OS_POSIX) |
| 191 #include "chrome/browser/chrome_browser_main_posix.h" | 192 #include "chrome/browser/chrome_browser_main_posix.h" |
| 192 #endif | 193 #endif |
| 193 | 194 |
| 194 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 195 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 195 #include "base/debug/leak_annotations.h" | 196 #include "base/debug/leak_annotations.h" |
| 196 #include "components/crash/content/app/breakpad_linux.h" | 197 #include "components/crash/content/app/breakpad_linux.h" |
| 197 #include "components/crash/content/browser/crash_handler_host_linux.h" | 198 #include "components/crash/content/browser/crash_handler_host_linux.h" |
| 198 #endif | 199 #endif |
| 199 | 200 |
| 201 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 202 #include "chrome/browser/android/new_tab_page_url_handler.h" |
| 203 #include "chrome/browser/android/webapps/single_tab_mode_tab_helper.h" |
| 204 #include "components/service_tab_launcher/browser/android/service_tab_launcher.h
" |
| 205 #endif |
| 206 |
| 200 #if defined(OS_ANDROID) | 207 #if defined(OS_ANDROID) |
| 201 #include "ui/base/ui_base_paths.h" | 208 #include "ui/base/ui_base_paths.h" |
| 202 #include "ui/gfx/android/device_display_info.h" | 209 #include "ui/gfx/android/device_display_info.h" |
| 203 #endif | 210 #endif |
| 204 | 211 |
| 205 #if defined(TOOLKIT_VIEWS) | 212 #if defined(TOOLKIT_VIEWS) |
| 206 #include "chrome/browser/ui/views/chrome_browser_main_extra_parts_views.h" | 213 #include "chrome/browser/ui/views/chrome_browser_main_extra_parts_views.h" |
| 207 #endif | 214 #endif |
| 208 | 215 |
| 209 #if defined(USE_ASH) | 216 #if defined(USE_ASH) |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 | 277 |
| 271 #if defined(ENABLE_MEDIA_ROUTER) | 278 #if defined(ENABLE_MEDIA_ROUTER) |
| 272 #include "chrome/browser/media/router/media_router_feature.h" | 279 #include "chrome/browser/media/router/media_router_feature.h" |
| 273 #include "chrome/browser/media/router/presentation_service_delegate_impl.h" | 280 #include "chrome/browser/media/router/presentation_service_delegate_impl.h" |
| 274 #endif | 281 #endif |
| 275 | 282 |
| 276 #if defined(ENABLE_WAYLAND_SERVER) | 283 #if defined(ENABLE_WAYLAND_SERVER) |
| 277 #include "chrome/browser/chrome_browser_main_extra_parts_exo.h" | 284 #include "chrome/browser/chrome_browser_main_extra_parts_exo.h" |
| 278 #endif | 285 #endif |
| 279 | 286 |
| 280 #if defined(OS_ANDROID) && !defined(USE_AURA) | |
| 281 #include "chrome/browser/android/new_tab_page_url_handler.h" | |
| 282 #include "chrome/browser/android/webapps/single_tab_mode_tab_helper.h" | |
| 283 #include "components/service_tab_launcher/browser/android/service_tab_launcher.h
" | |
| 284 #endif | |
| 285 | |
| 286 using base::FileDescriptor; | 287 using base::FileDescriptor; |
| 287 using blink::WebWindowFeatures; | 288 using blink::WebWindowFeatures; |
| 288 using content::AccessTokenStore; | 289 using content::AccessTokenStore; |
| 289 using content::BrowserThread; | 290 using content::BrowserThread; |
| 290 using content::BrowserURLHandler; | 291 using content::BrowserURLHandler; |
| 291 using content::ChildProcessSecurityPolicy; | 292 using content::ChildProcessSecurityPolicy; |
| 292 using content::QuotaPermissionContext; | 293 using content::QuotaPermissionContext; |
| 293 using content::RenderFrameHost; | 294 using content::RenderFrameHost; |
| 294 using content::RenderViewHost; | 295 using content::RenderViewHost; |
| 295 using content::ResourceType; | 296 using content::ResourceType; |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 safe_browsing_ui_manager_->ReportInvalidCertificateChain( | 583 safe_browsing_ui_manager_->ReportInvalidCertificateChain( |
| 583 serialized_report, base::Bind(&base::DoNothing)); | 584 serialized_report, base::Bind(&base::DoNothing)); |
| 584 } | 585 } |
| 585 } | 586 } |
| 586 | 587 |
| 587 private: | 588 private: |
| 588 const scoped_refptr<safe_browsing::SafeBrowsingUIManager> | 589 const scoped_refptr<safe_browsing::SafeBrowsingUIManager> |
| 589 safe_browsing_ui_manager_; | 590 safe_browsing_ui_manager_; |
| 590 }; | 591 }; |
| 591 | 592 |
| 592 | 593 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 593 // TODO(bshe): Use defined(ANDROID_JAVA_UI) once | |
| 594 // codereview.chromium.org/1459793002 landed. | |
| 595 #if defined(OS_ANDROID) && !defined(USE_AURA) | |
| 596 void HandleSingleTabModeBlockOnUIThread(const BlockedWindowParams& params) { | 594 void HandleSingleTabModeBlockOnUIThread(const BlockedWindowParams& params) { |
| 597 WebContents* web_contents = tab_util::GetWebContentsByFrameID( | 595 WebContents* web_contents = tab_util::GetWebContentsByFrameID( |
| 598 params.render_process_id(), params.opener_render_frame_id()); | 596 params.render_process_id(), params.opener_render_frame_id()); |
| 599 if (!web_contents) | 597 if (!web_contents) |
| 600 return; | 598 return; |
| 601 | 599 |
| 602 SingleTabModeTabHelper::FromWebContents(web_contents)->HandleOpenUrl(params); | 600 SingleTabModeTabHelper::FromWebContents(web_contents)->HandleOpenUrl(params); |
| 603 } | 601 } |
| 604 #endif | 602 #endif // BUILDFLAG(ANDROID_JAVA_UI) |
| 605 | 603 |
| 606 #if defined(OS_ANDROID) | 604 #if defined(OS_ANDROID) |
| 607 float GetDeviceScaleAdjustment() { | 605 float GetDeviceScaleAdjustment() { |
| 608 static const float kMinFSM = 1.05f; | 606 static const float kMinFSM = 1.05f; |
| 609 static const int kWidthForMinFSM = 320; | 607 static const int kWidthForMinFSM = 320; |
| 610 static const float kMaxFSM = 1.3f; | 608 static const float kMaxFSM = 1.3f; |
| 611 static const int kWidthForMaxFSM = 800; | 609 static const int kWidthForMaxFSM = 800; |
| 612 | 610 |
| 613 gfx::DeviceDisplayInfo info; | 611 gfx::DeviceDisplayInfo info; |
| 614 int minWidth = info.GetSmallestDIPWidth(); | 612 int minWidth = info.GetSmallestDIPWidth(); |
| (...skipping 1554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2169 std::string()) != | 2167 std::string()) != |
| 2170 CONTENT_SETTING_ALLOW) { | 2168 CONTENT_SETTING_ALLOW) { |
| 2171 BrowserThread::PostTask(BrowserThread::UI, | 2169 BrowserThread::PostTask(BrowserThread::UI, |
| 2172 FROM_HERE, | 2170 FROM_HERE, |
| 2173 base::Bind(&HandleBlockedPopupOnUIThread, | 2171 base::Bind(&HandleBlockedPopupOnUIThread, |
| 2174 blocked_params)); | 2172 blocked_params)); |
| 2175 return false; | 2173 return false; |
| 2176 } | 2174 } |
| 2177 } | 2175 } |
| 2178 | 2176 |
| 2179 // TODO(bshe): Use defined(ANDROID_JAVA_UI) once | 2177 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 2180 // codereview.chromium.org/1459793002 landed. | |
| 2181 #if defined(OS_ANDROID) && !defined(USE_AURA) | |
| 2182 if (SingleTabModeTabHelper::IsRegistered(render_process_id, | 2178 if (SingleTabModeTabHelper::IsRegistered(render_process_id, |
| 2183 opener_render_view_id)) { | 2179 opener_render_view_id)) { |
| 2184 BrowserThread::PostTask(BrowserThread::UI, | 2180 BrowserThread::PostTask(BrowserThread::UI, |
| 2185 FROM_HERE, | 2181 FROM_HERE, |
| 2186 base::Bind(&HandleSingleTabModeBlockOnUIThread, | 2182 base::Bind(&HandleSingleTabModeBlockOnUIThread, |
| 2187 blocked_params)); | 2183 blocked_params)); |
| 2188 return false; | 2184 return false; |
| 2189 } | 2185 } |
| 2190 #endif | 2186 #endif |
| 2191 | 2187 |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2342 for (size_t i = 0; i < extra_parts_.size(); ++i) | 2338 for (size_t i = 0; i < extra_parts_.size(); ++i) |
| 2343 extra_parts_[i]->BrowserURLHandlerCreated(handler); | 2339 extra_parts_[i]->BrowserURLHandlerCreated(handler); |
| 2344 | 2340 |
| 2345 // about: handler. Must come before chrome: handler, since it will | 2341 // about: handler. Must come before chrome: handler, since it will |
| 2346 // rewrite about: urls to chrome: URLs and then expect chrome: to | 2342 // rewrite about: urls to chrome: URLs and then expect chrome: to |
| 2347 // actually handle them. Also relies on a preliminary fixup phase. | 2343 // actually handle them. Also relies on a preliminary fixup phase. |
| 2348 handler->SetFixupHandler(&FixupBrowserAboutURL); | 2344 handler->SetFixupHandler(&FixupBrowserAboutURL); |
| 2349 handler->AddHandlerPair(&WillHandleBrowserAboutURL, | 2345 handler->AddHandlerPair(&WillHandleBrowserAboutURL, |
| 2350 BrowserURLHandler::null_handler()); | 2346 BrowserURLHandler::null_handler()); |
| 2351 | 2347 |
| 2352 // TODO(bshe): Use defined(ANDROID_JAVA_UI) once | 2348 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 2353 // codereview.chromium.org/1459793002 landed. | |
| 2354 #if defined(OS_ANDROID) && !defined(USE_AURA) | |
| 2355 // Handler to rewrite chrome://newtab on Android. | 2349 // Handler to rewrite chrome://newtab on Android. |
| 2356 handler->AddHandlerPair(&chrome::android::HandleAndroidNativePageURL, | 2350 handler->AddHandlerPair(&chrome::android::HandleAndroidNativePageURL, |
| 2357 BrowserURLHandler::null_handler()); | 2351 BrowserURLHandler::null_handler()); |
| 2358 #else | 2352 #else |
| 2359 // Handler to rewrite chrome://newtab for InstantExtended. | 2353 // Handler to rewrite chrome://newtab for InstantExtended. |
| 2360 handler->AddHandlerPair(&search::HandleNewTabURLRewrite, | 2354 handler->AddHandlerPair(&search::HandleNewTabURLRewrite, |
| 2361 &search::HandleNewTabURLReverseRewrite); | 2355 &search::HandleNewTabURLReverseRewrite); |
| 2362 #endif | 2356 #endif |
| 2363 | 2357 |
| 2364 // chrome: & friends. | 2358 // chrome: & friends. |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2630 base::ASCIIToUTF16("Media App"))); | 2624 base::ASCIIToUTF16("Media App"))); |
| 2631 #endif | 2625 #endif |
| 2632 } | 2626 } |
| 2633 | 2627 |
| 2634 void ChromeContentBrowserClient::OpenURL( | 2628 void ChromeContentBrowserClient::OpenURL( |
| 2635 content::BrowserContext* browser_context, | 2629 content::BrowserContext* browser_context, |
| 2636 const content::OpenURLParams& params, | 2630 const content::OpenURLParams& params, |
| 2637 const base::Callback<void(content::WebContents*)>& callback) { | 2631 const base::Callback<void(content::WebContents*)>& callback) { |
| 2638 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2632 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 2639 | 2633 |
| 2640 // TODO(bshe): Use !defined(ANDROID_JAVA_UI) once | 2634 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 2641 // codereview.chromium.org/1459793002 landed. | 2635 service_tab_launcher::ServiceTabLauncher::GetInstance()->LaunchTab( |
| 2642 #if (!defined(OS_ANDROID) || defined(USE_AURA)) && !defined(OS_IOS) | 2636 browser_context, params, callback); |
| 2637 #elif !defined(OS_IOS) |
| 2643 chrome::NavigateParams nav_params( | 2638 chrome::NavigateParams nav_params( |
| 2644 Profile::FromBrowserContext(browser_context), | 2639 Profile::FromBrowserContext(browser_context), |
| 2645 params.url, | 2640 params.url, |
| 2646 params.transition); | 2641 params.transition); |
| 2647 FillNavigateParamsFromOpenURLParams(&nav_params, params); | 2642 FillNavigateParamsFromOpenURLParams(&nav_params, params); |
| 2648 nav_params.user_gesture = params.user_gesture; | 2643 nav_params.user_gesture = params.user_gesture; |
| 2649 | 2644 |
| 2650 Navigate(&nav_params); | 2645 Navigate(&nav_params); |
| 2651 callback.Run(nav_params.target_contents); | 2646 callback.Run(nav_params.target_contents); |
| 2652 #elif defined(OS_ANDROID) | |
| 2653 service_tab_launcher::ServiceTabLauncher::GetInstance()->LaunchTab( | |
| 2654 browser_context, params, callback); | |
| 2655 #else | 2647 #else |
| 2656 NOTIMPLEMENTED(); | 2648 NOTIMPLEMENTED(); |
| 2657 #endif | 2649 #endif |
| 2658 } | 2650 } |
| 2659 | 2651 |
| 2660 content::PresentationServiceDelegate* | 2652 content::PresentationServiceDelegate* |
| 2661 ChromeContentBrowserClient::GetPresentationServiceDelegate( | 2653 ChromeContentBrowserClient::GetPresentationServiceDelegate( |
| 2662 content::WebContents* web_contents) { | 2654 content::WebContents* web_contents) { |
| 2663 #if defined(ENABLE_MEDIA_ROUTER) | 2655 #if defined(ENABLE_MEDIA_ROUTER) |
| 2664 content::BrowserContext* context = web_contents->GetBrowserContext(); | 2656 content::BrowserContext* context = web_contents->GetBrowserContext(); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2792 if (channel <= kMaxDisableEncryptionChannel) { | 2784 if (channel <= kMaxDisableEncryptionChannel) { |
| 2793 static const char* const kWebRtcDevSwitchNames[] = { | 2785 static const char* const kWebRtcDevSwitchNames[] = { |
| 2794 switches::kDisableWebRtcEncryption, | 2786 switches::kDisableWebRtcEncryption, |
| 2795 }; | 2787 }; |
| 2796 to_command_line->CopySwitchesFrom(from_command_line, | 2788 to_command_line->CopySwitchesFrom(from_command_line, |
| 2797 kWebRtcDevSwitchNames, | 2789 kWebRtcDevSwitchNames, |
| 2798 arraysize(kWebRtcDevSwitchNames)); | 2790 arraysize(kWebRtcDevSwitchNames)); |
| 2799 } | 2791 } |
| 2800 } | 2792 } |
| 2801 #endif // defined(ENABLE_WEBRTC) | 2793 #endif // defined(ENABLE_WEBRTC) |
| OLD | NEW |