| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/ui/webui/inspect_ui.h" | 5 #include "chrome/browser/ui/webui/inspect_ui.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "chrome/browser/devtools/devtools_targets_ui.h" | 9 #include "chrome/browser/devtools/devtools_targets_ui.h" |
| 10 #include "chrome/browser/devtools/devtools_ui_bindings.h" | 10 #include "chrome/browser/devtools/devtools_ui_bindings.h" |
| 11 #include "chrome/browser/devtools/devtools_window.h" | 11 #include "chrome/browser/devtools/devtools_window.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/ui/browser_navigator_params.h" | 13 #include "chrome/browser/ui/browser_navigator_params.h" |
| 14 #include "chrome/browser/ui/singleton_tabs.h" | 14 #include "chrome/browser/ui/singleton_tabs.h" |
| 15 #include "chrome/browser/ui/webui/theme_source.h" | 15 #include "chrome/browser/ui/webui/theme_source.h" |
| 16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 17 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
| 18 #include "chrome/grit/browser_resources.h" | 18 #include "chrome/grit/browser_resources.h" |
| 19 #include "components/prefs/pref_service.h" | 19 #include "components/prefs/pref_service.h" |
| 20 #include "components/ui_devtools/devtools_server.h" | 20 #include "components/ui_devtools/devtools_server.h" |
| 21 #include "content/public/browser/devtools_agent_host.h" | 21 #include "content/public/browser/devtools_agent_host.h" |
| 22 #include "content/public/browser/navigation_entry.h" | 22 #include "content/public/browser/navigation_entry.h" |
| 23 #include "content/public/browser/navigation_handle.h" |
| 23 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
| 24 #include "content/public/browser/notification_source.h" | 25 #include "content/public/browser/notification_source.h" |
| 25 #include "content/public/browser/notification_types.h" | 26 #include "content/public/browser/notification_types.h" |
| 26 #include "content/public/browser/user_metrics.h" | 27 #include "content/public/browser/user_metrics.h" |
| 27 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
| 28 #include "content/public/browser/web_contents_delegate.h" | 29 #include "content/public/browser/web_contents_delegate.h" |
| 29 #include "content/public/browser/web_contents_observer.h" | 30 #include "content/public/browser/web_contents_observer.h" |
| 30 #include "content/public/browser/web_ui.h" | 31 #include "content/public/browser/web_ui.h" |
| 31 #include "content/public/browser/web_ui_data_source.h" | 32 #include "content/public/browser/web_ui_data_source.h" |
| 32 #include "content/public/browser/web_ui_message_handler.h" | 33 #include "content/public/browser/web_ui_message_handler.h" |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 public: | 280 public: |
| 280 DevToolsUIBindingsEnabler(WebContents* web_contents, | 281 DevToolsUIBindingsEnabler(WebContents* web_contents, |
| 281 const GURL& url); | 282 const GURL& url); |
| 282 ~DevToolsUIBindingsEnabler() override {} | 283 ~DevToolsUIBindingsEnabler() override {} |
| 283 | 284 |
| 284 DevToolsUIBindings* GetBindings(); | 285 DevToolsUIBindings* GetBindings(); |
| 285 | 286 |
| 286 private: | 287 private: |
| 287 // contents::WebContentsObserver overrides. | 288 // contents::WebContentsObserver overrides. |
| 288 void WebContentsDestroyed() override; | 289 void WebContentsDestroyed() override; |
| 289 void DidNavigateMainFrame( | 290 void DidFinishNavigation( |
| 290 const content::LoadCommittedDetails& details, | 291 content::NavigationHandle* navigation_handle) override; |
| 291 const content::FrameNavigateParams& params) override; | |
| 292 | 292 |
| 293 DevToolsUIBindings bindings_; | 293 DevToolsUIBindings bindings_; |
| 294 GURL url_; | 294 GURL url_; |
| 295 DISALLOW_COPY_AND_ASSIGN(DevToolsUIBindingsEnabler); | 295 DISALLOW_COPY_AND_ASSIGN(DevToolsUIBindingsEnabler); |
| 296 }; | 296 }; |
| 297 | 297 |
| 298 DevToolsUIBindingsEnabler::DevToolsUIBindingsEnabler( | 298 DevToolsUIBindingsEnabler::DevToolsUIBindingsEnabler( |
| 299 WebContents* web_contents, | 299 WebContents* web_contents, |
| 300 const GURL& url) | 300 const GURL& url) |
| 301 : WebContentsObserver(web_contents), | 301 : WebContentsObserver(web_contents), |
| 302 bindings_(web_contents), | 302 bindings_(web_contents), |
| 303 url_(url) { | 303 url_(url) { |
| 304 } | 304 } |
| 305 | 305 |
| 306 DevToolsUIBindings* DevToolsUIBindingsEnabler::GetBindings() { | 306 DevToolsUIBindings* DevToolsUIBindingsEnabler::GetBindings() { |
| 307 return &bindings_; | 307 return &bindings_; |
| 308 } | 308 } |
| 309 | 309 |
| 310 void DevToolsUIBindingsEnabler::WebContentsDestroyed() { | 310 void DevToolsUIBindingsEnabler::WebContentsDestroyed() { |
| 311 delete this; | 311 delete this; |
| 312 } | 312 } |
| 313 | 313 |
| 314 void DevToolsUIBindingsEnabler::DidNavigateMainFrame( | 314 void DevToolsUIBindingsEnabler::DidFinishNavigation( |
| 315 const content::LoadCommittedDetails& details, | 315 content::NavigationHandle* navigation_handle) { |
| 316 const content::FrameNavigateParams& params) { | 316 if (!navigation_handle->IsInMainFrame() || !navigation_handle->HasCommitted()) |
| 317 if (url_ != params.url) | 317 return; |
| 318 |
| 319 if (url_ != navigation_handle->GetURL()) |
| 318 delete this; | 320 delete this; |
| 319 } | 321 } |
| 320 | 322 |
| 321 } // namespace | 323 } // namespace |
| 322 | 324 |
| 323 // InspectUI -------------------------------------------------------- | 325 // InspectUI -------------------------------------------------------- |
| 324 | 326 |
| 325 InspectUI::InspectUI(content::WebUI* web_ui) | 327 InspectUI::InspectUI(content::WebUI* web_ui) |
| 326 : WebUIController(web_ui) { | 328 : WebUIController(web_ui) { |
| 327 web_ui->AddMessageHandler(base::MakeUnique<InspectMessageHandler>(this)); | 329 web_ui->AddMessageHandler(base::MakeUnique<InspectMessageHandler>(this)); |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 handler->ForceUpdate(); | 626 handler->ForceUpdate(); |
| 625 } | 627 } |
| 626 | 628 |
| 627 void InspectUI::PopulatePortStatus(const base::Value& status) { | 629 void InspectUI::PopulatePortStatus(const base::Value& status) { |
| 628 web_ui()->CallJavascriptFunctionUnsafe("populatePortStatus", status); | 630 web_ui()->CallJavascriptFunctionUnsafe("populatePortStatus", status); |
| 629 } | 631 } |
| 630 | 632 |
| 631 void InspectUI::ShowIncognitoWarning() { | 633 void InspectUI::ShowIncognitoWarning() { |
| 632 web_ui()->CallJavascriptFunctionUnsafe("showIncognitoWarning"); | 634 web_ui()->CallJavascriptFunctionUnsafe("showIncognitoWarning"); |
| 633 } | 635 } |
| OLD | NEW |