Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Side by Side Diff: chrome/browser/tab_contents/tab_contents_view_gtk.h

Issue 159889: GTK: Fancy html5 draggy stuff. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/app/chrome_dll_main.cc ('k') | chrome/browser/tab_contents/tab_contents_view_gtk.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_GTK_H_ 5 #ifndef CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_GTK_H_
6 #define CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_GTK_H_ 6 #define CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_GTK_H_
7 7
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 9
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/message_loop.h"
12 #include "base/scoped_ptr.h" 13 #include "base/scoped_ptr.h"
13 #include "chrome/browser/gtk/focus_store_gtk.h" 14 #include "chrome/browser/gtk/focus_store_gtk.h"
14 #include "chrome/browser/tab_contents/tab_contents_view.h" 15 #include "chrome/browser/tab_contents/tab_contents_view.h"
15 #include "chrome/common/notification_observer.h" 16 #include "chrome/common/notification_observer.h"
16 #include "chrome/common/notification_registrar.h" 17 #include "chrome/common/notification_registrar.h"
17 #include "chrome/common/owned_widget_gtk.h" 18 #include "chrome/common/owned_widget_gtk.h"
18 19
19 class BlockedPopupContainerViewGtk; 20 class BlockedPopupContainerViewGtk;
20 class ConstrainedWindowGtk; 21 class ConstrainedWindowGtk;
21 class GtkThemeProperties; 22 class GtkThemeProperties;
22 class RenderViewContextMenuGtk; 23 class RenderViewContextMenuGtk;
23 class SadTabGtk; 24 class SadTabGtk;
24 class WebDragDest; 25 class WebDragDest;
25 typedef struct _GtkFloatingContainer GtkFloatingContainer; 26 typedef struct _GtkFloatingContainer GtkFloatingContainer;
26 27
27 class TabContentsViewGtk : public TabContentsView, 28 class TabContentsViewGtk : public TabContentsView,
28 public NotificationObserver { 29 public NotificationObserver,
30 public MessageLoopForUI::Observer {
29 public: 31 public:
30 // The corresponding TabContents is passed in the constructor, and manages our 32 // The corresponding TabContents is passed in the constructor, and manages our
31 // lifetime. This doesn't need to be the case, but is this way currently 33 // lifetime. This doesn't need to be the case, but is this way currently
32 // because that's what was easiest when they were split. 34 // because that's what was easiest when they were split.
33 explicit TabContentsViewGtk(TabContents* tab_contents); 35 explicit TabContentsViewGtk(TabContents* tab_contents);
34 virtual ~TabContentsViewGtk(); 36 virtual ~TabContentsViewGtk();
35 37
36 // Unlike Windows, the BlockedPopupContainerView needs to collaborate with 38 // Unlike Windows, the BlockedPopupContainerView needs to collaborate with
37 // the TabContentsViewGtk to position the notification. 39 // the TabContentsViewGtk to position the notification.
38 void AttachBlockedPopupView(BlockedPopupContainerViewGtk* popup_view); 40 void AttachBlockedPopupView(BlockedPopupContainerViewGtk* popup_view);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 virtual void GotFocus(); 72 virtual void GotFocus();
71 virtual void TakeFocus(bool reverse); 73 virtual void TakeFocus(bool reverse);
72 virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event); 74 virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event);
73 75
74 // NotificationObserver implementation --------------------------------------- 76 // NotificationObserver implementation ---------------------------------------
75 77
76 virtual void Observe(NotificationType type, 78 virtual void Observe(NotificationType type,
77 const NotificationSource& source, 79 const NotificationSource& source,
78 const NotificationDetails& details); 80 const NotificationDetails& details);
79 81
82
83 protected:
84 // MessageLoop::Observer implementation:
85 virtual void WillProcessEvent(GdkEvent* event);
86 virtual void DidProcessEvent(GdkEvent* event);
87
80 private: 88 private:
81 // Insert the given widget into the content area. Should only be used for 89 // Insert the given widget into the content area. Should only be used for
82 // web pages and the like (including interstitials and sad tab). Note that 90 // web pages and the like (including interstitials and sad tab). Note that
83 // this will be perfectly happy to insert overlapping render views, so care 91 // this will be perfectly happy to insert overlapping render views, so care
84 // should be taken that the correct one is hidden/shown. 92 // should be taken that the correct one is hidden/shown.
85 void InsertIntoContentArea(GtkWidget* widget); 93 void InsertIntoContentArea(GtkWidget* widget);
86 94
87 // Tell webkit the drag is over. 95 void CancelDragIfAny();
88 void DragEnded();
89 96
90 // We keep track of the timestamp of the latest mousedown event. 97 // We keep track of the timestamp of the latest mousedown event.
91 static gboolean OnMouseDown(GtkWidget* widget, 98 static gboolean OnMouseDown(GtkWidget* widget,
92 GdkEventButton* event, TabContentsViewGtk* view); 99 GdkEventButton* event, TabContentsViewGtk* view);
93 100
94 // Used to propagate size changes on |fixed_| to its children. 101 // Used to propagate size changes on |fixed_| to its children.
95 static gboolean OnSizeAllocate(GtkWidget* widget, 102 static gboolean OnSizeAllocate(GtkWidget* widget,
96 GtkAllocation* config, 103 GtkAllocation* config,
97 TabContentsViewGtk* view); 104 TabContentsViewGtk* view);
98 105
99 static void OnSetFloatingPosition( 106 static void OnSetFloatingPosition(
100 GtkFloatingContainer* floating_container, GtkAllocation* allocation, 107 GtkFloatingContainer* floating_container, GtkAllocation* allocation,
101 TabContentsViewGtk* tab_contents_view); 108 TabContentsViewGtk* tab_contents_view);
102 109
103 // Webkit DnD. 110 // Webkit source-side DnD.
104 static void OnDragEnd(GtkWidget* widget, GdkDragContext* drag_context, 111 static gboolean OnDragFailedThunk(GtkWidget* widget,
105 TabContentsViewGtk* tab_contents_view); 112 GdkDragContext* drag_context,
106 static void OnDragDataGet(GtkWidget* drag_widget, 113 GtkDragResult result,
107 GdkDragContext* context, GtkSelectionData* selection_data, 114 TabContentsViewGtk* view) {
108 guint target_type, guint time, TabContentsViewGtk* view); 115 return view->OnDragFailed();
116 }
117 gboolean OnDragFailed();
118 static void OnDragEndThunk(GtkWidget* widget,
119 GdkDragContext* drag_context,
120 TabContentsViewGtk* view) {
121 view->OnDragEnd();
122 }
123 void OnDragEnd();
124 static void OnDragDataGetThunk(GtkWidget* drag_widget,
125 GdkDragContext* context,
126 GtkSelectionData* selection_data,
127 guint target_type,
128 guint time,
129 TabContentsViewGtk* view) {
130 view->OnDragDataGet(context, selection_data, target_type, time);
131 }
132 void OnDragDataGet(GdkDragContext* context, GtkSelectionData* selection_data,
133 guint target_type, guint time);
109 134
110 // Contains |fixed_| as its GtkBin member and a possible floating widget from 135 // Contains |fixed_| as its GtkBin member and a possible floating widget from
111 // |popup_view_|. 136 // |popup_view_|.
112 OwnedWidgetGtk floating_; 137 OwnedWidgetGtk floating_;
113 138
114 // This container holds the tab's web page views. It is a GtkFixed so that we 139 // This container holds the tab's web page views. It is a GtkFixed so that we
115 // can control the size of the web pages. 140 // can control the size of the web pages.
116 GtkWidget* fixed_; 141 GtkWidget* fixed_;
117 142
118 // The context menu is reset every time we show it, but we keep a pointer to 143 // The context menu is reset every time we show it, but we keep a pointer to
(...skipping 13 matching lines...) Expand all
132 157
133 // Our UI for controlling popups (or NULL if no popup windows have been 158 // Our UI for controlling popups (or NULL if no popup windows have been
134 // opened). |popup_view_| is owned by the TabContents, not the view. 159 // opened). |popup_view_| is owned by the TabContents, not the view.
135 BlockedPopupContainerViewGtk* popup_view_; 160 BlockedPopupContainerViewGtk* popup_view_;
136 161
137 // Each individual UI for constrained dialogs currently displayed. The 162 // Each individual UI for constrained dialogs currently displayed. The
138 // objects in this vector are owned by the TabContents, not the view. 163 // objects in this vector are owned by the TabContents, not the view.
139 std::vector<ConstrainedWindowGtk*> constrained_windows_; 164 std::vector<ConstrainedWindowGtk*> constrained_windows_;
140 165
141 // The drop data for the current drag (for drags that originate in the render 166 // The drop data for the current drag (for drags that originate in the render
142 // view). 167 // view). Non-NULL iff there is a current drag.
143 scoped_ptr<WebDropData> drop_data_; 168 scoped_ptr<WebDropData> drop_data_;
144 // The mime type for the file contents of the current drag (if any). 169 // The mime type for the file contents of the current drag (if any).
145 GdkAtom drag_file_mime_type_; 170 GdkAtom drag_file_mime_type_;
146 // The helper object that handles drag destination related interactions with 171 // The helper object that handles drag destination related interactions with
147 // GTK. 172 // GTK.
148 scoped_ptr<WebDragDest> drag_dest_; 173 scoped_ptr<WebDragDest> drag_dest_;
174 // Whether the current drag has failed. Meaningless if we are not the source
175 // for a current drag.
176 bool drag_failed_;
177 // This is the widget we use to initiate drags. Since we don't use the
178 // renderer widget, we can persist drags even when our contents is switched
179 // out.
180 GtkWidget* drag_widget_;
149 181
150 DISALLOW_COPY_AND_ASSIGN(TabContentsViewGtk); 182 DISALLOW_COPY_AND_ASSIGN(TabContentsViewGtk);
151 }; 183 };
152 184
153 #endif // CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_GTK_H_ 185 #endif // CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_GTK_H_
OLDNEW
« no previous file with comments | « chrome/app/chrome_dll_main.cc ('k') | chrome/browser/tab_contents/tab_contents_view_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698