diff options
author | pinkerton@google.com <pinkerton@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-22 19:49:33 +0000 |
---|---|---|
committer | pinkerton@google.com <pinkerton@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-22 19:49:33 +0000 |
commit | d938aed98c3e683586d37b6dcbb1b20d95eb771a (patch) | |
tree | fae8ab8e22165f3bc2f5a9cd8196f9f464dd6983 /chrome/browser | |
parent | 6e452a3354856da6d4896fb3edaf96d64aad7bd0 (diff) | |
download | chromium_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/browser')
-rw-r--r-- | chrome/browser/app_controller_mac.mm | 3 | ||||
-rw-r--r-- | chrome/browser/browser.cc | 43 | ||||
-rw-r--r-- | chrome/browser/browser.h | 26 |
3 files changed, 51 insertions, 21 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); |