Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_BASE_H_ | |
| 6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_BASE_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 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" | |
| 25 | |
| 26 class Profile; | |
| 27 | |
| 28 namespace content { | |
| 29 class DevToolsClientHost; | |
| 30 struct FileChooserParams; | |
| 31 class WebContents; | |
| 32 } | |
| 33 | |
| 34 // Base implementation of DevTools findings around front-end. | |
|
Vladislav Kaznacheev
2014/04/29 11:10:05
Findings? Cannot really parse the comment.
pfeldman
2014/04/29 11:28:11
Done. bindings :)
| |
| 35 class DevToolsWindowBase : public content::NotificationObserver, | |
| 36 public content::DevToolsFrontendHostDelegate, | |
| 37 public DevToolsEmbedderMessageDispatcher::Delegate, | |
| 38 public DevToolsAndroidBridge::DeviceCountListener { | |
| 39 public: | |
| 40 virtual ~DevToolsWindowBase(); | |
| 41 | |
| 42 content::WebContents* web_contents() { return web_contents_; } | |
| 43 | |
| 44 // content::NotificationObserver: | |
| 45 virtual void Observe(int type, | |
| 46 const content::NotificationSource& source, | |
| 47 const content::NotificationDetails& details) OVERRIDE; | |
| 48 | |
| 49 // content::DevToolsFrontendHostDelegate override: | |
| 50 virtual void InspectedContentsClosing() OVERRIDE; | |
| 51 virtual void DispatchOnEmbedder(const std::string& message) OVERRIDE; | |
| 52 | |
| 53 // DevToolsEmbedderMessageDispatcher::Delegate overrides: | |
| 54 virtual void ActivateWindow() OVERRIDE; | |
| 55 virtual void CloseWindow() OVERRIDE; | |
| 56 virtual void SetContentsInsets( | |
| 57 int left, int top, int right, int bottom) OVERRIDE; | |
| 58 virtual void SetContentsResizingStrategy( | |
| 59 const gfx::Insets& insets, const gfx::Size& min_size) OVERRIDE; | |
| 60 virtual void InspectElementCompleted() OVERRIDE; | |
| 61 virtual void MoveWindow(int x, int y) OVERRIDE; | |
| 62 virtual void SetIsDocked(bool is_docked) OVERRIDE; | |
| 63 virtual void OpenInNewTab(const std::string& url) OVERRIDE; | |
| 64 virtual void SaveToFile(const std::string& url, | |
| 65 const std::string& content, | |
| 66 bool save_as) OVERRIDE; | |
| 67 virtual void AppendToFile(const std::string& url, | |
| 68 const std::string& content) OVERRIDE; | |
| 69 virtual void RequestFileSystems() OVERRIDE; | |
| 70 virtual void AddFileSystem() OVERRIDE; | |
| 71 virtual void RemoveFileSystem(const std::string& file_system_path) OVERRIDE; | |
| 72 virtual void UpgradeDraggedFileSystemPermissions( | |
| 73 const std::string& file_system_url) OVERRIDE; | |
| 74 virtual void IndexPath(int request_id, | |
| 75 const std::string& file_system_path) OVERRIDE; | |
| 76 virtual void StopIndexing(int request_id) OVERRIDE; | |
| 77 virtual void SearchInPath(int request_id, | |
| 78 const std::string& file_system_path, | |
| 79 const std::string& query) OVERRIDE; | |
| 80 virtual void SetWhitelistedShortcuts(const std::string& message) OVERRIDE; | |
| 81 virtual void ZoomIn() OVERRIDE; | |
| 82 virtual void ZoomOut() OVERRIDE; | |
| 83 virtual void ResetZoom() OVERRIDE; | |
| 84 virtual void OpenUrlOnRemoteDeviceAndInspect(const std::string& browser_id, | |
| 85 const std::string& url) OVERRIDE; | |
| 86 virtual void StartRemoteDevicesListener() OVERRIDE; | |
| 87 virtual void StopRemoteDevicesListener() OVERRIDE; | |
| 88 virtual void EnableRemoteDeviceCounter(bool enable) OVERRIDE; | |
| 89 | |
| 90 // DevToolsAndroidBridge::DeviceCountListener override: | |
| 91 virtual void DeviceCountChanged(int count) OVERRIDE; | |
| 92 | |
| 93 // Forwards discovered devices to frontend. | |
| 94 virtual void PopulateRemoteDevices(const std::string& source, | |
| 95 scoped_ptr<base::ListValue> targets); | |
| 96 | |
| 97 protected: | |
| 98 DevToolsWindowBase(content::WebContents* web_contents, | |
| 99 const GURL& frontend_url); | |
| 100 | |
| 101 virtual void AddDevToolsExtensionsToClient(); | |
| 102 virtual void DocumentOnLoadCompletedInMainFrame(); | |
| 103 void CallClientFunction(const std::string& function_name, | |
| 104 const base::Value* arg1, | |
| 105 const base::Value* arg2, | |
| 106 const base::Value* arg3); | |
| 107 Profile* profile() { return profile_; } | |
| 108 content::DevToolsClientHost* frontend_host() { return frontend_host_.get(); } | |
| 109 | |
| 110 private: | |
| 111 typedef base::Callback<void(bool)> InfoBarCallback; | |
| 112 | |
| 113 // DevToolsFileHelper callbacks. | |
| 114 void FileSavedAs(const std::string& url); | |
| 115 void CanceledFileSaveAs(const std::string& url); | |
| 116 void AppendedTo(const std::string& url); | |
| 117 void FileSystemsLoaded( | |
| 118 const std::vector<DevToolsFileHelper::FileSystem>& file_systems); | |
| 119 void FileSystemAdded(const DevToolsFileHelper::FileSystem& file_system); | |
| 120 void IndexingTotalWorkCalculated(int request_id, | |
| 121 const std::string& file_system_path, | |
| 122 int total_work); | |
| 123 void IndexingWorked(int request_id, | |
| 124 const std::string& file_system_path, | |
| 125 int worked); | |
| 126 void IndexingDone(int request_id, const std::string& file_system_path); | |
| 127 void SearchCompleted(int request_id, | |
| 128 const std::string& file_system_path, | |
| 129 const std::vector<std::string>& file_paths); | |
| 130 void ShowDevToolsConfirmInfoBar(const base::string16& message, | |
| 131 const InfoBarCallback& callback); | |
| 132 | |
| 133 // Theme and extensions support. | |
| 134 GURL ApplyThemeToURL(const GURL& base_url); | |
| 135 void UpdateTheme(); | |
| 136 | |
| 137 class FrontendWebContentsObserver; | |
| 138 friend class FrontendWebContentsObserver; | |
| 139 scoped_ptr<FrontendWebContentsObserver> frontend_contents_observer_; | |
| 140 | |
| 141 Profile* profile_; | |
| 142 content::WebContents* web_contents_; | |
| 143 bool device_listener_enabled_; | |
| 144 content::NotificationRegistrar registrar_; | |
| 145 scoped_ptr<content::DevToolsClientHost> frontend_host_; | |
| 146 scoped_ptr<DevToolsFileHelper> file_helper_; | |
| 147 scoped_refptr<DevToolsFileSystemIndexer> file_system_indexer_; | |
| 148 typedef std::map< | |
| 149 int, | |
| 150 scoped_refptr<DevToolsFileSystemIndexer::FileSystemIndexingJob> > | |
| 151 IndexingJobsMap; | |
| 152 IndexingJobsMap indexing_jobs_; | |
| 153 | |
| 154 scoped_ptr<DevToolsRemoteTargetsUIHandler> remote_targets_handler_; | |
| 155 scoped_ptr<DevToolsEmbedderMessageDispatcher> embedder_message_dispatcher_; | |
| 156 base::WeakPtrFactory<DevToolsWindowBase> weak_factory_; | |
| 157 | |
| 158 DISALLOW_COPY_AND_ASSIGN(DevToolsWindowBase); | |
| 159 }; | |
| 160 | |
| 161 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_BASE_H_ | |
| OLD | NEW |