diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-24 17:12:14 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-24 17:12:14 +0000 |
commit | 105bb0f7365ffbfa1530037f7d22595862d82bc4 (patch) | |
tree | 11a11dc36d9f962a630075b38165071aef2674cd /content | |
parent | 5312d4d73eefde8e63c01640e2ed6047c51bcec1 (diff) | |
download | chromium_src-105bb0f7365ffbfa1530037f7d22595862d82bc4.zip chromium_src-105bb0f7365ffbfa1530037f7d22595862d82bc4.tar.gz chromium_src-105bb0f7365ffbfa1530037f7d22595862d82bc4.tar.bz2 |
Remove history dependency from content.
BUG=76794
Review URL: http://codereview.chromium.org/7054008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86439 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/DEPS | 9 | ||||
-rw-r--r-- | content/browser/renderer_host/browser_render_process_host.cc | 1 | ||||
-rw-r--r-- | content/browser/renderer_host/render_process_host_browsertest.cc | 1 | ||||
-rw-r--r-- | content/browser/tab_contents/navigation_controller_unittest.cc | 200 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents.cc | 76 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents.h | 29 | ||||
-rw-r--r-- | content/browser/tab_contents/title_updated_details.h | 32 | ||||
-rw-r--r-- | content/common/notification_type.h | 4 | ||||
-rw-r--r-- | content/content_browser.gypi | 1 |
9 files changed, 140 insertions, 213 deletions
diff --git a/content/browser/DEPS b/content/browser/DEPS index 511995f..4f3a8f0 100644 --- a/content/browser/DEPS +++ b/content/browser/DEPS @@ -36,9 +36,6 @@ include_rules = [ "+chrome/browser/external_protocol_handler.h",
- # http://crbug.com/76794
- "+chrome/browser/history/history.h",
-
"+chrome/browser/load_from_memory_cache_details.h",
"+chrome/browser/load_notification_details.h",
@@ -106,16 +103,10 @@ include_rules = [ "+chrome/common/security_style.h",
# ONLY USED BY TESTS
- "+chrome/browser/chromeos/cros/mock_network_library.h",
"+chrome/browser/net/url_request_failed_dns_job.h",
"+chrome/browser/net/url_request_mock_http_job.h",
- "+chrome/browser/profiles/profile_manager.h",
- "+chrome/browser/sessions/session_service.h",
- "+chrome/browser/sessions/session_service_factory.h",
- "+chrome/browser/sessions/session_service_test_helper.h",
"+chrome/browser/ui/browser.h",
"+chrome/browser/ui/cocoa/find_pasteboard.h",
- "+chrome/browser/ui/tab_contents/tab_contents_wrapper.h",
"+chrome/common/net/test_url_fetcher_factory.h",
"+chrome/common/url_constants.h",
]
diff --git a/content/browser/renderer_host/browser_render_process_host.cc b/content/browser/renderer_host/browser_render_process_host.cc index e435a50..bb51104 100644 --- a/content/browser/renderer_host/browser_render_process_host.cc +++ b/content/browser/renderer_host/browser_render_process_host.cc @@ -27,7 +27,6 @@ #include "base/threading/thread.h" #include "base/threading/thread_restrictions.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/history/history.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/renderer_host/web_cache_manager.h" #include "chrome/common/chrome_paths.h" diff --git a/content/browser/renderer_host/render_process_host_browsertest.cc b/content/browser/renderer_host/render_process_host_browsertest.cc index ec093c6..4c442cf 100644 --- a/content/browser/renderer_host/render_process_host_browsertest.cc +++ b/content/browser/renderer_host/render_process_host_browsertest.cc @@ -5,7 +5,6 @@ #include "base/command_line.h" #include "chrome/browser/debugger/devtools_manager.h" #include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/url_constants.h" #include "chrome/test/in_process_browser_test.h" diff --git a/content/browser/tab_contents/navigation_controller_unittest.cc b/content/browser/tab_contents/navigation_controller_unittest.cc index 7c3ec23..73264c3 100644 --- a/content/browser/tab_contents/navigation_controller_unittest.cc +++ b/content/browser/tab_contents/navigation_controller_unittest.cc @@ -8,11 +8,13 @@ #include "base/stl_util-inl.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" -#include "chrome/browser/history/history.h" -#include "chrome/browser/profiles/profile_manager.h" -#include "chrome/browser/sessions/session_service.h" -#include "chrome/browser/sessions/session_service_factory.h" -#include "chrome/browser/sessions/session_service_test_helper.h" +// These are only used for commented out tests. If someone wants to enable +// them, they should be moved to chrome first. +// #include "chrome/browser/history/history.h" +// #include "chrome/browser/profiles/profile_manager.h" +// #include "chrome/browser/sessions/session_service.h" +// #include "chrome/browser/sessions/session_service_factory.h" +// #include "chrome/browser/sessions/session_service_test_helper.h" #include "chrome/browser/sessions/session_types.h" #include "chrome/common/render_messages.h" #include "chrome/test/test_notification_tracker.h" @@ -39,100 +41,6 @@ class NavigationControllerTest : public RenderViewHostTestHarness { NavigationControllerTest() {} }; -// NavigationControllerHistoryTest --------------------------------------------- - -class NavigationControllerHistoryTest : public NavigationControllerTest { - public: - NavigationControllerHistoryTest() - : url0("http://foo1"), - url1("http://foo1"), - url2("http://foo1"), - profile_manager_(NULL) { - } - - virtual ~NavigationControllerHistoryTest() { - // Prevent our base class from deleting the profile since profile's - // lifetime is managed by profile_manager_. - STLDeleteElements(&windows_); - } - - // testing::Test overrides. - virtual void SetUp() { - NavigationControllerTest::SetUp(); - - // Force the session service to be created. - SessionService* service = new SessionService(profile()); - SessionServiceFactory::SetForTestProfile(profile(), service); - service->SetWindowType(window_id, Browser::TYPE_TABBED); - service->SetWindowBounds(window_id, gfx::Rect(0, 1, 2, 3), false); - service->SetTabIndexInWindow(window_id, - controller().session_id(), 0); - controller().SetWindowID(window_id); - - session_helper_.set_service(service); - } - - virtual void TearDown() { - // Release profile's reference to the session service. Otherwise the file - // will still be open and we won't be able to delete the directory below. - session_helper_.ReleaseService(); // profile owns this - SessionServiceFactory::SetForTestProfile(profile(), NULL); - - // Make sure we wait for history to shut down before continuing. The task - // we add will cause our message loop to quit once it is destroyed. - HistoryService* history = - profile()->GetHistoryService(Profile::IMPLICIT_ACCESS); - if (history) { - history->SetOnBackendDestroyTask(new MessageLoop::QuitTask); - MessageLoop::current()->Run(); - } - - // Do normal cleanup before deleting the profile directory below. - NavigationControllerTest::TearDown(); - - ASSERT_TRUE(file_util::Delete(test_dir_, true)); - ASSERT_FALSE(file_util::PathExists(test_dir_)); - } - - // Deletes the current profile manager and creates a new one. Indirectly this - // shuts down the history database and reopens it. - void ReopenDatabase() { - session_helper_.set_service(NULL); - SessionServiceFactory::SetForTestProfile(profile(), NULL); - - SessionService* service = new SessionService(profile()); - SessionServiceFactory::SetForTestProfile(profile(), service); - session_helper_.set_service(service); - } - - void GetLastSession() { - SessionServiceFactory::GetForProfile(profile())->TabClosed( - controller().window_id(), controller().session_id(), false); - - ReopenDatabase(); - Time close_time; - - session_helper_.ReadWindows(&windows_); - } - - CancelableRequestConsumer consumer; - - // URLs for testing. - const GURL url0; - const GURL url1; - const GURL url2; - - std::vector<SessionWindow*> windows_; - - SessionID window_id; - - SessionServiceTestHelper session_helper_; - - private: - ProfileManager* profile_manager_; - FilePath test_dir_; -}; - void RegisterForAllNavNotifications(TestNotificationTracker* tracker, NavigationController* controller) { tracker->ListenFor(NotificationType::NAV_ENTRY_COMMITTED, @@ -2166,6 +2074,100 @@ TEST_F(NavigationControllerTest, PruneAllButActiveForTransient) { (but not Vista) cleaning up the directory after they run. This should be fixed. +// NavigationControllerHistoryTest --------------------------------------------- + +class NavigationControllerHistoryTest : public NavigationControllerTest { + public: + NavigationControllerHistoryTest() + : url0("http://foo1"), + url1("http://foo1"), + url2("http://foo1"), + profile_manager_(NULL) { + } + + virtual ~NavigationControllerHistoryTest() { + // Prevent our base class from deleting the profile since profile's + // lifetime is managed by profile_manager_. + STLDeleteElements(&windows_); + } + + // testing::Test overrides. + virtual void SetUp() { + NavigationControllerTest::SetUp(); + + // Force the session service to be created. + SessionService* service = new SessionService(profile()); + SessionServiceFactory::SetForTestProfile(profile(), service); + service->SetWindowType(window_id, Browser::TYPE_TABBED); + service->SetWindowBounds(window_id, gfx::Rect(0, 1, 2, 3), false); + service->SetTabIndexInWindow(window_id, + controller().session_id(), 0); + controller().SetWindowID(window_id); + + session_helper_.set_service(service); + } + + virtual void TearDown() { + // Release profile's reference to the session service. Otherwise the file + // will still be open and we won't be able to delete the directory below. + session_helper_.ReleaseService(); // profile owns this + SessionServiceFactory::SetForTestProfile(profile(), NULL); + + // Make sure we wait for history to shut down before continuing. The task + // we add will cause our message loop to quit once it is destroyed. + HistoryService* history = + profile()->GetHistoryService(Profile::IMPLICIT_ACCESS); + if (history) { + history->SetOnBackendDestroyTask(new MessageLoop::QuitTask); + MessageLoop::current()->Run(); + } + + // Do normal cleanup before deleting the profile directory below. + NavigationControllerTest::TearDown(); + + ASSERT_TRUE(file_util::Delete(test_dir_, true)); + ASSERT_FALSE(file_util::PathExists(test_dir_)); + } + + // Deletes the current profile manager and creates a new one. Indirectly this + // shuts down the history database and reopens it. + void ReopenDatabase() { + session_helper_.set_service(NULL); + SessionServiceFactory::SetForTestProfile(profile(), NULL); + + SessionService* service = new SessionService(profile()); + SessionServiceFactory::SetForTestProfile(profile(), service); + session_helper_.set_service(service); + } + + void GetLastSession() { + SessionServiceFactory::GetForProfile(profile())->TabClosed( + controller().window_id(), controller().session_id(), false); + + ReopenDatabase(); + Time close_time; + + session_helper_.ReadWindows(&windows_); + } + + CancelableRequestConsumer consumer; + + // URLs for testing. + const GURL url0; + const GURL url1; + const GURL url2; + + std::vector<SessionWindow*> windows_; + + SessionID window_id; + + SessionServiceTestHelper session_helper_; + + private: + ProfileManager* profile_manager_; + FilePath test_dir_; +}; + // A basic test case. Navigates to a single url, and make sure the history // db matches. TEST_F(NavigationControllerHistoryTest, Basic) { diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc index e6f8aa0..34365f3 100644 --- a/content/browser/tab_contents/tab_contents.cc +++ b/content/browser/tab_contents/tab_contents.cc @@ -17,7 +17,6 @@ #include "chrome/browser/debugger/devtools_manager.h" #include "chrome/browser/defaults.h" #include "chrome/browser/external_protocol_handler.h" -#include "chrome/browser/history/history.h" #include "chrome/browser/load_from_memory_cache_details.h" #include "chrome/browser/load_notification_details.h" #include "chrome/browser/notifications/desktop_notification_service.h" @@ -46,6 +45,7 @@ #include "content/browser/tab_contents/tab_contents_delegate.h" #include "content/browser/tab_contents/tab_contents_observer.h" #include "content/browser/tab_contents/tab_contents_view.h" +#include "content/browser/tab_contents/title_updated_details.h" #include "content/browser/user_metrics.h" #include "content/browser/webui/web_ui_factory.h" #include "content/common/bindings_policy.h" @@ -215,7 +215,6 @@ TabContents::TabContents(Profile* profile, load_state_(net::LOAD_STATE_IDLE), upload_size_(0), upload_position_(0), - received_page_title_(false), displayed_insecure_content_(false), capturing_contents_(false), is_being_destroyed_(false), @@ -804,26 +803,6 @@ void TabContents::SystemDragEnded() { delegate()->DragEnded(); } -void TabContents::UpdateHistoryForNavigation( - scoped_refptr<history::HistoryAddPageArgs> add_page_args) { - if (profile()->IsOffTheRecord()) - return; - - // Add to history service. - HistoryService* hs = profile()->GetHistoryService(Profile::IMPLICIT_ACCESS); - if (hs) - hs->AddPage(*add_page_args); -} - -void TabContents::UpdateHistoryPageTitle(const NavigationEntry& entry) { - if (profile()->IsOffTheRecord()) - return; - - HistoryService* hs = profile()->GetHistoryService(Profile::IMPLICIT_ACCESS); - if (hs) - hs->SetPageTitle(entry.virtual_url(), entry.title()); -} - double TabContents::GetZoomLevel() const { HostZoomMap* zoom_map = profile()->GetHostZoomMap(); if (!zoom_map) @@ -1170,9 +1149,6 @@ void TabContents::DidNavigateMainFramePostCommit( UpdateTargetURL(details.entry->page_id(), GURL()); } - // Allow the new page to set the title again. - received_page_title_ = false; - if (!details.is_in_page) { // Once the main frame is navigated, we're no longer considered to have // displayed insecure content. @@ -1262,31 +1238,6 @@ void TabContents::UpdateMaxPageIDIfNecessary(SiteInstance* site_instance, } } -scoped_refptr<history::HistoryAddPageArgs> -TabContents::CreateHistoryAddPageArgs( - const GURL& virtual_url, - const NavigationController::LoadCommittedDetails& details, - const ViewHostMsg_FrameNavigate_Params& params) { - scoped_refptr<history::HistoryAddPageArgs> add_page_args( - new history::HistoryAddPageArgs( - params.url, base::Time::Now(), this, params.page_id, params.referrer, - params.redirects, params.transition, history::SOURCE_BROWSED, - details.did_replace_entry)); - if (PageTransition::IsMainFrame(params.transition) && - virtual_url != params.url) { - // Hack on the "virtual" URL so that it will appear in history. For some - // types of URLs, we will display a magic URL that is different from where - // the page is actually navigated. We want the user to see in history what - // they saw in the URL bar, so we add the virtual URL as a redirect. This - // only applies to the main frame, as the virtual URL doesn't apply to - // sub-frames. - add_page_args->url = virtual_url; - if (!add_page_args->redirects.empty()) - add_page_args->redirects.back() = virtual_url; - } - return add_page_args; -} - bool TabContents::UpdateTitleForEntry(NavigationEntry* entry, const std::wstring& title) { // For file URLs without a title, use the pathname instead. In the case of a @@ -1307,18 +1258,15 @@ bool TabContents::UpdateTitleForEntry(NavigationEntry* entry, entry->set_title(final_title); - if (!received_page_title_) { - UpdateHistoryPageTitle(*entry); - received_page_title_ = explicit_set; - } - // Lastly, set the title for the view. view_->SetPageTitle(UTF16ToWideHack(final_title)); + TitleUpdatedDetails details(entry, explicit_set); + NotificationService::current()->Notify( NotificationType::TAB_CONTENTS_TITLE_UPDATED, Source<TabContents>(this), - NotificationService::NoDetails()); + Details<TitleUpdatedDetails>(&details)); return true; } @@ -1515,22 +1463,6 @@ void TabContents::DidNavigate(RenderViewHost* rvh, is_main_frame, params.url, transition_type)); } - // Update history. Note that this needs to happen after the entry is complete, - // which WillNavigate[Main,Sub]Frame will do before this function is called. - if (params.should_update_history) { - // Most of the time, the displayURL matches the loaded URL, but for about: - // URLs, we use a data: URL as the real value. We actually want to save the - // about: URL to the history db and keep the data: URL hidden. This is what - // the TabContents' URL getter does. - scoped_refptr<history::HistoryAddPageArgs> add_page_args( - CreateHistoryAddPageArgs(GetURL(), details, params)); - if (!delegate() || - delegate()->ShouldAddNavigationToHistory(*add_page_args, - details.type)) { - UpdateHistoryForNavigation(add_page_args); - } - } - if (!did_navigate) return; // No navigation happened. diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h index 3f43e22..f4020c9 100644 --- a/content/browser/tab_contents/tab_contents.h +++ b/content/browser/tab_contents/tab_contents.h @@ -39,10 +39,6 @@ namespace gfx { class Rect; } -namespace history { -class HistoryAddPageArgs; -} - class Extension; class LoadNotificationDetails; class Profile; @@ -471,15 +467,6 @@ class TabContents : public PageNavigator, virtual void SetBookmarkDragDelegate( RenderViewHostDelegate::BookmarkDrag* bookmark_drag); - // Updates history with the specified navigation. This is called by - // OnMsgNavigate to update history state. - void UpdateHistoryForNavigation( - scoped_refptr<history::HistoryAddPageArgs> add_page_args); - - // Sends the page title to the history service. This is called when we receive - // the page title and we know we want to update history. - void UpdateHistoryPageTitle(const NavigationEntry& entry); - // Gets the zoom level for this tab. double GetZoomLevel() const; @@ -551,9 +538,6 @@ class TabContents : public PageNavigator, // TODO(brettw) TestTabContents shouldn't exist! friend class TestTabContents; - // Used to access the CreateHistoryAddPageArgs member function. - friend class ExternalTabContainer; - // Add all the TabContentObservers. void AddObservers(); @@ -633,13 +617,6 @@ class TabContents : public PageNavigator, void UpdateMaxPageIDIfNecessary(SiteInstance* site_instance, RenderViewHost* rvh); - // Returns the history::HistoryAddPageArgs to use for adding a page to - // history. - scoped_refptr<history::HistoryAddPageArgs> CreateHistoryAddPageArgs( - const GURL& virtual_url, - const NavigationController::LoadCommittedDetails& details, - const ViewHostMsg_FrameNavigate_Params& params); - // Saves the given title to the navigation entry and does associated work. It // will update history and the view for the new title, and also synthesize // titles for file URLs that have none (so we require that the URL of the @@ -831,12 +808,6 @@ class TabContents : public PageNavigator, // Data for current page ----------------------------------------------------- - // Whether we have a (non-empty) title for the current page. - // Used to prevent subsequent title updates from affecting history. This - // prevents some weirdness because some AJAXy apps use titles for status - // messages. - bool received_page_title_; - // When a navigation occurs, we record its contents MIME type. It can be // used to check whether we can do something for some special contents. std::string contents_mime_type_; diff --git a/content/browser/tab_contents/title_updated_details.h b/content/browser/tab_contents/title_updated_details.h new file mode 100644 index 0000000..89b7b7e --- /dev/null +++ b/content/browser/tab_contents/title_updated_details.h @@ -0,0 +1,32 @@ +// 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. + +#ifndef CONTENT_BROWSER_TAB_CONTENTS_TITLE_UPDATED_DETAILS_ +#define CONTENT_BROWSER_TAB_CONTENTS_TITLE_UPDATED_DETAILS_ +#pragma once + +#include "base/basictypes.h" + +class NavigationEntry; + +class TitleUpdatedDetails { + public: + TitleUpdatedDetails(const NavigationEntry* entry, bool explicit_set) + : entry_(entry), + explicit_set_(explicit_set) {} + ~TitleUpdatedDetails() {} + + const NavigationEntry* entry() const { return entry_; } + bool explicit_set() const { return explicit_set_; } + + private: + const NavigationEntry* entry_; + bool explicit_set_; // If a synthesized title. + + TitleUpdatedDetails() {} + + DISALLOW_COPY_AND_ASSIGN(TitleUpdatedDetails); +}; + +#endif // CONTENT_BROWSER_TAB_CONTENTS_TITLE_UPDATED_DETAILS_ diff --git a/content/common/notification_type.h b/content/common/notification_type.h index ad81546..f2428ba 100644 --- a/content/common/notification_type.h +++ b/content/common/notification_type.h @@ -329,8 +329,8 @@ class NotificationType { TAB_CONTENTS_DISCONNECTED, // This notification is sent after TabContents' title is updated. The source - // is a Source<TabContents> with a pointer to the TabContents. No details - // are expected. + // is a Source<TabContents> with a pointer to the TabContents. The details + // is a Details<TitleUpdatedDetails> that contains more information. TAB_CONTENTS_TITLE_UPDATED, // This message is sent when a new InfoBar has been added to a TabContents. diff --git a/content/content_browser.gypi b/content/content_browser.gypi index 6d13ab6..612e744 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -315,6 +315,7 @@ 'browser/tab_contents/tab_contents_observer.h', 'browser/tab_contents/tab_contents_view.cc', 'browser/tab_contents/tab_contents_view.h', + 'browser/tab_contents/title_updated_details.h', 'browser/trace_controller.cc', 'browser/trace_controller.h', 'browser/trace_message_filter.cc', |