| OLD | NEW | 
|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_DELEGATE_H_ | 
| 6 #define CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_DELEGATE_H_ | 6 #define CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_DELEGATE_H_ | 
| 7 | 7 | 
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" | 
|  | 9 #include "base/gfx/rect.h" | 
| 9 #include "chrome/browser/tab_contents/page_navigator.h" | 10 #include "chrome/browser/tab_contents/page_navigator.h" | 
| 10 #include "chrome/common/navigation_types.h" | 11 #include "chrome/common/navigation_types.h" | 
| 11 | 12 | 
| 12 namespace gfx { |  | 
| 13 class Point; |  | 
| 14 class Rect; |  | 
| 15 } |  | 
| 16 |  | 
| 17 class TabContents; | 13 class TabContents; | 
| 18 class HtmlDialogContentsDelegate; | 14 class HtmlDialogContentsDelegate; | 
| 19 | 15 | 
| 20 // Objects implement this interface to get notified about changes in the | 16 // Objects implement this interface to get notified about changes in the | 
| 21 // TabContents and to provide necessary functionality. | 17 // TabContents and to provide necessary functionality. | 
| 22 class TabContentsDelegate : public PageNavigator { | 18 class TabContentsDelegate : public PageNavigator { | 
| 23  public: | 19  public: | 
| 24   // Opens a new URL inside the passed in TabContents, if source is 0 open | 20   // Opens a new URL inside the passed in TabContents, if source is 0 open | 
| 25   // in the current front-most tab. | 21   // in the current front-most tab. | 
| 26   virtual void OpenURLFromTab(TabContents* source, | 22   virtual void OpenURLFromTab(TabContents* source, | 
| 27                               const GURL& url, const GURL& referrer, | 23                               const GURL& url, const GURL& referrer, | 
| 28                               WindowOpenDisposition disposition, | 24                               WindowOpenDisposition disposition, | 
| 29                               PageTransition::Type transition) = 0; | 25                               PageTransition::Type transition) = 0; | 
| 30 | 26 | 
| 31   virtual void OpenURL(const GURL& url, const GURL& referrer, | 27   virtual void OpenURL(const GURL& url, const GURL& referrer, | 
| 32                        WindowOpenDisposition disposition, | 28                        WindowOpenDisposition disposition, | 
| 33                        PageTransition::Type transition) | 29                        PageTransition::Type transition) { | 
| 34   { |  | 
| 35     OpenURLFromTab(NULL, url, referrer, disposition, transition); | 30     OpenURLFromTab(NULL, url, referrer, disposition, transition); | 
| 36   } | 31   } | 
| 37 | 32 | 
| 38   // Called to inform the delegate that the tab content's navigation state | 33   // Called to inform the delegate that the tab content's navigation state | 
| 39   // changed. The |changed_flags| indicates the parts of the navigation state | 34   // changed. The |changed_flags| indicates the parts of the navigation state | 
| 40   // that have been updated, and is any combination of the | 35   // that have been updated, and is any combination of the | 
| 41   // |TabContents::InvalidateTypes| bits. | 36   // |TabContents::InvalidateTypes| bits. | 
| 42   virtual void NavigationStateChanged(const TabContents* source, | 37   virtual void NavigationStateChanged(const TabContents* source, | 
| 43                                       unsigned changed_flags) = 0; | 38                                       unsigned changed_flags) = 0; | 
| 44 | 39 | 
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 99   virtual void ContentsZoomChange(bool zoom_in) { } | 94   virtual void ContentsZoomChange(bool zoom_in) { } | 
| 100 | 95 | 
| 101   // Check whether this contents is inside a window dedicated to running a web | 96   // Check whether this contents is inside a window dedicated to running a web | 
| 102   // application. | 97   // application. | 
| 103   virtual bool IsApplication() { return false; } | 98   virtual bool IsApplication() { return false; } | 
| 104 | 99 | 
| 105   // Detach the given tab and convert it to a "webapp" view.  The tab must be | 100   // Detach the given tab and convert it to a "webapp" view.  The tab must be | 
| 106   // a WebContents with a valid WebApp set. | 101   // a WebContents with a valid WebApp set. | 
| 107   virtual void ConvertContentsToApplication(TabContents* source) { } | 102   virtual void ConvertContentsToApplication(TabContents* source) { } | 
| 108 | 103 | 
| 109   // Informs the TabContentsDelegate that some of our state has changed | 104   // Informs the TabContentsDelegate that some of our state has changed | 
| 110   // for this tab. | 105   // for this tab. | 
| 111   virtual void ContentsStateChanged(TabContents* source) {} | 106   virtual void ContentsStateChanged(TabContents* source) {} | 
| 112 | 107 | 
| 113   // Return whether this tab contents should have a URL bar. Only web contents | 108   // Return whether this tab contents should have a URL bar. Only web contents | 
| 114   // opened with a minimal chrome and their popups can be displayed without a | 109   // opened with a minimal chrome and their popups can be displayed without a | 
| 115   // URL bar. | 110   // URL bar. | 
| 116   virtual bool ShouldDisplayURLField() { return true; } | 111   virtual bool ShouldDisplayURLField() { return true; } | 
| 117 | 112 | 
| 118   // Whether this tab can be blurred through a javascript obj.blur() | 113   // Whether this tab can be blurred through a javascript obj.blur() | 
| 119   // call. ConstrainedWindows shouldn't be able to be blurred. | 114   // call. ConstrainedWindows shouldn't be able to be blurred. | 
| 120   virtual bool CanBlur() const { return true; } | 115   virtual bool CanBlur() const { return true; } | 
| 121 | 116 | 
|  | 117   // Return the rect where to display the resize corner, if any, otherwise | 
|  | 118   // an empty rect. | 
|  | 119   virtual gfx::Rect GetRootWindowResizerRect() const { return gfx::Rect(); } | 
|  | 120 | 
| 122   // Show a dialog with HTML content. |delegate| contains a pointer to the | 121   // Show a dialog with HTML content. |delegate| contains a pointer to the | 
| 123   // delegate who knows how to display the dialog (which file URL and JSON | 122   // delegate who knows how to display the dialog (which file URL and JSON | 
| 124   // string input to use during initialization). |parent_window| is the window | 123   // string input to use during initialization). |parent_window| is the window | 
| 125   // that should be parent of the dialog, or NULL for the default. | 124   // that should be parent of the dialog, or NULL for the default. | 
| 126   virtual void ShowHtmlDialog(HtmlDialogContentsDelegate* delegate, | 125   virtual void ShowHtmlDialog(HtmlDialogContentsDelegate* delegate, | 
| 127                               void* parent_window) { } | 126                               void* parent_window) { } | 
| 128 | 127 | 
| 129   // Tells us that we've finished firing this tab's beforeunload event. | 128   // Tells us that we've finished firing this tab's beforeunload event. | 
| 130   // The proceed bool tells us whether the user chose to proceed closing the | 129   // The proceed bool tells us whether the user chose to proceed closing the | 
| 131   // tab. Returns true if the tab can continue on firing it's unload event. | 130   // tab. Returns true if the tab can continue on firing it's unload event. | 
| 132   // If we're closing the entire browser, then we'll want to delay firing | 131   // If we're closing the entire browser, then we'll want to delay firing | 
| 133   // unload events until all the beforeunload events have fired. | 132   // unload events until all the beforeunload events have fired. | 
| 134   virtual void BeforeUnloadFired(TabContents* tab, | 133   virtual void BeforeUnloadFired(TabContents* tab, | 
| 135                                  bool proceed, | 134                                  bool proceed, | 
| 136                                  bool* proceed_to_fire_unload) { | 135                                  bool* proceed_to_fire_unload) { | 
| 137     *proceed_to_fire_unload = true; | 136     *proceed_to_fire_unload = true; | 
| 138   } | 137   } | 
| 139 | 138 | 
| 140   // Send IPC to external host. Default implementation is do nothing. | 139   // Send IPC to external host. Default implementation is do nothing. | 
| 141   virtual void ForwardMessageToExternalHost(const std::string& receiver, | 140   virtual void ForwardMessageToExternalHost(const std::string& receiver, | 
| 142                                             const std::string& message) {}; | 141                                             const std::string& message) {} | 
| 143 | 142 | 
| 144   // If the delegate is hosting tabs externally. | 143   // If the delegate is hosting tabs externally. | 
| 145   virtual bool IsExternalTabContainer() const { return false; } | 144   virtual bool IsExternalTabContainer() const { return false; } | 
| 146 | 145 | 
| 147   // Sets focus to the location bar or some other place that is appropriate. | 146   // Sets focus to the location bar or some other place that is appropriate. | 
| 148   // This is called when the tab wants to encourage user input, like for the | 147   // This is called when the tab wants to encourage user input, like for the | 
| 149   // new tab page. | 148   // new tab page. | 
| 150   virtual void SetFocusToLocationBar() {} | 149   virtual void SetFocusToLocationBar() {} | 
| 151 }; | 150 }; | 
| 152 | 151 | 
| 153 #endif  // CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_DELEGATE_H_ | 152 #endif  // CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_DELEGATE_H_ | 
| OLD | NEW | 
|---|