[Telemetry] Always uploading browser log if enabled instead of wait for crash to...
[chromium-blink-merge.git] / components / html_viewer / html_frame_tree_manager.h
blob25e26f07ab8c6947809f5b13787c5b2f3f6e951a
1 // Copyright 2015 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.
5 #ifndef COMPONENTS_HTML_VIEWER_HTML_FRAME_TREE_MANAGER_H_
6 #define COMPONENTS_HTML_VIEWER_HTML_FRAME_TREE_MANAGER_H_
8 #include <map>
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "mandoline/tab/public/interfaces/frame_tree.mojom.h"
14 namespace blink {
15 class WebView;
18 namespace mojo {
19 class ApplicationImpl;
20 class View;
23 namespace html_viewer {
25 class DocumentResourceWaiter;
26 class GlobalState;
27 class HTMLFrame;
28 class HTMLFrameDelegate;
30 // HTMLFrameTreeManager is responsible for managing the frames that comprise a
31 // document. Some of the frames may be remote. HTMLFrameTreeManager updates its
32 // state in response to changes from the FrameTreeServer, as well as changes
33 // from the underlying frames. The frame tree has at least one local frame
34 // that is backed by a mojo::View.
35 class HTMLFrameTreeManager {
36 public:
37 // Creates a new HTMLFrame. The caller owns the return value and must call
38 // Close() when done.
39 static HTMLFrame* CreateFrameAndAttachToTree(
40 GlobalState* global_state,
41 mojo::ApplicationImpl* app,
42 mojo::View* view,
43 scoped_ptr<DocumentResourceWaiter> resource_waiter,
44 HTMLFrameDelegate* delegate);
46 GlobalState* global_state() { return global_state_; }
48 blink::WebView* GetWebView();
50 private:
51 friend class HTMLFrame;
52 using TreeMap = std::map<uint32_t, HTMLFrameTreeManager*>;
54 explicit HTMLFrameTreeManager(GlobalState* global_state);
55 ~HTMLFrameTreeManager();
57 void Init(HTMLFrameDelegate* delegate,
58 mojo::View* local_view,
59 const mojo::Array<mandoline::FrameDataPtr>& frame_data);
61 // Creates a Frame per FrameData element in |frame_data|. Returns the root.
62 HTMLFrame* BuildFrameTree(
63 HTMLFrameDelegate* delegate,
64 const mojo::Array<mandoline::FrameDataPtr>& frame_data,
65 uint32_t local_frame_id,
66 mojo::View* local_view);
68 // Returns this HTMLFrameTreeManager from |instances_|.
69 void RemoveFromInstances();
71 // Invoked when a Frame is destroyed.
72 void OnFrameDestroyed(HTMLFrame* frame);
74 // Each HTMLFrame delegates FrameTreeClient methods to the
75 // HTMLFrameTreeManager the frame is in. HTMLFrameTreeManager only responds
76 // to changes from the |local_root_| (this is because each FrameTreeClient
77 // sees the same change, and a change only need be processed once).
78 void ProcessOnFrameAdded(HTMLFrame* source,
79 mandoline::FrameDataPtr frame_data);
80 void ProcessOnFrameRemoved(HTMLFrame* source, uint32_t frame_id);
81 void ProcessOnFrameClientPropertyChanged(HTMLFrame* source,
82 uint32_t frame_id,
83 const mojo::String& name,
84 mojo::Array<uint8_t> new_data);
86 static TreeMap* instances_;
88 GlobalState* global_state_;
90 HTMLFrame* root_;
92 // The |local_root_| is the HTMLFrame that is the highest frame that is
93 // local.
94 HTMLFrame* local_root_;
96 DISALLOW_COPY_AND_ASSIGN(HTMLFrameTreeManager);
99 } // namespace html_viewer
101 #endif // COMPONENTS_HTML_VIEWER_HTML_FRAME_TREE_MANAGER_H_