diff options
author | Kristian Monsen <kristianm@google.com> | 2011-05-24 16:24:13 +0100 |
---|---|---|
committer | Kristian Monsen <kristianm@google.com> | 2011-05-25 14:13:32 +0100 |
commit | 3f50c38dc070f4bb515c1b64450dae14f316474e (patch) | |
tree | 29f309f9534e05c47244eedb438fc612578d133b /chrome/browser/tab_contents | |
parent | e23bef148f7be2bdf9c3cb2cd3aa5ceebf1190fb (diff) | |
download | external_chromium-3f50c38dc070f4bb515c1b64450dae14f316474e.zip external_chromium-3f50c38dc070f4bb515c1b64450dae14f316474e.tar.gz external_chromium-3f50c38dc070f4bb515c1b64450dae14f316474e.tar.bz2 |
Merge Chromium at r10.0.634.0: Initial merge by git.
Change-Id: Iac2af492818d119bcc2562eb5fdabf5ab0b6df9c
Diffstat (limited to 'chrome/browser/tab_contents')
11 files changed, 266 insertions, 256 deletions
diff --git a/chrome/browser/tab_contents/interstitial_page.cc b/chrome/browser/tab_contents/interstitial_page.cc index 8548c8d..263b67c 100644 --- a/chrome/browser/tab_contents/interstitial_page.cc +++ b/chrome/browser/tab_contents/interstitial_page.cc @@ -9,7 +9,7 @@ #include "base/compiler_specific.h" #include "base/message_loop.h" #include "base/string_util.h" -#include "base/thread.h" +#include "base/threading/thread.h" #include "base/utf_string_conversions.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/browser_process.h" diff --git a/chrome/browser/tab_contents/navigation_entry.cc b/chrome/browser/tab_contents/navigation_entry.cc index a14fc08..d5504ba 100644 --- a/chrome/browser/tab_contents/navigation_entry.cc +++ b/chrome/browser/tab_contents/navigation_entry.cc @@ -13,7 +13,6 @@ #include "chrome/browser/renderer_host/site_instance.h" #include "chrome/browser/tab_contents/navigation_controller.h" #include "chrome/common/chrome_constants.h" -#include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" #include "grit/app_resources.h" #include "net/base/net_util.h" @@ -78,7 +77,7 @@ void NavigationEntry::set_site_instance(SiteInstance* site_instance) { } const string16& NavigationEntry::GetTitleForDisplay( - const NavigationController* navigation_controller) { + const std::string& languages) { // Most pages have real titles. Don't even bother caching anything if this is // the case. if (!title_.empty()) @@ -90,12 +89,6 @@ const string16& NavigationEntry::GetTitleForDisplay( return cached_display_title_; // Use the virtual URL first if any, and fall back on using the real URL. - std::string languages; - if (navigation_controller) { - languages = navigation_controller->profile()->GetPrefs()-> - GetString(prefs::kAcceptLanguages); - } - string16 title; std::wstring elided_title; if (!virtual_url_.is_empty()) { diff --git a/chrome/browser/tab_contents/navigation_entry.h b/chrome/browser/tab_contents/navigation_entry.h index ca97e02..57d93c4 100644 --- a/chrome/browser/tab_contents/navigation_entry.h +++ b/chrome/browser/tab_contents/navigation_entry.h @@ -16,7 +16,6 @@ #include "googleurl/src/gurl.h" #include "third_party/skia/include/core/SkBitmap.h" -class NavigationController; class SiteInstance; //////////////////////////////////////////////////////////////////////////////// @@ -322,12 +321,10 @@ class NavigationEntry { // Page-related helpers ------------------------------------------------------ // Returns the title to be displayed on the tab. This could be the title of - // the page if it is available or the URL. - // - // The NavigationController corresponding to this entry must be given so we - // can get the preferences so we can optionally format a URL for display. It - // may be NULL if you don't need proper URL formatting (e.g. unit tests). - const string16& GetTitleForDisplay(const NavigationController* controller); + // the page if it is available or the URL. |languages| is the list of + // accpeted languages (e.g., prefs::kAcceptLanguages) or empty if proper + // URL formatting isn't needed (e.g., unit tests). + const string16& GetTitleForDisplay(const std::string& languages); // Returns true if the current tab is in view source mode. This will be false // if there is no navigation. diff --git a/chrome/browser/tab_contents/navigation_entry_unittest.cc b/chrome/browser/tab_contents/navigation_entry_unittest.cc index e28cf1c..014817c 100644 --- a/chrome/browser/tab_contents/navigation_entry_unittest.cc +++ b/chrome/browser/tab_contents/navigation_entry_unittest.cc @@ -53,18 +53,18 @@ TEST_F(NavigationEntryTest, NavigationEntryURLs) { EXPECT_EQ(GURL(), entry1_.get()->url()); EXPECT_EQ(GURL(), entry1_.get()->virtual_url()); - EXPECT_TRUE(entry1_.get()->GetTitleForDisplay(NULL).empty()); + EXPECT_TRUE(entry1_.get()->GetTitleForDisplay("").empty()); // Setting URL affects virtual_url and GetTitleForDisplay entry1_.get()->set_url(GURL("http://www.google.com")); EXPECT_EQ(GURL("http://www.google.com"), entry1_.get()->url()); EXPECT_EQ(GURL("http://www.google.com"), entry1_.get()->virtual_url()); EXPECT_EQ(ASCIIToUTF16("www.google.com"), - entry1_.get()->GetTitleForDisplay(NULL)); + entry1_.get()->GetTitleForDisplay("")); // Title affects GetTitleForDisplay entry1_.get()->set_title(ASCIIToUTF16("Google")); - EXPECT_EQ(ASCIIToUTF16("Google"), entry1_.get()->GetTitleForDisplay(NULL)); + EXPECT_EQ(ASCIIToUTF16("Google"), entry1_.get()->GetTitleForDisplay("")); // Setting virtual_url doesn't affect URL entry2_.get()->set_virtual_url(GURL("display:url")); @@ -73,7 +73,7 @@ TEST_F(NavigationEntryTest, NavigationEntryURLs) { EXPECT_EQ(GURL("display:url"), entry2_.get()->virtual_url()); // Having a title set in constructor overrides virtual URL - EXPECT_EQ(ASCIIToUTF16("title"), entry2_.get()->GetTitleForDisplay(NULL)); + EXPECT_EQ(ASCIIToUTF16("title"), entry2_.get()->GetTitleForDisplay("")); // User typed URL is independent of the others EXPECT_EQ(GURL(), entry1_.get()->user_typed_url()); diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc index 2ee6d08..f35c0e0 100644 --- a/chrome/browser/tab_contents/render_view_context_menu.cc +++ b/chrome/browser/tab_contents/render_view_context_menu.cc @@ -1394,16 +1394,6 @@ bool RenderViewContextMenu::IsDevCommandEnabled(int id) const { if (active_entry->url().SchemeIs(chrome::kGearsScheme)) return false; -#if defined NDEBUG - bool debug_mode = false; -#else - bool debug_mode = true; -#endif - // Don't inspect new tab UI, etc. - if (active_entry->url().SchemeIs(chrome::kChromeUIScheme) && !debug_mode && - active_entry->url().host() != chrome::kChromeUIDevToolsHost) - return false; - // Don't inspect about:network, about:memory, etc. // However, we do want to inspect about:blank, which is often // used by ordinary web pages. diff --git a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc index 491e7f6..568ae4c 100644 --- a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc +++ b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc @@ -291,6 +291,8 @@ WebPreferences RenderViewHostDelegateHelper::GetWebkitPrefs( command_line.HasSwitch(switches::kEnableAccelerated2dCanvas); web_prefs.accelerated_layers_enabled = command_line.HasSwitch(switches::kEnableAcceleratedLayers); + web_prefs.accelerated_video_enabled = + !command_line.HasSwitch(switches::kDisableAcceleratedVideo); web_prefs.memory_info_enabled = command_line.HasSwitch(switches::kEnableMemoryInfo); web_prefs.hyperlink_auditing_enabled = diff --git a/chrome/browser/tab_contents/render_view_host_manager.cc b/chrome/browser/tab_contents/render_view_host_manager.cc index bcc9a78..ed5628e 100644 --- a/chrome/browser/tab_contents/render_view_host_manager.cc +++ b/chrome/browser/tab_contents/render_view_host_manager.cc @@ -298,6 +298,12 @@ bool RenderViewHostManager::ShouldSwapProcessesForNavigation( // into the same process. if (new_entry->url().SchemeIs(chrome::kExtensionScheme)) return true; + // When a tab is created, it starts as TYPE_NORMAL. If the new entry is a + // DOM UI page, it needs to be grouped with other DOM UI pages. This matches + // the logic when transitioning between DOM UI and normal pages. + Profile* profile = delegate_->GetControllerForRenderManager().profile(); + if (DOMUIFactory::UseDOMUIForURL(profile, new_entry->url())) + return true; return false; } diff --git a/chrome/browser/tab_contents/render_view_host_manager_unittest.cc b/chrome/browser/tab_contents/render_view_host_manager_unittest.cc index d6a58a1..5325abe 100644 --- a/chrome/browser/tab_contents/render_view_host_manager_unittest.cc +++ b/chrome/browser/tab_contents/render_view_host_manager_unittest.cc @@ -253,8 +253,6 @@ TEST_F(RenderViewHostManagerTest, DOMUI) { EXPECT_TRUE(host); EXPECT_TRUE(host == manager.current_host()); EXPECT_FALSE(manager.pending_render_view_host()); - EXPECT_TRUE(manager.pending_dom_ui()); - EXPECT_FALSE(manager.dom_ui()); // It's important that the site instance get set on the DOM UI page as soon // as the navigation starts, rather than lazily after it commits, so we don't @@ -263,11 +261,13 @@ TEST_F(RenderViewHostManagerTest, DOMUI) { EXPECT_TRUE(host->site_instance()->has_site()); EXPECT_EQ(url, host->site_instance()->site()); - // Commit. - manager.DidNavigateMainFrame(host); - + // The DOM UI is committed immediately because the RenderViewHost has not been + // used yet. UpdateRendererStateForNavigate() took the short cut path. EXPECT_FALSE(manager.pending_dom_ui()); EXPECT_TRUE(manager.dom_ui()); + + // Commit. + manager.DidNavigateMainFrame(host); } // Tests that chrome: URLs that are not DOM UI pages do not get grouped into diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index 3dba1a8..698d691 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -10,6 +10,7 @@ #include "app/resource_bundle.h" #include "base/auto_reset.h" #include "base/metrics/histogram.h" +#include "base/metrics/stats_counters.h" #include "base/string16.h" #include "base/string_util.h" #include "base/time.h" @@ -21,6 +22,7 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/browser_shutdown.h" #include "chrome/browser/character_encoding.h" +#include "chrome/browser/child_process_security_policy.h" #include "chrome/browser/content_settings/content_settings_details.h" #include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/debugger/devtools_manager.h" @@ -44,6 +46,7 @@ #include "chrome/browser/load_from_memory_cache_details.h" #include "chrome/browser/load_notification_details.h" #include "chrome/browser/metrics/metric_event_duration_details.h" +#include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/modal_html_dialog_delegate.h" #include "chrome/browser/omnibox_search_hint.h" #include "chrome/browser/platform_util.h" @@ -548,6 +551,36 @@ void TabContents::RegisterUserPrefs(PrefService* prefs) { IDS_STATIC_ENCODING_LIST); } +bool TabContents::OnMessageReceived(const IPC::Message& message) { + bool handled = true; + bool message_is_ok = true; + IPC_BEGIN_MESSAGE_MAP_EX(TabContents, message, message_is_ok) + IPC_MESSAGE_HANDLER(ViewHostMsg_DidStartProvisionalLoadForFrame, + OnDidStartProvisionalLoadForFrame) + IPC_MESSAGE_HANDLER(ViewHostMsg_DidRedirectProvisionalLoad, + OnDidRedirectProvisionalLoad) + IPC_MESSAGE_HANDLER(ViewHostMsg_DidFailProvisionalLoadWithError, + OnDidFailProvisionalLoadWithError) + IPC_MESSAGE_HANDLER(ViewHostMsg_DidLoadResourceFromMemoryCache, + OnDidLoadResourceFromMemoryCache) + IPC_MESSAGE_HANDLER(ViewHostMsg_DidDisplayInsecureContent, + OnDidDisplayInsecureContent) + IPC_MESSAGE_HANDLER(ViewHostMsg_DidRunInsecureContent, + OnDidRunInsecureContent) + IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentLoadedInFrame, + OnDocumentLoadedInFrame) + IPC_MESSAGE_HANDLER(ViewHostMsg_DidFinishLoad, OnDidFinishLoad) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP_EX() + + if (!message_is_ok) { + UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); + GetRenderProcessHost()->ReceivedBadMessage(); + } + + return handled; +} + // Returns true if contains content rendered by an extension. bool TabContents::HostsExtension() const { return GetURL().SchemeIs(chrome::kExtensionScheme); @@ -618,9 +651,10 @@ const string16& TabContents::GetTitle() const { // Transient entries take precedence. They are used for interstitial pages // that are shown on top of existing pages. NavigationEntry* entry = controller_.GetTransientEntry(); - if (entry) - return entry->GetTitleForDisplay(&controller_); - + if (entry) { + return entry->GetTitleForDisplay(profile()->GetPrefs()-> + GetString(prefs::kAcceptLanguages)); + } DOMUI* our_dom_ui = render_manager_.pending_dom_ui() ? render_manager_.pending_dom_ui() : render_manager_.dom_ui(); if (our_dom_ui) { @@ -639,8 +673,10 @@ const string16& TabContents::GetTitle() const { // keep the old page's title until the new load has committed and we get a new // title. entry = controller_.GetLastCommittedEntry(); - if (entry) - return entry->GetTitleForDisplay(&controller_); + if (entry) { + return entry->GetTitleForDisplay(profile()->GetPrefs()-> + GetString(prefs::kAcceptLanguages)); + } return EmptyString16(); } @@ -719,40 +755,41 @@ bool TabContents::ShouldDisplayFavIcon() { return true; } -std::wstring TabContents::GetStatusText() const { +string16 TabContents::GetStatusText() const { if (!is_loading() || load_state_ == net::LOAD_STATE_IDLE) - return std::wstring(); + return string16(); switch (load_state_) { case net::LOAD_STATE_WAITING_FOR_CACHE: - return l10n_util::GetString(IDS_LOAD_STATE_WAITING_FOR_CACHE); + return l10n_util::GetStringUTF16(IDS_LOAD_STATE_WAITING_FOR_CACHE); case net::LOAD_STATE_ESTABLISHING_PROXY_TUNNEL: - return l10n_util::GetString(IDS_LOAD_STATE_ESTABLISHING_PROXY_TUNNEL); + return + l10n_util::GetStringUTF16(IDS_LOAD_STATE_ESTABLISHING_PROXY_TUNNEL); case net::LOAD_STATE_RESOLVING_PROXY_FOR_URL: - return l10n_util::GetString(IDS_LOAD_STATE_RESOLVING_PROXY_FOR_URL); + return l10n_util::GetStringUTF16(IDS_LOAD_STATE_RESOLVING_PROXY_FOR_URL); case net::LOAD_STATE_RESOLVING_HOST: - return l10n_util::GetString(IDS_LOAD_STATE_RESOLVING_HOST); + return l10n_util::GetStringUTF16(IDS_LOAD_STATE_RESOLVING_HOST); case net::LOAD_STATE_CONNECTING: - return l10n_util::GetString(IDS_LOAD_STATE_CONNECTING); + return l10n_util::GetStringUTF16(IDS_LOAD_STATE_CONNECTING); case net::LOAD_STATE_SSL_HANDSHAKE: - return l10n_util::GetString(IDS_LOAD_STATE_SSL_HANDSHAKE); + return l10n_util::GetStringUTF16(IDS_LOAD_STATE_SSL_HANDSHAKE); case net::LOAD_STATE_SENDING_REQUEST: if (upload_size_) - return l10n_util::GetStringF( + return l10n_util::GetStringFUTF16Int( IDS_LOAD_STATE_SENDING_REQUEST_WITH_PROGRESS, static_cast<int>((100 * upload_position_) / upload_size_)); else - return l10n_util::GetString(IDS_LOAD_STATE_SENDING_REQUEST); + return l10n_util::GetStringUTF16(IDS_LOAD_STATE_SENDING_REQUEST); case net::LOAD_STATE_WAITING_FOR_RESPONSE: - return l10n_util::GetStringF(IDS_LOAD_STATE_WAITING_FOR_RESPONSE, - load_state_host_); + return l10n_util::GetStringFUTF16(IDS_LOAD_STATE_WAITING_FOR_RESPONSE, + load_state_host_); // Ignore net::LOAD_STATE_READING_RESPONSE and net::LOAD_STATE_IDLE case net::LOAD_STATE_IDLE: case net::LOAD_STATE_READING_RESPONSE: break; } - return std::wstring(); + return string16(); } void TabContents::AddNavigationObserver(WebNavigationObserver* observer) { @@ -1555,6 +1592,159 @@ void TabContents::ViewSource() { delegate_->ViewSourceForTab(this, active_entry->url()); } +void TabContents::OnDidStartProvisionalLoadForFrame(int64 frame_id, + bool is_main_frame, + const GURL& url) { + bool is_error_page = (url.spec() == chrome::kUnreachableWebDataURL); + GURL validated_url(url); + render_view_host()->FilterURL(ChildProcessSecurityPolicy::GetInstance(), + GetRenderProcessHost()->id(), &validated_url); + + ProvisionalLoadDetails details( + is_main_frame, + controller_.IsURLInPageNavigation(validated_url), + validated_url, std::string(), false, is_error_page, frame_id); + NotificationService::current()->Notify( + NotificationType::FRAME_PROVISIONAL_LOAD_START, + Source<NavigationController>(&controller_), + Details<ProvisionalLoadDetails>(&details)); + if (is_main_frame) { + // If we're displaying a network error page do not reset the content + // settings delegate's cookies so the user has a chance to modify cookie + // settings. + if (!is_error_page) + content_settings_delegate_->ClearCookieSpecificContentSettings(); + content_settings_delegate_->ClearGeolocationContentSettings(); + } +} + +void TabContents::OnDidRedirectProvisionalLoad(int32 page_id, + const GURL& source_url, + const GURL& target_url) { + NavigationEntry* entry; + if (page_id == -1) + entry = controller_.pending_entry(); + else + entry = controller_.GetEntryWithPageID(GetSiteInstance(), page_id); + if (!entry || entry->url() != source_url) + return; + entry->set_url(target_url); +} + +void TabContents::OnDidFailProvisionalLoadWithError( + int64 frame_id, + bool is_main_frame, + int error_code, + const GURL& url, + bool showing_repost_interstitial) { + VLOG(1) << "Failed Provisional Load: " << url.possibly_invalid_spec() + << ", error_code: " << error_code + << " is_main_frame: " << is_main_frame + << " showing_repost_interstitial: " << showing_repost_interstitial + << " frame_id: " << frame_id; + GURL validated_url(url); + render_view_host()->FilterURL(ChildProcessSecurityPolicy::GetInstance(), + GetRenderProcessHost()->id(), &validated_url); + + if (net::ERR_ABORTED == error_code) { + // EVIL HACK ALERT! Ignore failed loads when we're showing interstitials. + // This means that the interstitial won't be torn down properly, which is + // bad. But if we have an interstitial, go back to another tab type, and + // then load the same interstitial again, we could end up getting the first + // interstitial's "failed" message (as a result of the cancel) when we're on + // the second one. + // + // We can't tell this apart, so we think we're tearing down the current page + // which will cause a crash later one. There is also some code in + // RenderViewHostManager::RendererAbortedProvisionalLoad that is commented + // out because of this problem. + // + // http://code.google.com/p/chromium/issues/detail?id=2855 + // Because this will not tear down the interstitial properly, if "back" is + // back to another tab type, the interstitial will still be somewhat alive + // in the previous tab type. If you navigate somewhere that activates the + // tab with the interstitial again, you'll see a flash before the new load + // commits of the interstitial page. + if (showing_interstitial_page()) { + LOG(WARNING) << "Discarding message during interstitial."; + return; + } + + // This will discard our pending entry if we cancelled the load (e.g., if we + // decided to download the file instead of load it). Only discard the + // pending entry if the URLs match, otherwise the user initiated a navigate + // before the page loaded so that the discard would discard the wrong entry. + NavigationEntry* pending_entry = controller_.pending_entry(); + if (pending_entry && pending_entry->url() == validated_url) { + controller_.DiscardNonCommittedEntries(); + // Update the URL display. + NotifyNavigationStateChanged(TabContents::INVALIDATE_URL); + } + + render_manager_.RendererAbortedProvisionalLoad(render_view_host()); + } + + // Send out a notification that we failed a provisional load with an error. + ProvisionalLoadDetails details( + is_main_frame, controller_.IsURLInPageNavigation(validated_url), + validated_url, std::string(), false, false, frame_id); + details.set_error_code(error_code); + + NotificationService::current()->Notify( + NotificationType::FAIL_PROVISIONAL_LOAD_WITH_ERROR, + Source<NavigationController>(&controller_), + Details<ProvisionalLoadDetails>(&details)); +} + +void TabContents::OnDidLoadResourceFromMemoryCache( + const GURL& url, + const std::string& frame_origin, + const std::string& main_frame_origin, + const std::string& security_info) { + static base::StatsCounter cache("WebKit.CacheHit"); + cache.Increment(); + + // Send out a notification that we loaded a resource from our memory cache. + int cert_id = 0, cert_status = 0, security_bits = -1, connection_status = 0; + SSLManager::DeserializeSecurityInfo(security_info, + &cert_id, &cert_status, + &security_bits, + &connection_status); + LoadFromMemoryCacheDetails details(url, frame_origin, main_frame_origin, + GetRenderProcessHost()->id(), cert_id, + cert_status); + + NotificationService::current()->Notify( + NotificationType::LOAD_FROM_MEMORY_CACHE, + Source<NavigationController>(&controller_), + Details<LoadFromMemoryCacheDetails>(&details)); +} + +void TabContents::OnDidDisplayInsecureContent() { + displayed_insecure_content_ = true; + SSLManager::NotifySSLInternalStateChanged(); +} + +void TabContents::OnDidRunInsecureContent( + const std::string& security_origin) { + controller_.ssl_manager()->DidRunInsecureContent(security_origin); +} + +void TabContents::OnDocumentLoadedInFrame(int64 frame_id) { + controller_.DocumentLoadedInFrame(); + NotificationService::current()->Notify( + NotificationType::FRAME_DOM_CONTENT_LOADED, + Source<NavigationController>(&controller_), + Details<int64>(&frame_id)); +} + +void TabContents::OnDidFinishLoad(int64 frame_id) { + NotificationService::current()->Notify( + NotificationType::FRAME_DID_FINISH_LOAD, + Source<NavigationController>(&controller_), + Details<int64>(&frame_id)); +} + // Notifies the RenderWidgetHost instance about the fact that the page is // loading, or done loading and calls the base implementation. void TabContents::SetIsLoading(bool is_loading, @@ -2189,148 +2379,6 @@ void TabContents::OnInstantSupportDetermined(int32 page_id, bool result) { delegate()->OnInstantSupportDetermined(page_id, result); } -void TabContents::DidStartProvisionalLoadForFrame( - RenderViewHost* render_view_host, - int64 frame_id, - bool is_main_frame, - bool is_error_page, - const GURL& url) { - ProvisionalLoadDetails details(is_main_frame, - controller_.IsURLInPageNavigation(url), - url, std::string(), false, - is_error_page, frame_id); - NotificationService::current()->Notify( - NotificationType::FRAME_PROVISIONAL_LOAD_START, - Source<NavigationController>(&controller_), - Details<ProvisionalLoadDetails>(&details)); - if (is_main_frame) { - // If we're displaying a network error page do not reset the content - // settings delegate's cookies so the user has a chance to modify cookie - // settings. - if (!is_error_page) - content_settings_delegate_->ClearCookieSpecificContentSettings(); - content_settings_delegate_->ClearGeolocationContentSettings(); - } -} - -void TabContents::DidStartReceivingResourceResponse( - const ResourceRequestDetails& details) { - NotificationService::current()->Notify( - NotificationType::RESOURCE_RESPONSE_STARTED, - Source<NavigationController>(&controller()), - Details<const ResourceRequestDetails>(&details)); -} - -void TabContents::DidRedirectResource( - const ResourceRedirectDetails& details) { - NotificationService::current()->Notify( - NotificationType::RESOURCE_RECEIVED_REDIRECT, - Source<NavigationController>(&controller()), - Details<const ResourceRequestDetails>(&details)); -} - -void TabContents::DidLoadResourceFromMemoryCache( - const GURL& url, - const std::string& frame_origin, - const std::string& main_frame_origin, - const std::string& security_info) { - // Send out a notification that we loaded a resource from our memory cache. - int cert_id = 0, cert_status = 0, security_bits = -1, connection_status = 0; - SSLManager::DeserializeSecurityInfo(security_info, - &cert_id, &cert_status, - &security_bits, - &connection_status); - LoadFromMemoryCacheDetails details(url, frame_origin, main_frame_origin, - GetRenderProcessHost()->id(), cert_id, - cert_status); - - NotificationService::current()->Notify( - NotificationType::LOAD_FROM_MEMORY_CACHE, - Source<NavigationController>(&controller_), - Details<LoadFromMemoryCacheDetails>(&details)); -} - -void TabContents::DidDisplayInsecureContent() { - displayed_insecure_content_ = true; - SSLManager::NotifySSLInternalStateChanged(); -} - -void TabContents::DidRunInsecureContent(const std::string& security_origin) { - controller_.ssl_manager()->DidRunInsecureContent(security_origin); -} - -void TabContents::DidFailProvisionalLoadWithError( - RenderViewHost* render_view_host, - int64 frame_id, - bool is_main_frame, - int error_code, - const GURL& url, - bool showing_repost_interstitial) { - if (net::ERR_ABORTED == error_code) { - // EVIL HACK ALERT! Ignore failed loads when we're showing interstitials. - // This means that the interstitial won't be torn down properly, which is - // bad. But if we have an interstitial, go back to another tab type, and - // then load the same interstitial again, we could end up getting the first - // interstitial's "failed" message (as a result of the cancel) when we're on - // the second one. - // - // We can't tell this apart, so we think we're tearing down the current page - // which will cause a crash later one. There is also some code in - // RenderViewHostManager::RendererAbortedProvisionalLoad that is commented - // out because of this problem. - // - // http://code.google.com/p/chromium/issues/detail?id=2855 - // Because this will not tear down the interstitial properly, if "back" is - // back to another tab type, the interstitial will still be somewhat alive - // in the previous tab type. If you navigate somewhere that activates the - // tab with the interstitial again, you'll see a flash before the new load - // commits of the interstitial page. - if (showing_interstitial_page()) { - LOG(WARNING) << "Discarding message during interstitial."; - return; - } - - // This will discard our pending entry if we cancelled the load (e.g., if we - // decided to download the file instead of load it). Only discard the - // pending entry if the URLs match, otherwise the user initiated a navigate - // before the page loaded so that the discard would discard the wrong entry. - NavigationEntry* pending_entry = controller_.pending_entry(); - if (pending_entry && pending_entry->url() == url) { - controller_.DiscardNonCommittedEntries(); - // Update the URL display. - NotifyNavigationStateChanged(TabContents::INVALIDATE_URL); - } - - render_manager_.RendererAbortedProvisionalLoad(render_view_host); - } - - // Send out a notification that we failed a provisional load with an error. - ProvisionalLoadDetails details(is_main_frame, - controller_.IsURLInPageNavigation(url), - url, std::string(), false, false, frame_id); - details.set_error_code(error_code); - - NotificationService::current()->Notify( - NotificationType::FAIL_PROVISIONAL_LOAD_WITH_ERROR, - Source<NavigationController>(&controller_), - Details<ProvisionalLoadDetails>(&details)); -} - -void TabContents::DocumentLoadedInFrame(int64 frame_id) { - controller_.DocumentLoadedInFrame(); - NotificationService::current()->Notify( - NotificationType::FRAME_DOM_CONTENT_LOADED, - Source<NavigationController>(&controller_), - Details<int64>(&frame_id)); -} - -void TabContents::DidFinishLoad(int64 frame_id) { - NotificationService::current()->Notify( - NotificationType::FRAME_DID_FINISH_LOAD, - Source<NavigationController>(&controller_), - Details<int64>(&frame_id)); -} - void TabContents::OnContentSettingsAccessed(bool content_was_blocked) { if (delegate_) delegate_->OnContentSettingsChange(this); @@ -2350,10 +2398,6 @@ RenderViewHostDelegate::BrowserIntegration* return this; } -RenderViewHostDelegate::Resource* TabContents::GetResourceDelegate() { - return this; -} - RenderViewHostDelegate::ContentSettings* TabContents::GetContentSettingsDelegate() { return content_settings_delegate_.get(); @@ -2773,19 +2817,6 @@ void TabContents::DocumentOnLoadCompletedInMainFrame( Details<int>(&page_id)); } -void TabContents::DidRedirectProvisionalLoad(int32 page_id, - const GURL& source_url, - const GURL& target_url) { - NavigationEntry* entry; - if (page_id == -1) - entry = controller_.pending_entry(); - else - entry = controller_.GetEntryWithPageID(GetSiteInstance(), page_id); - if (!entry || entry->url() != source_url) - return; - entry->set_url(target_url); -} - void TabContents::RequestOpenURL(const GURL& url, const GURL& referrer, WindowOpenDisposition disposition) { if (render_manager_.dom_ui()) { @@ -3076,8 +3107,8 @@ void TabContents::LoadStateChanged(const GURL& url, std::wstring languages = UTF8ToWide(profile()->GetPrefs()->GetString(prefs::kAcceptLanguages)); std::string host = url.host(); - load_state_host_ = - net::IDNToUnicode(host.c_str(), host.size(), languages, NULL); + load_state_host_ = WideToUTF16Hack( + net::IDNToUnicode(host.c_str(), host.size(), languages, NULL)); if (load_state_ == net::LOAD_STATE_READING_RESPONSE) SetNotWaitingForResponse(); if (is_loading()) diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h index 500418c..150d101 100644 --- a/chrome/browser/tab_contents/tab_contents.h +++ b/chrome/browser/tab_contents/tab_contents.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -48,6 +48,7 @@ private: #include "base/basictypes.h" #include "base/gtest_prod_util.h" #include "base/scoped_ptr.h" +#include "base/string16.h" #include "chrome/browser/dom_ui/dom_ui_factory.h" #include "chrome/browser/download/save_package.h" #include "chrome/browser/extensions/image_loading_tracker.h" @@ -72,6 +73,10 @@ private: #include "gfx/native_widget_types.h" #include "net/base/load_states.h" +#if defined(OS_WIN) +#include "base/win/scoped_handle.h" +#endif + namespace gfx { class Rect; } @@ -84,10 +89,6 @@ namespace printing { class PrintViewManager; } -namespace IPC { -class Message; -} - namespace webkit_glue { struct PasswordForm; } @@ -127,7 +128,6 @@ class TabContents : public PageNavigator, public NotificationObserver, public RenderViewHostDelegate, public RenderViewHostDelegate::BrowserIntegration, - public RenderViewHostDelegate::Resource, public RenderViewHostManager::Delegate, public JavaScriptAppModalDialogDelegate, public ImageLoadingTracker::Observer, @@ -294,7 +294,7 @@ class TabContents : public PageNavigator, virtual bool ShouldDisplayFavIcon(); // Returns a human-readable description the tab's loading state. - virtual std::wstring GetStatusText() const; + virtual string16 GetStatusText() const; // Add and remove observers for page navigation notifications. Adding or // removing multiple times has no effect. The order in which notifications @@ -818,6 +818,27 @@ class TabContents : public PageNavigator, // Used to access RVH Delegates. friend class PrerenderManager; + // Message handlers. + void OnDidStartProvisionalLoadForFrame(int64 frame_id, + bool main_frame, + const GURL& url); + void OnDidRedirectProvisionalLoad(int32 page_id, + const GURL& source_url, + const GURL& target_url); + void OnDidFailProvisionalLoadWithError(int64 frame_id, + bool main_frame, + int error_code, + const GURL& url, + bool showing_repost_interstitial); + void OnDidLoadResourceFromMemoryCache(const GURL& url, + const std::string& frame_origin, + const std::string& main_frame_origin, + const std::string& security_info); + void OnDidDisplayInsecureContent(); + void OnDidRunInsecureContent(const std::string& security_origin); + void OnDocumentLoadedInFrame(int64 frame_id); + void OnDidFinishLoad(int64 frame_id); + // Changes the IsLoading state and notifies delegate as needed // |details| is used to provide details on the load that just finished // (but can be null if not applicable). Can be overridden. @@ -953,43 +974,12 @@ class TabContents : public PageNavigator, const std::vector<std::string>& suggestions); virtual void OnInstantSupportDetermined(int32 page_id, bool result); - // RenderViewHostDelegate::Resource implementation. - virtual void DidStartProvisionalLoadForFrame(RenderViewHost* render_view_host, - int64 frame_id, - bool is_main_frame, - bool is_error_page, - const GURL& url); - virtual void DidStartReceivingResourceResponse( - const ResourceRequestDetails& details); - virtual void DidRedirectProvisionalLoad(int32 page_id, - const GURL& source_url, - const GURL& target_url); - virtual void DidRedirectResource( - const ResourceRedirectDetails& details); - virtual void DidLoadResourceFromMemoryCache( - const GURL& url, - const std::string& frame_origin, - const std::string& main_frame_origin, - const std::string& security_info); - virtual void DidDisplayInsecureContent(); - virtual void DidRunInsecureContent(const std::string& security_origin); - virtual void DidFailProvisionalLoadWithError( - RenderViewHost* render_view_host, - int64 frame_id, - bool is_main_frame, - int error_code, - const GURL& url, - bool showing_repost_interstitial); - virtual void DocumentLoadedInFrame(int64 frame_id); - virtual void DidFinishLoad(int64 frame_id); - // RenderViewHostDelegate implementation. virtual RenderViewHostDelegate::View* GetViewDelegate(); virtual RenderViewHostDelegate::RendererManagement* GetRendererManagementDelegate(); virtual RenderViewHostDelegate::BrowserIntegration* GetBrowserIntegrationDelegate(); - virtual RenderViewHostDelegate::Resource* GetResourceDelegate(); virtual RenderViewHostDelegate::ContentSettings* GetContentSettingsDelegate(); virtual RenderViewHostDelegate::Save* GetSaveDelegate(); virtual RenderViewHostDelegate::Printing* GetPrintingDelegate(); @@ -1001,6 +991,7 @@ class TabContents : public PageNavigator, virtual AutomationResourceRoutingDelegate* GetAutomationResourceRoutingDelegate(); virtual TabContents* GetAsTabContents(); + virtual bool OnMessageReceived(const IPC::Message& message); virtual ViewType::Type GetRenderViewType() const; virtual int GetBrowserWindowID() const; virtual void RenderViewCreated(RenderViewHost* render_view_host); @@ -1213,7 +1204,7 @@ class TabContents : public PageNavigator, // The current load state and the URL associated with it. net::LoadState load_state_; - std::wstring load_state_host_; + string16 load_state_host_; // Upload progress, for displaying in the status bar. // Set to zero when there is no significant upload happening. uint64 upload_size_; @@ -1327,7 +1318,7 @@ class TabContents : public PageNavigator, // Handle to an event that's set when the page is showing a message box (or // equivalent constrained window). Plugin processes check this to know if // they should pump messages then. - ScopedHandle message_box_active_; + base::win::ScopedHandle message_box_active_; #endif // The time that the last javascript message was dismissed. diff --git a/chrome/browser/tab_contents/thumbnail_generator.cc b/chrome/browser/tab_contents/thumbnail_generator.cc index 80c609b..1844f67 100644 --- a/chrome/browser/tab_contents/thumbnail_generator.cc +++ b/chrome/browser/tab_contents/thumbnail_generator.cc @@ -23,7 +23,7 @@ #include "third_party/skia/include/core/SkBitmap.h" #if defined(OS_WIN) -#include "app/win_util.h" +#include "app/win/win_util.h" #endif // Overview @@ -205,7 +205,7 @@ void ThumbnailGenerator::AskForSnapshot(RenderWidgetHost* renderer, // Duplicate the handle to the DIB here because the renderer process does not // have permission. The duplicated handle is owned by the renderer process, // which is responsible for closing it. - TransportDIB::Handle renderer_dib_handle = win_util::GetSectionForProcess( + TransportDIB::Handle renderer_dib_handle = app::win::GetSectionForProcess( thumbnail_dib->handle(), renderer->process()->GetHandle(), false); |