Home | History | Annotate | Download | only in tabs
      1 // Copyright (c) 2012 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_VIEWS_TABS_TAB_RENDERER_DATA_H_
      6 #define CHROME_BROWSER_UI_VIEWS_TABS_TAB_RENDERER_DATA_H_
      7 
      8 #include "base/process/kill.h"
      9 #include "base/strings/string16.h"
     10 #include "chrome/browser/ui/views/chrome_views_export.h"
     11 #include "ui/gfx/image/image_skia.h"
     12 #include "url/gurl.h"
     13 
     14 // Wraps the state needed by the renderers.
     15 struct CHROME_VIEWS_EXPORT TabRendererData {
     16   // Different types of network activity for a tab. The NetworkState of a tab
     17   // may be used to alter the UI (e.g. show different kinds of loading
     18   // animations).
     19   enum NetworkState {
     20     NETWORK_STATE_NONE,     // no network activity.
     21     NETWORK_STATE_WAITING,  // waiting for a connection.
     22     NETWORK_STATE_LOADING,  // connected, transferring data.
     23   };
     24 
     25   // Capture state of this tab. If a WebRTC media stream is active, then it is
     26   // recording. If tab capturing is active then it is projecting.
     27   enum CaptureState {
     28     CAPTURE_STATE_NONE,
     29     CAPTURE_STATE_RECORDING,
     30     CAPTURE_STATE_PROJECTING
     31   };
     32 
     33   // Audio playing state of this tab. If muting is added this is where it
     34   // should go.
     35   enum AudioState {
     36     AUDIO_STATE_NONE,
     37     AUDIO_STATE_PLAYING
     38   };
     39 
     40   TabRendererData();
     41   ~TabRendererData();
     42 
     43   // This interprets the crashed status to decide whether or not this
     44   // render data represents a tab that is "crashed" (i.e. the render
     45   // process died unexpectedly).
     46   bool IsCrashed() const {
     47     return (crashed_status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED ||
     48             crashed_status == base::TERMINATION_STATUS_PROCESS_CRASHED ||
     49             crashed_status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION);
     50   }
     51 
     52   bool AudioActive() const {
     53     return audio_state != AUDIO_STATE_NONE;
     54   }
     55 
     56   bool CaptureActive() const {
     57     return capture_state != CAPTURE_STATE_NONE;
     58   }
     59 
     60   // Returns true if the TabRendererData is same as given |data|.
     61   bool Equals(const TabRendererData& data);
     62 
     63   gfx::ImageSkia favicon;
     64   NetworkState network_state;
     65   string16 title;
     66   GURL url;
     67   bool loading;
     68   base::TerminationStatus crashed_status;
     69   bool incognito;
     70   bool show_icon;
     71   bool mini;
     72   bool blocked;
     73   bool app;
     74   CaptureState capture_state;
     75   AudioState audio_state;
     76 };
     77 
     78 #endif  // CHROME_BROWSER_UI_VIEWS_TABS_TAB_RENDERER_DATA_H_
     79