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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 #include "chrome/browser/chromeos/login/signin/merge_session_navigation_throttle
.h" | 175 #include "chrome/browser/chromeos/login/signin/merge_session_navigation_throttle
.h" |
176 #include "chrome/browser/chromeos/login/signin/merge_session_throttling_utils.h" | 176 #include "chrome/browser/chromeos/login/signin/merge_session_throttling_utils.h" |
177 #include "chrome/browser/chromeos/login/startup_utils.h" | 177 #include "chrome/browser/chromeos/login/startup_utils.h" |
178 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 178 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
179 #include "chrome/browser/chromeos/system/input_device_settings.h" | 179 #include "chrome/browser/chromeos/system/input_device_settings.h" |
180 #include "chromeos/chromeos_switches.h" | 180 #include "chromeos/chromeos_switches.h" |
181 #include "components/user_manager/user_manager.h" | 181 #include "components/user_manager/user_manager.h" |
182 #elif defined(OS_LINUX) | 182 #elif defined(OS_LINUX) |
183 #include "chrome/browser/chrome_browser_main_linux.h" | 183 #include "chrome/browser/chrome_browser_main_linux.h" |
184 #elif defined(OS_ANDROID) | 184 #elif defined(OS_ANDROID) |
185 #include "chrome/browser/android/new_tab_page_url_handler.h" | |
186 #include "chrome/browser/android/webapps/single_tab_mode_tab_helper.h" | |
187 #include "chrome/browser/chrome_browser_main_android.h" | 185 #include "chrome/browser/chrome_browser_main_android.h" |
188 #include "chrome/common/descriptors_android.h" | 186 #include "chrome/common/descriptors_android.h" |
189 #include "components/crash/content/browser/crash_dump_manager_android.h" | 187 #include "components/crash/content/browser/crash_dump_manager_android.h" |
190 #include "components/navigation_interception/intercept_navigation_delegate.h" | 188 #include "components/navigation_interception/intercept_navigation_delegate.h" |
191 #include "components/service_tab_launcher/browser/android/service_tab_launcher.h
" | |
192 #include "ui/base/resource/resource_bundle_android.h" | 189 #include "ui/base/resource/resource_bundle_android.h" |
193 #elif defined(OS_POSIX) | 190 #elif defined(OS_POSIX) |
194 #include "chrome/browser/chrome_browser_main_posix.h" | 191 #include "chrome/browser/chrome_browser_main_posix.h" |
195 #endif | 192 #endif |
196 | 193 |
197 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 194 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
198 #include "base/debug/leak_annotations.h" | 195 #include "base/debug/leak_annotations.h" |
199 #include "components/crash/content/app/breakpad_linux.h" | 196 #include "components/crash/content/app/breakpad_linux.h" |
200 #include "components/crash/content/browser/crash_handler_host_linux.h" | 197 #include "components/crash/content/browser/crash_handler_host_linux.h" |
201 #endif | 198 #endif |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 | 270 |
274 #if defined(ENABLE_MEDIA_ROUTER) | 271 #if defined(ENABLE_MEDIA_ROUTER) |
275 #include "chrome/browser/media/router/media_router_feature.h" | 272 #include "chrome/browser/media/router/media_router_feature.h" |
276 #include "chrome/browser/media/router/presentation_service_delegate_impl.h" | 273 #include "chrome/browser/media/router/presentation_service_delegate_impl.h" |
277 #endif | 274 #endif |
278 | 275 |
279 #if defined(ENABLE_WAYLAND_SERVER) | 276 #if defined(ENABLE_WAYLAND_SERVER) |
280 #include "chrome/browser/chrome_browser_main_extra_parts_exo.h" | 277 #include "chrome/browser/chrome_browser_main_extra_parts_exo.h" |
281 #endif | 278 #endif |
282 | 279 |
| 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 |
283 using base::FileDescriptor; | 286 using base::FileDescriptor; |
284 using blink::WebWindowFeatures; | 287 using blink::WebWindowFeatures; |
285 using content::AccessTokenStore; | 288 using content::AccessTokenStore; |
286 using content::BrowserThread; | 289 using content::BrowserThread; |
287 using content::BrowserURLHandler; | 290 using content::BrowserURLHandler; |
288 using content::ChildProcessSecurityPolicy; | 291 using content::ChildProcessSecurityPolicy; |
289 using content::QuotaPermissionContext; | 292 using content::QuotaPermissionContext; |
290 using content::RenderFrameHost; | 293 using content::RenderFrameHost; |
291 using content::RenderViewHost; | 294 using content::RenderViewHost; |
292 using content::ResourceType; | 295 using content::ResourceType; |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 safe_browsing_ui_manager_->ReportInvalidCertificateChain( | 582 safe_browsing_ui_manager_->ReportInvalidCertificateChain( |
580 serialized_report, base::Bind(&base::DoNothing)); | 583 serialized_report, base::Bind(&base::DoNothing)); |
581 } | 584 } |
582 } | 585 } |
583 | 586 |
584 private: | 587 private: |
585 const scoped_refptr<safe_browsing::SafeBrowsingUIManager> | 588 const scoped_refptr<safe_browsing::SafeBrowsingUIManager> |
586 safe_browsing_ui_manager_; | 589 safe_browsing_ui_manager_; |
587 }; | 590 }; |
588 | 591 |
589 #if defined(OS_ANDROID) | |
590 | 592 |
| 593 // TODO(bshe): Use defined(ANDROID_JAVA_UI) once |
| 594 // codereview.chromium.org/1459793002 landed. |
| 595 #if defined(OS_ANDROID) && !defined(USE_AURA) |
591 void HandleSingleTabModeBlockOnUIThread(const BlockedWindowParams& params) { | 596 void HandleSingleTabModeBlockOnUIThread(const BlockedWindowParams& params) { |
592 WebContents* web_contents = tab_util::GetWebContentsByFrameID( | 597 WebContents* web_contents = tab_util::GetWebContentsByFrameID( |
593 params.render_process_id(), params.opener_render_frame_id()); | 598 params.render_process_id(), params.opener_render_frame_id()); |
594 if (!web_contents) | 599 if (!web_contents) |
595 return; | 600 return; |
596 | 601 |
597 SingleTabModeTabHelper::FromWebContents(web_contents)->HandleOpenUrl(params); | 602 SingleTabModeTabHelper::FromWebContents(web_contents)->HandleOpenUrl(params); |
598 } | 603 } |
| 604 #endif |
599 | 605 |
| 606 #if defined(OS_ANDROID) |
600 float GetDeviceScaleAdjustment() { | 607 float GetDeviceScaleAdjustment() { |
601 static const float kMinFSM = 1.05f; | 608 static const float kMinFSM = 1.05f; |
602 static const int kWidthForMinFSM = 320; | 609 static const int kWidthForMinFSM = 320; |
603 static const float kMaxFSM = 1.3f; | 610 static const float kMaxFSM = 1.3f; |
604 static const int kWidthForMaxFSM = 800; | 611 static const int kWidthForMaxFSM = 800; |
605 | 612 |
606 gfx::DeviceDisplayInfo info; | 613 gfx::DeviceDisplayInfo info; |
607 int minWidth = info.GetSmallestDIPWidth(); | 614 int minWidth = info.GetSmallestDIPWidth(); |
608 | 615 |
609 if (minWidth <= kWidthForMinFSM) | 616 if (minWidth <= kWidthForMinFSM) |
610 return kMinFSM; | 617 return kMinFSM; |
611 if (minWidth >= kWidthForMaxFSM) | 618 if (minWidth >= kWidthForMaxFSM) |
612 return kMaxFSM; | 619 return kMaxFSM; |
613 | 620 |
614 // The font scale multiplier varies linearly between kMinFSM and kMaxFSM. | 621 // The font scale multiplier varies linearly between kMinFSM and kMaxFSM. |
615 float ratio = static_cast<float>(minWidth - kWidthForMinFSM) / | 622 float ratio = static_cast<float>(minWidth - kWidthForMinFSM) / |
616 (kWidthForMaxFSM - kWidthForMinFSM); | 623 (kWidthForMaxFSM - kWidthForMinFSM); |
617 return ratio * (kMaxFSM - kMinFSM) + kMinFSM; | 624 return ratio * (kMaxFSM - kMinFSM) + kMinFSM; |
618 } | 625 } |
619 | |
620 #endif // defined(OS_ANDROID) | 626 #endif // defined(OS_ANDROID) |
621 | 627 |
622 #if defined(ENABLE_EXTENSIONS) | 628 #if defined(ENABLE_EXTENSIONS) |
623 // By default, JavaScript and images are enabled in guest content. | 629 // By default, JavaScript and images are enabled in guest content. |
624 void GetGuestViewDefaultContentSettingRules( | 630 void GetGuestViewDefaultContentSettingRules( |
625 bool incognito, | 631 bool incognito, |
626 RendererContentSettingRules* rules) { | 632 RendererContentSettingRules* rules) { |
627 rules->image_rules.push_back( | 633 rules->image_rules.push_back( |
628 ContentSettingPatternSource(ContentSettingsPattern::Wildcard(), | 634 ContentSettingPatternSource(ContentSettingsPattern::Wildcard(), |
629 ContentSettingsPattern::Wildcard(), | 635 ContentSettingsPattern::Wildcard(), |
(...skipping 1539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2169 std::string()) != | 2175 std::string()) != |
2170 CONTENT_SETTING_ALLOW) { | 2176 CONTENT_SETTING_ALLOW) { |
2171 BrowserThread::PostTask(BrowserThread::UI, | 2177 BrowserThread::PostTask(BrowserThread::UI, |
2172 FROM_HERE, | 2178 FROM_HERE, |
2173 base::Bind(&HandleBlockedPopupOnUIThread, | 2179 base::Bind(&HandleBlockedPopupOnUIThread, |
2174 blocked_params)); | 2180 blocked_params)); |
2175 return false; | 2181 return false; |
2176 } | 2182 } |
2177 } | 2183 } |
2178 | 2184 |
2179 #if defined(OS_ANDROID) | 2185 // TODO(bshe): Use defined(ANDROID_JAVA_UI) once |
| 2186 // codereview.chromium.org/1459793002 landed. |
| 2187 #if defined(OS_ANDROID) && !defined(USE_AURA) |
2180 if (SingleTabModeTabHelper::IsRegistered(render_process_id, | 2188 if (SingleTabModeTabHelper::IsRegistered(render_process_id, |
2181 opener_render_view_id)) { | 2189 opener_render_view_id)) { |
2182 BrowserThread::PostTask(BrowserThread::UI, | 2190 BrowserThread::PostTask(BrowserThread::UI, |
2183 FROM_HERE, | 2191 FROM_HERE, |
2184 base::Bind(&HandleSingleTabModeBlockOnUIThread, | 2192 base::Bind(&HandleSingleTabModeBlockOnUIThread, |
2185 blocked_params)); | 2193 blocked_params)); |
2186 return false; | 2194 return false; |
2187 } | 2195 } |
2188 #endif | 2196 #endif |
2189 | 2197 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2340 for (size_t i = 0; i < extra_parts_.size(); ++i) | 2348 for (size_t i = 0; i < extra_parts_.size(); ++i) |
2341 extra_parts_[i]->BrowserURLHandlerCreated(handler); | 2349 extra_parts_[i]->BrowserURLHandlerCreated(handler); |
2342 | 2350 |
2343 // about: handler. Must come before chrome: handler, since it will | 2351 // about: handler. Must come before chrome: handler, since it will |
2344 // rewrite about: urls to chrome: URLs and then expect chrome: to | 2352 // rewrite about: urls to chrome: URLs and then expect chrome: to |
2345 // actually handle them. Also relies on a preliminary fixup phase. | 2353 // actually handle them. Also relies on a preliminary fixup phase. |
2346 handler->SetFixupHandler(&FixupBrowserAboutURL); | 2354 handler->SetFixupHandler(&FixupBrowserAboutURL); |
2347 handler->AddHandlerPair(&WillHandleBrowserAboutURL, | 2355 handler->AddHandlerPair(&WillHandleBrowserAboutURL, |
2348 BrowserURLHandler::null_handler()); | 2356 BrowserURLHandler::null_handler()); |
2349 | 2357 |
2350 #if defined(OS_ANDROID) | 2358 // TODO(bshe): Use defined(ANDROID_JAVA_UI) once |
| 2359 // codereview.chromium.org/1459793002 landed. |
| 2360 #if defined(OS_ANDROID) && !defined(USE_AURA) |
2351 // Handler to rewrite chrome://newtab on Android. | 2361 // Handler to rewrite chrome://newtab on Android. |
2352 handler->AddHandlerPair(&chrome::android::HandleAndroidNativePageURL, | 2362 handler->AddHandlerPair(&chrome::android::HandleAndroidNativePageURL, |
2353 BrowserURLHandler::null_handler()); | 2363 BrowserURLHandler::null_handler()); |
2354 #else | 2364 #else |
2355 // Handler to rewrite chrome://newtab for InstantExtended. | 2365 // Handler to rewrite chrome://newtab for InstantExtended. |
2356 handler->AddHandlerPair(&search::HandleNewTabURLRewrite, | 2366 handler->AddHandlerPair(&search::HandleNewTabURLRewrite, |
2357 &search::HandleNewTabURLReverseRewrite); | 2367 &search::HandleNewTabURLReverseRewrite); |
2358 #endif | 2368 #endif |
2359 | 2369 |
2360 // chrome: & friends. | 2370 // chrome: & friends. |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2626 base::ASCIIToUTF16("Media App"))); | 2636 base::ASCIIToUTF16("Media App"))); |
2627 #endif | 2637 #endif |
2628 } | 2638 } |
2629 | 2639 |
2630 void ChromeContentBrowserClient::OpenURL( | 2640 void ChromeContentBrowserClient::OpenURL( |
2631 content::BrowserContext* browser_context, | 2641 content::BrowserContext* browser_context, |
2632 const content::OpenURLParams& params, | 2642 const content::OpenURLParams& params, |
2633 const base::Callback<void(content::WebContents*)>& callback) { | 2643 const base::Callback<void(content::WebContents*)>& callback) { |
2634 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2644 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
2635 | 2645 |
2636 #if !defined(OS_ANDROID) && !defined(OS_IOS) | 2646 // TODO(bshe): Use !defined(ANDROID_JAVA_UI) once |
| 2647 // codereview.chromium.org/1459793002 landed. |
| 2648 #if (!defined(OS_ANDROID) || defined(USE_AURA)) && !defined(OS_IOS) |
2637 chrome::NavigateParams nav_params( | 2649 chrome::NavigateParams nav_params( |
2638 Profile::FromBrowserContext(browser_context), | 2650 Profile::FromBrowserContext(browser_context), |
2639 params.url, | 2651 params.url, |
2640 params.transition); | 2652 params.transition); |
2641 FillNavigateParamsFromOpenURLParams(&nav_params, params); | 2653 FillNavigateParamsFromOpenURLParams(&nav_params, params); |
2642 nav_params.user_gesture = params.user_gesture; | 2654 nav_params.user_gesture = params.user_gesture; |
2643 | 2655 |
2644 Navigate(&nav_params); | 2656 Navigate(&nav_params); |
2645 callback.Run(nav_params.target_contents); | 2657 callback.Run(nav_params.target_contents); |
2646 #elif defined(OS_ANDROID) | 2658 #elif defined(OS_ANDROID) |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2786 if (channel <= kMaxDisableEncryptionChannel) { | 2798 if (channel <= kMaxDisableEncryptionChannel) { |
2787 static const char* const kWebRtcDevSwitchNames[] = { | 2799 static const char* const kWebRtcDevSwitchNames[] = { |
2788 switches::kDisableWebRtcEncryption, | 2800 switches::kDisableWebRtcEncryption, |
2789 }; | 2801 }; |
2790 to_command_line->CopySwitchesFrom(from_command_line, | 2802 to_command_line->CopySwitchesFrom(from_command_line, |
2791 kWebRtcDevSwitchNames, | 2803 kWebRtcDevSwitchNames, |
2792 arraysize(kWebRtcDevSwitchNames)); | 2804 arraysize(kWebRtcDevSwitchNames)); |
2793 } | 2805 } |
2794 } | 2806 } |
2795 #endif // defined(ENABLE_WEBRTC) | 2807 #endif // defined(ENABLE_WEBRTC) |
OLD | NEW |