diff options
author | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-22 18:35:10 +0000 |
---|---|---|
committer | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-22 18:35:10 +0000 |
commit | d480bc80924732bfe029c894db68cecb15ce0a9f (patch) | |
tree | 063298145cedbcd6cac8fb8987b1e5b41416c45c /chrome | |
parent | 878c426fd8ec9fc5568a7549d7cebad29db3413e (diff) | |
download | chromium_src-d480bc80924732bfe029c894db68cecb15ce0a9f.zip chromium_src-d480bc80924732bfe029c894db68cecb15ce0a9f.tar.gz chromium_src-d480bc80924732bfe029c894db68cecb15ce0a9f.tar.bz2 |
Fix DIR_SOURCE_ROOT to work in bundles like Chromium.app. Add more ui tests. Add a resource for tabs with no title on mac. Fix window title reporting. Remove the Browser dependency from the tab strip (only needs a TabStripModel).
Review URL: http://codereview.chromium.org/93025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14212 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/app/chromium_strings.grd | 3 | ||||
-rw-r--r-- | chrome/browser/browser_uitest.cc | 23 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_controller.mm | 8 | ||||
-rw-r--r-- | chrome/browser/cocoa/cocoa_test_helper.h | 1 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_strip_controller.h | 3 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_strip_controller.mm | 15 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_window_controller.h | 3 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_window_controller.mm | 6 | ||||
-rw-r--r-- | chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc | 9 | ||||
-rw-r--r-- | chrome/chrome.gyp | 2 | ||||
-rw-r--r-- | chrome/common/platform_util_mac.mm | 16 |
11 files changed, 74 insertions, 15 deletions
diff --git a/chrome/app/chromium_strings.grd b/chrome/app/chromium_strings.grd index d5c6ca1..b051698 100644 --- a/chrome/app/chromium_strings.grd +++ b/chrome/app/chromium_strings.grd @@ -151,6 +151,9 @@ be available for now. --> <message name="IDS_BROWSER_WINDOW_TITLE_FORMAT_NO_LOGO" desc="The format for titles displayed when the window has no distributor logo displayed"> <ph name="PAGE_TITLE">$1<ex>Google</ex></ph> </message> + <message name="IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED" desc="Tabs and windows on MacOS with no title use this string."> + Untitled + </message> <message name="IDS_ABOUT_VERSION_COMPANY_NAME" desc="Company name on the about pages"> The Chromium Authors </message> diff --git a/chrome/browser/browser_uitest.cc b/chrome/browser/browser_uitest.cc index 2f52007..99f9ccc 100644 --- a/chrome/browser/browser_uitest.cc +++ b/chrome/browser/browser_uitest.cc @@ -25,10 +25,17 @@ namespace { // Given a page title, returns the expected window caption string. std::wstring WindowCaptionFromPageTitle(std::wstring page_title) { +#if defined(OS_WIN) || defined(OS_LINUX) if (page_title.empty()) return l10n_util::GetString(IDS_PRODUCT_NAME); return l10n_util::GetStringF(IDS_BROWSER_WINDOW_TITLE_FORMAT, page_title); +#elif defined(OS_MACOSX) + // On Mac, we don't want to suffix the page title with the application name. + if (page_title.empty()) + return l10n_util::GetString(IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED); + return page_title; +#endif } class BrowserTest : public UITest { @@ -61,8 +68,6 @@ class VisibleBrowserTest : public UITest { } }; -} // namespace - // Launch the app on a page with no title, check that the app title was set // correctly. TEST_F(BrowserTest, NoTitle) { @@ -112,12 +117,18 @@ TEST_F(BrowserTest, ThirtyFourTabs) { return; // See browser\renderer_host\render_process_host.cc for the algorithm to // decide how many processes to create. +#if defined(OS_WIN) || defined(OS_LINUX) +// TODO(pinkerton): Turn this back on for Mac when ChromeBrowserProcessId() +// gets implemented. Right now we don't have a good way to do it, and keeping +// a file always open just so UI tests can check renderers seems a bit +// wasteful. int process_count = GetBrowserProcessCount(); if (base::SysInfo::AmountOfPhysicalMemoryMB() >= 2048) { EXPECT_GE(process_count, 24); } else { EXPECT_LE(process_count, 23); } +#endif } #if defined(OS_WIN) @@ -246,7 +257,13 @@ TEST_F(BrowserTest, OtherRedirectsDontForkProcess) { int orig_tab_count = -1; ASSERT_TRUE(window->GetTabCount(&orig_tab_count)); int orig_process_count = GetBrowserProcessCount(); +#if defined(OS_WIN) || defined(OS_LINUX) +// TODO(pinkerton): Turn this back on for Mac when ChromeBrowserProcessId() +// gets implemented. Right now we don't have a good way to do it, and keeping +// a file always open just so UI tests can check renderers seems a bit +// wasteful. ASSERT_GE(orig_process_count, 1); +#endif // Use JavaScript URL to almost fork a new tab, but not quite. (Leave the // opener non-null.) Should not fork a process. @@ -295,3 +312,5 @@ TEST_F(VisibleBrowserTest, WindowOpenClose) { FAIL() << "failed to get error page title"; } #endif + +} // namespace diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm index 41007cd..4a318f7 100644 --- a/chrome/browser/cocoa/browser_window_controller.mm +++ b/chrome/browser/cocoa/browser_window_controller.mm @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/sys_string_conversions.h" #include "chrome/app/chrome_dll_resource.h" // IDC_* #include "chrome/browser/browser.h" #include "chrome/browser/browser_list.h" @@ -89,7 +90,7 @@ willPositionSheet:(NSWindow *)sheet tabStripController_.reset([[TabStripController alloc] initWithView:[self tabStripView] switchView:[self tabContentArea] - browser:browser_.get()]); + model:browser_->tabstrip_model()]); // Create a controller for the toolbar, giving it the toolbar model object // and the toolbar view from the nib. The controller will handle @@ -354,6 +355,11 @@ willPositionSheet:(NSWindow *)sheet return browser_->tabstrip_model()->count(); } +- (NSString*)selectedTabTitle { + TabContents* contents = browser_->tabstrip_model()->GetSelectedTabContents(); + return base::SysUTF16ToNSString(contents->GetTitle()); +} + - (void)selectTabWithContents:(TabContents*)newContents previousContents:(TabContents*)oldContents atIndex:(NSInteger)index diff --git a/chrome/browser/cocoa/cocoa_test_helper.h b/chrome/browser/cocoa/cocoa_test_helper.h index 28515276..aca0df7 100644 --- a/chrome/browser/cocoa/cocoa_test_helper.h +++ b/chrome/browser/cocoa/cocoa_test_helper.h @@ -10,6 +10,7 @@ #include "base/file_path.h" #include "base/mac_util.h" #include "base/path_service.h" +#import "base/scoped_nsobject.h" #if defined(GOOGLE_CHROME_BUILD) #define APP_NAME "Chrome.app" diff --git a/chrome/browser/cocoa/tab_strip_controller.h b/chrome/browser/cocoa/tab_strip_controller.h index faa7132..d4bd199 100644 --- a/chrome/browser/cocoa/tab_strip_controller.h +++ b/chrome/browser/cocoa/tab_strip_controller.h @@ -13,7 +13,6 @@ @class TabStripView; -class Browser; class TabStripModelObserverBridge; class TabStripModel; class TabContents; @@ -55,7 +54,7 @@ class ToolbarModel; // you have retained them. - (id)initWithView:(TabStripView*)view switchView:(NSView*)switchView - browser:(Browser*)browser; + model:(TabStripModel*)model; // Return the rect, in WebKit coordinates (flipped), of the window's grow box // in the coordinate system of the content area of the currently selected tab. diff --git a/chrome/browser/cocoa/tab_strip_controller.mm b/chrome/browser/cocoa/tab_strip_controller.mm index 8528ef1..524d11c 100644 --- a/chrome/browser/cocoa/tab_strip_controller.mm +++ b/chrome/browser/cocoa/tab_strip_controller.mm @@ -16,17 +16,19 @@ #import "chrome/browser/cocoa/tab_view.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tabs/tab_strip_model.h" +#include "chrome/common/l10n_util.h" +#include "grit/chromium_strings.h" @implementation TabStripController - (id)initWithView:(TabStripView*)view switchView:(NSView*)switchView - browser:(Browser*)browser { - DCHECK(view && switchView && browser); + model:(TabStripModel*)model { + DCHECK(view && switchView && model); if ((self = [super init])) { tabView_ = view; switchView_ = switchView; - tabModel_ = browser->tabstrip_model(); + tabModel_ = model; bridge_.reset(new TabStripModelObserverBridge(tabModel_, self)); tabContentsArray_.reset([[NSMutableArray alloc] init]); tabArray_.reset([[NSMutableArray alloc] init]); @@ -190,8 +192,11 @@ NSString* titleString = nil; if (contents) titleString = base::SysUTF16ToNSString(contents->GetTitle()); - if (![titleString length]) - titleString = NSLocalizedString(@"untitled", nil); + if (![titleString length]) { + titleString = + base::SysWideToNSString( + l10n_util::GetString(IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED)); + } [tab setTitle:titleString]; } diff --git a/chrome/browser/cocoa/tab_window_controller.h b/chrome/browser/cocoa/tab_window_controller.h index 43df6f2..60d13de 100644 --- a/chrome/browser/cocoa/tab_window_controller.h +++ b/chrome/browser/cocoa/tab_window_controller.h @@ -65,6 +65,9 @@ // dragging the only tab in the window. - (NSInteger)numberOfTabs; +// The title of the selected tab. +- (NSString*)selectedTabTitle; + @end @interface TabWindowController(ProtectedMethods) diff --git a/chrome/browser/cocoa/tab_window_controller.mm b/chrome/browser/cocoa/tab_window_controller.mm index 456c973..89ae67f 100644 --- a/chrome/browser/cocoa/tab_window_controller.mm +++ b/chrome/browser/cocoa/tab_window_controller.mm @@ -129,4 +129,10 @@ return 0; } +- (NSString*)selectedTabTitle { + // subclass must implement + NOTIMPLEMENTED(); + return @""; +} + @end diff --git a/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc b/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc index 1491d6d..4454c1f 100644 --- a/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc +++ b/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc @@ -193,9 +193,15 @@ TEST_F(ResourceDispatcherTest, CrossSiteOnunloadCookie) { ASSERT_STREQ("foo", value_result.c_str()); } +#if !defined(OS_MACOSX) // Tests that the onbeforeunload and onunload logic is shortcutted if the old // renderer is gone. In that case, we don't want to wait for the old renderer // to run the handlers. +// TODO(pinkerton): We need to disable this because the crash causes +// the OS CrashReporter process to kick in to analyze the poor dead renderer. +// Unfortunately, if the app isn't stripped of debug symbols, this takes about +// five minutes to complete and isn't conducive to quick turnarounds. As we +// don't currently strip the app on the build bots, this is bad times. TEST_F(ResourceDispatcherTest, CrossSiteAfterCrash) { // This test only works in multi-process mode if (in_process_renderer()) @@ -216,6 +222,7 @@ TEST_F(ResourceDispatcherTest, CrossSiteAfterCrash) { CheckTitleTest(L"content-sniffer-test0.html", L"Content Sniffer Test 0"); } +#endif // Tests that cross-site navigations work when the new page does not go through // the BufferedEventHandler (e.g., non-http{s} URLs). (Bug 1225872) @@ -292,7 +299,7 @@ TEST_F(ResourceDispatcherTest, CrossSiteNavigationErrorPage) { test_url.possibly_invalid_spec() + "'"; tab->NavigateToURLAsync(GURL(redirect_url)); // Wait for JavaScript redirect to happen. - PlatformThread::Sleep(sleep_timeout_ms()); + PlatformThread::Sleep(sleep_timeout_ms() * 3); EXPECT_TRUE(tab->GetTabTitle(&tab_title)); EXPECT_EQ(L"Title Of Awesomeness", tab_title); } diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 3ab1df3..8c48cd8 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -2052,13 +2052,11 @@ 'sources!': [ # TODO(port) 'app/chrome_main_uitest.cc', - 'browser/browser_uitest.cc', 'browser/crash_recovery_uitest.cc', 'browser/download/download_uitest.cc', 'browser/download/save_page_uitest.cc', 'browser/login_prompt_uitest.cc', 'browser/metrics/metrics_service_uitest.cc', - 'browser/renderer_host/resource_dispatcher_host_uitest.cc', 'browser/sessions/session_restore_uitest.cc', 'test/chrome_process_util_uitest.cc', 'test/reliability/page_load_test.cc', diff --git a/chrome/common/platform_util_mac.mm b/chrome/common/platform_util_mac.mm index 37cd39c..d61a50c9 100644 --- a/chrome/common/platform_util_mac.mm +++ b/chrome/common/platform_util_mac.mm @@ -9,6 +9,9 @@ #include "base/file_path.h" #include "base/logging.h" #include "base/sys_string_conversions.h" +#include "chrome/browser/cocoa/tab_window_controller.h" +#include "chrome/common/l10n_util.h" +#include "grit/chromium_strings.h" namespace platform_util { @@ -23,8 +26,17 @@ gfx::NativeWindow GetTopLevel(gfx::NativeView view) { } string16 GetWindowTitle(gfx::NativeWindow window) { - NOTIMPLEMENTED(); - return string16(); + NSString* title = nil; + if ([[window delegate] isKindOfClass:[TabWindowController class]]) + title = [[window delegate] selectedTabTitle]; + else + title = [window title]; + // If we don't yet have a title, use "Untitled". + if (![title length]) + return WideToUTF16(l10n_util::GetString( + IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED)); + + return base::SysNSStringToUTF16(title); } } // namespace platform_util |