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/android/tab_android.h" | 5 #include "chrome/browser/android/tab_android.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "base/trace_event/trace_event.h" | 11 #include "base/trace_event/trace_event.h" |
12 #include "cc/layers/layer.h" | 12 #include "cc/layers/layer.h" |
13 #include "chrome/browser/android/chrome_web_contents_delegate_android.h" | 13 #include "chrome/browser/android/chrome_web_contents_delegate_android.h" |
14 #include "chrome/browser/android/compositor/tab_content_manager.h" | 14 #include "chrome/browser/android/compositor/tab_content_manager.h" |
15 #include "chrome/browser/android/hung_renderer_infobar_delegate.h" | |
15 #include "chrome/browser/android/metrics/uma_utils.h" | 16 #include "chrome/browser/android/metrics/uma_utils.h" |
16 #include "chrome/browser/android/offline_pages/offline_page_bridge.h" | 17 #include "chrome/browser/android/offline_pages/offline_page_bridge.h" |
17 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" | 18 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" |
18 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 19 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
19 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" | 20 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" |
20 #include "chrome/browser/browser_about_handler.h" | 21 #include "chrome/browser/browser_about_handler.h" |
21 #include "chrome/browser/chrome_notification_types.h" | 22 #include "chrome/browser/chrome_notification_types.h" |
22 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 23 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
23 #include "chrome/browser/infobars/infobar_service.h" | 24 #include "chrome/browser/infobars/infobar_service.h" |
24 #include "chrome/browser/prerender/prerender_contents.h" | 25 #include "chrome/browser/prerender/prerender_contents.h" |
(...skipping 23 matching lines...) Expand all Loading... | |
48 #include "chrome/browser/ui/tab_helpers.h" | 49 #include "chrome/browser/ui/tab_helpers.h" |
49 #include "chrome/common/instant_types.h" | 50 #include "chrome/common/instant_types.h" |
50 #include "chrome/common/render_messages.h" | 51 #include "chrome/common/render_messages.h" |
51 #include "chrome/common/url_constants.h" | 52 #include "chrome/common/url_constants.h" |
52 #include "components/bookmarks/browser/bookmark_model.h" | 53 #include "components/bookmarks/browser/bookmark_model.h" |
53 #include "components/bookmarks/browser/bookmark_node.h" | 54 #include "components/bookmarks/browser/bookmark_node.h" |
54 #include "components/bookmarks/browser/bookmark_utils.h" | 55 #include "components/bookmarks/browser/bookmark_utils.h" |
55 #include "components/bookmarks/managed/managed_bookmark_service.h" | 56 #include "components/bookmarks/managed/managed_bookmark_service.h" |
56 #include "components/dom_distiller/core/url_utils.h" | 57 #include "components/dom_distiller/core/url_utils.h" |
57 #include "components/favicon/content/content_favicon_driver.h" | 58 #include "components/favicon/content/content_favicon_driver.h" |
59 #include "components/infobars/core/infobar.h" | |
58 #include "components/infobars/core/infobar_container.h" | 60 #include "components/infobars/core/infobar_container.h" |
59 #include "components/navigation_interception/intercept_navigation_delegate.h" | 61 #include "components/navigation_interception/intercept_navigation_delegate.h" |
60 #include "components/navigation_interception/navigation_params.h" | 62 #include "components/navigation_interception/navigation_params.h" |
61 #include "components/offline_pages/offline_page_feature.h" | 63 #include "components/offline_pages/offline_page_feature.h" |
62 #include "components/offline_pages/offline_page_item.h" | 64 #include "components/offline_pages/offline_page_item.h" |
63 #include "components/offline_pages/offline_page_model.h" | 65 #include "components/offline_pages/offline_page_model.h" |
64 #include "components/url_formatter/url_fixer.h" | 66 #include "components/url_formatter/url_fixer.h" |
65 #include "content/public/browser/android/compositor.h" | 67 #include "content/public/browser/android/compositor.h" |
66 #include "content/public/browser/android/content_view_core.h" | 68 #include "content/public/browser/android/content_view_core.h" |
67 #include "content/public/browser/browser_thread.h" | 69 #include "content/public/browser/browser_thread.h" |
(...skipping 26 matching lines...) Expand all Loading... | |
94 using content::WebContents; | 96 using content::WebContents; |
95 using navigation_interception::InterceptNavigationDelegate; | 97 using navigation_interception::InterceptNavigationDelegate; |
96 using navigation_interception::NavigationParams; | 98 using navigation_interception::NavigationParams; |
97 | 99 |
98 namespace { | 100 namespace { |
99 | 101 |
100 const int kImageSearchThumbnailMinSize = 300 * 300; | 102 const int kImageSearchThumbnailMinSize = 300 * 300; |
101 const int kImageSearchThumbnailMaxWidth = 600; | 103 const int kImageSearchThumbnailMaxWidth = 600; |
102 const int kImageSearchThumbnailMaxHeight = 600; | 104 const int kImageSearchThumbnailMaxHeight = 600; |
103 | 105 |
106 infobars::InfoBar* FindHungRendererInfoBar(InfoBarService* infobar_service) { | |
107 for (size_t i = 0; i < infobar_service->infobar_count(); ++i) { | |
108 infobars::InfoBar* infobar = infobar_service->infobar_at(i); | |
109 if (!infobar || !infobar->delegate()) | |
Peter Kasting
2015/09/01 22:24:05
These cannot be null.
jdduke (slow)
2015/09/02 00:04:01
Done.
| |
110 continue; | |
111 | |
112 if (!infobar->delegate()->AsHungRendererInfoBarDelegate()) | |
Peter Kasting
2015/09/01 22:24:05
Nit: Simpler:
if (infobar->delegate()->AsHung
jdduke (slow)
2015/09/02 00:04:01
Done.
| |
113 continue; | |
114 | |
115 return infobar; | |
116 } | |
117 return nullptr; | |
118 } | |
119 | |
104 } // namespace | 120 } // namespace |
105 | 121 |
106 TabAndroid* TabAndroid::FromWebContents(content::WebContents* web_contents) { | 122 TabAndroid* TabAndroid::FromWebContents(content::WebContents* web_contents) { |
107 CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(web_contents); | 123 CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(web_contents); |
108 if (!core_tab_helper) | 124 if (!core_tab_helper) |
109 return NULL; | 125 return NULL; |
110 | 126 |
111 CoreTabHelperDelegate* core_delegate = core_tab_helper->delegate(); | 127 CoreTabHelperDelegate* core_delegate = core_tab_helper->delegate(); |
112 if (!core_delegate) | 128 if (!core_delegate) |
113 return NULL; | 129 return NULL; |
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
835 offline_pages::OfflinePageModelFactory::GetForBrowserContext( | 851 offline_pages::OfflinePageModelFactory::GetForBrowserContext( |
836 GetProfile()); | 852 GetProfile()); |
837 return offline_page_model->GetPageByOfflineURL(url); | 853 return offline_page_model->GetPageByOfflineURL(url); |
838 } | 854 } |
839 | 855 |
840 bool TabAndroid::HasPrerenderedUrl(JNIEnv* env, jobject obj, jstring url) { | 856 bool TabAndroid::HasPrerenderedUrl(JNIEnv* env, jobject obj, jstring url) { |
841 GURL gurl(base::android::ConvertJavaStringToUTF8(env, url)); | 857 GURL gurl(base::android::ConvertJavaStringToUTF8(env, url)); |
842 return HasPrerenderedUrl(gurl); | 858 return HasPrerenderedUrl(gurl); |
843 } | 859 } |
844 | 860 |
861 void TabAndroid::OnRendererUnresponsive(JNIEnv* env, jobject obj) { | |
862 InfoBarService* infobar_service = | |
863 InfoBarService::FromWebContents(web_contents()); | |
864 if (!infobar_service) | |
Peter Kasting
2015/09/01 22:24:05
When will this be null? Either you shouldn't be c
jdduke (slow)
2015/09/02 00:04:01
I don't think it can be, I looked at some other co
| |
865 return; | |
866 | |
867 DCHECK(!FindHungRendererInfoBar(infobar_service)); | |
868 | |
869 scoped_ptr<ConfirmInfoBarDelegate> delegate( | |
870 new HungRendererInfoBarDelegate(web_contents())); | |
871 infobar_service->AddInfoBar( | |
872 infobar_service->CreateConfirmInfoBar(delegate.Pass())); | |
873 } | |
874 | |
875 void TabAndroid::OnRendererResponsive(JNIEnv* env, jobject obj) { | |
876 InfoBarService* infobar_service = | |
877 InfoBarService::FromWebContents(web_contents()); | |
878 if (!infobar_service) | |
879 return; | |
880 | |
881 infobars::InfoBar* hung_renderer_infobar = | |
882 FindHungRendererInfoBar(infobar_service); | |
883 if (!hung_renderer_infobar) | |
884 return; | |
885 | |
886 hung_renderer_infobar->delegate() | |
887 ->AsHungRendererInfoBarDelegate() | |
888 ->OnRendererResponsive(); | |
889 infobar_service->RemoveInfoBar(hung_renderer_infobar); | |
890 } | |
891 | |
845 namespace { | 892 namespace { |
846 | 893 |
847 class ChromeInterceptNavigationDelegate : public InterceptNavigationDelegate { | 894 class ChromeInterceptNavigationDelegate : public InterceptNavigationDelegate { |
848 public: | 895 public: |
849 ChromeInterceptNavigationDelegate(JNIEnv* env, jobject jdelegate) | 896 ChromeInterceptNavigationDelegate(JNIEnv* env, jobject jdelegate) |
850 : InterceptNavigationDelegate(env, jdelegate) {} | 897 : InterceptNavigationDelegate(env, jdelegate) {} |
851 | 898 |
852 bool ShouldIgnoreNavigation( | 899 bool ShouldIgnoreNavigation( |
853 const NavigationParams& navigation_params) override { | 900 const NavigationParams& navigation_params) override { |
854 NavigationParams chrome_navigation_params(navigation_params); | 901 NavigationParams chrome_navigation_params(navigation_params); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
928 // s^{n+1} / s^{n} = 2100 / 2000 | 975 // s^{n+1} / s^{n} = 2100 / 2000 |
929 // s = 1.05 | 976 // s = 1.05 |
930 // s^b = 60000 | 977 // s^b = 60000 |
931 // b = ln(60000) / ln(1.05) ~= 225 | 978 // b = ln(60000) / ln(1.05) ~= 225 |
932 UMA_HISTOGRAM_CUSTOM_TIMES("Startup.FirstCommitNavigationTime", | 979 UMA_HISTOGRAM_CUSTOM_TIMES("Startup.FirstCommitNavigationTime", |
933 base::Time::Now() - chrome::android::GetMainEntryPointTime(), | 980 base::Time::Now() - chrome::android::GetMainEntryPointTime(), |
934 base::TimeDelta::FromMilliseconds(1), | 981 base::TimeDelta::FromMilliseconds(1), |
935 base::TimeDelta::FromMinutes(1), | 982 base::TimeDelta::FromMinutes(1), |
936 225); | 983 225); |
937 } | 984 } |
OLD | NEW |