| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/tab_contents/web_contents_view_gtk.h" | 5 #include "chrome/browser/tab_contents/web_contents_view_gtk.h" |
| 6 | 6 |
| 7 #include <gdk/gdk.h> | 7 #include <gdk/gdk.h> |
| 8 #include <gdk/gdkkeysyms.h> | 8 #include <gdk/gdkkeysyms.h> |
| 9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
| 10 | 10 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 66 |
| 67 WebContentsViewGtk::WebContentsViewGtk(WebContents* web_contents) | 67 WebContentsViewGtk::WebContentsViewGtk(WebContents* web_contents) |
| 68 : WebContentsView(web_contents), | 68 : WebContentsView(web_contents), |
| 69 vbox_(gtk_vbox_new(FALSE, 0)) { | 69 vbox_(gtk_vbox_new(FALSE, 0)) { |
| 70 } | 70 } |
| 71 | 71 |
| 72 WebContentsViewGtk::~WebContentsViewGtk() { | 72 WebContentsViewGtk::~WebContentsViewGtk() { |
| 73 vbox_.Destroy(); | 73 vbox_.Destroy(); |
| 74 } | 74 } |
| 75 | 75 |
| 76 WebContents* WebContentsViewGtk::GetWebContents() { | |
| 77 return web_contents_; | |
| 78 } | |
| 79 | |
| 80 void WebContentsViewGtk::CreateView() { | 76 void WebContentsViewGtk::CreateView() { |
| 81 NOTIMPLEMENTED(); | 77 NOTIMPLEMENTED(); |
| 82 } | 78 } |
| 83 | 79 |
| 84 RenderWidgetHostView* WebContentsViewGtk::CreateViewForWidget( | 80 RenderWidgetHostView* WebContentsViewGtk::CreateViewForWidget( |
| 85 RenderWidgetHost* render_widget_host) { | 81 RenderWidgetHost* render_widget_host) { |
| 86 DCHECK(!render_widget_host->view()); | 82 DCHECK(!render_widget_host->view()); |
| 87 RenderWidgetHostViewGtk* view = | 83 RenderWidgetHostViewGtk* view = |
| 88 new RenderWidgetHostViewGtk(render_widget_host); | 84 new RenderWidgetHostViewGtk(render_widget_host); |
| 89 view->InitAsChild(); | 85 view->InitAsChild(); |
| 90 content_view_ = view->native_view(); | 86 content_view_ = view->native_view(); |
| 91 g_signal_connect(content_view_, "focus", | 87 g_signal_connect(content_view_, "focus", |
| 92 G_CALLBACK(OnFocus), web_contents_); | 88 G_CALLBACK(OnFocus), web_contents()); |
| 93 g_signal_connect(view->native_view(), "leave-notify-event", | 89 g_signal_connect(view->native_view(), "leave-notify-event", |
| 94 G_CALLBACK(OnLeaveNotify), web_contents_); | 90 G_CALLBACK(OnLeaveNotify), web_contents()); |
| 95 g_signal_connect(view->native_view(), "motion-notify-event", | 91 g_signal_connect(view->native_view(), "motion-notify-event", |
| 96 G_CALLBACK(OnMouseMove), web_contents_); | 92 G_CALLBACK(OnMouseMove), web_contents()); |
| 97 gtk_widget_add_events(view->native_view(), GDK_LEAVE_NOTIFY_MASK | | 93 gtk_widget_add_events(view->native_view(), GDK_LEAVE_NOTIFY_MASK | |
| 98 GDK_POINTER_MOTION_MASK); | 94 GDK_POINTER_MOTION_MASK); |
| 99 gtk_container_foreach(GTK_CONTAINER(vbox_.get()), RemoveWidget, vbox_.get()); | 95 gtk_container_foreach(GTK_CONTAINER(vbox_.get()), RemoveWidget, vbox_.get()); |
| 100 gtk_box_pack_start(GTK_BOX(vbox_.get()), content_view_, TRUE, TRUE, 0); | 96 gtk_box_pack_start(GTK_BOX(vbox_.get()), content_view_, TRUE, TRUE, 0); |
| 101 return view; | 97 return view; |
| 102 } | 98 } |
| 103 | 99 |
| 104 gfx::NativeView WebContentsViewGtk::GetNativeView() const { | 100 gfx::NativeView WebContentsViewGtk::GetNativeView() const { |
| 105 return vbox_.get(); | 101 return vbox_.get(); |
| 106 } | 102 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 NOTIMPLEMENTED(); | 143 NOTIMPLEMENTED(); |
| 148 } | 144 } |
| 149 | 145 |
| 150 bool WebContentsViewGtk::GetFindBarWindowInfo(gfx::Point* position, | 146 bool WebContentsViewGtk::GetFindBarWindowInfo(gfx::Point* position, |
| 151 bool* fully_visible) const { | 147 bool* fully_visible) const { |
| 152 NOTIMPLEMENTED(); | 148 NOTIMPLEMENTED(); |
| 153 return false; | 149 return false; |
| 154 } | 150 } |
| 155 | 151 |
| 156 void WebContentsViewGtk::SetInitialFocus() { | 152 void WebContentsViewGtk::SetInitialFocus() { |
| 157 if (web_contents_->FocusLocationBarByDefault()) | 153 if (web_contents()->FocusLocationBarByDefault()) |
| 158 web_contents_->delegate()->SetFocusToLocationBar(); | 154 web_contents()->delegate()->SetFocusToLocationBar(); |
| 159 else | 155 else |
| 160 gtk_widget_grab_focus(content_view_); | 156 gtk_widget_grab_focus(content_view_); |
| 161 } | 157 } |
| 162 | 158 |
| 163 void WebContentsViewGtk::StoreFocus() { | 159 void WebContentsViewGtk::StoreFocus() { |
| 164 NOTIMPLEMENTED(); | 160 NOTIMPLEMENTED(); |
| 165 } | 161 } |
| 166 | 162 |
| 167 void WebContentsViewGtk::RestoreFocus() { | 163 void WebContentsViewGtk::RestoreFocus() { |
| 168 // TODO(estade): implement this function. | 164 // TODO(estade): implement this function. |
| 169 // For now just assume we are viewing the tab for the first time. | 165 // For now just assume we are viewing the tab for the first time. |
| 170 SetInitialFocus(); | 166 SetInitialFocus(); |
| 171 NOTIMPLEMENTED(); | 167 NOTIMPLEMENTED(); |
| 172 } | 168 } |
| 173 | 169 |
| 174 void WebContentsViewGtk::UpdateDragCursor(bool is_drop_target) { | 170 void WebContentsViewGtk::UpdateDragCursor(bool is_drop_target) { |
| 175 NOTIMPLEMENTED(); | 171 NOTIMPLEMENTED(); |
| 176 } | 172 } |
| 177 | 173 |
| 178 // This is called when we the renderer asks us to take focus back (i.e., it has | 174 // This is called when we the renderer asks us to take focus back (i.e., it has |
| 179 // iterated past the last focusable element on the page). | 175 // iterated past the last focusable element on the page). |
| 180 void WebContentsViewGtk::TakeFocus(bool reverse) { | 176 void WebContentsViewGtk::TakeFocus(bool reverse) { |
| 181 web_contents_->delegate()->SetFocusToLocationBar(); | 177 web_contents()->delegate()->SetFocusToLocationBar(); |
| 182 } | 178 } |
| 183 | 179 |
| 184 void WebContentsViewGtk::HandleKeyboardEvent( | 180 void WebContentsViewGtk::HandleKeyboardEvent( |
| 185 const NativeWebKeyboardEvent& event) { | 181 const NativeWebKeyboardEvent& event) { |
| 186 // This may be an accelerator. Pass it on to GTK. | 182 // This may be an accelerator. Pass it on to GTK. |
| 187 GtkWindow* window = GetTopLevelNativeWindow(); | 183 GtkWindow* window = GetTopLevelNativeWindow(); |
| 188 gtk_accel_groups_activate(G_OBJECT(window), event.os_event->keyval, | 184 gtk_accel_groups_activate(G_OBJECT(window), event.os_event->keyval, |
| 189 GdkModifierType(event.os_event->state)); | 185 GdkModifierType(event.os_event->state)); |
| 190 } | 186 } |
| 191 | 187 |
| 192 void WebContentsViewGtk::OnFindReply(int request_id, | 188 void WebContentsViewGtk::OnFindReply(int request_id, |
| 193 int number_of_matches, | 189 int number_of_matches, |
| 194 const gfx::Rect& selection_rect, | 190 const gfx::Rect& selection_rect, |
| 195 int active_match_ordinal, | 191 int active_match_ordinal, |
| 196 bool final_update) { | 192 bool final_update) { |
| 197 NOTIMPLEMENTED(); | 193 NOTIMPLEMENTED(); |
| 198 } | 194 } |
| 199 | 195 |
| 200 void WebContentsViewGtk::ShowContextMenu(const ContextMenuParams& params) { | 196 void WebContentsViewGtk::ShowContextMenu(const ContextMenuParams& params) { |
| 201 context_menu_.reset(new RenderViewContextMenuGtk(web_contents_, params)); | 197 context_menu_.reset(new RenderViewContextMenuGtk(web_contents(), params)); |
| 202 context_menu_->Popup(); | 198 context_menu_->Popup(); |
| 203 } | 199 } |
| 204 | 200 |
| 205 void WebContentsViewGtk::StartDragging(const WebDropData& drop_data) { | 201 void WebContentsViewGtk::StartDragging(const WebDropData& drop_data) { |
| 206 NOTIMPLEMENTED(); | 202 NOTIMPLEMENTED(); |
| 207 } | 203 } |
| 208 | 204 |
| 209 WebContents* WebContentsViewGtk::CreateNewWindowInternal( | 205 WebContents* WebContentsViewGtk::CreateNewWindowInternal( |
| 210 int route_id, | 206 int route_id, |
| 211 base::WaitableEvent* modal_dialog_event) { | 207 base::WaitableEvent* modal_dialog_event) { |
| 212 NOTIMPLEMENTED(); | 208 NOTIMPLEMENTED(); |
| 213 return NULL; | 209 return NULL; |
| 214 } | 210 } |
| 215 | 211 |
| 216 void WebContentsViewGtk::ShowCreatedWindowInternal( | 212 void WebContentsViewGtk::ShowCreatedWindowInternal( |
| 217 WebContents* new_web_contents, | 213 WebContents* new_web_contents, |
| 218 WindowOpenDisposition disposition, | 214 WindowOpenDisposition disposition, |
| 219 const gfx::Rect& initial_pos, | 215 const gfx::Rect& initial_pos, |
| 220 bool user_gesture) { | 216 bool user_gesture) { |
| 221 NOTIMPLEMENTED(); | 217 NOTIMPLEMENTED(); |
| 222 } | 218 } |
| OLD | NEW |