OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/devtools/devtools_ui_bindings.h" | 5 #include "chrome/browser/devtools/devtools_ui_bindings.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 // value "false". Otherwise, creates a dev tools confirm infobar and delegate | 110 // value "false". Otherwise, creates a dev tools confirm infobar and delegate |
111 // and adds the infobar to |infobar_service|. | 111 // and adds the infobar to |infobar_service|. |
112 static void Create(InfoBarService* infobar_service, | 112 static void Create(InfoBarService* infobar_service, |
113 const InfoBarCallback& callback, | 113 const InfoBarCallback& callback, |
114 const base::string16& message); | 114 const base::string16& message); |
115 | 115 |
116 private: | 116 private: |
117 DevToolsConfirmInfoBarDelegate( | 117 DevToolsConfirmInfoBarDelegate( |
118 const InfoBarCallback& callback, | 118 const InfoBarCallback& callback, |
119 const base::string16& message); | 119 const base::string16& message); |
120 virtual ~DevToolsConfirmInfoBarDelegate(); | 120 ~DevToolsConfirmInfoBarDelegate() override; |
121 | 121 |
122 virtual base::string16 GetMessageText() const override; | 122 base::string16 GetMessageText() const override; |
123 virtual base::string16 GetButtonLabel(InfoBarButton button) const override; | 123 base::string16 GetButtonLabel(InfoBarButton button) const override; |
124 virtual bool Accept() override; | 124 bool Accept() override; |
125 virtual bool Cancel() override; | 125 bool Cancel() override; |
126 | 126 |
127 InfoBarCallback callback_; | 127 InfoBarCallback callback_; |
128 const base::string16 message_; | 128 const base::string16 message_; |
129 | 129 |
130 DISALLOW_COPY_AND_ASSIGN(DevToolsConfirmInfoBarDelegate); | 130 DISALLOW_COPY_AND_ASSIGN(DevToolsConfirmInfoBarDelegate); |
131 }; | 131 }; |
132 | 132 |
133 void DevToolsConfirmInfoBarDelegate::Create( | 133 void DevToolsConfirmInfoBarDelegate::Create( |
134 InfoBarService* infobar_service, | 134 InfoBarService* infobar_service, |
135 const InfoBarCallback& callback, | 135 const InfoBarCallback& callback, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 } | 180 } |
181 | 181 |
182 // DevToolsUIDefaultDelegate -------------------------------------------------- | 182 // DevToolsUIDefaultDelegate -------------------------------------------------- |
183 | 183 |
184 class DefaultBindingsDelegate : public DevToolsUIBindings::Delegate { | 184 class DefaultBindingsDelegate : public DevToolsUIBindings::Delegate { |
185 public: | 185 public: |
186 explicit DefaultBindingsDelegate(content::WebContents* web_contents) | 186 explicit DefaultBindingsDelegate(content::WebContents* web_contents) |
187 : web_contents_(web_contents) {} | 187 : web_contents_(web_contents) {} |
188 | 188 |
189 private: | 189 private: |
190 virtual ~DefaultBindingsDelegate() {} | 190 ~DefaultBindingsDelegate() override {} |
191 | 191 |
192 virtual void ActivateWindow() override; | 192 void ActivateWindow() override; |
193 virtual void CloseWindow() override {} | 193 void CloseWindow() override {} |
194 virtual void SetInspectedPageBounds(const gfx::Rect& rect) override {} | 194 void SetInspectedPageBounds(const gfx::Rect& rect) override {} |
195 virtual void InspectElementCompleted() override {} | 195 void InspectElementCompleted() override {} |
196 virtual void MoveWindow(int x, int y) override {} | 196 void MoveWindow(int x, int y) override {} |
197 virtual void SetIsDocked(bool is_docked) override {} | 197 void SetIsDocked(bool is_docked) override {} |
198 virtual void OpenInNewTab(const std::string& url) override; | 198 void OpenInNewTab(const std::string& url) override; |
199 virtual void SetWhitelistedShortcuts(const std::string& message) override {} | 199 void SetWhitelistedShortcuts(const std::string& message) override {} |
200 | 200 |
201 virtual void InspectedContentsClosing() override; | 201 void InspectedContentsClosing() override; |
202 virtual void OnLoadCompleted() override {} | 202 void OnLoadCompleted() override {} |
203 virtual InfoBarService* GetInfoBarService() override; | 203 InfoBarService* GetInfoBarService() override; |
204 virtual void RenderProcessGone() override {} | 204 void RenderProcessGone() override {} |
205 | 205 |
206 content::WebContents* web_contents_; | 206 content::WebContents* web_contents_; |
207 DISALLOW_COPY_AND_ASSIGN(DefaultBindingsDelegate); | 207 DISALLOW_COPY_AND_ASSIGN(DefaultBindingsDelegate); |
208 }; | 208 }; |
209 | 209 |
210 void DefaultBindingsDelegate::ActivateWindow() { | 210 void DefaultBindingsDelegate::ActivateWindow() { |
211 web_contents_->GetDelegate()->ActivateContents(web_contents_); | 211 web_contents_->GetDelegate()->ActivateContents(web_contents_); |
212 web_contents_->Focus(); | 212 web_contents_->Focus(); |
213 } | 213 } |
214 | 214 |
(...skipping 14 matching lines...) Expand all Loading... |
229 } | 229 } |
230 | 230 |
231 } // namespace | 231 } // namespace |
232 | 232 |
233 // DevToolsUIBindings::FrontendWebContentsObserver ---------------------------- | 233 // DevToolsUIBindings::FrontendWebContentsObserver ---------------------------- |
234 | 234 |
235 class DevToolsUIBindings::FrontendWebContentsObserver | 235 class DevToolsUIBindings::FrontendWebContentsObserver |
236 : public content::WebContentsObserver { | 236 : public content::WebContentsObserver { |
237 public: | 237 public: |
238 explicit FrontendWebContentsObserver(DevToolsUIBindings* ui_bindings); | 238 explicit FrontendWebContentsObserver(DevToolsUIBindings* ui_bindings); |
239 virtual ~FrontendWebContentsObserver(); | 239 ~FrontendWebContentsObserver() override; |
240 | 240 |
241 private: | 241 private: |
242 // contents::WebContentsObserver: | 242 // contents::WebContentsObserver: |
243 virtual void RenderProcessGone(base::TerminationStatus status) override; | 243 void RenderProcessGone(base::TerminationStatus status) override; |
244 virtual void AboutToNavigateRenderView( | 244 void AboutToNavigateRenderView( |
245 content::RenderViewHost* render_view_host) override; | 245 content::RenderViewHost* render_view_host) override; |
246 virtual void DocumentOnLoadCompletedInMainFrame() override; | 246 void DocumentOnLoadCompletedInMainFrame() override; |
247 virtual void DidNavigateMainFrame( | 247 void DidNavigateMainFrame( |
248 const content::LoadCommittedDetails& details, | 248 const content::LoadCommittedDetails& details, |
249 const content::FrameNavigateParams& params) override; | 249 const content::FrameNavigateParams& params) override; |
250 | 250 |
251 DevToolsUIBindings* devtools_bindings_; | 251 DevToolsUIBindings* devtools_bindings_; |
252 DISALLOW_COPY_AND_ASSIGN(FrontendWebContentsObserver); | 252 DISALLOW_COPY_AND_ASSIGN(FrontendWebContentsObserver); |
253 }; | 253 }; |
254 | 254 |
255 DevToolsUIBindings::FrontendWebContentsObserver::FrontendWebContentsObserver( | 255 DevToolsUIBindings::FrontendWebContentsObserver::FrontendWebContentsObserver( |
256 DevToolsUIBindings* devtools_ui_bindings) | 256 DevToolsUIBindings* devtools_ui_bindings) |
257 : WebContentsObserver(devtools_ui_bindings->web_contents()), | 257 : WebContentsObserver(devtools_ui_bindings->web_contents()), |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 if (frontend_loaded_) | 891 if (frontend_loaded_) |
892 return; | 892 return; |
893 frontend_loaded_ = true; | 893 frontend_loaded_ = true; |
894 | 894 |
895 // Call delegate first - it seeds importants bit of information. | 895 // Call delegate first - it seeds importants bit of information. |
896 delegate_->OnLoadCompleted(); | 896 delegate_->OnLoadCompleted(); |
897 | 897 |
898 UpdateTheme(); | 898 UpdateTheme(); |
899 AddDevToolsExtensionsToClient(); | 899 AddDevToolsExtensionsToClient(); |
900 } | 900 } |
OLD | NEW |