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 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/files/scoped_file.h" | 13 #include "base/files/scoped_file.h" |
14 #include "base/i18n/icu_util.h" | 14 #include "base/i18n/icu_util.h" |
15 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
16 #include "base/path_service.h" | 16 #include "base/path_service.h" |
17 #include "base/prefs/pref_service.h" | 17 #include "base/prefs/pref_service.h" |
18 #include "base/prefs/scoped_user_pref_update.h" | 18 #include "base/prefs/scoped_user_pref_update.h" |
| 19 #include "base/rand_util.h" |
19 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
20 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
21 #include "base/threading/sequenced_worker_pool.h" | 22 #include "base/threading/sequenced_worker_pool.h" |
| 23 #include "base/time/time.h" |
22 #include "chrome/browser/browser_about_handler.h" | 24 #include "chrome/browser/browser_about_handler.h" |
23 #include "chrome/browser/browser_process.h" | 25 #include "chrome/browser/browser_process.h" |
24 #include "chrome/browser/browser_shutdown.h" | 26 #include "chrome/browser/browser_shutdown.h" |
25 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 27 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
26 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 28 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
27 #include "chrome/browser/character_encoding.h" | 29 #include "chrome/browser/character_encoding.h" |
| 30 #include "chrome/browser/chrome_browser_main.h" |
28 #include "chrome/browser/chrome_content_browser_client_parts.h" | 31 #include "chrome/browser/chrome_content_browser_client_parts.h" |
29 #include "chrome/browser/chrome_net_benchmarking_message_filter.h" | 32 #include "chrome/browser/chrome_net_benchmarking_message_filter.h" |
30 #include "chrome/browser/chrome_quota_permission_context.h" | 33 #include "chrome/browser/chrome_quota_permission_context.h" |
31 #include "chrome/browser/content_settings/cookie_settings.h" | 34 #include "chrome/browser/content_settings/cookie_settings.h" |
32 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 35 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
33 #include "chrome/browser/defaults.h" | 36 #include "chrome/browser/defaults.h" |
34 #include "chrome/browser/download/download_prefs.h" | 37 #include "chrome/browser/download/download_prefs.h" |
35 #include "chrome/browser/font_family_cache.h" | 38 #include "chrome/browser/font_family_cache.h" |
36 #include "chrome/browser/geolocation/chrome_access_token_store.h" | 39 #include "chrome/browser/geolocation/chrome_access_token_store.h" |
37 #include "chrome/browser/geolocation/geolocation_permission_context.h" | 40 #include "chrome/browser/geolocation/geolocation_permission_context.h" |
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 | 804 |
802 #if defined(USE_X11) | 805 #if defined(USE_X11) |
803 main_parts->AddParts(new ChromeBrowserMainExtraPartsX11()); | 806 main_parts->AddParts(new ChromeBrowserMainExtraPartsX11()); |
804 #endif | 807 #endif |
805 | 808 |
806 chrome::AddMetricsExtraParts(main_parts); | 809 chrome::AddMetricsExtraParts(main_parts); |
807 | 810 |
808 return main_parts; | 811 return main_parts; |
809 } | 812 } |
810 | 813 |
| 814 namespace { |
| 815 |
| 816 void PostAfterStartupTaskImpl( |
| 817 const tracked_objects::Location& from_here, |
| 818 const scoped_refptr<base::TaskRunner>& task_runner, |
| 819 const base::Closure& task) { |
| 820 if (!IsBrowserStartupComplete()) { |
| 821 const int kMinDelay = 5; |
| 822 const int kMaxDelay = 30; |
| 823 task_runner->PostDelayedTask( |
| 824 FROM_HERE, |
| 825 base::Bind(PostAfterStartupTaskImpl, from_here, task_runner, task), |
| 826 base::TimeDelta::FromSeconds(base::RandInt(kMinDelay, kMaxDelay))); |
| 827 return; |
| 828 } |
| 829 task_runner->PostTask(from_here, task); |
| 830 } |
| 831 |
| 832 } // namespace |
| 833 |
| 834 void ChromeContentBrowserClient::PostAfterStartupTask( |
| 835 const tracked_objects::Location& from_here, |
| 836 const scoped_refptr<base::TaskRunner>& task_runner, |
| 837 const base::Closure& task) { |
| 838 PostAfterStartupTaskImpl(from_here, task_runner, task); |
| 839 } |
| 840 |
811 std::string ChromeContentBrowserClient::GetStoragePartitionIdForSite( | 841 std::string ChromeContentBrowserClient::GetStoragePartitionIdForSite( |
812 content::BrowserContext* browser_context, | 842 content::BrowserContext* browser_context, |
813 const GURL& site) { | 843 const GURL& site) { |
814 std::string partition_id; | 844 std::string partition_id; |
815 | 845 |
816 // The partition ID for webview guest processes is the string value of its | 846 // The partition ID for webview guest processes is the string value of its |
817 // SiteInstance URL - "chrome-guest://app_id/persist?partition". | 847 // SiteInstance URL - "chrome-guest://app_id/persist?partition". |
818 if (site.SchemeIs(content::kGuestScheme)) { | 848 if (site.SchemeIs(content::kGuestScheme)) { |
819 partition_id = site.spec(); | 849 partition_id = site.spec(); |
820 } else if (site.GetOrigin().spec() == kChromeUIChromeSigninURL) { | 850 } else if (site.GetOrigin().spec() == kChromeUIChromeSigninURL) { |
(...skipping 1819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2640 switches::kDisableWebRtcEncryption, | 2670 switches::kDisableWebRtcEncryption, |
2641 }; | 2671 }; |
2642 to_command_line->CopySwitchesFrom(from_command_line, | 2672 to_command_line->CopySwitchesFrom(from_command_line, |
2643 kWebRtcDevSwitchNames, | 2673 kWebRtcDevSwitchNames, |
2644 arraysize(kWebRtcDevSwitchNames)); | 2674 arraysize(kWebRtcDevSwitchNames)); |
2645 } | 2675 } |
2646 } | 2676 } |
2647 #endif // defined(ENABLE_WEBRTC) | 2677 #endif // defined(ENABLE_WEBRTC) |
2648 | 2678 |
2649 } // namespace chrome | 2679 } // namespace chrome |
OLD | NEW |