Home | History | Annotate | Download | only in webui
      1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_TAB_CONTENTS_DELEGATE_H_
      6 #define CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_TAB_CONTENTS_DELEGATE_H_
      7 #pragma once
      8 
      9 #include "content/browser/tab_contents/tab_contents_delegate.h"
     10 
     11 class Browser;
     12 class Profile;
     13 
     14 // This class implements (and mostly ignores) most of TabContentsDelegate for
     15 // use in an HTML dialog.  Subclasses need only override a few methods instead
     16 // of the everything from TabContentsDelegate; this way, implementations on
     17 // all platforms behave consistently.
     18 
     19 class HtmlDialogTabContentsDelegate : public TabContentsDelegate {
     20  public:
     21   // Profile must be non-NULL.
     22   explicit HtmlDialogTabContentsDelegate(Profile* profile);
     23 
     24   virtual ~HtmlDialogTabContentsDelegate();
     25 
     26   // The returned profile is guaranteed to be original if non-NULL.
     27   Profile* profile() const;
     28 
     29   // Calling this causes all following events sent from the
     30   // TabContents object to be ignored.  It also makes all following
     31   // calls to profile() return NULL.
     32   void Detach();
     33 
     34   // TabContentsDelegate declarations.  Subclasses of this still need to
     35   // override:
     36   //   virtual void MoveContents(TabContents* source, const gfx::Rect& pos);
     37 
     38   virtual void OpenURLFromTab(TabContents* source,
     39                               const GURL& url, const GURL& referrer,
     40                               WindowOpenDisposition disposition,
     41                               PageTransition::Type transition);
     42   virtual void NavigationStateChanged(const TabContents* source,
     43                                       unsigned changed_flags);
     44   virtual void AddNewContents(TabContents* source,
     45                               TabContents* new_contents,
     46                               WindowOpenDisposition disposition,
     47                               const gfx::Rect& initial_pos,
     48                               bool user_gesture);
     49   virtual void ActivateContents(TabContents* contents);
     50   virtual void DeactivateContents(TabContents* contents);
     51   virtual void LoadingStateChanged(TabContents* source);
     52   virtual void CloseContents(TabContents* source);
     53   virtual bool IsPopup(const TabContents* source) const;
     54   virtual void UpdateTargetURL(TabContents* source, const GURL& url);
     55   virtual bool ShouldAddNavigationToHistory(
     56       const history::HistoryAddPageArgs& add_page_args,
     57       NavigationType::Type navigation_type);
     58 
     59  private:
     60   Profile* profile_;  // Weak pointer.  Always an original profile.
     61 };
     62 
     63 #endif  // CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_TAB_CONTENTS_DELEGATE_H_
     64