| 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/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "base/prefs/scoped_user_pref_update.h" |
| 11 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 13 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/values.h" | 16 #include "base/values.h" |
| 16 #include "chrome/browser/chrome_notification_types.h" | 17 #include "chrome/browser/chrome_notification_types.h" |
| 17 #include "chrome/browser/devtools/devtools_target_impl.h" | 18 #include "chrome/browser/devtools/devtools_target_impl.h" |
| 18 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" | 19 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" |
| 19 #include "chrome/browser/infobars/infobar_service.h" | 20 #include "chrome/browser/infobars/infobar_service.h" |
| 21 #include "chrome/browser/prefs/pref_service_syncable.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/themes/theme_properties.h" | 23 #include "chrome/browser/themes/theme_properties.h" |
| 22 #include "chrome/browser/themes/theme_service.h" | 24 #include "chrome/browser/themes/theme_service.h" |
| 23 #include "chrome/browser/themes/theme_service_factory.h" | 25 #include "chrome/browser/themes/theme_service_factory.h" |
| 24 #include "chrome/browser/ui/browser.h" | 26 #include "chrome/browser/ui/browser.h" |
| 25 #include "chrome/browser/ui/browser_iterator.h" | 27 #include "chrome/browser/ui/browser_iterator.h" |
| 26 #include "chrome/browser/ui/browser_list.h" | 28 #include "chrome/browser/ui/browser_list.h" |
| 27 #include "chrome/browser/ui/browser_window.h" | 29 #include "chrome/browser/ui/browser_window.h" |
| 28 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 30 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 29 #include "chrome/common/chrome_switches.h" | 31 #include "chrome/common/chrome_switches.h" |
| 30 #include "chrome/common/extensions/chrome_manifest_url_handlers.h" | 32 #include "chrome/common/extensions/chrome_manifest_url_handlers.h" |
| 33 #include "chrome/common/pref_names.h" |
| 31 #include "chrome/common/url_constants.h" | 34 #include "chrome/common/url_constants.h" |
| 32 #include "chrome/grit/generated_resources.h" | 35 #include "chrome/grit/generated_resources.h" |
| 33 #include "components/infobars/core/confirm_infobar_delegate.h" | 36 #include "components/infobars/core/confirm_infobar_delegate.h" |
| 34 #include "components/infobars/core/infobar.h" | 37 #include "components/infobars/core/infobar.h" |
| 35 #include "components/ui/zoom/page_zoom.h" | 38 #include "components/ui/zoom/page_zoom.h" |
| 36 #include "content/public/browser/favicon_status.h" | 39 #include "content/public/browser/favicon_status.h" |
| 37 #include "content/public/browser/invalidate_type.h" | 40 #include "content/public/browser/invalidate_type.h" |
| 38 #include "content/public/browser/navigation_controller.h" | 41 #include "content/public/browser/navigation_controller.h" |
| 39 #include "content/public/browser/navigation_entry.h" | 42 #include "content/public/browser/navigation_entry.h" |
| 40 #include "content/public/browser/notification_source.h" | 43 #include "content/public/browser/notification_source.h" |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 private: | 201 private: |
| 199 ~DefaultBindingsDelegate() override {} | 202 ~DefaultBindingsDelegate() override {} |
| 200 | 203 |
| 201 void ActivateWindow() override; | 204 void ActivateWindow() override; |
| 202 void CloseWindow() override {} | 205 void CloseWindow() override {} |
| 203 void SetInspectedPageBounds(const gfx::Rect& rect) override {} | 206 void SetInspectedPageBounds(const gfx::Rect& rect) override {} |
| 204 void InspectElementCompleted() override {} | 207 void InspectElementCompleted() override {} |
| 205 void SetIsDocked(bool is_docked) override {} | 208 void SetIsDocked(bool is_docked) override {} |
| 206 void OpenInNewTab(const std::string& url) override; | 209 void OpenInNewTab(const std::string& url) override; |
| 207 void SetWhitelistedShortcuts(const std::string& message) override {} | 210 void SetWhitelistedShortcuts(const std::string& message) override {} |
| 211 using DispatchCallback = |
| 212 DevToolsEmbedderMessageDispatcher::Delegate::DispatchCallback; |
| 208 | 213 |
| 209 void InspectedContentsClosing() override; | 214 void InspectedContentsClosing() override; |
| 210 void OnLoadCompleted() override {} | 215 void OnLoadCompleted() override {} |
| 211 InfoBarService* GetInfoBarService() override; | 216 InfoBarService* GetInfoBarService() override; |
| 212 void RenderProcessGone(bool crashed) override {} | 217 void RenderProcessGone(bool crashed) override {} |
| 213 | 218 |
| 214 content::WebContents* web_contents_; | 219 content::WebContents* web_contents_; |
| 215 DISALLOW_COPY_AND_ASSIGN(DefaultBindingsDelegate); | 220 DISALLOW_COPY_AND_ASSIGN(DefaultBindingsDelegate); |
| 216 }; | 221 }; |
| 217 | 222 |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 if (enabled) { | 733 if (enabled) { |
| 729 remote_targets_handler_ = DevToolsTargetsUIHandler::CreateForAdb( | 734 remote_targets_handler_ = DevToolsTargetsUIHandler::CreateForAdb( |
| 730 base::Bind(&DevToolsUIBindings::DevicesUpdated, | 735 base::Bind(&DevToolsUIBindings::DevicesUpdated, |
| 731 base::Unretained(this)), | 736 base::Unretained(this)), |
| 732 profile_); | 737 profile_); |
| 733 } else { | 738 } else { |
| 734 remote_targets_handler_.reset(); | 739 remote_targets_handler_.reset(); |
| 735 } | 740 } |
| 736 } | 741 } |
| 737 | 742 |
| 743 void DevToolsUIBindings::GetPreferences(const DispatchCallback& callback) { |
| 744 const DictionaryValue* prefs = |
| 745 profile_->GetPrefs()->GetDictionary(prefs::kDevToolsPreferences); |
| 746 callback.Run(prefs); |
| 747 } |
| 748 |
| 749 void DevToolsUIBindings::SetPreference(const std::string& name, |
| 750 const std::string& value) { |
| 751 DictionaryPrefUpdate update(profile_->GetPrefs(), |
| 752 prefs::kDevToolsPreferences); |
| 753 update.Get()->SetStringWithoutPathExpansion(name, value); |
| 754 } |
| 755 |
| 756 void DevToolsUIBindings::RemovePreference(const std::string& name) { |
| 757 DictionaryPrefUpdate update(profile_->GetPrefs(), |
| 758 prefs::kDevToolsPreferences); |
| 759 update.Get()->RemoveWithoutPathExpansion(name, nullptr); |
| 760 } |
| 761 |
| 762 void DevToolsUIBindings::ClearPreferences() { |
| 763 DictionaryPrefUpdate update(profile_->GetPrefs(), |
| 764 prefs::kDevToolsPreferences); |
| 765 update.Get()->Clear(); |
| 766 } |
| 767 |
| 738 void DevToolsUIBindings::SendMessageToBrowser(const std::string& message) { | 768 void DevToolsUIBindings::SendMessageToBrowser(const std::string& message) { |
| 739 if (agent_host_.get()) | 769 if (agent_host_.get()) |
| 740 agent_host_->DispatchProtocolMessage(message); | 770 agent_host_->DispatchProtocolMessage(message); |
| 741 } | 771 } |
| 742 | 772 |
| 743 void DevToolsUIBindings::RecordEnumeratedHistogram(const std::string& name, | 773 void DevToolsUIBindings::RecordEnumeratedHistogram(const std::string& name, |
| 744 int sample, | 774 int sample, |
| 745 int boundary_value) { | 775 int boundary_value) { |
| 746 if (!(boundary_value >= 0 && boundary_value < 100 && sample >= 0 && | 776 if (!(boundary_value >= 0 && boundary_value < 100 && sample >= 0 && |
| 747 sample < boundary_value)) { | 777 sample < boundary_value)) { |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1019 if (frontend_loaded_) | 1049 if (frontend_loaded_) |
| 1020 return; | 1050 return; |
| 1021 frontend_loaded_ = true; | 1051 frontend_loaded_ = true; |
| 1022 | 1052 |
| 1023 // Call delegate first - it seeds importants bit of information. | 1053 // Call delegate first - it seeds importants bit of information. |
| 1024 delegate_->OnLoadCompleted(); | 1054 delegate_->OnLoadCompleted(); |
| 1025 | 1055 |
| 1026 UpdateTheme(); | 1056 UpdateTheme(); |
| 1027 AddDevToolsExtensionsToClient(); | 1057 AddDevToolsExtensionsToClient(); |
| 1028 } | 1058 } |
| OLD | NEW |