summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorpinkerton@google.com <pinkerton@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-22 19:49:33 +0000
committerpinkerton@google.com <pinkerton@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-22 19:49:33 +0000
commitd938aed98c3e683586d37b6dcbb1b20d95eb771a (patch)
treefae8ab8e22165f3bc2f5a9cd8196f9f464dd6983 /chrome
parent6e452a3354856da6d4896fb3edaf96d64aad7bd0 (diff)
downloadchromium_src-d938aed98c3e683586d37b6dcbb1b20d95eb771a.zip
chromium_src-d938aed98c3e683586d37b6dcbb1b20d95eb771a.tar.gz
chromium_src-d938aed98c3e683586d37b6dcbb1b20d95eb771a.tar.bz2
More scaffolding for back/forward/reload/home, start of WebContents
Review URL: http://codereview.chromium.org/18507 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8493 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/app_controller_mac.mm3
-rw-r--r--chrome/browser/browser.cc43
-rw-r--r--chrome/browser/browser.h26
-rw-r--r--chrome/common/temp_scaffolding_stubs.cpp14
-rw-r--r--chrome/common/temp_scaffolding_stubs.h98
5 files changed, 154 insertions, 30 deletions
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm
index f2face3..01638dc 100644
--- a/chrome/browser/app_controller_mac.mm
+++ b/chrome/browser/app_controller_mac.mm
@@ -9,6 +9,7 @@
#import "chrome/browser/browser.h"
#import "chrome/browser/browser_list.h"
#import "chrome/browser/command_updater.h"
+#import "chrome/common/temp_scaffolding_stubs.h"
@interface AppController(PRIVATE)
- (void)initMenuState;
@@ -76,7 +77,7 @@
NSInteger tag = [sender tag];
switch (tag) {
case IDC_NEW_WINDOW:
- Browser::OpenEmptyWindow(NULL);
+ Browser::OpenEmptyWindow(ProfileManager::FakeProfile());
break;
};
}
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 6691066..ad50f67 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -8,6 +8,11 @@
#include "base/string_util.h"
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/browser/browser_list.h"
+#include "chrome/browser/metrics/user_metrics.h"
+#include "chrome/browser/tab_contents/tab_contents_type.h"
+#include "chrome/common/chrome_constants.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/common/page_transition_types.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
#include "net/base/cookie_monster.h"
@@ -15,6 +20,7 @@
#include "net/base/net_util.h"
#include "net/base/registry_controlled_domain.h"
#include "net/url_request/url_request_context.h"
+#include "webkit/glue/window_open_disposition.h"
#if defined(OS_WIN)
@@ -36,7 +42,6 @@
#include "chrome/browser/dom_ui/new_tab_ui.h"
#include "chrome/browser/download/save_package.h"
#include "chrome/browser/history_tab_ui.h"
-#include "chrome/browser/metrics/user_metrics.h"
#include "chrome/browser/options_window.h"
#include "chrome/browser/net/url_fixer_upper.h"
#include "chrome/browser/plugin_process_host.h"
@@ -60,8 +65,6 @@
#include "chrome/browser/views/status_bubble.h"
#include "chrome/browser/views/toolbar_star_toggle.h"
#include "chrome/browser/window_sizer.h"
-#include "chrome/common/chrome_constants.h"
-#include "chrome/common/chrome_switches.h"
#include "chrome/common/l10n_util.h"
#include "chrome/common/win_util.h"
@@ -278,8 +281,6 @@ void Browser::OpenEmptyWindow(Profile* profile) {
browser->window()->Show();
}
-#if defined(OS_WIN)
-
// static
void Browser::OpenURLOffTheRecord(Profile* profile, const GURL& url) {
Profile* off_the_record_profile = profile->GetOffTheRecordProfile();
@@ -293,6 +294,7 @@ void Browser::OpenURLOffTheRecord(Profile* profile, const GURL& url) {
browser->window()->Show();
}
+#if defined(OS_WIN)
// static
void Browser::OpenWebApplication(Profile* profile, WebApp* app) {
const std::wstring& app_name =
@@ -304,6 +306,7 @@ void Browser::OpenWebApplication(Profile* profile, WebApp* app) {
browser->AddWebApplicationTab(profile, app, false);
browser->window()->Show();
}
+#endif
///////////////////////////////////////////////////////////////////////////////
// Browser, State Storage and Retrieval for UI:
@@ -374,6 +377,8 @@ SkBitmap Browser::GetCurrentPageIcon() const {
return contents ? contents->GetFavIcon() : SkBitmap();
}
+#if defined(OS_WIN)
+
std::wstring Browser::GetCurrentPageTitle() const {
TabContents* contents = tabstrip_model_.GetSelectedTabContents();
std::wstring title;
@@ -547,6 +552,8 @@ void Browser::ShowNativeUITab(const GURL& url) {
AddNewContents(NULL, contents, NEW_FOREGROUND_TAB, gfx::Rect(), true);
}
+#endif // OS_WIN
+
///////////////////////////////////////////////////////////////////////////////
// Browser, Assorted browser commands:
@@ -574,6 +581,7 @@ void Browser::GoForward() {
GetSelectedTabContents()->controller()->GoForward();
}
+
void Browser::Reload() {
UserMetrics::RecordAction(L"Reload", profile_);
@@ -603,6 +611,7 @@ void Browser::Home() {
homepage_url, GURL(), PageTransition::AUTO_BOOKMARK);
}
+#if defined(OS_WIN)
void Browser::OpenCurrentURL() {
UserMetrics::RecordAction(L"LoadURL", profile_);
LocationBarView* lbv = GetLocationBarView();
@@ -618,6 +627,7 @@ void Browser::Go() {
if (lbv)
lbv->location_entry()->model()->AcceptInput(CURRENT_TAB, false);
}
+#endif
void Browser::Stop() {
UserMetrics::RecordAction(L"Stop", profile_);
@@ -635,8 +645,10 @@ void Browser::NewIncognitoWindow() {
}
void Browser::NewProfileWindowByIndex(int index) {
+#if defined(OS_WIN)
UserMetrics::RecordAction(L"NewProfileWindowByIndex", profile_);
UserDataManager::Get()->LaunchChromeForProfile(index);
+#endif
}
void Browser::CloseWindow() {
@@ -644,6 +656,8 @@ void Browser::CloseWindow() {
window_->Close();
}
+#if defined(OS_WIN)
+
void Browser::NewTab() {
UserMetrics::RecordAction(L"NewTab", profile_);
if (type() == TYPE_NORMAL) {
@@ -1091,14 +1105,15 @@ void Browser::ExecuteCommand(int id) {
// The order of commands in this switch statement must match the function
// declaration order in browser.h!
switch (id) {
-#if defined(OS_WIN)
// Navigation commands
case IDC_BACK: GoBack(); break;
case IDC_FORWARD: GoForward(); break;
case IDC_RELOAD: Reload(); break;
case IDC_HOME: Home(); break;
+#if defined(OS_WIN)
case IDC_OPEN_CURRENT_URL: OpenCurrentURL(); break;
case IDC_GO: Go(); break;
+#endif
case IDC_STOP: Stop(); break;
// Window management commands
@@ -1114,6 +1129,7 @@ void Browser::ExecuteCommand(int id) {
case IDC_NEW_WINDOW_PROFILE_7:
case IDC_NEW_WINDOW_PROFILE_8:
NewProfileWindowByIndex(id - IDC_NEW_WINDOW_PROFILE_0); break;
+#if defined(OS_WIN)
case IDC_CLOSE_WINDOW: CloseWindow(); break;
case IDC_NEW_TAB: NewTab(); break;
case IDC_CLOSE_TAB: CloseTab(); break;
@@ -1219,10 +1235,8 @@ void Browser::ExecuteCommand(int id) {
case IDC_VIEW_PASSWORDS: OpenPasswordManager(); break;
case IDC_ABOUT: OpenAboutChromeDialog(); break;
case IDC_HELP_PAGE: OpenHelpTab(); break;
-
-#elif defined(OS_MACOSX)
- case IDC_NEW_WINDOW: NewWindow(); break;
#endif
+
default:
LOG(WARNING) << "Received Unimplemented Command: " << id;
break;
@@ -1300,6 +1314,8 @@ TabContents* Browser::CreateTabContentsForURL(
return contents;
}
+#endif // OS_WIN
+
bool Browser::CanDuplicateContentsAt(int index) {
TabContents* contents = GetTabContentsAt(index);
DCHECK(contents);
@@ -1308,6 +1324,8 @@ bool Browser::CanDuplicateContentsAt(int index) {
return nc ? (nc->active_contents() && nc->GetLastCommittedEntry()) : false;
}
+#if defined(OS_WIN)
+
void Browser::DuplicateContentsAt(int index) {
TabContents* contents = GetTabContentsAt(index);
TabContents* new_contents = NULL;
@@ -2034,8 +2052,6 @@ void Browser::InitCommandState() {
}
}
-#if defined(OS_WIN)
-
void Browser::UpdateCommandsForTabState() {
TabContents* current_tab = GetSelectedTabContents();
if (!current_tab) // May be NULL during tab restore.
@@ -2104,6 +2120,8 @@ void Browser::SetStarredButtonToggled(bool starred) {
star_button->SetToggled(starred);
}
+#if defined(OS_WIN)
+
///////////////////////////////////////////////////////////////////////////////
// Browser, UI update coalescing and handling (private):
@@ -2232,6 +2250,8 @@ void Browser::RemoveScheduledUpdatesFor(TabContents* contents) {
}
}
+#endif // OS_WIN
+
///////////////////////////////////////////////////////////////////////////////
// Browser, Getters for UI (private):
@@ -2247,6 +2267,7 @@ StatusBubble* Browser::GetStatusBubble() {
return window_->GetStatusBubble();
}
+#if defined(OS_WIN)
///////////////////////////////////////////////////////////////////////////////
// Browser, Session restore functions (private):
diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h
index cd53a18..349b504 100644
--- a/chrome/browser/browser.h
+++ b/chrome/browser/browser.h
@@ -117,15 +117,16 @@ class Browser : public TabStripModelDelegate,
// Opens a new window with the default blank tab.
static void OpenEmptyWindow(Profile* profile);
-#if defined(OS_WIN)
- // Opens the a new application window for the specified WebApp.
- static void OpenWebApplication(Profile* profile, WebApp* app);
-
// Opens the specified URL in a new browser window in an incognito session.
// If there is already an existing active incognito session for the specified
// |profile|, that session is re-used.
static void OpenURLOffTheRecord(Profile* profile, const GURL& url);
+#if defined(OS_WIN)
+ // Opens the a new application window for the specified WebApp.
+ static void OpenWebApplication(Profile* profile, WebApp* app);
+#endif
+
// State Storage and Retrieval for UI ///////////////////////////////////////
// Save and restore the window position.
@@ -138,6 +139,7 @@ class Browser : public TabStripModelDelegate,
// Gets the FavIcon of the page in the selected tab.
SkBitmap GetCurrentPageIcon() const;
+#if defined(OS_WIN)
// Gets the title of the page in the selected tab.
std::wstring GetCurrentPageTitle() const;
@@ -182,7 +184,6 @@ class Browser : public TabStripModelDelegate,
}
// Tab adding/showing functions /////////////////////////////////////////////
-#if defined(OS_WIN)
// Add a new tab with the specified URL. If instance is not null, its process
// will be used to render the tab.
@@ -191,6 +192,7 @@ class Browser : public TabStripModelDelegate,
PageTransition::Type transition, bool foreground,
SiteInstance* instance);
+#if defined(OS_WIN)
// Add a new application tab for the specified URL. If lazy is true, the tab
// won't be selected. Further, the initial web page load will only take place
// when the tab is first selected.
@@ -230,21 +232,23 @@ class Browser : public TabStripModelDelegate,
// NOTE: Within each of the following sections, the IDs are ordered roughly by
// how they appear in the GUI/menus (left to right, top to bottom, etc.).
+#endif
// Navigation commands
void GoBack();
void GoForward();
void Reload();
void Home();
+#if defined(OS_WIN)
void OpenCurrentURL();
+#endif
void Go();
void Stop();
-#endif
// Window management commands
void NewWindow();
-#if defined(OS_WIN)
void NewIncognitoWindow();
void NewProfileWindowByIndex(int index);
void CloseWindow();
+#if defined(OS_WIN)
void NewTab();
void CloseTab();
void SelectNextTab();
@@ -342,7 +346,9 @@ class Browser : public TabStripModelDelegate,
PageTransition::Type transition,
bool defer_load,
SiteInstance* instance) const;
+#endif
virtual bool CanDuplicateContentsAt(int index);
+#if defined(OS_WIN)
virtual void DuplicateContentsAt(int index);
virtual void CloseFrameAfterDragSession();
@@ -412,7 +418,6 @@ class Browser : public TabStripModelDelegate,
// Initialize state for all browser commands.
void InitCommandState();
-#if defined(OS_WIN)
// Update commands which may be enabled or disabled depending on the tab's
// state.
void UpdateCommandsForTabState();
@@ -425,6 +430,7 @@ class Browser : public TabStripModelDelegate,
// TODO(evanm): migrate this to the commands framework.
void SetStarredButtonToggled(bool starred);
+#if defined(OS_WIN)
// UI update coalescing and handling ////////////////////////////////////////
// Asks the toolbar (and as such the location bar) to update its state to
@@ -455,7 +461,6 @@ class Browser : public TabStripModelDelegate,
// Getters for the location bar and go button.
#endif // OS_WIN
LocationBarView* GetLocationBarView() const;
-#if defined(OS_WIN)
GoButton* GetGoButton();
// Returns the StatusBubble from the current toolbar. It is possible for
@@ -463,6 +468,7 @@ class Browser : public TabStripModelDelegate,
// TODO(beng): remove this.
StatusBubble* GetStatusBubble();
+#if defined(OS_WIN)
// Session restore functions ////////////////////////////////////////////////
// Notifies the history database of the index for all tabs whose index is
@@ -515,11 +521,13 @@ class Browser : public TabStripModelDelegate,
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.
GURL GetHomePage();
+#if defined(OS_WIN)
// Advance the find selection by one. Direction is either forward or
// backwards depending on parameter passed in.
void AdvanceFindSelection(bool forward_direction);
diff --git a/chrome/common/temp_scaffolding_stubs.cpp b/chrome/common/temp_scaffolding_stubs.cpp
index bdfec42..301d935 100644
--- a/chrome/common/temp_scaffolding_stubs.cpp
+++ b/chrome/common/temp_scaffolding_stubs.cpp
@@ -142,6 +142,10 @@ Profile* ProfileManager::GetDefaultProfile(const std::wstring& user_data_dir) {
return new Profile(default_profile_dir);
}
+Profile* ProfileManager::FakeProfile() {
+ return new Profile(L"");
+}
+
//--------------------------------------------------------------------------
Profile::Profile(const std::wstring& path)
@@ -217,10 +221,12 @@ void Browser::Observe(NotificationType type,
const NotificationDetails& details) {
}
-LocationBarView* Browser::GetLocationBarView() const {
- return window_->GetLocationBarView();
+GURL Browser::GetHomePage() {
+ return GURL("http://dev.chromium.org");
}
-void Browser::NewWindow() {
- Browser::OpenEmptyWindow(NULL);
+TabContents* Browser::AddTabWithURL(
+ const GURL& url, const GURL& referrer, PageTransition::Type transition,
+ bool foreground, SiteInstance* instance) {
+ return NULL;
}
diff --git a/chrome/common/temp_scaffolding_stubs.h b/chrome/common/temp_scaffolding_stubs.h
index 428cfb2..1c0d988 100644
--- a/chrome/common/temp_scaffolding_stubs.h
+++ b/chrome/common/temp_scaffolding_stubs.h
@@ -13,14 +13,22 @@
#include "base/basictypes.h"
#include "base/ref_counted.h"
+#include "base/gfx/rect.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/tab_contents/tab_contents_type.h"
+#include "chrome/common/page_transition_types.h"
+#include "googleurl/src/gurl.h"
+#include "skia/include/SkBitmap.h"
+#include "webkit/glue/window_open_disposition.h"
class Browser;
class CommandLine;
class MetricsService;
+class NavigationEntry;
class ProfileManager;
class Profile;
class SessionID;
+class TabContents;
class URLRequestContext;
class WebContents;
@@ -158,6 +166,7 @@ class UserDataManager {
struct SessionService {
void WindowClosed(const SessionID &) { }
+ void SetWindowBounds(const SessionID&, const gfx::Rect&, bool) { }
};
class TabRestoreService {
@@ -177,7 +186,8 @@ class Profile {
bool IsOffTheRecord() { return false; }
URLRequestContext* GetRequestContext() { return NULL; }
virtual Profile* GetOriginalProfile() { return this; }
-
+ virtual Profile* GetOffTheRecordProfile() { return this; }
+ bool HasSessionService() { return false; }
private:
std::wstring GetPrefFilePath();
@@ -193,6 +203,9 @@ class ProfileManager : NonThreadSafe {
static std::wstring GetDefaultProfileDir(const std::wstring& user_data_dir);
static std::wstring GetDefaultProfilePath(const std::wstring& profile_dir);
static void ShutdownSessionServices() { }
+ // This doesn't really exist, but is used when there is no browser window
+ // from which to get the profile. We'll find a better solution later.
+ static Profile* FakeProfile();
private:
DISALLOW_EVIL_CONSTRUCTORS(ProfileManager);
};
@@ -223,11 +236,30 @@ void InstallJankometer(const CommandLine&);
//---------------------------------------------------------------------------
// These stubs are for Browser
+class SavePackage {
+ public:
+ static bool IsSavableContents(const std::string& contents_mime_type) {
+ return false;
+ }
+ static bool IsSavableURL(const GURL& url) { return false; }
+};
+
class LocationBarView {
public:
void ShowFirstRunBubble() { }
};
+class GoButton {
+ public:
+ typedef enum Mode { MODE_GO = 0, MODE_STOP };
+ void ChangeMode(Mode mode) { }
+};
+
+class ToolbarStarToggle {
+ public:
+ void SetToggled(bool) { }
+};
+
class DebuggerWindow : public base::RefCountedThreadSafe<DebuggerWindow> {
public:
};
@@ -240,29 +272,77 @@ class TabStripModelObserver {
public:
};
+class NavigationEntry {
+ public:
+ const GURL& url() const { return url_; }
+ private:
+ GURL url_;
+};
+
class NavigationController {
public:
+ NavigationController() : entry_(new NavigationEntry) { }
+ virtual ~NavigationController() { }
+ bool CanGoBack() const { return false; }
+ bool CanGoForward() const { return false; }
+ void GoBack() { }
+ void GoForward() { }
+ void Reload(bool) { }
+ TabContents* active_contents() const { return NULL; }
+ NavigationEntry* GetLastCommittedEntry() const { return entry_.get(); }
+ NavigationEntry* GetActiveEntry() const { return entry_.get(); }
+ void LoadURL(const GURL& url, const GURL& referrer,
+ PageTransition::Type type) { }
+ private:
+ scoped_ptr<NavigationEntry> entry_;
};
class TabContentsDelegate {
public:
+ virtual void OpenURL(const GURL& url, const GURL& referrer,
+ WindowOpenDisposition disposition,
+ PageTransition::Type transition) { }
+};
+
+class InterstitialPage {
+ public:
+ virtual void DontProceed() { }
};
class TabContents {
public:
TabContents() : controller_(new NavigationController) { }
+ virtual ~TabContents() { }
NavigationController* controller() const { return controller_.get(); }
- WebContents* AsWebContents() const { return NULL; }
+ virtual WebContents* AsWebContents() const { return NULL; }
+ virtual SkBitmap GetFavIcon() const { return SkBitmap(); }
+ const GURL& GetURL() const { return url_; }
+ virtual const std::wstring& GetTitle() const { return title_; }
+ TabContentsType type() const { return TAB_CONTENTS_WEB; }
+ virtual void Focus() { }
+ virtual void Stop() { }
private:
+ GURL url_;
+ std::wstring title_;
scoped_ptr<NavigationController> controller_;
};
-// fake a tab strip, though it can't have any entries because the browser dtor
-// checks.
+class WebContents : public TabContents {
+ public:
+ WebContents* AsWebContents() { return this; }
+ bool showing_interstitial_page() const { return false; }
+ InterstitialPage* interstitial_page() const { return NULL; }
+ bool is_starred() const { return false; }
+ const std::string& contents_mime_type() const { return mime_type_; }
+ private:
+ std::string mime_type_;
+};
+
+// fake a tab strip with one entry.
class TabStripModel {
public:
TabStripModel(TabStripModelDelegate* delegate, Profile* profile)
- : contents_(new TabContents) { }
+ : contents_(new WebContents) { }
virtual ~TabStripModel() { }
bool empty() const { return contents_.get() == NULL; }
int count() const { return contents_.get() ? 1 : 0; }
@@ -301,4 +381,12 @@ class ToolbarModel {
public:
};
+class WindowSizer {
+ public:
+ static void GetBrowserWindowBounds(const std::wstring& app_name,
+ const gfx::Rect& specified_bounds,
+ gfx::Rect* window_bounds,
+ bool* maximized) { }
+};
+
#endif // CHROME_COMMON_TEMP_SCAFFOLDING_STUBS_H_