summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-17 22:13:19 +0000
committerpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-17 22:13:19 +0000
commita239c3f7a4dbf736b6b5dce686619819f6c86f18 (patch)
tree081722636f668bb0198713a788be349bc940c6b1
parent41528efa2a2fd9e199f422dffd64c95518adc838 (diff)
downloadchromium_src-a239c3f7a4dbf736b6b5dce686619819f6c86f18.zip
chromium_src-a239c3f7a4dbf736b6b5dce686619819f6c86f18.tar.gz
chromium_src-a239c3f7a4dbf736b6b5dce686619819f6c86f18.tar.bz2
Remove TabContentsDelegate from scaffolding. Remove a large chunk of ifdef'd code from browser.cc to go along with it as well as enabling more functionality.
Review URL: http://codereview.chromium.org/21424 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9908 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser.cc31
-rw-r--r--chrome/browser/browser.h17
-rw-r--r--chrome/browser/fav_icon_helper.cc7
-rw-r--r--chrome/common/temp_scaffolding_stubs.cc21
-rw-r--r--chrome/common/temp_scaffolding_stubs.h64
5 files changed, 27 insertions, 113 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 4c87134..06b6281 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/location_bar.h"
#include "chrome/browser/metrics/user_metrics.h"
+#include "chrome/browser/net/url_fixer_upper.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/sessions/session_service.h"
#include "chrome/browser/sessions/session_types.h"
@@ -59,7 +60,6 @@
#include "chrome/browser/download/save_package.h"
#include "chrome/browser/history_tab_ui.h"
#include "chrome/browser/options_window.h"
-#include "chrome/browser/net/url_fixer_upper.h"
#include "chrome/browser/ssl/ssl_error_info.h"
#include "chrome/browser/status_bubble.h"
#include "chrome/browser/tab_contents/interstitial_page.h"
@@ -450,8 +450,12 @@ void Browser::OnWindowClosing() {
if (!ShouldCloseWindow())
return;
+#if defined(OS_WIN) || defined(OS_LINUX)
+ // We don't want to do this on Mac since closing all windows isn't a sign
+ // that the app is shutting down.
if (BrowserList::size() == 1)
browser_shutdown::OnShutdownStarting(browser_shutdown::WINDOW_CLOSE);
+#endif
// Don't use HasSessionService here, we want to force creation of the
// session service so that user can restore what was open.
@@ -529,7 +533,6 @@ void Browser::ReplaceRestoredTab(
restored_controller);
}
-#if defined(OS_WIN)
void Browser::ShowNativeUITab(const GURL& url) {
int i, c;
TabContents* tc;
@@ -547,7 +550,6 @@ void Browser::ShowNativeUITab(const GURL& url) {
NULL);
AddNewContents(NULL, contents, NEW_FOREGROUND_TAB, gfx::Rect(), true);
}
-#endif // OS_WIN
///////////////////////////////////////////////////////////////////////////////
// Browser, Assorted browser commands:
@@ -1414,8 +1416,6 @@ void Browser::TabInsertedAt(TabContents* contents,
Source<TabContents>(contents));
}
-#if defined(OS_WIN)
-
void Browser::TabClosingAt(TabContents* contents, int index) {
NavigationController* controller = contents->controller();
DCHECK(controller);
@@ -1441,8 +1441,6 @@ void Browser::TabDetachedAt(TabContents* contents, int index) {
Source<TabContents>(contents));
}
-#endif
-
void Browser::TabSelectedAt(TabContents* old_contents,
TabContents* new_contents,
int index,
@@ -1652,8 +1650,6 @@ void Browser::ReplaceContents(TabContents* source, TabContents* new_contents) {
Source<TabContents>(new_contents));
}
-#if defined(OS_WIN)
-
void Browser::AddNewContents(TabContents* source,
TabContents* new_contents,
WindowOpenDisposition disposition,
@@ -1756,6 +1752,8 @@ void Browser::URLStarredChanged(TabContents* source, bool starred) {
window_->SetStarredState(starred);
}
+#if defined(OS_WIN)
+// TODO(port): Refactor this to win-specific delegate?
void Browser::ContentsMouseEvent(TabContents* source, UINT message) {
if (!GetStatusBubble())
return;
@@ -1768,6 +1766,7 @@ void Browser::ContentsMouseEvent(TabContents* source, UINT message) {
}
}
}
+#endif
void Browser::UpdateTargetURL(TabContents* source, const GURL& url) {
if (!GetStatusBubble())
@@ -1802,16 +1801,12 @@ void Browser::ConvertContentsToApplication(TabContents* contents) {
browser->window()->Show();
}
-#endif // OS_WIN
-
void Browser::ContentsStateChanged(TabContents* source) {
int index = tabstrip_model_.GetIndexOfTabContents(source);
if (index != TabStripModel::kNoTab)
tabstrip_model_.UpdateTabContentsStateAt(index);
}
-#if defined(OS_WIN)
-
bool Browser::ShouldDisplayURLField() {
return !IsApplication();
}
@@ -1865,6 +1860,7 @@ void Browser::SetFocusToLocationBar() {
window_->SetFocusToLocationBar();
}
+
///////////////////////////////////////////////////////////////////////////////
// Browser, SelectFileDialog::Listener implementation:
@@ -1874,6 +1870,7 @@ void Browser::FileSelected(const std::wstring& path, void* params) {
OpenURL(file_url, GURL(), CURRENT_TAB, PageTransition::TYPED);
}
+
///////////////////////////////////////////////////////////////////////////////
// Browser, NotificationObserver implementation:
@@ -1909,7 +1906,6 @@ void Browser::Observe(NotificationType type,
}
}
-#endif // OS_WIN
///////////////////////////////////////////////////////////////////////////////
// Browser, Command and state updating (private):
@@ -2366,8 +2362,6 @@ Browser* Browser::GetOrCreateTabbedBrowser() {
return browser;
}
-#if defined(OS_WIN)
-
void Browser::BuildPopupWindow(TabContents* source,
TabContents* new_contents,
const gfx::Rect& initial_pos) {
@@ -2389,13 +2383,14 @@ GURL Browser::GetHomePage() {
if (profile_->GetPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage))
return NewTabUIURL();
GURL home_page = GURL(URLFixerUpper::FixupURL(
- profile_->GetPrefs()->GetString(prefs::kHomePage),
- std::wstring()));
+ WideToUTF8(profile_->GetPrefs()->GetString(prefs::kHomePage)),
+ std::string()));
if (!home_page.is_valid())
return NewTabUIURL();
return home_page;
}
+#if defined(OS_WIN)
void Browser::AdvanceFindSelection(bool forward_direction) {
GetSelectedTabContents()->AsWebContents()->view()->FindInPage(
*this, true, forward_direction);
diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h
index 826c0b4..8a584ff 100644
--- a/chrome/browser/browser.h
+++ b/chrome/browser/browser.h
@@ -20,6 +20,7 @@
#include "chrome/browser/command_updater.h"
#include "chrome/browser/sessions/session_id.h"
#include "chrome/browser/tabs/tab_strip_model.h"
+#include "chrome/browser/tab_contents/tab_contents_delegate.h"
#include "chrome/common/notification_observer.h"
#include "chrome/common/pref_member.h"
#include "base/gfx/rect.h"
@@ -29,7 +30,6 @@
#if defined(OS_WIN)
#include "chrome/browser/shell_dialogs.h"
#include "chrome/browser/tab_contents/tab_contents.h"
-#include "chrome/browser/tab_contents/tab_contents_delegate.h"
#include "chrome/browser/toolbar_model.h"
#endif
@@ -214,9 +214,7 @@ class Browser : public TabStripModelDelegate,
// Show a native UI tab given a URL. If a tab with the same URL is already
// visible in this browser, it becomes selected. Otherwise a new tab is
// created.
-#if defined(OS_WIN)
void ShowNativeUITab(const GURL& url);
-#endif
// Assorted browser commands ////////////////////////////////////////////////
@@ -343,10 +341,8 @@ class Browser : public TabStripModelDelegate,
virtual void TabInsertedAt(TabContents* contents,
int index,
bool foreground);
-#if defined(OS_WIN)
virtual void TabClosingAt(TabContents* contents, int index);
virtual void TabDetachedAt(TabContents* contents, int index);
-#endif
virtual void TabSelectedAt(TabContents* old_contents,
TabContents* new_contents,
int index,
@@ -364,31 +360,28 @@ class Browser : public TabStripModelDelegate,
virtual void NavigationStateChanged(const TabContents* source,
unsigned changed_flags);
virtual void ReplaceContents(TabContents* source, TabContents* new_contents);
-#if defined(OS_WIN)
virtual void AddNewContents(TabContents* source,
TabContents* new_contents,
WindowOpenDisposition disposition,
const gfx::Rect& initial_pos,
bool user_gesture);
virtual void ActivateContents(TabContents* contents);
-#endif
virtual void LoadingStateChanged(TabContents* source);
-#if defined(OS_WIN)
virtual void CloseContents(TabContents* source);
virtual void MoveContents(TabContents* source, const gfx::Rect& pos);
virtual bool IsPopup(TabContents* source);
virtual void ToolbarSizeChanged(TabContents* source, bool is_animating);
virtual void URLStarredChanged(TabContents* source, bool starred);
+#if defined(OS_WIN)
virtual void ContentsMouseEvent(TabContents* source, uint32 message);
+#endif
virtual void UpdateTargetURL(TabContents* source, const GURL& url);
virtual void ContentsZoomChange(bool zoom_in);
virtual bool IsApplication() const;
virtual void ConvertContentsToApplication(TabContents* source);
-#endif
virtual void ContentsStateChanged(TabContents* source);
-#if defined(OS_WIN)
virtual bool ShouldDisplayURLField();
virtual void BeforeUnloadFired(TabContents* source,
bool proceed,
@@ -401,8 +394,6 @@ class Browser : public TabStripModelDelegate,
// Overridden from SelectFileDialog::Listener:
virtual void FileSelected(const std::wstring& path, void* params);
-#endif // OS_WIN
-
// Overridden from NotificationObserver:
virtual void Observe(NotificationType type,
const NotificationSource& source,
@@ -501,14 +492,12 @@ class Browser : public TabStripModelDelegate,
// receiving Browser. Creates a new Browser if none are available.
Browser* GetOrCreateTabbedBrowser();
-#if defined(OS_WIN)
// Creates a new popup window with its own Browser object with the
// incoming sizing information. |initial_pos|'s origin() is the
// window origin, and its size() is the size of the content area.
void BuildPopupWindow(TabContents* source,
TabContents* new_contents,
const gfx::Rect& initial_pos);
-#endif
// Returns what the user's home page is, or the new tab page if the home page
// has not been set.
diff --git a/chrome/browser/fav_icon_helper.cc b/chrome/browser/fav_icon_helper.cc
index a35868d..3b23e3b 100644
--- a/chrome/browser/fav_icon_helper.cc
+++ b/chrome/browser/fav_icon_helper.cc
@@ -11,16 +11,11 @@
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/tab_contents/navigation_controller.h"
#include "chrome/browser/tab_contents/navigation_entry.h"
+#include "chrome/browser/tab_contents/tab_contents_delegate.h"
#include "chrome/browser/tab_contents/web_contents.h"
#include "chrome/common/gfx/favicon_size.h"
#include "skia/ext/image_operations.h"
-#if defined(OS_WIN)
-#include "chrome/browser/tab_contents/tab_contents_delegate.h"
-#elif defined(OS_POSIX)
-#include "chrome/common/temp_scaffolding_stubs.h"
-#endif
-
FavIconHelper::FavIconHelper(WebContents* web_contents)
: web_contents_(web_contents),
got_fav_icon_url_(false),
diff --git a/chrome/common/temp_scaffolding_stubs.cc b/chrome/common/temp_scaffolding_stubs.cc
index 1219c88..9ba6d3e 100644
--- a/chrome/common/temp_scaffolding_stubs.cc
+++ b/chrome/common/temp_scaffolding_stubs.cc
@@ -138,7 +138,9 @@ void OpenFirstRunDialog(Profile* profile) { NOTIMPLEMENTED(); }
GURL NewTabUIURL() {
NOTIMPLEMENTED();
- return GURL();
+ // TODO(port): returning a blank URL here confuses the page IDs so make sure
+ // we load something
+ return GURL("http://dev.chromium.org");
}
//--------------------------------------------------------------------------
@@ -174,23 +176,6 @@ void UninstallJankometer() {
//--------------------------------------------------------------------------
-void Browser::Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details) {
- NOTIMPLEMENTED();
-}
-
-GURL Browser::GetHomePage() {
- NOTIMPLEMENTED();
- return GURL("http://dev.chromium.org");
-}
-
-void Browser::LoadingStateChanged(TabContents* source) {
- NOTIMPLEMENTED();
-}
-
-//--------------------------------------------------------------------------
-
TabContents* TabContents::CreateWithType(TabContentsType type,
Profile* profile,
SiteInstance* instance) {
diff --git a/chrome/common/temp_scaffolding_stubs.h b/chrome/common/temp_scaffolding_stubs.h
index 0520df2..fdd0d48 100644
--- a/chrome/common/temp_scaffolding_stubs.h
+++ b/chrome/common/temp_scaffolding_stubs.h
@@ -78,6 +78,7 @@ class SessionID;
class SiteInstance;
class SpellChecker;
class TabContents;
+class TabContentsDelegate;
class TabNavigation;
struct ThumbnailScore;
class Task;
@@ -405,6 +406,7 @@ class StatusBubble {
public:
void SetStatus(const std::wstring&) { NOTIMPLEMENTED(); }
void Hide() { NOTIMPLEMENTED(); }
+ void SetURL(const GURL&, const std::wstring&) { NOTIMPLEMENTED(); }
};
class SavePackage : public base::RefCountedThreadSafe<SavePackage>,
@@ -466,62 +468,6 @@ class FaviconStatus {
GURL url_;
};
-class TabContentsDelegate {
- public:
- virtual void OpenURLFromTab(TabContents* source,
- const GURL& url, const GURL& referrer,
- WindowOpenDisposition disposition,
- PageTransition::Type transition) {
- NOTIMPLEMENTED();
- }
- virtual void OpenURL(const GURL& url, const GURL& referrer,
- WindowOpenDisposition disposition,
- PageTransition::Type transition) {
- OpenURLFromTab(NULL, url, referrer, disposition, transition);
- }
- virtual void UpdateTargetURL(TabContents*, const GURL&) { NOTIMPLEMENTED(); }
- virtual void CloseContents(TabContents*) { NOTIMPLEMENTED(); }
- virtual void MoveContents(TabContents*, const gfx::Rect&) {
- NOTIMPLEMENTED();
- }
- virtual bool IsPopup(TabContents*) {
- NOTIMPLEMENTED();
- return false;
- }
- virtual void ForwardMessageToExternalHost(const std::string&,
- const std::string&) {
- NOTIMPLEMENTED();
- }
- virtual TabContents* GetConstrainingContents(TabContents*) {
- NOTIMPLEMENTED();
- return NULL;
- }
- virtual void ShowHtmlDialog(ModalHtmlDialogDelegate*, void*) {
- NOTIMPLEMENTED();
- }
- virtual bool CanBlur() {
- NOTIMPLEMENTED();
- return true;
- }
- virtual gfx::Rect GetRootWindowResizerRect() const {
- return gfx::Rect();
- }
-
- virtual bool IsExternalTabContainer() {
- NOTIMPLEMENTED();
- return false;
- }
- virtual void BeforeUnloadFired(WebContents*, bool, bool*) {
- NOTIMPLEMENTED();
- }
- virtual void URLStarredChanged(WebContents*, bool) { NOTIMPLEMENTED(); }
- virtual void ConvertContentsToApplication(WebContents*) { NOTIMPLEMENTED(); }
- virtual void ReplaceContents(TabContents*, TabContents*) { NOTIMPLEMENTED(); }
- virtual void NavigationStateChanged(const TabContents*, unsigned int) {
- NOTIMPLEMENTED();
- }
-};
-
class InterstitialPage {
public:
InterstitialPage(WebContents* tab, bool new_navigation, const GURL& url) {
@@ -856,7 +802,11 @@ class ConstrainedWindow {
void CloseConstrainedWindow() { NOTIMPLEMENTED(); }
};
-class ModalHtmlDialogDelegate {
+class HtmlDialogContentsDelegate {
+ public:
+};
+
+class ModalHtmlDialogDelegate : public HtmlDialogContentsDelegate {
public:
ModalHtmlDialogDelegate(const GURL&, int, int, const std::string&,
IPC::Message*, WebContents*) { }