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

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

Issue 6336012: Get rid of RenderViewHostDelegate::BrowserIntegration since it was unnecessar... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/tab_contents/tab_contents.h" 5 #include "chrome/browser/tab_contents/tab_contents.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 OnDidDisplayInsecureContent) 613 OnDidDisplayInsecureContent)
614 IPC_MESSAGE_HANDLER(ViewHostMsg_DidRunInsecureContent, 614 IPC_MESSAGE_HANDLER(ViewHostMsg_DidRunInsecureContent,
615 OnDidRunInsecureContent) 615 OnDidRunInsecureContent)
616 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentLoadedInFrame, 616 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentLoadedInFrame,
617 OnDocumentLoadedInFrame) 617 OnDocumentLoadedInFrame)
618 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFinishLoad, OnDidFinishLoad) 618 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFinishLoad, OnDidFinishLoad)
619 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateContentRestrictions, 619 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateContentRestrictions,
620 OnUpdateContentRestrictions) 620 OnUpdateContentRestrictions)
621 IPC_MESSAGE_HANDLER(ViewHostMsg_PDFHasUnsupportedFeature, 621 IPC_MESSAGE_HANDLER(ViewHostMsg_PDFHasUnsupportedFeature,
622 OnPDFHasUnsupportedFeature) 622 OnPDFHasUnsupportedFeature)
623 IPC_MESSAGE_HANDLER(ViewHostMsg_Find_Reply, OnFindReply)
624 IPC_MESSAGE_HANDLER(ViewHostMsg_GoToEntryAtOffset, OnGoToEntryAtOffset)
625 IPC_MESSAGE_HANDLER(ViewHostMsg_MissingPluginStatus, OnMissingPluginStatus)
626 IPC_MESSAGE_HANDLER(ViewHostMsg_CrashedPlugin, OnCrashedPlugin)
627 IPC_MESSAGE_HANDLER(ViewHostMsg_BlockedOutdatedPlugin,
628 OnBlockedOutdatedPlugin)
629 IPC_MESSAGE_HANDLER(ViewHostMsg_DidGetApplicationInfo,
630 OnDidGetApplicationInfo)
631 IPC_MESSAGE_HANDLER(ViewHostMsg_InstallApplication,
632 OnInstallApplication)
633 IPC_MESSAGE_HANDLER(ViewHostMsg_PageContents, OnPageContents)
634 IPC_MESSAGE_HANDLER(ViewHostMsg_PageTranslated, OnPageTranslated)
635 IPC_MESSAGE_HANDLER(ViewHostMsg_SetSuggestions, OnSetSuggestions)
636 IPC_MESSAGE_HANDLER(ViewHostMsg_InstantSupportDetermined,
637 OnInstantSupportDetermined)
623 IPC_MESSAGE_UNHANDLED(handled = false) 638 IPC_MESSAGE_UNHANDLED(handled = false)
624 IPC_END_MESSAGE_MAP_EX() 639 IPC_END_MESSAGE_MAP_EX()
625 640
626 if (!message_is_ok) { 641 if (!message_is_ok) {
627 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); 642 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVD"));
628 GetRenderProcessHost()->ReceivedBadMessage(); 643 GetRenderProcessHost()->ReceivedBadMessage();
629 } 644 }
630 645
631 return handled; 646 return handled;
632 } 647 }
(...skipping 1601 matching lines...) Expand 10 before | Expand all | Expand 10 after
2234 // or the favicon url wasn't obtained before the load started. This assumes 2249 // or the favicon url wasn't obtained before the load started. This assumes
2235 // the later. 2250 // the later.
2236 // TODO(sky): Need a way to set the favicon that doesn't involve generating 2251 // TODO(sky): Need a way to set the favicon that doesn't involve generating
2237 // its url. 2252 // its url.
2238 new_url->SetFavIconURL(TemplateURL::GenerateFaviconURL(params.referrer)); 2253 new_url->SetFavIconURL(TemplateURL::GenerateFaviconURL(params.referrer));
2239 } 2254 }
2240 new_url->set_safe_for_autoreplace(true); 2255 new_url->set_safe_for_autoreplace(true);
2241 url_model->Add(new_url); 2256 url_model->Add(new_url);
2242 } 2257 }
2243 2258
2244 void TabContents::OnUserGesture() {
2245 // See comment in RenderViewHostDelegate::OnUserGesture as to why we do this.
2246 DownloadRequestLimiter* limiter =
2247 g_browser_process->download_request_limiter();
2248 if (limiter)
2249 limiter->OnUserGesture(this);
2250 ExternalProtocolHandler::PermitLaunchUrl();
2251 }
2252
2253 void TabContents::OnFindReply(int request_id, 2259 void TabContents::OnFindReply(int request_id,
2254 int number_of_matches, 2260 int number_of_matches,
2255 const gfx::Rect& selection_rect, 2261 const gfx::Rect& selection_rect,
2256 int active_match_ordinal, 2262 int active_match_ordinal,
2257 bool final_update) { 2263 bool final_update) {
2258 // Ignore responses for requests that have been aborted. 2264 // Ignore responses for requests that have been aborted.
2259 if (find_op_aborted_)
2260 return;
2261
2262 // Ignore responses for requests other than the one we have most recently 2265 // Ignore responses for requests other than the one we have most recently
2263 // issued. That way we won't act on stale results when the user has 2266 // issued. That way we won't act on stale results when the user has
2264 // already typed in another query. 2267 // already typed in another query.
2265 if (request_id != current_find_request_id_) 2268 if (!find_op_aborted_ && request_id == current_find_request_id_) {
2266 return; 2269 if (number_of_matches == -1)
2270 number_of_matches = last_search_result_.number_of_matches();
2271 if (active_match_ordinal == -1)
2272 active_match_ordinal = last_search_result_.active_match_ordinal();
2267 2273
2268 if (number_of_matches == -1) 2274 gfx::Rect selection = selection_rect;
2269 number_of_matches = last_search_result_.number_of_matches(); 2275 if (selection.IsEmpty())
2270 if (active_match_ordinal == -1) 2276 selection = last_search_result_.selection_rect();
2271 active_match_ordinal = last_search_result_.active_match_ordinal();
2272 2277
2273 gfx::Rect selection = selection_rect; 2278 // Notify the UI, automation and any other observers that a find result was
2274 if (selection.IsEmpty()) 2279 // found.
2275 selection = last_search_result_.selection_rect(); 2280 last_search_result_ = FindNotificationDetails(
2281 request_id, number_of_matches, selection, active_match_ordinal,
2282 final_update);
2283 NotificationService::current()->Notify(
2284 NotificationType::FIND_RESULT_AVAILABLE,
2285 Source<TabContents>(this),
2286 Details<FindNotificationDetails>(&last_search_result_));
2287 }
2276 2288
2277 // Notify the UI, automation and any other observers that a find result was 2289 // Send a notification to the renderer that we are ready to receive more
2278 // found. 2290 // results from the scoping effort of the Find operation. The FindInPage
2279 last_search_result_ = FindNotificationDetails(request_id, number_of_matches, 2291 // scoping is asynchronous and periodically sends results back up to the
2280 selection, active_match_ordinal, 2292 // browser using IPC. In an effort to not spam the browser we have the
2281 final_update); 2293 // browser send an ACK for each FindReply message and have the renderer
2282 NotificationService::current()->Notify( 2294 // queue up the latest status message while waiting for this ACK.
2283 NotificationType::FIND_RESULT_AVAILABLE, 2295 render_view_host()->Send(new ViewMsg_FindReplyACK(
2284 Source<TabContents>(this), 2296 render_view_host()->routing_id()));
2285 Details<FindNotificationDetails>(&last_search_result_));
2286 } 2297 }
2287 2298
2288 void TabContents::GoToEntryAtOffset(int offset) { 2299 void TabContents::OnGoToEntryAtOffset(int offset) {
2289 if (!delegate_ || delegate_->OnGoToEntryOffset(offset)) { 2300 if (!delegate_ || delegate_->OnGoToEntryOffset(offset)) {
2290 NavigationEntry* entry = controller_.GetEntryAtOffset(offset); 2301 NavigationEntry* entry = controller_.GetEntryAtOffset(offset);
2291 if (!entry) 2302 if (!entry)
2292 return; 2303 return;
2293 // Note that we don't call NavigationController::GotToOffset() as we don't 2304 // Note that we don't call NavigationController::GotToOffset() as we don't
2294 // want to create a pending navigation entry (it might end up lingering 2305 // want to create a pending navigation entry (it might end up lingering
2295 // http://crbug.com/51680). 2306 // http://crbug.com/51680).
2296 entry->set_transition_type(entry->transition_type() | 2307 entry->set_transition_type(entry->transition_type() |
2297 PageTransition::FORWARD_BACK); 2308 PageTransition::FORWARD_BACK);
2298 NavigateToEntry(*entry, NavigationController::NO_RELOAD); 2309 NavigateToEntry(*entry, NavigationController::NO_RELOAD);
(...skipping 24 matching lines...) Expand all
2323 plugin_name.erase(plugin_name.length() - plugin_extension.length()); 2334 plugin_name.erase(plugin_name.length() - plugin_extension.length());
2324 #endif // OS_MACOSX 2335 #endif // OS_MACOSX
2325 } 2336 }
2326 SkBitmap* crash_icon = ResourceBundle::GetSharedInstance().GetBitmapNamed( 2337 SkBitmap* crash_icon = ResourceBundle::GetSharedInstance().GetBitmapNamed(
2327 IDR_INFOBAR_PLUGIN_CRASHED); 2338 IDR_INFOBAR_PLUGIN_CRASHED);
2328 AddInfoBar(new SimpleAlertInfoBarDelegate(this, crash_icon, 2339 AddInfoBar(new SimpleAlertInfoBarDelegate(this, crash_icon,
2329 l10n_util::GetStringFUTF16(IDS_PLUGIN_CRASHED_PROMPT, 2340 l10n_util::GetStringFUTF16(IDS_PLUGIN_CRASHED_PROMPT,
2330 WideToUTF16Hack(plugin_name)), true)); 2341 WideToUTF16Hack(plugin_name)), true));
2331 } 2342 }
2332 2343
2333 void TabContents::OnCrashedWorker() {
2334 AddInfoBar(new SimpleAlertInfoBarDelegate(this, NULL,
2335 l10n_util::GetStringUTF16(IDS_WEBWORKER_CRASHED_PROMPT), true));
2336 }
2337
2338 void TabContents::OnDidGetApplicationInfo(int32 page_id, 2344 void TabContents::OnDidGetApplicationInfo(int32 page_id,
2339 const WebApplicationInfo& info) { 2345 const WebApplicationInfo& info) {
2340 web_app_info_ = info; 2346 web_app_info_ = info;
2341 2347
2342 if (delegate()) 2348 if (delegate())
2343 delegate()->OnDidGetApplicationInfo(this, page_id); 2349 delegate()->OnDidGetApplicationInfo(this, page_id);
2344 } 2350 }
2345 2351
2346 void TabContents::OnInstallApplication(const WebApplicationInfo& info) { 2352 void TabContents::OnInstallApplication(const WebApplicationInfo& info) {
2347 if (delegate()) 2353 if (delegate())
2348 delegate()->OnInstallApplication(this, info); 2354 delegate()->OnInstallApplication(this, info);
2349 } 2355 }
2350 2356
2351 void TabContents::OnBlockedOutdatedPlugin(const string16& name, 2357 void TabContents::OnBlockedOutdatedPlugin(const string16& name,
2352 const GURL& update_url) { 2358 const GURL& update_url) {
2353 new OutdatedPluginInfoBar(this, name, update_url); 2359 new OutdatedPluginInfoBar(this, name, update_url);
2354 } 2360 }
2355 2361
2356 void TabContents::OnPageContents(const GURL& url, 2362 void TabContents::OnPageContents(const GURL& url,
2357 int renderer_process_id,
2358 int32 page_id, 2363 int32 page_id,
2359 const string16& contents, 2364 const string16& contents,
2360 const std::string& language, 2365 const std::string& language,
2361 bool page_translatable) { 2366 bool page_translatable) {
2362 // Don't index any https pages. People generally don't want their bank 2367 // Don't index any https pages. People generally don't want their bank
2363 // accounts, etc. indexed on their computer, especially since some of these 2368 // accounts, etc. indexed on their computer, especially since some of these
2364 // things are not marked cachable. 2369 // things are not marked cachable.
2365 // TODO(brettw) we may want to consider more elaborate heuristics such as 2370 // TODO(brettw) we may want to consider more elaborate heuristics such as
2366 // the cachability of the page. We may also want to consider subframes (this 2371 // the cachability of the page. We may also want to consider subframes (this
2367 // test will still index subframes if the subframe is SSL). 2372 // test will still index subframes if the subframe is SSL).
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2425 2430
2426 RenderViewHostDelegate::View* TabContents::GetViewDelegate() { 2431 RenderViewHostDelegate::View* TabContents::GetViewDelegate() {
2427 return view_.get(); 2432 return view_.get();
2428 } 2433 }
2429 2434
2430 RenderViewHostDelegate::RendererManagement* 2435 RenderViewHostDelegate::RendererManagement*
2431 TabContents::GetRendererManagementDelegate() { 2436 TabContents::GetRendererManagementDelegate() {
2432 return &render_manager_; 2437 return &render_manager_;
2433 } 2438 }
2434 2439
2435 RenderViewHostDelegate::BrowserIntegration*
2436 TabContents::GetBrowserIntegrationDelegate() {
2437 return this;
2438 }
2439
2440 RenderViewHostDelegate::ContentSettings* 2440 RenderViewHostDelegate::ContentSettings*
2441 TabContents::GetContentSettingsDelegate() { 2441 TabContents::GetContentSettingsDelegate() {
2442 return content_settings_delegate_.get(); 2442 return content_settings_delegate_.get();
2443 } 2443 }
2444 2444
2445 RenderViewHostDelegate::Save* TabContents::GetSaveDelegate() { 2445 RenderViewHostDelegate::Save* TabContents::GetSaveDelegate() {
2446 return save_package_.get(); // May be NULL, but we can return NULL. 2446 return save_package_.get(); // May be NULL, but we can return NULL.
2447 } 2447 }
2448 2448
2449 RenderViewHostDelegate::Printing* TabContents::GetPrintingDelegate() { 2449 RenderViewHostDelegate::Printing* TabContents::GetPrintingDelegate() {
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
3046 #if defined(OS_MACOSX) 3046 #if defined(OS_MACOSX)
3047 // Disable accelerated compositing if IOSurface's are not supported, 3047 // Disable accelerated compositing if IOSurface's are not supported,
3048 // as is the case in 10.5. 3048 // as is the case in 10.5.
3049 if (!IOSurfaceSupport::Initialize()) 3049 if (!IOSurfaceSupport::Initialize())
3050 web_prefs.accelerated_compositing_enabled = false; 3050 web_prefs.accelerated_compositing_enabled = false;
3051 #endif 3051 #endif
3052 3052
3053 return web_prefs; 3053 return web_prefs;
3054 } 3054 }
3055 3055
3056 void TabContents::OnUserGesture() {
3057 // See comment in RenderViewHostDelegate::OnUserGesture as to why we do this.
3058 DownloadRequestLimiter* limiter =
3059 g_browser_process->download_request_limiter();
3060 if (limiter)
3061 limiter->OnUserGesture(this);
3062 ExternalProtocolHandler::PermitLaunchUrl();
3063 }
3064
3056 void TabContents::OnIgnoredUIEvent() { 3065 void TabContents::OnIgnoredUIEvent() {
3057 if (constrained_window_count()) { 3066 if (constrained_window_count()) {
3058 ConstrainedWindow* window = *constrained_window_begin(); 3067 ConstrainedWindow* window = *constrained_window_begin();
3059 window->FocusConstrainedWindow(); 3068 window->FocusConstrainedWindow();
3060 } 3069 }
3061 } 3070 }
3062 3071
3063 void TabContents::OnJSOutOfMemory() { 3072 void TabContents::OnJSOutOfMemory() {
3064 AddInfoBar(new SimpleAlertInfoBarDelegate(this, NULL, 3073 AddInfoBar(new SimpleAlertInfoBarDelegate(this, NULL,
3065 l10n_util::GetStringUTF16(IDS_JS_OUT_OF_MEMORY_PROMPT), true)); 3074 l10n_util::GetStringUTF16(IDS_JS_OUT_OF_MEMORY_PROMPT), true));
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
3137 } 3146 }
3138 3147
3139 void TabContents::UpdateZoomLimits(int minimum_percent, 3148 void TabContents::UpdateZoomLimits(int minimum_percent,
3140 int maximum_percent, 3149 int maximum_percent,
3141 bool remember) { 3150 bool remember) {
3142 minimum_zoom_percent_ = minimum_percent; 3151 minimum_zoom_percent_ = minimum_percent;
3143 maximum_zoom_percent_ = maximum_percent; 3152 maximum_zoom_percent_ = maximum_percent;
3144 temporary_zoom_settings_ = !remember; 3153 temporary_zoom_settings_ = !remember;
3145 } 3154 }
3146 3155
3156 void TabContents::WorkerCrashed() {
3157 AddInfoBar(new SimpleAlertInfoBarDelegate(this, NULL,
3158 l10n_util::GetStringUTF16(IDS_WEBWORKER_CRASHED_PROMPT), true));
3159 }
3160
3147 void TabContents::BeforeUnloadFiredFromRenderManager( 3161 void TabContents::BeforeUnloadFiredFromRenderManager(
3148 bool proceed, 3162 bool proceed,
3149 bool* proceed_to_fire_unload) { 3163 bool* proceed_to_fire_unload) {
3150 if (delegate()) 3164 if (delegate())
3151 delegate()->BeforeUnloadFired(this, proceed, proceed_to_fire_unload); 3165 delegate()->BeforeUnloadFired(this, proceed, proceed_to_fire_unload);
3152 } 3166 }
3153 3167
3154 void TabContents::DidStartLoadingFromRenderManager( 3168 void TabContents::DidStartLoadingFromRenderManager(
3155 RenderViewHost* render_view_host) { 3169 RenderViewHost* render_view_host) {
3156 DidStartLoading(); 3170 DidStartLoading();
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
3381 if (pm != NULL) { 3395 if (pm != NULL) {
3382 if (pm->MaybeUsePreloadedPage(this, url)) { 3396 if (pm->MaybeUsePreloadedPage(this, url)) {
3383 // TODO(tburkard): If the preloaded page has not finished preloading 3397 // TODO(tburkard): If the preloaded page has not finished preloading
3384 // yet, we should not do this. 3398 // yet, we should not do this.
3385 DidStopLoading(); 3399 DidStopLoading();
3386 return true; 3400 return true;
3387 } 3401 }
3388 } 3402 }
3389 return false; 3403 return false;
3390 } 3404 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698