Home | History | Annotate | Download | only in login
      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_CHROMEOS_LOGIN_WEB_PAGE_SCREEN_H_
      6 #define CHROME_BROWSER_CHROMEOS_LOGIN_WEB_PAGE_SCREEN_H_
      7 #pragma once
      8 
      9 #include "base/timer.h"
     10 #include "chrome/browser/chromeos/login/screen_observer.h"
     11 #include "content/browser/tab_contents/tab_contents_delegate.h"
     12 
     13 class GURL;
     14 
     15 namespace chromeos {
     16 
     17 // Base class for wizard screen that holds web page.
     18 class WebPageScreen : public TabContentsDelegate {
     19  public:
     20   explicit WebPageScreen() {}
     21   virtual ~WebPageScreen() {}
     22 
     23   // Exits from the screen with the specified exit code.
     24   virtual void CloseScreen(ScreenObserver::ExitCodes code) = 0;
     25 
     26  protected:
     27   // TabContentsDelegate implementation:
     28   virtual void OpenURLFromTab(TabContents* source,
     29                               const GURL& url, const GURL& referrer,
     30                               WindowOpenDisposition disposition,
     31                               PageTransition::Type transition) {}
     32   virtual void NavigationStateChanged(const TabContents* source,
     33                                       unsigned changed_flags) = 0;
     34   virtual void AddNewContents(TabContents* source,
     35                               TabContents* new_contents,
     36                               WindowOpenDisposition disposition,
     37                               const gfx::Rect& initial_pos,
     38                               bool user_gesture) {}
     39   virtual void ActivateContents(TabContents* contents) {}
     40   virtual void DeactivateContents(TabContents* contents) {}
     41   virtual void LoadingStateChanged(TabContents* source) = 0;
     42   virtual void CloseContents(TabContents* source) {}
     43   virtual bool IsPopup(TabContents* source) { return false; }
     44   virtual void UpdateTargetURL(TabContents* source, const GURL& url) {}
     45   virtual bool ShouldAddNavigationToHistory(
     46       const history::HistoryAddPageArgs& add_page_args,
     47       NavigationType::Type navigation_type) {
     48     return false;
     49   }
     50   virtual void MoveContents(TabContents* source, const gfx::Rect& pos) {}
     51   virtual bool HandleContextMenu(const ContextMenuParams& params);
     52 
     53   // Called by |timeout_timer_|. Stops page fetching and closes screen.
     54   virtual void OnNetworkTimeout();
     55 
     56   // Start/stop timeout timer.
     57   void StartTimeoutTimer();
     58   void StopTimeoutTimer();
     59 
     60  private:
     61   // Timer used for network response timeout.
     62   base::OneShotTimer<WebPageScreen> timeout_timer_;
     63 
     64   DISALLOW_COPY_AND_ASSIGN(WebPageScreen);
     65 };
     66 
     67 }  // namespace chromeos
     68 
     69 #endif  // CHROME_BROWSER_CHROMEOS_LOGIN_WEB_PAGE_SCREEN_H_
     70