summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-20 19:37:34 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-20 19:37:34 +0000
commitfe5a8a4ff6f5758f8dbf7e6e9578df97fb8633db (patch)
tree6e65cdd055407d7787f5fbfc7f4323e892e38b3e /chrome/browser
parent6aec56b2bafcf1bffd50a097b3f03688e66006e2 (diff)
downloadchromium_src-fe5a8a4ff6f5758f8dbf7e6e9578df97fb8633db.zip
chromium_src-fe5a8a4ff6f5758f8dbf7e6e9578df97fb8633db.tar.gz
chromium_src-fe5a8a4ff6f5758f8dbf7e6e9578df97fb8633db.tar.bz2
Linux UI hook ups:
- Fix new tab focus - attach f5 for refresh Review URL: http://codereview.chromium.org/42422 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12206 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/gtk/browser_toolbar_gtk.cc3
-rw-r--r--chrome/browser/gtk/browser_window_gtk.cc11
-rw-r--r--chrome/browser/tab_contents/web_contents_view_gtk.cc27
-rw-r--r--chrome/browser/tab_contents/web_contents_view_gtk.h4
4 files changed, 35 insertions, 10 deletions
diff --git a/chrome/browser/gtk/browser_toolbar_gtk.cc b/chrome/browser/gtk/browser_toolbar_gtk.cc
index 5b4d932..7240a59 100644
--- a/chrome/browser/gtk/browser_toolbar_gtk.cc
+++ b/chrome/browser/gtk/browser_toolbar_gtk.cc
@@ -94,6 +94,9 @@ void BrowserToolbarGtk::Init(Profile* profile,
reload_.reset(BuildToolbarButton(IDR_RELOAD, IDR_RELOAD_P, IDR_RELOAD_H, 0,
l10n_util::GetString(IDS_TOOLTIP_RELOAD)));
AddAcceleratorToButton(reload_, GDK_r, GDK_CONTROL_MASK);
+ // Any modifier except alt can be combined with f5 (this matches windows
+ // chromium).
+ AddAcceleratorToButton(reload_, GDK_F5, GDK_MODIFIER_MASK & ~GDK_MOD1_MASK);
// TODO(port): we need to dynamically react to changes in show_home_button_
// and hide/show home appropriately. But we don't have a UI for it yet.
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc
index 19b12e5..6ce674b 100644
--- a/chrome/browser/gtk/browser_window_gtk.cc
+++ b/chrome/browser/gtk/browser_window_gtk.cc
@@ -13,6 +13,7 @@
#include "base/path_service.h"
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/browser/browser.h"
+#include "chrome/browser/browser_list.h"
#include "chrome/browser/find_bar_controller.h"
#include "chrome/browser/gtk/browser_toolbar_gtk.h"
#include "chrome/browser/gtk/find_bar_gtk.h"
@@ -22,6 +23,7 @@
#include "chrome/browser/location_bar.h"
#include "chrome/browser/renderer_host/render_widget_host_view_gtk.h"
#include "chrome/browser/tab_contents/web_contents.h"
+#include "chrome/browser/tab_contents/web_contents_view.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/resource_bundle.h"
#include "chrome/views/controls/button/text_button.h"
@@ -433,6 +435,9 @@ void BrowserWindowGtk::TabDetachedAt(TabContents* contents, int index) {
}
}
+// TODO(estade): this function should probably be unforked from the BrowserView
+// function of the same name by having a shared partial BrowserWindow
+// implementation.
void BrowserWindowGtk::TabSelectedAt(TabContents* old_contents,
TabContents* new_contents,
int index,
@@ -446,6 +451,12 @@ void BrowserWindowGtk::TabSelectedAt(TabContents* old_contents,
contents_container_->SetTabContents(new_contents);
new_contents->DidBecomeSelected();
+ // TODO(estade): after we manage browser activation, add a check to make sure
+ // we are the active browser before calling RestoreFocus().
+ if (!browser_->tabstrip_model()->closing_all() &&
+ new_contents->AsWebContents()) {
+ new_contents->AsWebContents()->view()->RestoreFocus();
+ }
// Update all the UI bits.
UpdateTitleBar();
diff --git a/chrome/browser/tab_contents/web_contents_view_gtk.cc b/chrome/browser/tab_contents/web_contents_view_gtk.cc
index c3345cb..3f4785f 100644
--- a/chrome/browser/tab_contents/web_contents_view_gtk.cc
+++ b/chrome/browser/tab_contents/web_contents_view_gtk.cc
@@ -21,8 +21,8 @@
namespace {
// Called when the content view gtk widget is tabbed to. We always return true
-// and grab focus if we don't have it. The call to SetInitialFocus() forwards
-// the tab to webkit. We leave focus via TakeFocus().
+// and grab focus if we don't have it. The call to SetInitialFocus(bool)
+// forwards the tab to webkit. We leave focus via TakeFocus().
// We cast the WebContents to a TabContents because SetInitialFocus is public
// in TabContents and protected in WebContents.
gboolean OnFocus(GtkWidget* widget, GtkDirectionType focus,
@@ -87,7 +87,8 @@ RenderWidgetHostView* WebContentsViewGtk::CreateViewForWidget(
RenderWidgetHostViewGtk* view =
new RenderWidgetHostViewGtk(render_widget_host);
view->InitAsChild();
- g_signal_connect(view->native_view(), "focus",
+ content_view_ = view->native_view();
+ g_signal_connect(content_view_, "focus",
G_CALLBACK(OnFocus), web_contents_);
g_signal_connect(view->native_view(), "leave-notify-event",
G_CALLBACK(OnLeaveNotify), web_contents_);
@@ -96,7 +97,7 @@ RenderWidgetHostView* WebContentsViewGtk::CreateViewForWidget(
gtk_widget_add_events(view->native_view(), GDK_LEAVE_NOTIFY_MASK |
GDK_POINTER_MOTION_MASK);
gtk_container_foreach(GTK_CONTAINER(vbox_.get()), RemoveWidget, vbox_.get());
- gtk_box_pack_start(GTK_BOX(vbox_.get()), view->native_view(), TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox_.get()), content_view_, TRUE, TRUE, 0);
return view;
}
@@ -105,8 +106,7 @@ gfx::NativeView WebContentsViewGtk::GetNativeView() const {
}
gfx::NativeView WebContentsViewGtk::GetContentNativeView() const {
- NOTIMPLEMENTED();
- return NULL;
+ return content_view_;
}
gfx::NativeWindow WebContentsViewGtk::GetTopLevelNativeWindow() const {
@@ -118,7 +118,8 @@ void WebContentsViewGtk::GetContainerBounds(gfx::Rect* out) const {
}
void WebContentsViewGtk::OnContentsDestroy() {
- NOTIMPLEMENTED();
+ // TODO(estade): Windows uses this function cancel pending drag-n-drop drags.
+ // We don't have drags yet, so do nothing for now.
}
void WebContentsViewGtk::SetPageTitle(const std::wstring& title) {
@@ -153,15 +154,21 @@ bool WebContentsViewGtk::GetFindBarWindowInfo(gfx::Point* position,
}
void WebContentsViewGtk::SetInitialFocus() {
- // TODO(port)
+ if (web_contents_->FocusLocationBarByDefault())
+ web_contents_->delegate()->SetFocusToLocationBar();
+ else
+ gtk_widget_grab_focus(content_view_);
}
void WebContentsViewGtk::StoreFocus() {
- // TODO(port)
+ NOTIMPLEMENTED();
}
void WebContentsViewGtk::RestoreFocus() {
- // TODO(port)
+ // TODO(estade): implement this function.
+ // For now just assume we are viewing the tab for the first time.
+ SetInitialFocus();
+ NOTIMPLEMENTED();
}
void WebContentsViewGtk::UpdateDragCursor(bool is_drop_target) {
diff --git a/chrome/browser/tab_contents/web_contents_view_gtk.h b/chrome/browser/tab_contents/web_contents_view_gtk.h
index bf8822b..7e69ae9 100644
--- a/chrome/browser/tab_contents/web_contents_view_gtk.h
+++ b/chrome/browser/tab_contents/web_contents_view_gtk.h
@@ -68,8 +68,12 @@ class WebContentsViewGtk : public WebContentsView {
private:
WebContents* web_contents_;
+ // The native widget for the tab.
OwnedWidgetGtk vbox_;
+ // The native widget for the contents of the tab. We do not own this widget.
+ GtkWidget* content_view_;
+
// The context menu is reset every time we show it, but we keep a pointer to
// between uses so that it won't go out of scope before we're done with it.
scoped_ptr<RenderViewContextMenuGtk> context_menu_;