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/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 #include "content/browser/tab_contents/tab_contents_observer.h" | 86 #include "content/browser/tab_contents/tab_contents_observer.h" |
87 #include "content/browser/tab_contents/tab_contents_view.h" | 87 #include "content/browser/tab_contents/tab_contents_view.h" |
88 #include "content/browser/webui/web_ui.h" | 88 #include "content/browser/webui/web_ui.h" |
89 #include "content/common/navigation_types.h" | 89 #include "content/common/navigation_types.h" |
90 #include "content/common/notification_service.h" | 90 #include "content/common/notification_service.h" |
91 #include "net/base/net_util.h" | 91 #include "net/base/net_util.h" |
92 #include "net/base/registry_controlled_domain.h" | 92 #include "net/base/registry_controlled_domain.h" |
93 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 93 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
94 #include "ui/base/resource/resource_bundle.h" | 94 #include "ui/base/resource/resource_bundle.h" |
95 #include "ui/gfx/codec/png_codec.h" | 95 #include "ui/gfx/codec/png_codec.h" |
96 #include "ui/gfx/favicon_size.h" | |
sky
2011/03/28 15:02:58
Is this include needed?
michaelbai
2011/03/29 00:00:50
Done.
| |
96 #include "webkit/glue/password_form.h" | 97 #include "webkit/glue/password_form.h" |
97 #include "webkit/glue/webpreferences.h" | 98 #include "webkit/glue/webpreferences.h" |
98 | 99 |
99 #if defined(OS_MACOSX) | 100 #if defined(OS_MACOSX) |
100 #include "app/surface/io_surface_support_mac.h" | 101 #include "app/surface/io_surface_support_mac.h" |
101 #endif // defined(OS_MACOSX) | 102 #endif // defined(OS_MACOSX) |
102 | 103 |
103 #if defined(OS_CHROMEOS) | 104 #if defined(OS_CHROMEOS) |
104 #include "chrome/browser/chromeos/locale_change_guard.h" | 105 #include "chrome/browser/chromeos/locale_change_guard.h" |
105 #endif // defined(OS_CHROMEOS) | 106 #endif // defined(OS_CHROMEOS) |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 } | 383 } |
383 | 384 |
384 FOR_EACH_OBSERVER(TabContentsObserver, observers_, TabContentsDestroyed()); | 385 FOR_EACH_OBSERVER(TabContentsObserver, observers_, TabContentsDestroyed()); |
385 | 386 |
386 net::NetworkChangeNotifier::RemoveOnlineStateObserver(this); | 387 net::NetworkChangeNotifier::RemoveOnlineStateObserver(this); |
387 } | 388 } |
388 | 389 |
389 void TabContents::AddObservers() { | 390 void TabContents::AddObservers() { |
390 printing_.reset(new printing::PrintViewManager(this)); | 391 printing_.reset(new printing::PrintViewManager(this)); |
391 print_preview_.reset(new printing::PrintPreviewMessageHandler(this)); | 392 print_preview_.reset(new printing::PrintPreviewMessageHandler(this)); |
392 favicon_helper_.reset(new FaviconHelper(this)); | 393 favicon_helper_.reset(new FaviconHelper(this, FaviconHelper::FAVICON)); |
394 | |
395 if (browser_defaults::kEnableTouchIcon) { | |
sky
2011/03/28 15:02:58
no {}
michaelbai
2011/03/29 00:00:50
Done.
| |
396 touch_icon_helper_.reset(new FaviconHelper(this, FaviconHelper::TOUCH)); | |
397 } | |
398 | |
393 autofill_manager_.reset(new AutofillManager(this)); | 399 autofill_manager_.reset(new AutofillManager(this)); |
394 autocomplete_history_manager_.reset(new AutocompleteHistoryManager(this)); | 400 autocomplete_history_manager_.reset(new AutocompleteHistoryManager(this)); |
395 desktop_notification_handler_.reset( | 401 desktop_notification_handler_.reset( |
396 new DesktopNotificationHandlerForTC(this, GetRenderProcessHost())); | 402 new DesktopNotificationHandlerForTC(this, GetRenderProcessHost())); |
397 plugin_observer_.reset(new PluginObserver(this)); | 403 plugin_observer_.reset(new PluginObserver(this)); |
398 safebrowsing_detection_host_.reset(new safe_browsing::ClientSideDetectionHost( | 404 safebrowsing_detection_host_.reset(new safe_browsing::ClientSideDetectionHost( |
399 this)); | 405 this)); |
400 net::NetworkChangeNotifier::AddOnlineStateObserver(this); | 406 net::NetworkChangeNotifier::AddOnlineStateObserver(this); |
401 } | 407 } |
402 | 408 |
(...skipping 29 matching lines...) Expand all Loading... | |
432 IPC_MESSAGE_HANDLER(ViewHostMsg_GoToEntryAtOffset, OnGoToEntryAtOffset) | 438 IPC_MESSAGE_HANDLER(ViewHostMsg_GoToEntryAtOffset, OnGoToEntryAtOffset) |
433 IPC_MESSAGE_HANDLER(ViewHostMsg_DidGetApplicationInfo, | 439 IPC_MESSAGE_HANDLER(ViewHostMsg_DidGetApplicationInfo, |
434 OnDidGetApplicationInfo) | 440 OnDidGetApplicationInfo) |
435 IPC_MESSAGE_HANDLER(ViewHostMsg_InstallApplication, | 441 IPC_MESSAGE_HANDLER(ViewHostMsg_InstallApplication, |
436 OnInstallApplication) | 442 OnInstallApplication) |
437 IPC_MESSAGE_HANDLER(ViewHostMsg_PageContents, OnPageContents) | 443 IPC_MESSAGE_HANDLER(ViewHostMsg_PageContents, OnPageContents) |
438 IPC_MESSAGE_HANDLER(ViewHostMsg_PageTranslated, OnPageTranslated) | 444 IPC_MESSAGE_HANDLER(ViewHostMsg_PageTranslated, OnPageTranslated) |
439 IPC_MESSAGE_HANDLER(ViewHostMsg_SetSuggestions, OnSetSuggestions) | 445 IPC_MESSAGE_HANDLER(ViewHostMsg_SetSuggestions, OnSetSuggestions) |
440 IPC_MESSAGE_HANDLER(ViewHostMsg_InstantSupportDetermined, | 446 IPC_MESSAGE_HANDLER(ViewHostMsg_InstantSupportDetermined, |
441 OnInstantSupportDetermined) | 447 OnInstantSupportDetermined) |
448 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) | |
442 IPC_MESSAGE_UNHANDLED(handled = false) | 449 IPC_MESSAGE_UNHANDLED(handled = false) |
443 IPC_END_MESSAGE_MAP_EX() | 450 IPC_END_MESSAGE_MAP_EX() |
444 | 451 |
445 if (!message_is_ok) { | 452 if (!message_is_ok) { |
446 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); | 453 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); |
447 GetRenderProcessHost()->ReceivedBadMessage(); | 454 GetRenderProcessHost()->ReceivedBadMessage(); |
448 } | 455 } |
449 | 456 |
450 return handled; | 457 return handled; |
451 } | 458 } |
(...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1663 // page. | 1670 // page. |
1664 UpdateTargetURL(details.entry->page_id(), GURL()); | 1671 UpdateTargetURL(details.entry->page_id(), GURL()); |
1665 } | 1672 } |
1666 | 1673 |
1667 // Allow the new page to set the title again. | 1674 // Allow the new page to set the title again. |
1668 received_page_title_ = false; | 1675 received_page_title_ = false; |
1669 | 1676 |
1670 // Get the favicon, either from history or request it from the net. | 1677 // Get the favicon, either from history or request it from the net. |
1671 favicon_helper_->FetchFavicon(details.entry->url()); | 1678 favicon_helper_->FetchFavicon(details.entry->url()); |
1672 | 1679 |
1680 if (touch_icon_helper_.get()) | |
1681 touch_icon_helper_->FetchFavicon(details.entry->url()); | |
1682 | |
1673 // Clear all page actions, blocked content notifications and browser actions | 1683 // Clear all page actions, blocked content notifications and browser actions |
1674 // for this tab, unless this is an in-page navigation. | 1684 // for this tab, unless this is an in-page navigation. |
1675 if (!details.is_in_page) { | 1685 if (!details.is_in_page) { |
1676 ExtensionService* service = profile()->GetExtensionService(); | 1686 ExtensionService* service = profile()->GetExtensionService(); |
1677 if (service) { | 1687 if (service) { |
1678 for (size_t i = 0; i < service->extensions()->size(); ++i) { | 1688 for (size_t i = 0; i < service->extensions()->size(); ++i) { |
1679 ExtensionAction* browser_action = | 1689 ExtensionAction* browser_action = |
1680 service->extensions()->at(i)->browser_action(); | 1690 service->extensions()->at(i)->browser_action(); |
1681 if (browser_action) { | 1691 if (browser_action) { |
1682 browser_action->ClearAllValuesForTab(controller().session_id().id()); | 1692 browser_action->ClearAllValuesForTab(controller().session_id().id()); |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1969 InstantCompleteBehavior behavior) { | 1979 InstantCompleteBehavior behavior) { |
1970 if (delegate()) | 1980 if (delegate()) |
1971 delegate()->OnSetSuggestions(page_id, suggestions, behavior); | 1981 delegate()->OnSetSuggestions(page_id, suggestions, behavior); |
1972 } | 1982 } |
1973 | 1983 |
1974 void TabContents::OnInstantSupportDetermined(int32 page_id, bool result) { | 1984 void TabContents::OnInstantSupportDetermined(int32 page_id, bool result) { |
1975 if (delegate()) | 1985 if (delegate()) |
1976 delegate()->OnInstantSupportDetermined(page_id, result); | 1986 delegate()->OnInstantSupportDetermined(page_id, result); |
1977 } | 1987 } |
1978 | 1988 |
1989 void TabContents::OnUpdateFaviconURL( | |
1990 int32 page_id, | |
1991 const std::vector<FaviconURL>& candidates) { | |
1992 favicon_helper().OnUpdateFaviconURL(page_id, candidates); | |
1993 if (touch_icon_helper_.get()) | |
1994 touch_icon_helper_->OnUpdateFaviconURL(page_id, candidates); | |
1995 } | |
1996 | |
1979 void TabContents::OnContentSettingsAccessed(bool content_was_blocked) { | 1997 void TabContents::OnContentSettingsAccessed(bool content_was_blocked) { |
1980 if (delegate_) | 1998 if (delegate_) |
1981 delegate_->OnContentSettingsChange(this); | 1999 delegate_->OnContentSettingsChange(this); |
1982 } | 2000 } |
1983 | 2001 |
1984 RenderViewHostDelegate::View* TabContents::GetViewDelegate() { | 2002 RenderViewHostDelegate::View* TabContents::GetViewDelegate() { |
1985 return view_.get(); | 2003 return view_.get(); |
1986 } | 2004 } |
1987 | 2005 |
1988 RenderViewHostDelegate::RendererManagement* | 2006 RenderViewHostDelegate::RendererManagement* |
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2818 | 2836 |
2819 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 2837 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
2820 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); | 2838 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); |
2821 rwh_view->SetSize(view()->GetContainerSize()); | 2839 rwh_view->SetSize(view()->GetContainerSize()); |
2822 } | 2840 } |
2823 | 2841 |
2824 void TabContents::OnOnlineStateChanged(bool online) { | 2842 void TabContents::OnOnlineStateChanged(bool online) { |
2825 render_view_host()->Send(new ViewMsg_NetworkStateChanged( | 2843 render_view_host()->Send(new ViewMsg_NetworkStateChanged( |
2826 render_view_host()->routing_id(), online)); | 2844 render_view_host()->routing_id(), online)); |
2827 } | 2845 } |
OLD | NEW |