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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 | 291 |
292 void DevToolsUIBindings::FrontendWebContentsObserver:: | 292 void DevToolsUIBindings::FrontendWebContentsObserver:: |
293 DidNavigateMainFrame(const content::LoadCommittedDetails& details, | 293 DidNavigateMainFrame(const content::LoadCommittedDetails& details, |
294 const content::FrameNavigateParams& params) { | 294 const content::FrameNavigateParams& params) { |
295 devtools_bindings_->DidNavigateMainFrame(); | 295 devtools_bindings_->DidNavigateMainFrame(); |
296 } | 296 } |
297 | 297 |
298 // DevToolsUIBindings --------------------------------------------------------- | 298 // DevToolsUIBindings --------------------------------------------------------- |
299 | 299 |
300 DevToolsUIBindings* DevToolsUIBindings::ForWebContents( | 300 DevToolsUIBindings* DevToolsUIBindings::ForWebContents( |
301 content::WebContents* web_contents) { | 301 content::WebContents* web_contents) { |
302 if (g_instances == NULL) | 302 if (g_instances == NULL) |
303 return NULL; | 303 return NULL; |
304 DevToolsUIBindingsList* instances = g_instances.Pointer(); | 304 DevToolsUIBindingsList* instances = g_instances.Pointer(); |
305 for (DevToolsUIBindingsList::iterator it(instances->begin()); | 305 for (DevToolsUIBindingsList::iterator it(instances->begin()); |
306 it != instances->end(); ++it) { | 306 it != instances->end(); ++it) { |
307 if ((*it)->web_contents() == web_contents) | 307 if ((*it)->web_contents() == web_contents) |
308 return *it; | 308 return *it; |
309 } | 309 } |
310 return NULL; | 310 return NULL; |
311 } | 311 } |
312 | 312 |
313 // static | 313 // static |
314 GURL DevToolsUIBindings::ApplyThemeToURL(Profile* profile, | 314 GURL DevToolsUIBindings::ApplyThemeToURL(Profile* profile, |
315 const GURL& base_url) { | 315 const GURL& base_url) { |
316 std::string frontend_url = base_url.spec(); | 316 std::string frontend_url = base_url.spec(); |
317 ThemeService* tp = ThemeServiceFactory::GetForProfile(profile); | 317 ThemeService* tp = ThemeServiceFactory::GetForProfile(profile); |
318 DCHECK(tp); | 318 DCHECK(tp); |
319 std::string url_string( | 319 std::string url_string( |
320 frontend_url + | 320 frontend_url + |
321 ((frontend_url.find("?") == std::string::npos) ? "?" : "&") + | 321 ((frontend_url.find("?") == std::string::npos) ? "?" : "&") + |
322 "dockSide=undocked" + // TODO(dgozman): remove this support in M38. | 322 "dockSide=undocked" + // TODO(dgozman): remove this support in M38. |
323 "&toolbarColor=" + | 323 "&toolbarColor=" + |
324 SkColorToRGBAString(tp->GetColor(ThemeProperties::COLOR_TOOLBAR)) + | 324 SkColorToRGBAString(tp->GetColor(ThemeProperties::COLOR_TOOLBAR)) + |
325 "&textColor=" + | 325 "&textColor=" + |
326 SkColorToRGBAString(tp->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT))); | 326 SkColorToRGBAString(tp->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT))); |
327 if (CommandLine::ForCurrentProcess()->HasSwitch( | 327 if (CommandLine::ForCurrentProcess()->HasSwitch( |
328 switches::kEnableDevToolsExperiments)) | 328 switches::kEnableDevToolsExperiments)) |
329 url_string += "&experiments=true"; | 329 url_string += "&experiments=true"; |
330 #if defined(DEBUG_DEVTOOLS) | 330 #if defined(DEBUG_DEVTOOLS) |
331 url_string += "&debugFrontend=true"; | 331 url_string += "&debugFrontend=true"; |
332 #endif // defined(DEBUG_DEVTOOLS) | 332 #endif // defined(DEBUG_DEVTOOLS) |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 } else { | 667 } else { |
668 remote_targets_handler_.reset(); | 668 remote_targets_handler_.reset(); |
669 } | 669 } |
670 } | 670 } |
671 | 671 |
672 void DevToolsUIBindings::SendMessageToBrowser(const std::string& message) { | 672 void DevToolsUIBindings::SendMessageToBrowser(const std::string& message) { |
673 if (agent_host_.get()) | 673 if (agent_host_.get()) |
674 agent_host_->DispatchProtocolMessage(message); | 674 agent_host_->DispatchProtocolMessage(message); |
675 } | 675 } |
676 | 676 |
| 677 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
677 void DevToolsUIBindings::DeviceCountChanged(int count) { | 678 void DevToolsUIBindings::DeviceCountChanged(int count) { |
678 base::FundamentalValue value(count); | 679 base::FundamentalValue value(count); |
679 CallClientFunction("InspectorFrontendAPI.deviceCountUpdated", &value, NULL, | 680 CallClientFunction("InspectorFrontendAPI.deviceCountUpdated", &value, NULL, |
680 NULL); | 681 NULL); |
681 } | 682 } |
| 683 #endif |
682 | 684 |
683 void DevToolsUIBindings::DevicesUpdated( | 685 void DevToolsUIBindings::DevicesUpdated( |
684 const std::string& source, | 686 const std::string& source, |
685 const base::ListValue& targets) { | 687 const base::ListValue& targets) { |
686 CallClientFunction("InspectorFrontendAPI.devicesUpdated", &targets, NULL, | 688 CallClientFunction("InspectorFrontendAPI.devicesUpdated", &targets, NULL, |
687 NULL); | 689 NULL); |
688 } | 690 } |
689 | 691 |
690 void DevToolsUIBindings::FileSavedAs(const std::string& url) { | 692 void DevToolsUIBindings::FileSavedAs(const std::string& url) { |
691 base::StringValue url_value(url); | 693 base::StringValue url_value(url); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 if (frontend_loaded_) | 892 if (frontend_loaded_) |
891 return; | 893 return; |
892 frontend_loaded_ = true; | 894 frontend_loaded_ = true; |
893 | 895 |
894 // Call delegate first - it seeds importants bit of information. | 896 // Call delegate first - it seeds importants bit of information. |
895 delegate_->OnLoadCompleted(); | 897 delegate_->OnLoadCompleted(); |
896 | 898 |
897 UpdateTheme(); | 899 UpdateTheme(); |
898 AddDevToolsExtensionsToClient(); | 900 AddDevToolsExtensionsToClient(); |
899 } | 901 } |
OLD | NEW |