Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / chrome / browser / devtools / devtools_ui_bindings.h
blob1bfa13e77a1c51cad3c84061403ac2a34b1f323b
1 // Copyright 2014 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 CHROME_BROWSER_DEVTOOLS_DEVTOOLS_UI_BINDINGS_H_
6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_UI_BINDINGS_H_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "base/strings/string16.h"
15 #include "chrome/browser/devtools/device/devtools_android_bridge.h"
16 #include "chrome/browser/devtools/devtools_embedder_message_dispatcher.h"
17 #include "chrome/browser/devtools/devtools_file_helper.h"
18 #include "chrome/browser/devtools/devtools_file_system_indexer.h"
19 #include "chrome/browser/devtools/devtools_targets_ui.h"
20 #include "content/public/browser/devtools_client_host.h"
21 #include "content/public/browser/devtools_frontend_host_delegate.h"
22 #include "content/public/browser/notification_observer.h"
23 #include "content/public/browser/notification_registrar.h"
24 #include "ui/gfx/size.h"
26 class InfoBarService;
27 class Profile;
29 namespace content {
30 class DevToolsClientHost;
31 struct FileChooserParams;
32 class WebContents;
35 // Base implementation of DevTools bindings around front-end.
36 class DevToolsUIBindings : public content::NotificationObserver,
37 public content::DevToolsFrontendHostDelegate,
38 public DevToolsEmbedderMessageDispatcher::Delegate,
39 public DevToolsAndroidBridge::DeviceCountListener {
40 public:
41 static DevToolsUIBindings* ForWebContents(
42 content::WebContents* web_contents);
43 static GURL ApplyThemeToURL(Profile* profile, const GURL& base_url);
45 class Delegate {
46 public:
47 virtual ~Delegate() {}
48 virtual void ActivateWindow() = 0;
49 virtual void CloseWindow() = 0;
50 virtual void SetContentsInsets(
51 int left, int top, int right, int bottom) = 0;
52 virtual void SetContentsResizingStrategy(
53 const gfx::Insets& insets, const gfx::Size& min_size) = 0;
54 virtual void InspectElementCompleted() = 0;
55 virtual void MoveWindow(int x, int y) = 0;
56 virtual void SetIsDocked(bool is_docked) = 0;
57 virtual void OpenInNewTab(const std::string& url) = 0;
58 virtual void SetWhitelistedShortcuts(const std::string& message) = 0;
60 virtual void InspectedContentsClosing() = 0;
61 virtual void OnLoadCompleted() = 0;
62 virtual InfoBarService* GetInfoBarService() = 0;
65 explicit DevToolsUIBindings(content::WebContents* web_contents);
66 virtual ~DevToolsUIBindings();
68 content::WebContents* web_contents() { return web_contents_; }
69 Profile* profile() { return profile_; }
70 content::DevToolsClientHost* frontend_host() { return frontend_host_.get(); }
72 void SetDelegate(Delegate* delegate);
73 void CallClientFunction(const std::string& function_name,
74 const base::Value* arg1,
75 const base::Value* arg2,
76 const base::Value* arg3);
78 private:
79 // content::NotificationObserver:
80 virtual void Observe(int type,
81 const content::NotificationSource& source,
82 const content::NotificationDetails& details) OVERRIDE;
84 // content::DevToolsFrontendHostDelegate override:
85 virtual void InspectedContentsClosing() OVERRIDE;
86 virtual void DispatchOnEmbedder(const std::string& message) OVERRIDE;
88 // DevToolsEmbedderMessageDispatcher::Delegate overrides:
89 virtual void ActivateWindow() OVERRIDE;
90 virtual void CloseWindow() OVERRIDE;
91 virtual void SetContentsInsets(
92 int left, int top, int right, int bottom) OVERRIDE;
93 virtual void SetContentsResizingStrategy(
94 const gfx::Insets& insets, const gfx::Size& min_size) OVERRIDE;
95 virtual void InspectElementCompleted() OVERRIDE;
96 virtual void MoveWindow(int x, int y) OVERRIDE;
97 virtual void SetIsDocked(bool is_docked) OVERRIDE;
98 virtual void OpenInNewTab(const std::string& url) OVERRIDE;
99 virtual void SaveToFile(const std::string& url,
100 const std::string& content,
101 bool save_as) OVERRIDE;
102 virtual void AppendToFile(const std::string& url,
103 const std::string& content) OVERRIDE;
104 virtual void RequestFileSystems() OVERRIDE;
105 virtual void AddFileSystem() OVERRIDE;
106 virtual void RemoveFileSystem(const std::string& file_system_path) OVERRIDE;
107 virtual void UpgradeDraggedFileSystemPermissions(
108 const std::string& file_system_url) OVERRIDE;
109 virtual void IndexPath(int request_id,
110 const std::string& file_system_path) OVERRIDE;
111 virtual void StopIndexing(int request_id) OVERRIDE;
112 virtual void SearchInPath(int request_id,
113 const std::string& file_system_path,
114 const std::string& query) OVERRIDE;
115 virtual void SetWhitelistedShortcuts(const std::string& message) OVERRIDE;
116 virtual void ZoomIn() OVERRIDE;
117 virtual void ZoomOut() OVERRIDE;
118 virtual void ResetZoom() OVERRIDE;
119 virtual void OpenUrlOnRemoteDeviceAndInspect(const std::string& browser_id,
120 const std::string& url) OVERRIDE;
121 virtual void StartRemoteDevicesListener() OVERRIDE;
122 virtual void StopRemoteDevicesListener() OVERRIDE;
123 virtual void EnableRemoteDeviceCounter(bool enable) OVERRIDE;
125 // DevToolsAndroidBridge::DeviceCountListener override:
126 virtual void DeviceCountChanged(int count) OVERRIDE;
128 // Forwards discovered devices to frontend.
129 virtual void PopulateRemoteDevices(const std::string& source,
130 scoped_ptr<base::ListValue> targets);
132 void DocumentOnLoadCompletedInMainFrame();
134 // DevToolsFileHelper callbacks.
135 void FileSavedAs(const std::string& url);
136 void CanceledFileSaveAs(const std::string& url);
137 void AppendedTo(const std::string& url);
138 void FileSystemsLoaded(
139 const std::vector<DevToolsFileHelper::FileSystem>& file_systems);
140 void FileSystemAdded(const DevToolsFileHelper::FileSystem& file_system);
141 void IndexingTotalWorkCalculated(int request_id,
142 const std::string& file_system_path,
143 int total_work);
144 void IndexingWorked(int request_id,
145 const std::string& file_system_path,
146 int worked);
147 void IndexingDone(int request_id, const std::string& file_system_path);
148 void SearchCompleted(int request_id,
149 const std::string& file_system_path,
150 const std::vector<std::string>& file_paths);
151 typedef base::Callback<void(bool)> InfoBarCallback;
152 void ShowDevToolsConfirmInfoBar(const base::string16& message,
153 const InfoBarCallback& callback);
155 // Theme and extensions support.
156 void UpdateTheme();
157 void AddDevToolsExtensionsToClient();
159 class FrontendWebContentsObserver;
160 friend class FrontendWebContentsObserver;
161 scoped_ptr<FrontendWebContentsObserver> frontend_contents_observer_;
163 Profile* profile_;
164 content::WebContents* web_contents_;
165 scoped_ptr<Delegate> delegate_;
166 bool device_listener_enabled_;
167 content::NotificationRegistrar registrar_;
168 scoped_ptr<content::DevToolsClientHost> frontend_host_;
169 scoped_ptr<DevToolsFileHelper> file_helper_;
170 scoped_refptr<DevToolsFileSystemIndexer> file_system_indexer_;
171 typedef std::map<
172 int,
173 scoped_refptr<DevToolsFileSystemIndexer::FileSystemIndexingJob> >
174 IndexingJobsMap;
175 IndexingJobsMap indexing_jobs_;
177 scoped_ptr<DevToolsTargetsUIHandler> remote_targets_handler_;
178 scoped_ptr<DevToolsEmbedderMessageDispatcher> embedder_message_dispatcher_;
179 base::WeakPtrFactory<DevToolsUIBindings> weak_factory_;
181 DISALLOW_COPY_AND_ASSIGN(DevToolsUIBindings);
184 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_UI_BINDINGS_H_