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

Side by Side Diff: chrome/browser/ui/tab_contents/core_tab_helper.cc

Issue 2874833002: Don't compile code for desktop zoom or GuestViews on mobile platforms. (Closed)
Patch Set: Rebase. Created 3 years, 7 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/ui/prefs/prefs_tab_helper.cc ('k') | chrome/common/pref_names.h » ('j') | 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/ui/tab_contents/core_tab_helper.h" 5 #include "chrome/browser/ui/tab_contents/core_tab_helper.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/metrics/histogram_macros.h" 13 #include "base/metrics/histogram_macros.h"
14 #include "base/profiler/scoped_tracker.h" 14 #include "base/profiler/scoped_tracker.h"
15 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
16 #include "build/build_config.h" 16 #include "build/build_config.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/search_engines/template_url_service_factory.h" 18 #include "chrome/browser/search_engines/template_url_service_factory.h"
19 #include "chrome/browser/ui/browser_command_controller.h" 19 #include "chrome/browser/ui/browser_command_controller.h"
20 #include "chrome/browser/ui/browser_finder.h" 20 #include "chrome/browser/ui/browser_finder.h"
21 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
22 #include "chrome/common/render_messages.h" 22 #include "chrome/common/render_messages.h"
23 #include "chrome/common/thumbnail_capturer.mojom.h" 23 #include "chrome/common/thumbnail_capturer.mojom.h"
24 #include "chrome/grit/generated_resources.h" 24 #include "chrome/grit/generated_resources.h"
25 #include "components/guest_view/browser/guest_view_manager.h"
26 #include "components/search_engines/template_url.h" 25 #include "components/search_engines/template_url.h"
27 #include "components/search_engines/template_url_service.h" 26 #include "components/search_engines/template_url_service.h"
28 #include "components/strings/grit/components_strings.h" 27 #include "components/strings/grit/components_strings.h"
29 #include "components/web_cache/browser/web_cache_manager.h" 28 #include "components/web_cache/browser/web_cache_manager.h"
30 #include "content/public/browser/navigation_controller.h" 29 #include "content/public/browser/navigation_controller.h"
31 #include "content/public/browser/navigation_entry.h" 30 #include "content/public/browser/navigation_entry.h"
32 #include "content/public/browser/render_frame_host.h" 31 #include "content/public/browser/render_frame_host.h"
33 #include "content/public/browser/render_process_host.h" 32 #include "content/public/browser/render_process_host.h"
34 #include "content/public/browser/render_view_host.h" 33 #include "content/public/browser/render_view_host.h"
35 #include "content/public/browser/web_contents.h" 34 #include "content/public/browser/web_contents.h"
36 #include "content/public/common/content_switches.h" 35 #include "content/public/common/content_switches.h"
37 #include "content/public/common/context_menu_params.h" 36 #include "content/public/common/context_menu_params.h"
38 #include "net/base/load_states.h" 37 #include "net/base/load_states.h"
39 #include "net/http/http_request_headers.h" 38 #include "net/http/http_request_headers.h"
40 #include "services/service_manager/public/cpp/interface_provider.h" 39 #include "services/service_manager/public/cpp/interface_provider.h"
41 #include "ui/base/l10n/l10n_util.h" 40 #include "ui/base/l10n/l10n_util.h"
42 41
43 #if !defined(OS_ANDROID) 42 #if !defined(OS_ANDROID)
44 #include "chrome/browser/ui/browser.h" 43 #include "chrome/browser/ui/browser.h"
45 #endif 44 #endif
46 45
46 #if BUILDFLAG(ENABLE_EXTENSIONS)
47 #include "components/guest_view/browser/guest_view_manager.h"
48 #endif
49
47 using content::WebContents; 50 using content::WebContents;
48 51
49 namespace { 52 namespace {
50 53
51 const int kImageSearchThumbnailMinSize = 300 * 300; 54 const int kImageSearchThumbnailMinSize = 300 * 300;
52 const int kImageSearchThumbnailMaxWidth = 600; 55 const int kImageSearchThumbnailMaxWidth = 600;
53 const int kImageSearchThumbnailMaxHeight = 600; 56 const int kImageSearchThumbnailMaxHeight = 600;
54 57
55 } // namespace 58 } // namespace
56 59
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 } 125 }
123 126
124 // static 127 // static
125 bool CoreTabHelper::GetStatusTextForWebContents( 128 bool CoreTabHelper::GetStatusTextForWebContents(
126 base::string16* status_text, content::WebContents* source) { 129 base::string16* status_text, content::WebContents* source) {
127 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/467185 is 130 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/467185 is
128 // fixed. 131 // fixed.
129 tracked_objects::ScopedTracker tracking_profile1( 132 tracked_objects::ScopedTracker tracking_profile1(
130 FROM_HERE_WITH_EXPLICIT_FUNCTION( 133 FROM_HERE_WITH_EXPLICIT_FUNCTION(
131 "467185 CoreTabHelper::GetStatusTextForWebContents1")); 134 "467185 CoreTabHelper::GetStatusTextForWebContents1"));
135 #if BUILDFLAG(ENABLE_EXTENSIONS)
132 auto* guest_manager = guest_view::GuestViewManager::FromBrowserContext( 136 auto* guest_manager = guest_view::GuestViewManager::FromBrowserContext(
133 source->GetBrowserContext()); 137 source->GetBrowserContext());
138 #endif // BUILDFLAG(ENABLE_EXTENSIONS)
134 if (!source->IsLoading() || 139 if (!source->IsLoading() ||
135 source->GetLoadState().state == net::LOAD_STATE_IDLE) { 140 source->GetLoadState().state == net::LOAD_STATE_IDLE) {
141 #if BUILDFLAG(ENABLE_EXTENSIONS)
136 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/467185 142 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/467185
137 // is fixed. 143 // is fixed.
138 tracked_objects::ScopedTracker tracking_profile2( 144 tracked_objects::ScopedTracker tracking_profile2(
139 FROM_HERE_WITH_EXPLICIT_FUNCTION( 145 FROM_HERE_WITH_EXPLICIT_FUNCTION(
140 "467185 CoreTabHelper::GetStatusTextForWebContents2")); 146 "467185 CoreTabHelper::GetStatusTextForWebContents2"));
141 if (!guest_manager) 147 if (!guest_manager)
142 return false; 148 return false;
143 return guest_manager->ForEachGuest( 149 return guest_manager->ForEachGuest(
144 source, base::Bind(&CoreTabHelper::GetStatusTextForWebContents, 150 source, base::Bind(&CoreTabHelper::GetStatusTextForWebContents,
145 status_text)); 151 status_text));
152 #else // !BUILDFLAG(ENABLE_EXTENSIONS)
153 return false;
154 #endif // BUILDFLAG(ENABLE_EXTENSIONS)
146 } 155 }
147 156
148 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/467185 157 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/467185
149 // is fixed. 158 // is fixed.
150 tracked_objects::ScopedTracker tracking_profile3( 159 tracked_objects::ScopedTracker tracking_profile3(
151 FROM_HERE_WITH_EXPLICIT_FUNCTION( 160 FROM_HERE_WITH_EXPLICIT_FUNCTION(
152 "467185 CoreTabHelper::GetStatusTextForWebContents3")); 161 "467185 CoreTabHelper::GetStatusTextForWebContents3"));
153 162
154 switch (source->GetLoadState().state) { 163 switch (source->GetLoadState().state) {
155 case net::LOAD_STATE_WAITING_FOR_STALLED_SOCKET_POOL: 164 case net::LOAD_STATE_WAITING_FOR_STALLED_SOCKET_POOL:
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 source->GetLoadStateHost()); 228 source->GetLoadStateHost());
220 return true; 229 return true;
221 case net::LOAD_STATE_THROTTLED: 230 case net::LOAD_STATE_THROTTLED:
222 *status_text = l10n_util::GetStringUTF16(IDS_LOAD_STATE_THROTTLED); 231 *status_text = l10n_util::GetStringUTF16(IDS_LOAD_STATE_THROTTLED);
223 return true; 232 return true;
224 // Ignore net::LOAD_STATE_READING_RESPONSE and net::LOAD_STATE_IDLE 233 // Ignore net::LOAD_STATE_READING_RESPONSE and net::LOAD_STATE_IDLE
225 case net::LOAD_STATE_IDLE: 234 case net::LOAD_STATE_IDLE:
226 case net::LOAD_STATE_READING_RESPONSE: 235 case net::LOAD_STATE_READING_RESPONSE:
227 break; 236 break;
228 } 237 }
238 #if BUILDFLAG(ENABLE_EXTENSIONS)
229 if (!guest_manager) 239 if (!guest_manager)
230 return false; 240 return false;
231 241
232 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/467185 is 242 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/467185 is
233 // fixed. 243 // fixed.
234 tracked_objects::ScopedTracker tracking_profile4( 244 tracked_objects::ScopedTracker tracking_profile4(
235 FROM_HERE_WITH_EXPLICIT_FUNCTION( 245 FROM_HERE_WITH_EXPLICIT_FUNCTION(
236 "467185 CoreTabHelper::GetStatusTextForWebContents4")); 246 "467185 CoreTabHelper::GetStatusTextForWebContents4"));
237 return guest_manager->ForEachGuest( 247 return guest_manager->ForEachGuest(
238 source, base::Bind(&CoreTabHelper::GetStatusTextForWebContents, 248 source, base::Bind(&CoreTabHelper::GetStatusTextForWebContents,
239 status_text)); 249 status_text));
250 #else // !BUILDFLAG(ENABLE_EXTENSIONS)
251 return false;
252 #endif // BUILDFLAG(ENABLE_EXTENSIONS)
240 } 253 }
241 254
242 //////////////////////////////////////////////////////////////////////////////// 255 ////////////////////////////////////////////////////////////////////////////////
243 // WebContentsObserver overrides 256 // WebContentsObserver overrides
244 257
245 void CoreTabHelper::DidStartLoading() { 258 void CoreTabHelper::DidStartLoading() {
246 UpdateContentRestrictions(0); 259 UpdateContentRestrictions(0);
247 } 260 }
248 261
249 void CoreTabHelper::WasShown() { 262 void CoreTabHelper::WasShown() {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 DCHECK(!content_type.empty()); 346 DCHECK(!content_type.empty());
334 open_url_params.uses_post = true; 347 open_url_params.uses_post = true;
335 open_url_params.post_data = content::ResourceRequestBody::CreateFromBytes( 348 open_url_params.post_data = content::ResourceRequestBody::CreateFromBytes(
336 post_data.data(), post_data.size()); 349 post_data.data(), post_data.size());
337 open_url_params.extra_headers += base::StringPrintf( 350 open_url_params.extra_headers += base::StringPrintf(
338 "%s: %s\r\n", net::HttpRequestHeaders::kContentType, 351 "%s: %s\r\n", net::HttpRequestHeaders::kContentType,
339 content_type.c_str()); 352 content_type.c_str());
340 } 353 }
341 web_contents()->OpenURL(open_url_params); 354 web_contents()->OpenURL(open_url_params);
342 } 355 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/prefs/prefs_tab_helper.cc ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698