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