summaryrefslogtreecommitdiffstats
path: root/content/browser
diff options
context:
space:
mode:
Diffstat (limited to 'content/browser')
-rw-r--r--content/browser/DEPS5
-rw-r--r--content/browser/tab_contents/tab_contents.cc81
-rw-r--r--content/browser/tab_contents/tab_contents.h37
-rw-r--r--content/browser/tab_contents/tab_contents_observer.cc4
-rw-r--r--content/browser/tab_contents/tab_contents_observer.h4
-rw-r--r--content/browser/webui/web_ui_unittest.cc195
6 files changed, 14 insertions, 312 deletions
diff --git a/content/browser/DEPS b/content/browser/DEPS
index 5a7dec8..245dcfb 100644
--- a/content/browser/DEPS
+++ b/content/browser/DEPS
@@ -2,7 +2,7 @@ include_rules = [
"+content/gpu", # For gpu_info_collector.h. Needs to move to common\gpu.
# Listing of the remaining #chrome includes in content\browser. People are
- # actively working on reducing this to 0. Do not add anymore!
+ # actively working on reducing this to 0. Do not add any more!
"+chrome/browser/accessibility/browser_accessibility_state.h",
@@ -49,9 +49,6 @@ include_rules = [
"+chrome/browser/external_protocol_handler.h",
- "+chrome/browser/favicon/favicon_tab_helper.h",
- "+chrome/browser/favicon/favicon_service.h",
-
# http://crbug.com/76794
"+chrome/browser/history/history.h",
"+chrome/browser/history/history_types.h",
diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc
index 624691b..4119f0f 100644
--- a/content/browser/tab_contents/tab_contents.cc
+++ b/content/browser/tab_contents/tab_contents.cc
@@ -23,7 +23,6 @@
#include "chrome/browser/download/download_manager.h"
#include "chrome/browser/download/download_request_limiter.h"
#include "chrome/browser/external_protocol_handler.h"
-#include "chrome/browser/favicon/favicon_service.h"
#include "chrome/browser/history/history.h"
#include "chrome/browser/history/history_types.h"
#include "chrome/browser/load_from_memory_cache_details.h"
@@ -343,7 +342,6 @@ TabContents::~TabContents() {
void TabContents::AddObservers() {
content_settings_delegate_.reset(new TabSpecificContentSettings(this));
- favicon_tab_helper_.reset(new FaviconTabHelper(this));
plugin_observer_.reset(new PluginObserver(this));
net::NetworkChangeNotifier::AddOnlineStateObserver(this);
}
@@ -482,42 +480,6 @@ bool TabContents::ShouldDisplayURL() {
return true;
}
-SkBitmap TabContents::GetFavicon() const {
- // Like GetTitle(), we also want to use the favicon for the last committed
- // entry rather than a pending navigation entry.
- NavigationEntry* entry = controller_.GetTransientEntry();
- if (entry)
- return entry->favicon().bitmap();
-
- entry = controller_.GetLastCommittedEntry();
- if (entry)
- return entry->favicon().bitmap();
- return SkBitmap();
-}
-
-bool TabContents::FaviconIsValid() const {
- NavigationEntry* entry = controller_.GetTransientEntry();
- if (entry)
- return entry->favicon().is_valid();
-
- entry = controller_.GetLastCommittedEntry();
- if (entry)
- return entry->favicon().is_valid();
-
- return false;
-}
-
-bool TabContents::ShouldDisplayFavicon() {
- // Always display a throbber during pending loads.
- if (controller_.GetLastCommittedEntry() && controller_.pending_entry())
- return true;
-
- WebUI* web_ui = GetWebUIForCurrentState();
- if (web_ui)
- return !web_ui->hide_favicon();
- return true;
-}
-
void TabContents::AddObserver(TabContentsObserver* observer) {
observers_.AddObserver(observer);
}
@@ -673,15 +635,9 @@ bool TabContents::NavigateToEntry(
}
// Notify observers about navigation.
- FOR_EACH_OBSERVER(TabContentsObserver, observers_, NavigateToPendingEntry());
-
- if (reload_type != NavigationController::NO_RELOAD &&
- !profile()->IsOffTheRecord()) {
- FaviconService* favicon_service =
- profile()->GetFaviconService(Profile::IMPLICIT_ACCESS);
- if (favicon_service)
- favicon_service->SetFaviconOutOfDateForPage(entry.url());
- }
+ FOR_EACH_OBSERVER(TabContentsObserver,
+ observers_,
+ NavigateToPendingEntry(entry.url(), reload_type));
return true;
}
@@ -715,34 +671,6 @@ void TabContents::ShowPageInfo(const GURL& url,
delegate_->ShowPageInfo(profile(), url, ssl, show_history);
}
-void TabContents::SaveFavicon() {
- NavigationEntry* entry = controller_.GetActiveEntry();
- if (!entry || entry->url().is_empty())
- return;
-
- // Make sure the page is in history, otherwise adding the favicon does
- // nothing.
- HistoryService* history = profile()->GetOriginalProfile()->GetHistoryService(
- Profile::IMPLICIT_ACCESS);
- if (!history)
- return;
- history->AddPageNoVisitForBookmark(entry->url());
-
- FaviconService* service = profile()->GetOriginalProfile()->GetFaviconService(
- Profile::IMPLICIT_ACCESS);
- if (!service)
- return;
- const NavigationEntry::FaviconStatus& favicon(entry->favicon());
- if (!favicon.is_valid() || favicon.url().is_empty() ||
- favicon.bitmap().empty()) {
- return;
- }
- std::vector<unsigned char> image_data;
- gfx::PNGCodec::EncodeBGRASkBitmap(favicon.bitmap(), false, &image_data);
- service->SetFavicon(
- entry->url(), favicon.url(), image_data, history::FAVICON);
-}
-
ConstrainedWindow* TabContents::CreateConstrainedDialog(
ConstrainedWindowDelegate* delegate) {
ConstrainedWindow* window =
@@ -1372,9 +1300,6 @@ void TabContents::DidNavigateMainFramePostCommit(
// Allow the new page to set the title again.
received_page_title_ = false;
- // Get the favicon, either from history or request it from the net.
- favicon_tab_helper_->FetchFavicon(details.entry->url());
-
if (!details.is_in_page) {
// Once the main frame is navigated, we're no longer considered to have
// displayed insecure content.
diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h
index 9dc47a6..bfba774 100644
--- a/content/browser/tab_contents/tab_contents.h
+++ b/content/browser/tab_contents/tab_contents.h
@@ -15,7 +15,6 @@
#include "base/gtest_prod_util.h"
#include "base/memory/scoped_ptr.h"
#include "base/string16.h"
-#include "chrome/browser/favicon/favicon_tab_helper.h"
#include "chrome/browser/prefs/pref_change_registrar.h"
#include "chrome/browser/tab_contents/tab_specific_content_settings.h"
#include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h"
@@ -152,11 +151,6 @@ class TabContents : public PageNavigator,
return view_.get();
}
- // Returns the FaviconTabHelper of this TabContents.
- FaviconTabHelper& favicon_helper() {
- return *favicon_tab_helper_.get();
- }
-
// Tab navigation state ------------------------------------------------------
// Returns the current navigation properties, which if a navigation is
@@ -185,19 +179,6 @@ class TabContents : public PageNavigator,
// the user is invited to type into it.
virtual bool ShouldDisplayURL();
- // Returns the favicon for this tab, or IDR_DEFAULT_FAVICON if the tab does
- // not have a favicon. The default implementation uses the current navigation
- // entry. This will return an isNull bitmap if there are no navigation
- // entries, which should rarely happen.
- SkBitmap GetFavicon() const;
-
- // Returns true if we are not using the default favicon.
- bool FaviconIsValid() const;
-
- // Returns whether the favicon should be displayed. If this returns false, no
- // space is provided for the favicon, and the favicon is never displayed.
- virtual bool ShouldDisplayFavicon();
-
// Return whether this tab contents is loading a resource.
bool is_loading() const { return is_loading_; }
@@ -322,9 +303,6 @@ class TabContents : public PageNavigator,
const NavigationEntry::SSLStatus& ssl,
bool show_history);
- // Saves the favicon for the current page.
- void SaveFavicon();
-
// Window management ---------------------------------------------------------
// Create a new window constrained to this TabContents' clip and visibility.
@@ -573,6 +551,10 @@ class TabContents : public PageNavigator,
// Query the WebUIFactory for the TypeID for the current URL.
WebUI::TypeID GetWebUITypeForCurrentState();
+ // Returns the WebUI for the current state of the tab. This will either be
+ // the pending WebUI, the committed WebUI, or NULL.
+ WebUI* GetWebUIForCurrentState();
+
// From RenderViewHostDelegate.
virtual RenderViewHostDelegate::ContentSettings* GetContentSettingsDelegate();
@@ -668,10 +650,6 @@ class TabContents : public PageNavigator,
void ExpireInfoBars(
const NavigationController::LoadCommittedDetails& details);
- // Returns the WebUI for the current state of the tab. This will either be
- // the pending WebUI, the committed WebUI, or NULL.
- WebUI* GetWebUIForCurrentState();
-
// Navigation helpers --------------------------------------------------------
//
// These functions are helpers for Navigate() and DidNavigate().
@@ -887,9 +865,6 @@ class TabContents : public PageNavigator,
// Handles drag and drop event forwarding to extensions.
BookmarkDrag* bookmark_drag_;
- // Handles downloading favicons.
- scoped_ptr<FaviconTabHelper> favicon_tab_helper_;
-
// RenderViewHost::ContentSettingsDelegate.
scoped_ptr<TabSpecificContentSettings> content_settings_delegate_;
@@ -959,10 +934,6 @@ class TabContents : public PageNavigator,
// once.
bool notify_disconnection_;
- // Maps from handle to page_id.
- typedef std::map<FaviconService::Handle, int32> HistoryRequestMap;
- HistoryRequestMap history_requests_;
-
#if defined(OS_WIN)
// 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
diff --git a/content/browser/tab_contents/tab_contents_observer.cc b/content/browser/tab_contents/tab_contents_observer.cc
index 50bf910..5649de6 100644
--- a/content/browser/tab_contents/tab_contents_observer.cc
+++ b/content/browser/tab_contents/tab_contents_observer.cc
@@ -25,7 +25,9 @@ void TabContentsObserver::Registrar::Observe(TabContents* tab) {
tab_->AddObserver(observer_);
}
-void TabContentsObserver::NavigateToPendingEntry() {
+void TabContentsObserver::NavigateToPendingEntry(
+ const GURL& url,
+ NavigationController::ReloadType reload_type) {
}
void TabContentsObserver::DidNavigateMainFramePostCommit(
diff --git a/content/browser/tab_contents/tab_contents_observer.h b/content/browser/tab_contents/tab_contents_observer.h
index 9169cb0..bc1aba2 100644
--- a/content/browser/tab_contents/tab_contents_observer.h
+++ b/content/browser/tab_contents/tab_contents_observer.h
@@ -37,7 +37,9 @@ class TabContentsObserver : public IPC::Channel::Listener,
DISALLOW_COPY_AND_ASSIGN(Registrar);
};
- virtual void NavigateToPendingEntry();
+ virtual void NavigateToPendingEntry(
+ const GURL& url,
+ NavigationController::ReloadType reload_type);
virtual void DidNavigateMainFramePostCommit(
const NavigationController::LoadCommittedDetails& details,
diff --git a/content/browser/webui/web_ui_unittest.cc b/content/browser/webui/web_ui_unittest.cc
deleted file mode 100644
index 8c77777..0000000
--- a/content/browser/webui/web_ui_unittest.cc
+++ /dev/null
@@ -1,195 +0,0 @@
-// 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.
-
-#include "chrome/common/url_constants.h"
-#include "chrome/test/testing_profile.h"
-#include "content/browser/browser_thread.h"
-#include "content/browser/renderer_host/test_render_view_host.h"
-#include "content/browser/site_instance.h"
-#include "content/browser/tab_contents/navigation_controller.h"
-#include "content/browser/tab_contents/test_tab_contents.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-class WebUITest : public RenderViewHostTestHarness {
- public:
- WebUITest() : ui_thread_(BrowserThread::UI, MessageLoop::current()) {}
-
- // Tests navigating with a Web UI from a fresh (nothing pending or committed)
- // state, through pending, committed, then another navigation. The first page
- // ID that we should use is passed as a parameter. We'll use the next two
- // values. This must be increasing for the life of the tests.
- static void DoNavigationTest(TabContents* contents, int page_id) {
- NavigationController* controller = &contents->controller();
-
- // Start a pending load.
- GURL new_tab_url(chrome::kChromeUINewTabURL);
- controller->LoadURL(new_tab_url, GURL(), PageTransition::LINK);
-
- // The navigation entry should be pending with no committed entry.
- ASSERT_TRUE(controller->pending_entry());
- ASSERT_FALSE(controller->GetLastCommittedEntry());
-
- // Check the things the pending Web UI should have set.
- EXPECT_FALSE(contents->ShouldDisplayURL());
- EXPECT_FALSE(contents->ShouldDisplayFavicon());
- EXPECT_TRUE(contents->ShouldShowBookmarkBar());
- EXPECT_TRUE(contents->FocusLocationBarByDefault());
-
- // Now commit the load.
- static_cast<TestRenderViewHost*>(
- contents->render_view_host())->SendNavigate(page_id, new_tab_url);
-
- // The same flags should be set as before now that the load has committed.
- EXPECT_FALSE(contents->ShouldDisplayURL());
- EXPECT_FALSE(contents->ShouldDisplayFavicon());
- EXPECT_TRUE(contents->ShouldShowBookmarkBar());
- EXPECT_TRUE(contents->FocusLocationBarByDefault());
-
- // Start a pending navigation to a regular page.
- GURL next_url("http://google.com/");
- controller->LoadURL(next_url, GURL(), PageTransition::LINK);
-
- // Check the flags. Some should reflect the new page (URL, title), some
- // should reflect the old one (bookmark bar) until it has committed.
- EXPECT_TRUE(contents->ShouldDisplayURL());
- EXPECT_TRUE(contents->ShouldDisplayFavicon());
- EXPECT_TRUE(contents->ShouldShowBookmarkBar());
- EXPECT_FALSE(contents->FocusLocationBarByDefault());
-
- // Commit the regular page load. Note that we must send it to the "pending"
- // RenderViewHost if there is one, since this transition will also cause a
- // process transition, and our RVH pointer will be the "committed" one.
- // In the second call to this function from WebUIToStandard, it won't
- // actually be pending, which is the point of this test.
- if (contents->render_manager()->pending_render_view_host()) {
- static_cast<TestRenderViewHost*>(
- contents->render_manager()->pending_render_view_host())->SendNavigate(
- page_id + 1, next_url);
- } else {
- static_cast<TestRenderViewHost*>(
- contents->render_view_host())->SendNavigate(page_id + 1, next_url);
- }
-
- // The state should now reflect a regular page.
- EXPECT_TRUE(contents->ShouldDisplayURL());
- EXPECT_TRUE(contents->ShouldDisplayFavicon());
- EXPECT_FALSE(contents->ShouldShowBookmarkBar());
- EXPECT_FALSE(contents->FocusLocationBarByDefault());
- }
-
- private:
- BrowserThread ui_thread_;
-
- DISALLOW_COPY_AND_ASSIGN(WebUITest);
-};
-
-// Tests that the New Tab Page flags are correctly set and propogated by
-// TabContents when we first navigate to a Web UI page, then to a standard
-// non-DOM-UI page.
-TEST_F(WebUITest, WebUIToStandard) {
- DoNavigationTest(contents(), 1);
-
- // Test the case where we're not doing the initial navigation. This is
- // slightly different than the very-first-navigation case since the
- // SiteInstance will be the same (the original TabContents must still be
- // alive), which will trigger different behavior in RenderViewHostManager.
- TestTabContents contents2(profile_.get(), NULL);
-
- DoNavigationTest(&contents2, 101);
-}
-
-TEST_F(WebUITest, WebUIToWebUI) {
- // Do a load (this state is tested above).
- GURL new_tab_url(chrome::kChromeUINewTabURL);
- controller().LoadURL(new_tab_url, GURL(), PageTransition::LINK);
- rvh()->SendNavigate(1, new_tab_url);
-
- // Start another pending load of the new tab page.
- controller().LoadURL(new_tab_url, GURL(), PageTransition::LINK);
- rvh()->SendNavigate(2, new_tab_url);
-
- // The flags should be the same as the non-pending state.
- EXPECT_FALSE(contents()->ShouldDisplayURL());
- EXPECT_FALSE(contents()->ShouldDisplayFavicon());
- EXPECT_TRUE(contents()->ShouldShowBookmarkBar());
- EXPECT_TRUE(contents()->FocusLocationBarByDefault());
-}
-
-TEST_F(WebUITest, StandardToWebUI) {
- // Start a pending navigation to a regular page.
- GURL std_url("http://google.com/");
-
- controller().LoadURL(std_url, GURL(), PageTransition::LINK);
-
- // The state should now reflect the default.
- EXPECT_TRUE(contents()->ShouldDisplayURL());
- EXPECT_TRUE(contents()->ShouldDisplayFavicon());
- EXPECT_FALSE(contents()->ShouldShowBookmarkBar());
- EXPECT_FALSE(contents()->FocusLocationBarByDefault());
-
- // Commit the load, the state should be the same.
- rvh()->SendNavigate(1, std_url);
- EXPECT_TRUE(contents()->ShouldDisplayURL());
- EXPECT_TRUE(contents()->ShouldDisplayFavicon());
- EXPECT_FALSE(contents()->ShouldShowBookmarkBar());
- EXPECT_FALSE(contents()->FocusLocationBarByDefault());
-
- // Start a pending load for a WebUI.
- GURL new_tab_url(chrome::kChromeUINewTabURL);
- controller().LoadURL(new_tab_url, GURL(), PageTransition::LINK);
- EXPECT_FALSE(contents()->ShouldDisplayURL());
- EXPECT_TRUE(contents()->ShouldDisplayFavicon());
- EXPECT_FALSE(contents()->ShouldShowBookmarkBar());
- EXPECT_TRUE(contents()->FocusLocationBarByDefault());
-
- // Committing Web UI is tested above.
-}
-
-class TabContentsForFocusTest : public TestTabContents {
- public:
- TabContentsForFocusTest(Profile* profile, SiteInstance* instance)
- : TestTabContents(profile, instance), focus_called_(0) {
- }
-
- virtual void SetFocusToLocationBar(bool select_all) { ++focus_called_; }
- int focus_called() const { return focus_called_; }
-
- private:
- int focus_called_;
-};
-
-TEST_F(WebUITest, FocusOnNavigate) {
- // Setup. |tc| will be used to track when we try to focus the location bar.
- TabContentsForFocusTest* tc = new TabContentsForFocusTest(
- contents()->profile(),
- SiteInstance::CreateSiteInstance(contents()->profile()));
- tc->controller().CopyStateFrom(controller());
- SetContents(tc);
- int page_id = 200;
-
- // Load the NTP.
- GURL new_tab_url(chrome::kChromeUINewTabURL);
- controller().LoadURL(new_tab_url, GURL(), PageTransition::LINK);
- rvh()->SendNavigate(page_id, new_tab_url);
-
- // Navigate to another page.
- GURL next_url("http://google.com/");
- int next_page_id = page_id + 1;
- controller().LoadURL(next_url, GURL(), PageTransition::LINK);
- pending_rvh()->SendNavigate(next_page_id, next_url);
-
- // Navigate back. Should focus the location bar.
- int focus_called = tc->focus_called();
- ASSERT_TRUE(controller().CanGoBack());
- controller().GoBack();
- pending_rvh()->SendNavigate(page_id, new_tab_url);
- EXPECT_LT(focus_called, tc->focus_called());
-
- // Navigate forward. Shouldn't focus the location bar.
- focus_called = tc->focus_called();
- ASSERT_TRUE(controller().CanGoForward());
- controller().GoForward();
- pending_rvh()->SendNavigate(next_page_id, next_url);
- EXPECT_EQ(focus_called, tc->focus_called());
-}