Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Side by Side Diff: chrome/browser/android/tab_android.cc

Issue 1358923002: Extract TabChromeWebContentsDelegateAndroid into a separate class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@chrometab10
Patch Set: Rebase Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/android/tab_android.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
16 #include "chrome/browser/android/metrics/uma_utils.h" 15 #include "chrome/browser/android/metrics/uma_utils.h"
17 #include "chrome/browser/android/offline_pages/offline_page_bridge.h" 16 #include "chrome/browser/android/offline_pages/offline_page_bridge.h"
18 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" 17 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h"
19 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 18 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
20 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" 19 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h"
21 #include "chrome/browser/browser_about_handler.h" 20 #include "chrome/browser/browser_about_handler.h"
22 #include "chrome/browser/chrome_notification_types.h" 21 #include "chrome/browser/chrome_notification_types.h"
23 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 22 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
24 #include "chrome/browser/infobars/infobar_service.h" 23 #include "chrome/browser/infobars/infobar_service.h"
25 #include "chrome/browser/prerender/prerender_contents.h" 24 #include "chrome/browser/prerender/prerender_contents.h"
(...skipping 22 matching lines...) Expand all
48 #include "chrome/browser/ui/tab_helpers.h" 47 #include "chrome/browser/ui/tab_helpers.h"
49 #include "chrome/common/instant_types.h" 48 #include "chrome/common/instant_types.h"
50 #include "chrome/common/render_messages.h" 49 #include "chrome/common/render_messages.h"
51 #include "chrome/common/url_constants.h" 50 #include "chrome/common/url_constants.h"
52 #include "components/bookmarks/browser/bookmark_model.h" 51 #include "components/bookmarks/browser/bookmark_model.h"
53 #include "components/bookmarks/browser/bookmark_node.h" 52 #include "components/bookmarks/browser/bookmark_node.h"
54 #include "components/bookmarks/browser/bookmark_utils.h" 53 #include "components/bookmarks/browser/bookmark_utils.h"
55 #include "components/bookmarks/managed/managed_bookmark_service.h" 54 #include "components/bookmarks/managed/managed_bookmark_service.h"
56 #include "components/dom_distiller/core/url_utils.h" 55 #include "components/dom_distiller/core/url_utils.h"
57 #include "components/favicon/content/content_favicon_driver.h" 56 #include "components/favicon/content/content_favicon_driver.h"
58 #include "components/infobars/core/infobar.h"
59 #include "components/infobars/core/infobar_container.h"
60 #include "components/navigation_interception/intercept_navigation_delegate.h" 57 #include "components/navigation_interception/intercept_navigation_delegate.h"
61 #include "components/navigation_interception/navigation_params.h" 58 #include "components/navigation_interception/navigation_params.h"
62 #include "components/offline_pages/offline_page_feature.h" 59 #include "components/offline_pages/offline_page_feature.h"
63 #include "components/offline_pages/offline_page_item.h" 60 #include "components/offline_pages/offline_page_item.h"
64 #include "components/offline_pages/offline_page_model.h" 61 #include "components/offline_pages/offline_page_model.h"
65 #include "components/sessions/content/content_live_tab.h" 62 #include "components/sessions/content/content_live_tab.h"
66 #include "components/sessions/core/tab_restore_service.h" 63 #include "components/sessions/core/tab_restore_service.h"
67 #include "components/url_formatter/url_fixer.h" 64 #include "components/url_formatter/url_fixer.h"
68 #include "content/public/browser/android/compositor.h" 65 #include "content/public/browser/android/compositor.h"
69 #include "content/public/browser/android/content_view_core.h" 66 #include "content/public/browser/android/content_view_core.h"
(...skipping 27 matching lines...) Expand all
97 using content::WebContents; 94 using content::WebContents;
98 using navigation_interception::InterceptNavigationDelegate; 95 using navigation_interception::InterceptNavigationDelegate;
99 using navigation_interception::NavigationParams; 96 using navigation_interception::NavigationParams;
100 97
101 namespace { 98 namespace {
102 99
103 const int kImageSearchThumbnailMinSize = 300 * 300; 100 const int kImageSearchThumbnailMinSize = 300 * 300;
104 const int kImageSearchThumbnailMaxWidth = 600; 101 const int kImageSearchThumbnailMaxWidth = 600;
105 const int kImageSearchThumbnailMaxHeight = 600; 102 const int kImageSearchThumbnailMaxHeight = 600;
106 103
107 infobars::InfoBar* FindHungRendererInfoBar(InfoBarService* infobar_service) {
108 DCHECK(infobar_service);
109 for (size_t i = 0; i < infobar_service->infobar_count(); ++i) {
110 infobars::InfoBar* infobar = infobar_service->infobar_at(i);
111 if (infobar->delegate()->AsHungRendererInfoBarDelegate())
112 return infobar;
113 }
114 return nullptr;
115 }
116
117 } // namespace 104 } // namespace
118 105
119 TabAndroid* TabAndroid::FromWebContents(content::WebContents* web_contents) { 106 TabAndroid* TabAndroid::FromWebContents(content::WebContents* web_contents) {
120 CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(web_contents); 107 CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(web_contents);
121 if (!core_tab_helper) 108 if (!core_tab_helper)
122 return NULL; 109 return NULL;
123 110
124 CoreTabHelperDelegate* core_delegate = core_tab_helper->delegate(); 111 CoreTabHelperDelegate* core_delegate = core_tab_helper->delegate();
125 if (!core_delegate) 112 if (!core_delegate)
126 return NULL; 113 return NULL;
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 offline_pages::OfflinePageModelFactory::GetForBrowserContext( 851 offline_pages::OfflinePageModelFactory::GetForBrowserContext(
865 GetProfile()); 852 GetProfile());
866 return offline_page_model->GetPageByOfflineURL(url); 853 return offline_page_model->GetPageByOfflineURL(url);
867 } 854 }
868 855
869 bool TabAndroid::HasPrerenderedUrl(JNIEnv* env, jobject obj, jstring url) { 856 bool TabAndroid::HasPrerenderedUrl(JNIEnv* env, jobject obj, jstring url) {
870 GURL gurl(base::android::ConvertJavaStringToUTF8(env, url)); 857 GURL gurl(base::android::ConvertJavaStringToUTF8(env, url));
871 return HasPrerenderedUrl(gurl); 858 return HasPrerenderedUrl(gurl);
872 } 859 }
873 860
874 void TabAndroid::OnRendererUnresponsive(JNIEnv* env, jobject obj) {
875 InfoBarService* infobar_service =
876 InfoBarService::FromWebContents(web_contents());
877 DCHECK(!FindHungRendererInfoBar(infobar_service));
878 HungRendererInfoBarDelegate::Create(infobar_service,
879 web_contents()->GetRenderProcessHost());
880 }
881
882 void TabAndroid::OnRendererResponsive(JNIEnv* env, jobject obj) {
883 InfoBarService* infobar_service =
884 InfoBarService::FromWebContents(web_contents());
885 infobars::InfoBar* hung_renderer_infobar =
886 FindHungRendererInfoBar(infobar_service);
887 if (!hung_renderer_infobar)
888 return;
889
890 hung_renderer_infobar->delegate()
891 ->AsHungRendererInfoBarDelegate()
892 ->OnRendererResponsive();
893 infobar_service->RemoveInfoBar(hung_renderer_infobar);
894 }
895
896 namespace { 861 namespace {
897 862
898 class ChromeInterceptNavigationDelegate : public InterceptNavigationDelegate { 863 class ChromeInterceptNavigationDelegate : public InterceptNavigationDelegate {
899 public: 864 public:
900 ChromeInterceptNavigationDelegate(JNIEnv* env, jobject jdelegate) 865 ChromeInterceptNavigationDelegate(JNIEnv* env, jobject jdelegate)
901 : InterceptNavigationDelegate(env, jdelegate) {} 866 : InterceptNavigationDelegate(env, jdelegate) {}
902 867
903 bool ShouldIgnoreNavigation( 868 bool ShouldIgnoreNavigation(
904 const NavigationParams& navigation_params) override { 869 const NavigationParams& navigation_params) override {
905 NavigationParams chrome_navigation_params(navigation_params); 870 NavigationParams chrome_navigation_params(navigation_params);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 // s^{n+1} / s^{n} = 2100 / 2000 945 // s^{n+1} / s^{n} = 2100 / 2000
981 // s = 1.05 946 // s = 1.05
982 // s^b = 60000 947 // s^b = 60000
983 // b = ln(60000) / ln(1.05) ~= 225 948 // b = ln(60000) / ln(1.05) ~= 225
984 UMA_HISTOGRAM_CUSTOM_TIMES("Startup.FirstCommitNavigationTime", 949 UMA_HISTOGRAM_CUSTOM_TIMES("Startup.FirstCommitNavigationTime",
985 base::Time::Now() - chrome::android::GetMainEntryPointTime(), 950 base::Time::Now() - chrome::android::GetMainEntryPointTime(),
986 base::TimeDelta::FromMilliseconds(1), 951 base::TimeDelta::FromMilliseconds(1),
987 base::TimeDelta::FromMinutes(1), 952 base::TimeDelta::FromMinutes(1),
988 225); 953 225);
989 } 954 }
OLDNEW
« no previous file with comments | « chrome/browser/android/tab_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698