| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_UI_VIEWS_TABS_TAB_DRAG_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_TABS_TAB_DRAG_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_TABS_TAB_DRAG_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_TABS_TAB_DRAG_CONTROLLER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/timer.h" | 13 #include "base/timer.h" |
| 14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 14 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 15 #include "chrome/browser/ui/tabs/dock_info.h" | 15 #include "chrome/browser/ui/tabs/dock_info.h" |
| 16 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" | 16 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" |
| 17 #include "chrome/browser/ui/tabs/tab_strip_selection_model.h" | 17 #include "chrome/browser/ui/tabs/tab_strip_selection_model.h" |
| 18 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
| 19 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
| 20 #include "content/public/browser/web_contents_delegate.h" | 20 #include "content/public/browser/web_contents_delegate.h" |
| 21 #include "ui/gfx/rect.h" | 21 #include "ui/gfx/rect.h" |
| 22 #include "ui/views/widget/widget.h" | 22 #include "ui/views/widget/widget.h" |
| 23 | 23 |
| 24 namespace views { | 24 namespace views { |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 | 160 |
| 161 // The caller should continue. | 161 // The caller should continue. |
| 162 DRAG_BROWSER_RESULT_CONTINUE, | 162 DRAG_BROWSER_RESULT_CONTINUE, |
| 163 }; | 163 }; |
| 164 | 164 |
| 165 // Stores the date associated with a single tab that is being dragged. | 165 // Stores the date associated with a single tab that is being dragged. |
| 166 struct TabDragData { | 166 struct TabDragData { |
| 167 TabDragData(); | 167 TabDragData(); |
| 168 ~TabDragData(); | 168 ~TabDragData(); |
| 169 | 169 |
| 170 // The TabContentsWrapper being dragged. | 170 // The TabContents being dragged. |
| 171 TabContentsWrapper* contents; | 171 TabContents* contents; |
| 172 | 172 |
| 173 // The original content::WebContentsDelegate of |contents|, before it was | 173 // The original content::WebContentsDelegate of |contents|, before it was |
| 174 // detached from the browser window. We store this so that we can forward | 174 // detached from the browser window. We store this so that we can forward |
| 175 // certain delegate notifications back to it if we can't handle them | 175 // certain delegate notifications back to it if we can't handle them |
| 176 // locally. | 176 // locally. |
| 177 content::WebContentsDelegate* original_delegate; | 177 content::WebContentsDelegate* original_delegate; |
| 178 | 178 |
| 179 // This is the index of the tab in |source_tabstrip_| when the drag | 179 // This is the index of the tab in |source_tabstrip_| when the drag |
| 180 // began. This is used to restore the previous state if the drag is aborted. | 180 // began. This is used to restore the previous state if the drag is aborted. |
| 181 int source_model_index; | 181 int source_model_index; |
| 182 | 182 |
| 183 // If attached this is the tab in |attached_tabstrip_|. | 183 // If attached this is the tab in |attached_tabstrip_|. |
| 184 BaseTab* attached_tab; | 184 BaseTab* attached_tab; |
| 185 | 185 |
| 186 // Is the tab pinned? | 186 // Is the tab pinned? |
| 187 bool pinned; | 187 bool pinned; |
| 188 }; | 188 }; |
| 189 | 189 |
| 190 typedef std::vector<TabDragData> DragData; | 190 typedef std::vector<TabDragData> DragData; |
| 191 | 191 |
| 192 // Sets |drag_data| from |tab|. This also registers for necessary | 192 // Sets |drag_data| from |tab|. This also registers for necessary |
| 193 // notifications and resets the delegate of the TabContentsWrapper. | 193 // notifications and resets the delegate of the TabContents. |
| 194 void InitTabDragData(BaseTab* tab, TabDragData* drag_data); | 194 void InitTabDragData(BaseTab* tab, TabDragData* drag_data); |
| 195 | 195 |
| 196 // Overridden from content::WebContentsDelegate: | 196 // Overridden from content::WebContentsDelegate: |
| 197 virtual content::WebContents* OpenURLFromTab( | 197 virtual content::WebContents* OpenURLFromTab( |
| 198 content::WebContents* source, | 198 content::WebContents* source, |
| 199 const content::OpenURLParams& params) OVERRIDE; | 199 const content::OpenURLParams& params) OVERRIDE; |
| 200 virtual void NavigationStateChanged(const content::WebContents* source, | 200 virtual void NavigationStateChanged(const content::WebContents* source, |
| 201 unsigned changed_flags) OVERRIDE; | 201 unsigned changed_flags) OVERRIDE; |
| 202 virtual void AddNewContents(content::WebContents* source, | 202 virtual void AddNewContents(content::WebContents* source, |
| 203 content::WebContents* new_contents, | 203 content::WebContents* new_contents, |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 | 395 |
| 396 void BringWindowUnderPointToFront(const gfx::Point& screen_point); | 396 void BringWindowUnderPointToFront(const gfx::Point& screen_point); |
| 397 | 397 |
| 398 // Convenience for getting the TabDragData corresponding to the tab the user | 398 // Convenience for getting the TabDragData corresponding to the tab the user |
| 399 // started dragging. | 399 // started dragging. |
| 400 TabDragData* source_tab_drag_data() { | 400 TabDragData* source_tab_drag_data() { |
| 401 return &(drag_data_[source_tab_index_]); | 401 return &(drag_data_[source_tab_index_]); |
| 402 } | 402 } |
| 403 | 403 |
| 404 // Convenience for |source_tab_drag_data()->contents|. | 404 // Convenience for |source_tab_drag_data()->contents|. |
| 405 TabContentsWrapper* source_dragged_contents() { | 405 TabContents* source_dragged_contents() { |
| 406 return source_tab_drag_data()->contents; | 406 return source_tab_drag_data()->contents; |
| 407 } | 407 } |
| 408 | 408 |
| 409 // Returns the Widget of the currently attached TabStrip's BrowserView. | 409 // Returns the Widget of the currently attached TabStrip's BrowserView. |
| 410 views::Widget* GetAttachedBrowserWidget(); | 410 views::Widget* GetAttachedBrowserWidget(); |
| 411 | 411 |
| 412 // Returns true if the tabs were originality one after the other in | 412 // Returns true if the tabs were originality one after the other in |
| 413 // |source_tabstrip_|. | 413 // |source_tabstrip_|. |
| 414 bool AreTabsConsecutive(); | 414 bool AreTabsConsecutive(); |
| 415 | 415 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 // Non-null for the duration of RunMoveLoop. | 555 // Non-null for the duration of RunMoveLoop. |
| 556 views::Widget* move_loop_widget_; | 556 views::Widget* move_loop_widget_; |
| 557 | 557 |
| 558 // If non-null set to true from destructor. | 558 // If non-null set to true from destructor. |
| 559 bool* destroyed_; | 559 bool* destroyed_; |
| 560 | 560 |
| 561 DISALLOW_COPY_AND_ASSIGN(TabDragController); | 561 DISALLOW_COPY_AND_ASSIGN(TabDragController); |
| 562 }; | 562 }; |
| 563 | 563 |
| 564 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_DRAG_CONTROLLER_H_ | 564 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_DRAG_CONTROLLER_H_ |
| OLD | NEW |