Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/frame_host/navigation_controller_impl.h" | 5 #include "content/browser/frame_host/navigation_controller_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "base/strings/string_number_conversions.h" // Temporary | 11 #include "base/strings/string_number_conversions.h" // Temporary |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "base/trace_event/trace_event.h" | 15 #include "base/trace_event/trace_event.h" |
| 16 #include "build/build_config.h" | |
| 16 #include "cc/base/switches.h" | 17 #include "cc/base/switches.h" |
| 17 #include "components/mime_util/mime_util.h" | 18 #include "components/mime_util/mime_util.h" |
| 18 #include "content/browser/bad_message.h" | 19 #include "content/browser/bad_message.h" |
| 19 #include "content/browser/browser_url_handler_impl.h" | 20 #include "content/browser/browser_url_handler_impl.h" |
| 20 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" | 21 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" |
| 21 #include "content/browser/dom_storage/session_storage_namespace_impl.h" | 22 #include "content/browser/dom_storage/session_storage_namespace_impl.h" |
| 22 #include "content/browser/frame_host/debug_urls.h" | 23 #include "content/browser/frame_host/debug_urls.h" |
| 23 #include "content/browser/frame_host/interstitial_page_impl.h" | 24 #include "content/browser/frame_host/interstitial_page_impl.h" |
| 24 #include "content/browser/frame_host/navigation_entry_impl.h" | 25 #include "content/browser/frame_host/navigation_entry_impl.h" |
| 25 #include "content/browser/frame_host/navigation_entry_screenshot_manager.h" | 26 #include "content/browser/frame_host/navigation_entry_screenshot_manager.h" |
| 26 #include "content/browser/renderer_host/render_view_host_impl.h" // Temporary | 27 #include "content/browser/renderer_host/render_view_host_impl.h" // Temporary |
| 27 #include "content/browser/site_instance_impl.h" | 28 #include "content/browser/site_instance_impl.h" |
| 28 #include "content/common/frame_messages.h" | 29 #include "content/common/frame_messages.h" |
| 29 #include "content/common/view_messages.h" | 30 #include "content/common/view_messages.h" |
| 30 #include "content/public/browser/browser_context.h" | 31 #include "content/public/browser/browser_context.h" |
| 31 #include "content/public/browser/content_browser_client.h" | 32 #include "content/public/browser/content_browser_client.h" |
| 32 #include "content/public/browser/invalidate_type.h" | 33 #include "content/public/browser/invalidate_type.h" |
| 33 #include "content/public/browser/navigation_details.h" | 34 #include "content/public/browser/navigation_details.h" |
| 34 #include "content/public/browser/notification_service.h" | 35 #include "content/public/browser/notification_service.h" |
| 35 #include "content/public/browser/notification_types.h" | 36 #include "content/public/browser/notification_types.h" |
| 36 #include "content/public/browser/render_widget_host.h" | 37 #include "content/public/browser/render_widget_host.h" |
| 37 #include "content/public/browser/render_widget_host_view.h" | 38 #include "content/public/browser/render_widget_host_view.h" |
| 38 #include "content/public/browser/storage_partition.h" | 39 #include "content/public/browser/storage_partition.h" |
| 39 #include "content/public/browser/user_metrics.h" | 40 #include "content/public/browser/user_metrics.h" |
| 40 #include "content/public/common/content_client.h" | 41 #include "content/public/common/content_client.h" |
| 41 #include "content/public/common/content_constants.h" | 42 #include "content/public/common/content_constants.h" |
| 42 #include "content/public/common/content_switches.h" | 43 #include "content/public/common/content_switches.h" |
| 44 #include "media/base/mime_util.h" | |
| 43 #include "net/base/escape.h" | 45 #include "net/base/escape.h" |
| 44 #include "net/base/mime_util.h" | |
| 45 #include "net/base/net_util.h" | 46 #include "net/base/net_util.h" |
| 46 #include "skia/ext/platform_canvas.h" | 47 #include "skia/ext/platform_canvas.h" |
| 47 #include "url/url_constants.h" | 48 #include "url/url_constants.h" |
| 48 | 49 |
| 49 namespace content { | 50 namespace content { |
| 50 namespace { | 51 namespace { |
| 51 | 52 |
| 52 // Invoked when entries have been pruned, or removed. For example, if the | 53 // Invoked when entries have been pruned, or removed. For example, if the |
| 53 // current entries are [google, digg, yahoo], with the current entry google, | 54 // current entries are [google, digg, yahoo], with the current entry google, |
| 54 // and the user types in cnet, then digg and yahoo are pruned. | 55 // and the user types in cnet, then digg and yahoo are pruned. |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 489 NavigationEntryImpl* NavigationControllerImpl::GetLastCommittedEntry() const { | 490 NavigationEntryImpl* NavigationControllerImpl::GetLastCommittedEntry() const { |
| 490 if (last_committed_entry_index_ == -1) | 491 if (last_committed_entry_index_ == -1) |
| 491 return NULL; | 492 return NULL; |
| 492 return entries_[last_committed_entry_index_].get(); | 493 return entries_[last_committed_entry_index_].get(); |
| 493 } | 494 } |
| 494 | 495 |
| 495 bool NavigationControllerImpl::CanViewSource() const { | 496 bool NavigationControllerImpl::CanViewSource() const { |
| 496 const std::string& mime_type = delegate_->GetContentsMimeType(); | 497 const std::string& mime_type = delegate_->GetContentsMimeType(); |
| 497 bool is_viewable_mime_type = | 498 bool is_viewable_mime_type = |
| 498 mime_util::IsSupportedNonImageMimeType(mime_type) && | 499 mime_util::IsSupportedNonImageMimeType(mime_type) && |
| 499 !net::IsSupportedMediaMimeType(mime_type); | 500 !media::IsSupportedMediaMimeType(mime_type); |
| 500 NavigationEntry* visible_entry = GetVisibleEntry(); | 501 NavigationEntry* visible_entry = GetVisibleEntry(); |
| 501 return visible_entry && !visible_entry->IsViewSourceMode() && | 502 return visible_entry && !visible_entry->IsViewSourceMode() && |
| 502 is_viewable_mime_type && !delegate_->GetInterstitialPage(); | 503 is_viewable_mime_type && !delegate_->GetInterstitialPage(); |
| 503 } | 504 } |
| 504 | 505 |
| 505 int NavigationControllerImpl::GetLastCommittedEntryIndex() const { | 506 int NavigationControllerImpl::GetLastCommittedEntryIndex() const { |
| 506 return last_committed_entry_index_; | 507 return last_committed_entry_index_; |
| 507 } | 508 } |
| 508 | 509 |
| 509 int NavigationControllerImpl::GetEntryCount() const { | 510 int NavigationControllerImpl::GetEntryCount() const { |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 814 // pending parameters that were saved. | 815 // pending parameters that were saved. |
| 815 if (params.url_is_unreachable && failed_pending_entry_id_ != 0) { | 816 if (params.url_is_unreachable && failed_pending_entry_id_ != 0) { |
| 816 details->did_replace_entry = failed_pending_entry_should_replace_; | 817 details->did_replace_entry = failed_pending_entry_should_replace_; |
| 817 } else { | 818 } else { |
| 818 details->did_replace_entry = pending_entry_ && | 819 details->did_replace_entry = pending_entry_ && |
| 819 pending_entry_->should_replace_entry(); | 820 pending_entry_->should_replace_entry(); |
| 820 } | 821 } |
| 821 | 822 |
| 822 // Do navigation-type specific actions. These will make and commit an entry. | 823 // Do navigation-type specific actions. These will make and commit an entry. |
| 823 details->type = ClassifyNavigation(rfh, params); | 824 details->type = ClassifyNavigation(rfh, params); |
| 824 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 825 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
|
ddorwin
2015/05/09 02:12:02
In the future, if you have rebased, please upload
| |
| 825 switches::kSitePerProcess)) { | 826 switches::kSitePerProcess)) { |
| 826 // For site-per-process, both ClassifyNavigation methods get it wrong (see | 827 // For site-per-process, both ClassifyNavigation methods get it wrong (see |
| 827 // http://crbug.com/464014) so don't worry about a mismatch if that's the | 828 // http://crbug.com/464014) so don't worry about a mismatch if that's the |
| 828 // case. | 829 // case. |
| 829 DCHECK_EQ(details->type, ClassifyNavigationWithoutPageID(rfh, params)); | 830 DCHECK_EQ(details->type, ClassifyNavigationWithoutPageID(rfh, params)); |
| 830 } | 831 } |
| 831 | 832 |
| 832 // is_in_page must be computed before the entry gets committed. | 833 // is_in_page must be computed before the entry gets committed. |
| 833 details->is_in_page = AreURLsInPageNavigation(rfh->GetLastCommittedURL(), | 834 details->is_in_page = AreURLsInPageNavigation(rfh->GetLastCommittedURL(), |
| 834 params.url, params.was_within_same_page, rfh); | 835 params.url, params.was_within_same_page, rfh); |
| (...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2009 } | 2010 } |
| 2010 } | 2011 } |
| 2011 } | 2012 } |
| 2012 | 2013 |
| 2013 void NavigationControllerImpl::SetGetTimestampCallbackForTest( | 2014 void NavigationControllerImpl::SetGetTimestampCallbackForTest( |
| 2014 const base::Callback<base::Time()>& get_timestamp_callback) { | 2015 const base::Callback<base::Time()>& get_timestamp_callback) { |
| 2015 get_timestamp_callback_ = get_timestamp_callback; | 2016 get_timestamp_callback_ = get_timestamp_callback; |
| 2016 } | 2017 } |
| 2017 | 2018 |
| 2018 } // namespace content | 2019 } // namespace content |
| OLD | NEW |