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 #ifndef CHROME_BROWSER_VIEWS_FRAME_BROWSER_ROOT_VIEW_H | 5 #ifndef CHROME_BROWSER_VIEWS_FRAME_BROWSER_ROOT_VIEW_H |
6 #define CHROME_BROWSER_VIEWS_FRAME_BROWSER_ROOT_VIEW_H | 6 #define CHROME_BROWSER_VIEWS_FRAME_BROWSER_ROOT_VIEW_H |
7 | 7 |
8 #include "views/widget/root_view.h" | 8 #include "views/widget/root_view.h" |
9 | 9 |
10 class BrowserView; | |
10 class OSExchangeData; | 11 class OSExchangeData; |
11 class TabStripWrapper; | 12 class TabStripWrapper; |
12 | 13 |
13 // RootView implementation used by BrowserFrame. This forwards drop events to | 14 // RootView implementation used by BrowserFrame. This forwards drop events to |
14 // the TabStrip. Visually the tabstrip extends to the top of the frame, but in | 15 // the TabStrip. Visually the tabstrip extends to the top of the frame, but in |
15 // actually it doesn't. The tabstrip is only as high as a tab. To enable | 16 // actually it doesn't. The tabstrip is only as high as a tab. To enable |
16 // dropping above the tabstrip BrowserRootView forwards drop events to the | 17 // dropping above the tabstrip BrowserRootView forwards drop events to the |
17 // TabStrip. | 18 // TabStrip. |
18 class BrowserRootView : public views::RootView { | 19 class BrowserRootView : public views::RootView { |
19 public: | 20 public: |
20 // You must call set_tabstrip before this class will accept drops. | 21 // You must call set_tabstrip before this class will accept drops. |
21 BrowserRootView(views::Widget* widget); | 22 BrowserRootView(BrowserView* browser_view, views::Widget* widget); |
22 | |
23 // Sets the tabstrip associated with this window. This is used to forward | |
24 // drag and drop operations to, so no drops will be accepted if there is no | |
25 // tabstrip set. | |
26 void set_tabstrip(TabStripWrapper* tabstrip) { tabstrip_ = tabstrip; } | |
27 | 23 |
28 virtual bool GetDropFormats( | 24 virtual bool GetDropFormats( |
29 int* formats, | 25 int* formats, |
30 std::set<OSExchangeData::CustomFormat>* custom_formats); | 26 std::set<OSExchangeData::CustomFormat>* custom_formats); |
27 virtual bool AreDropTypesRequired(); | |
31 virtual bool CanDrop(const OSExchangeData& data); | 28 virtual bool CanDrop(const OSExchangeData& data); |
32 virtual void OnDragEntered(const views::DropTargetEvent& event); | 29 virtual void OnDragEntered(const views::DropTargetEvent& event); |
33 virtual int OnDragUpdated(const views::DropTargetEvent& event); | 30 virtual int OnDragUpdated(const views::DropTargetEvent& event); |
34 virtual void OnDragExited(); | 31 virtual void OnDragExited(); |
35 virtual int OnPerformDrop(const views::DropTargetEvent& event); | 32 virtual int OnPerformDrop(const views::DropTargetEvent& event); |
36 | 33 |
37 private: | 34 private: |
38 // Returns true if the event should be forwarded to the tabstrip. | 35 // Returns true if the event should be forwarded to the tabstrip. |
39 bool ShouldForwardToTabStrip(const views::DropTargetEvent& event); | 36 bool ShouldForwardToTabStrip(const views::DropTargetEvent& event); |
40 | 37 |
41 // Converts the event from the hosts coordinate system to the tabstrips | 38 // Converts the event from the hosts coordinate system to the tabstrips |
42 // coordinate system. | 39 // coordinate system. |
43 views::DropTargetEvent* MapEventToTabStrip( | 40 views::DropTargetEvent* MapEventToTabStrip( |
44 const views::DropTargetEvent& event); | 41 const views::DropTargetEvent& event, |
42 const OSExchangeData& data); | |
45 | 43 |
46 // The TabStrip. | 44 TabStripWrapper* tabstrip() const; |
47 TabStripWrapper* tabstrip_; | 45 |
46 // Returns true if |data| has string contents and the user can "paste and go" | |
47 // (see AutocompleteEditModel::CanPasteAndGo for details). If |url| is | |
48 // non-null and the user can "paste and go", |url| is set to the | |
49 // "paste and go" url. | |
50 bool GetPasteAndGoURL(const OSExchangeData& data, | |
51 GURL* url); | |
jcampan
2009/09/08 20:19:03
Nit: Can't this fit on one line?
| |
52 | |
53 // The BrowserView. | |
54 BrowserView* browser_view_; | |
48 | 55 |
49 // If true, drag and drop events are being forwarded to the tab strip. | 56 // If true, drag and drop events are being forwarded to the tab strip. |
50 // This is used to determine when to send OnDragEntered and OnDragExited | 57 // This is used to determine when to send OnDragEntered and OnDragExited |
51 // to the tab strip. | 58 // to the tab strip. |
52 bool forwarding_to_tab_strip_; | 59 bool forwarding_to_tab_strip_; |
53 | 60 |
54 DISALLOW_COPY_AND_ASSIGN(BrowserRootView); | 61 DISALLOW_COPY_AND_ASSIGN(BrowserRootView); |
55 }; | 62 }; |
56 | 63 |
57 #endif // CHROME_BROWSER_VIEWS_FRAME_BROWSER_ROOT_VIEW_H | 64 #endif // CHROME_BROWSER_VIEWS_FRAME_BROWSER_ROOT_VIEW_H |
OLD | NEW |