| OLD | NEW |
| 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 "content/browser/tab_contents/tab_contents.h" | 5 #include "content/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/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 UMA_HISTOGRAM_TIMES("Tab.Close", | 364 UMA_HISTOGRAM_TIMES("Tab.Close", |
| 365 base::TimeTicks::Now() - tab_close_start_time_); | 365 base::TimeTicks::Now() - tab_close_start_time_); |
| 366 } | 366 } |
| 367 | 367 |
| 368 FOR_EACH_OBSERVER(TabContentsObserver, observers_, TabContentsDestroyed()); | 368 FOR_EACH_OBSERVER(TabContentsObserver, observers_, TabContentsDestroyed()); |
| 369 | 369 |
| 370 net::NetworkChangeNotifier::RemoveOnlineStateObserver(this); | 370 net::NetworkChangeNotifier::RemoveOnlineStateObserver(this); |
| 371 } | 371 } |
| 372 | 372 |
| 373 void TabContents::AddObservers() { | 373 void TabContents::AddObservers() { |
| 374 favicon_helper_.reset(new FaviconHelper(this)); | 374 favicon_helper_.reset(new FaviconHelper(this, FaviconHelper::FAVICON)); |
| 375 if (browser_defaults::kEnableTouchIcon) |
| 376 touch_icon_helper_.reset(new FaviconHelper(this, FaviconHelper::TOUCH)); |
| 375 plugin_observer_.reset(new PluginObserver(this)); | 377 plugin_observer_.reset(new PluginObserver(this)); |
| 376 safebrowsing_detection_host_.reset(new safe_browsing::ClientSideDetectionHost( | 378 safebrowsing_detection_host_.reset(new safe_browsing::ClientSideDetectionHost( |
| 377 this)); | 379 this)); |
| 378 net::NetworkChangeNotifier::AddOnlineStateObserver(this); | 380 net::NetworkChangeNotifier::AddOnlineStateObserver(this); |
| 379 } | 381 } |
| 380 | 382 |
| 381 bool TabContents::OnMessageReceived(const IPC::Message& message) { | 383 bool TabContents::OnMessageReceived(const IPC::Message& message) { |
| 382 ObserverListBase<TabContentsObserver>::Iterator it(observers_); | 384 ObserverListBase<TabContentsObserver>::Iterator it(observers_); |
| 383 TabContentsObserver* observer; | 385 TabContentsObserver* observer; |
| 384 while ((observer = it.GetNext()) != NULL) | 386 while ((observer = it.GetNext()) != NULL) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 403 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentLoadedInFrame, | 405 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentLoadedInFrame, |
| 404 OnDocumentLoadedInFrame) | 406 OnDocumentLoadedInFrame) |
| 405 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFinishLoad, OnDidFinishLoad) | 407 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFinishLoad, OnDidFinishLoad) |
| 406 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateContentRestrictions, | 408 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateContentRestrictions, |
| 407 OnUpdateContentRestrictions) | 409 OnUpdateContentRestrictions) |
| 408 IPC_MESSAGE_HANDLER(ViewHostMsg_PDFHasUnsupportedFeature, | 410 IPC_MESSAGE_HANDLER(ViewHostMsg_PDFHasUnsupportedFeature, |
| 409 OnPDFHasUnsupportedFeature) | 411 OnPDFHasUnsupportedFeature) |
| 410 IPC_MESSAGE_HANDLER(ViewHostMsg_GoToEntryAtOffset, OnGoToEntryAtOffset) | 412 IPC_MESSAGE_HANDLER(ViewHostMsg_GoToEntryAtOffset, OnGoToEntryAtOffset) |
| 411 IPC_MESSAGE_HANDLER(ViewHostMsg_PageContents, OnPageContents) | 413 IPC_MESSAGE_HANDLER(ViewHostMsg_PageContents, OnPageContents) |
| 412 IPC_MESSAGE_HANDLER(ViewHostMsg_PageTranslated, OnPageTranslated) | 414 IPC_MESSAGE_HANDLER(ViewHostMsg_PageTranslated, OnPageTranslated) |
| 415 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) |
| 413 IPC_MESSAGE_UNHANDLED(handled = false) | 416 IPC_MESSAGE_UNHANDLED(handled = false) |
| 414 IPC_END_MESSAGE_MAP_EX() | 417 IPC_END_MESSAGE_MAP_EX() |
| 415 | 418 |
| 416 if (!message_is_ok) { | 419 if (!message_is_ok) { |
| 417 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); | 420 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); |
| 418 GetRenderProcessHost()->ReceivedBadMessage(); | 421 GetRenderProcessHost()->ReceivedBadMessage(); |
| 419 } | 422 } |
| 420 | 423 |
| 421 return handled; | 424 return handled; |
| 422 } | 425 } |
| (...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1527 // page. | 1530 // page. |
| 1528 UpdateTargetURL(details.entry->page_id(), GURL()); | 1531 UpdateTargetURL(details.entry->page_id(), GURL()); |
| 1529 } | 1532 } |
| 1530 | 1533 |
| 1531 // Allow the new page to set the title again. | 1534 // Allow the new page to set the title again. |
| 1532 received_page_title_ = false; | 1535 received_page_title_ = false; |
| 1533 | 1536 |
| 1534 // Get the favicon, either from history or request it from the net. | 1537 // Get the favicon, either from history or request it from the net. |
| 1535 favicon_helper_->FetchFavicon(details.entry->url()); | 1538 favicon_helper_->FetchFavicon(details.entry->url()); |
| 1536 | 1539 |
| 1540 if (touch_icon_helper_.get()) |
| 1541 touch_icon_helper_->FetchFavicon(details.entry->url()); |
| 1542 |
| 1537 // Clear all page actions, blocked content notifications and browser actions | 1543 // Clear all page actions, blocked content notifications and browser actions |
| 1538 // for this tab, unless this is an in-page navigation. | 1544 // for this tab, unless this is an in-page navigation. |
| 1539 if (!details.is_in_page) { | 1545 if (!details.is_in_page) { |
| 1540 // Close blocked popups. | 1546 // Close blocked popups. |
| 1541 if (blocked_contents_) { | 1547 if (blocked_contents_) { |
| 1542 AutoReset<bool> auto_reset(&dont_notify_render_view_, true); | 1548 AutoReset<bool> auto_reset(&dont_notify_render_view_, true); |
| 1543 blocked_contents_->Destroy(); | 1549 blocked_contents_->Destroy(); |
| 1544 blocked_contents_ = NULL; | 1550 blocked_contents_ = NULL; |
| 1545 } | 1551 } |
| 1546 | 1552 |
| (...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2398 | 2404 |
| 2399 void TabContents::RequestDesktopNotificationPermission( | 2405 void TabContents::RequestDesktopNotificationPermission( |
| 2400 const GURL& source_origin, int callback_context) { | 2406 const GURL& source_origin, int callback_context) { |
| 2401 DesktopNotificationService* service = | 2407 DesktopNotificationService* service = |
| 2402 profile()->GetDesktopNotificationService(); | 2408 profile()->GetDesktopNotificationService(); |
| 2403 service->RequestPermission( | 2409 service->RequestPermission( |
| 2404 source_origin, GetRenderProcessHost()->id(), | 2410 source_origin, GetRenderProcessHost()->id(), |
| 2405 render_view_host()->routing_id(), callback_context, this); | 2411 render_view_host()->routing_id(), callback_context, this); |
| 2406 } | 2412 } |
| 2407 | 2413 |
| 2414 void TabContents::OnUpdateFaviconURL( |
| 2415 int32 page_id, |
| 2416 const std::vector<FaviconURL>& candidates) { |
| 2417 favicon_helper().OnUpdateFaviconURL(page_id, candidates); |
| 2418 if (touch_icon_helper_.get()) |
| 2419 touch_icon_helper_->OnUpdateFaviconURL(page_id, candidates); |
| 2420 } |
| 2421 |
| 2408 void TabContents::BeforeUnloadFiredFromRenderManager( | 2422 void TabContents::BeforeUnloadFiredFromRenderManager( |
| 2409 bool proceed, | 2423 bool proceed, |
| 2410 bool* proceed_to_fire_unload) { | 2424 bool* proceed_to_fire_unload) { |
| 2411 if (delegate()) | 2425 if (delegate()) |
| 2412 delegate()->BeforeUnloadFired(this, proceed, proceed_to_fire_unload); | 2426 delegate()->BeforeUnloadFired(this, proceed, proceed_to_fire_unload); |
| 2413 } | 2427 } |
| 2414 | 2428 |
| 2415 void TabContents::DidStartLoadingFromRenderManager( | 2429 void TabContents::DidStartLoadingFromRenderManager( |
| 2416 RenderViewHost* render_view_host) { | 2430 RenderViewHost* render_view_host) { |
| 2417 DidStartLoading(); | 2431 DidStartLoading(); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2576 | 2590 |
| 2577 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 2591 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
| 2578 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); | 2592 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); |
| 2579 rwh_view->SetSize(view()->GetContainerSize()); | 2593 rwh_view->SetSize(view()->GetContainerSize()); |
| 2580 } | 2594 } |
| 2581 | 2595 |
| 2582 void TabContents::OnOnlineStateChanged(bool online) { | 2596 void TabContents::OnOnlineStateChanged(bool online) { |
| 2583 render_view_host()->Send(new ViewMsg_NetworkStateChanged( | 2597 render_view_host()->Send(new ViewMsg_NetworkStateChanged( |
| 2584 render_view_host()->routing_id(), online)); | 2598 render_view_host()->routing_id(), online)); |
| 2585 } | 2599 } |
| OLD | NEW |