summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-11 21:56:58 +0000
committerpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-11 21:56:58 +0000
commita4be1e85d6c73aea61d1c5b118d9804b1a8ca4f8 (patch)
tree4a2dd47cf3955e32839700f04a281e5cb742653f /chrome/browser
parentdbcb6d7712e923327e327b6fea5acf941d444fba (diff)
downloadchromium_src-a4be1e85d6c73aea61d1c5b118d9804b1a8ca4f8.zip
chromium_src-a4be1e85d6c73aea61d1c5b118d9804b1a8ca4f8.tar.gz
chromium_src-a4be1e85d6c73aea61d1c5b118d9804b1a8ca4f8.tar.bz2
Implement more of the TabContentsDelegate to hook up loading URLs from the location bar where there is UI to do so.
Review URL: http://codereview.chromium.org/21264 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9601 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/browser.cc6
-rw-r--r--chrome/browser/browser.h5
-rw-r--r--chrome/browser/cocoa/tab_contents_controller.mm32
3 files changed, 32 insertions, 11 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index af06203..a74a2ee 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -1507,8 +1507,6 @@ void Browser::TabStripEmpty() {
method_factory_.NewRunnableMethod(&Browser::CloseFrame));
}
-#if defined(OS_WIN)
-
///////////////////////////////////////////////////////////////////////////////
// Browser, TabContentsDelegate implementation:
@@ -1652,6 +1650,8 @@ 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,
@@ -2310,7 +2310,6 @@ bool Browser::HasCompletedUnloadProcessing() {
tabs_needing_unload_fired_.empty();
}
-#if defined(OS_WIN)
void Browser::CancelWindowClose() {
DCHECK(is_attempting_to_close_browser_);
// Only cancelling beforeunload should be able to cancel the window's close.
@@ -2341,7 +2340,6 @@ void Browser::ClearUnloadState(TabContents* tab) {
ProcessPendingTabs();
}
-#endif // OS_WIN
///////////////////////////////////////////////////////////////////////////////
// Browser, Assorted utility functions (private):
diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h
index 1259829..ea9a57d 100644
--- a/chrome/browser/browser.h
+++ b/chrome/browser/browser.h
@@ -356,7 +356,6 @@ class Browser : public TabStripModelDelegate,
int to_index);
virtual void TabStripEmpty();
-#if defined(OS_WIN)
// Overridden from TabContentsDelegate:
virtual void OpenURLFromTab(TabContents* source,
const GURL& url, const GURL& referrer,
@@ -365,6 +364,7 @@ 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,
@@ -477,7 +477,6 @@ class Browser : public TabStripModelDelegate,
// Whether we've completed firing all the tabs' beforeunload/unload events.
bool HasCompletedUnloadProcessing();
-#if defined(OS_WIN)
// Clears all the state associated with processing tabs' beforeunload/unload
// events since the user cancelled closing the window.
void CancelWindowClose();
@@ -492,7 +491,6 @@ class Browser : public TabStripModelDelegate,
// cases where a tab crashes or hangs even if the beforeunload/unload haven't
// successfully fired.
void ClearUnloadState(TabContents* tab);
-#endif
// Assorted utility functions ///////////////////////////////////////////////
@@ -524,7 +522,6 @@ class Browser : public TabStripModelDelegate,
// after a return to the message loop.
void CloseFrame();
-
// Compute a deterministic name based on the URL. We use this pseudo name
// as a key to store window location per application URLs.
static std::wstring ComputeApplicationNameFromURL(const GURL& url);
diff --git a/chrome/browser/cocoa/tab_contents_controller.mm b/chrome/browser/cocoa/tab_contents_controller.mm
index ebcb3d7..31948ec 100644
--- a/chrome/browser/cocoa/tab_contents_controller.mm
+++ b/chrome/browser/cocoa/tab_contents_controller.mm
@@ -4,6 +4,7 @@
#include "chrome/browser/cocoa/tab_contents_controller.h"
+#import "base/sys_string_conversions.h"
#import "chrome/app/chrome_dll_resource.h"
#import "chrome/browser/command_updater.h"
#import "chrome/browser/location_bar.h"
@@ -15,6 +16,11 @@
- (void)enabledStateChangedForCommand:(NSInteger)command enabled:(BOOL)enabled;
@end
+@interface TabContentsController(LocationBar)
+- (NSString*)locationBarString;
+- (void)focusLocationBar;
+@end
+
@interface TabContentsController(Private)
- (void)updateToolbarCommandStatus;
@end
@@ -35,20 +41,22 @@ class TabContentsCommandObserver : public CommandUpdater::CommandObserver {
CommandUpdater* commands_; // weak
};
-// TODO(pinkerton): implement these
+// A C++ bridge class that handles responding to requests from the
+// cross-platform code for information about the location bar. Just passes
+// everything back to the controller.
class LocationBarBridge : public LocationBar {
public:
LocationBarBridge(TabContentsController* controller);
// Overridden from LocationBar
virtual void ShowFirstRunBubble() { NOTIMPLEMENTED(); }
- virtual std::wstring GetInputString() const { NOTIMPLEMENTED(); return L""; }
+ virtual std::wstring GetInputString() const;
virtual WindowOpenDisposition GetWindowOpenDisposition() const
{ NOTIMPLEMENTED(); return NEW_FOREGROUND_TAB; }
virtual PageTransition::Type GetPageTransition() const
{ NOTIMPLEMENTED(); return 0; }
virtual void AcceptInput() { NOTIMPLEMENTED(); }
- virtual void FocusLocation() { NOTIMPLEMENTED(); }
+ virtual void FocusLocation();
virtual void FocusSearch() { NOTIMPLEMENTED(); }
virtual void SaveStateToContents(TabContents* contents) { NOTIMPLEMENTED(); }
@@ -152,6 +160,14 @@ class LocationBarBridge : public LocationBar {
[self updateToolbarCommandStatus];
}
+- (NSString*)locationBarString {
+ return [locationBar_ stringValue];
+}
+
+- (void)focusLocationBar {
+ [[locationBar_ window] makeFirstResponder:locationBar_];
+}
+
@end
//--------------------------------------------------------------------------
@@ -184,3 +200,13 @@ void TabContentsCommandObserver::EnabledStateChangedForCommand(int command,
LocationBarBridge::LocationBarBridge(TabContentsController* controller)
: controller_(controller) {
}
+
+std::wstring LocationBarBridge::GetInputString() const {
+ return base::SysNSStringToWide([controller_ locationBarString]);
+}
+
+void LocationBarBridge::FocusLocation() {
+ [controller_ focusLocationBar];
+}
+
+