| 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 break; | 604 break; |
| 605 default: | 605 default: |
| 606 NOTREACHED(); | 606 NOTREACHED(); |
| 607 } | 607 } |
| 608 action_on_load_ = DEVTOOLS_TOGGLE_ACTION_SHOW; | 608 action_on_load_ = DEVTOOLS_TOGGLE_ACTION_SHOW; |
| 609 } | 609 } |
| 610 | 610 |
| 611 std::string SkColorToRGBAString(SkColor color) { | 611 std::string SkColorToRGBAString(SkColor color) { |
| 612 // We convert the alpha using DoubleToString because StringPrintf will use | 612 // We convert the alpha using DoubleToString because StringPrintf will use |
| 613 // locale specific formatters (e.g., use , instead of . in German). | 613 // locale specific formatters (e.g., use , instead of . in German). |
| 614 return StringPrintf("rgba(%d,%d,%d,%s)", SkColorGetR(color), | 614 return base::StringPrintf("rgba(%d,%d,%d,%s)", SkColorGetR(color), |
| 615 SkColorGetG(color), SkColorGetB(color), | 615 SkColorGetG(color), SkColorGetB(color), |
| 616 base::DoubleToString(SkColorGetA(color) / 255.0).c_str()); | 616 base::DoubleToString(SkColorGetA(color) / 255.0).c_str()); |
| 617 } | 617 } |
| 618 | 618 |
| 619 // static | 619 // static |
| 620 GURL DevToolsWindow::GetDevToolsUrl(Profile* profile, | 620 GURL DevToolsWindow::GetDevToolsUrl(Profile* profile, |
| 621 DevToolsDockSide dock_side, | 621 DevToolsDockSide dock_side, |
| 622 bool shared_worker_frontend) { | 622 bool shared_worker_frontend) { |
| 623 ThemeService* tp = ThemeServiceFactory::GetForProfile(profile); | 623 ThemeService* tp = ThemeServiceFactory::GetForProfile(profile); |
| 624 CHECK(tp); | 624 CHECK(tp); |
| 625 | 625 |
| 626 SkColor color_toolbar = | 626 SkColor color_toolbar = |
| 627 tp->GetColor(ThemeProperties::COLOR_TOOLBAR); | 627 tp->GetColor(ThemeProperties::COLOR_TOOLBAR); |
| 628 SkColor color_tab_text = | 628 SkColor color_tab_text = |
| 629 tp->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT); | 629 tp->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT); |
| 630 | 630 |
| 631 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 631 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 632 bool experiments_enabled = | 632 bool experiments_enabled = |
| 633 command_line.HasSwitch(switches::kEnableDevToolsExperiments); | 633 command_line.HasSwitch(switches::kEnableDevToolsExperiments); |
| 634 | 634 |
| 635 std::string url_string = StringPrintf("%sdevtools.html?" | 635 std::string url_string = base::StringPrintf("%sdevtools.html?" |
| 636 "dockSide=%s&toolbarColor=%s&textColor=%s%s%s", | 636 "dockSide=%s&toolbarColor=%s&textColor=%s%s%s", |
| 637 chrome::kChromeUIDevToolsURL, | 637 chrome::kChromeUIDevToolsURL, |
| 638 SideToString(dock_side).c_str(), | 638 SideToString(dock_side).c_str(), |
| 639 SkColorToRGBAString(color_toolbar).c_str(), | 639 SkColorToRGBAString(color_toolbar).c_str(), |
| 640 SkColorToRGBAString(color_tab_text).c_str(), | 640 SkColorToRGBAString(color_tab_text).c_str(), |
| 641 shared_worker_frontend ? "&isSharedWorker=true" : "", | 641 shared_worker_frontend ? "&isSharedWorker=true" : "", |
| 642 experiments_enabled ? "&experiments=true" : ""); | 642 experiments_enabled ? "&experiments=true" : ""); |
| 643 return GURL(url_string); | 643 return GURL(url_string); |
| 644 } | 644 } |
| 645 | 645 |
| 646 void DevToolsWindow::UpdateTheme() { | 646 void DevToolsWindow::UpdateTheme() { |
| 647 ThemeService* tp = ThemeServiceFactory::GetForProfile(profile_); | 647 ThemeService* tp = ThemeServiceFactory::GetForProfile(profile_); |
| 648 CHECK(tp); | 648 CHECK(tp); |
| 649 | 649 |
| 650 SkColor color_toolbar = | 650 SkColor color_toolbar = |
| 651 tp->GetColor(ThemeProperties::COLOR_TOOLBAR); | 651 tp->GetColor(ThemeProperties::COLOR_TOOLBAR); |
| 652 SkColor color_tab_text = | 652 SkColor color_tab_text = |
| 653 tp->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT); | 653 tp->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT); |
| 654 std::string command = StringPrintf( | 654 std::string command = base::StringPrintf( |
| 655 "InspectorFrontendAPI.setToolbarColors(\"%s\", \"%s\")", | 655 "InspectorFrontendAPI.setToolbarColors(\"%s\", \"%s\")", |
| 656 SkColorToRGBAString(color_toolbar).c_str(), | 656 SkColorToRGBAString(color_toolbar).c_str(), |
| 657 SkColorToRGBAString(color_tab_text).c_str()); | 657 SkColorToRGBAString(color_tab_text).c_str()); |
| 658 web_contents_->GetRenderViewHost()-> | 658 web_contents_->GetRenderViewHost()-> |
| 659 ExecuteJavascriptInWebFrame(string16(), UTF8ToUTF16(command)); | 659 ExecuteJavascriptInWebFrame(string16(), UTF8ToUTF16(command)); |
| 660 } | 660 } |
| 661 | 661 |
| 662 void DevToolsWindow::AddNewContents(WebContents* source, | 662 void DevToolsWindow::AddNewContents(WebContents* source, |
| 663 WebContents* new_contents, | 663 WebContents* new_contents, |
| 664 WindowOpenDisposition disposition, | 664 WindowOpenDisposition disposition, |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1033 | 1033 |
| 1034 // static | 1034 // static |
| 1035 DevToolsDockSide DevToolsWindow::SideFromString( | 1035 DevToolsDockSide DevToolsWindow::SideFromString( |
| 1036 const std::string& dock_side) { | 1036 const std::string& dock_side) { |
| 1037 if (dock_side == kDockSideRight) | 1037 if (dock_side == kDockSideRight) |
| 1038 return DEVTOOLS_DOCK_SIDE_RIGHT; | 1038 return DEVTOOLS_DOCK_SIDE_RIGHT; |
| 1039 if (dock_side == kDockSideBottom) | 1039 if (dock_side == kDockSideBottom) |
| 1040 return DEVTOOLS_DOCK_SIDE_BOTTOM; | 1040 return DEVTOOLS_DOCK_SIDE_BOTTOM; |
| 1041 return DEVTOOLS_DOCK_SIDE_UNDOCKED; | 1041 return DEVTOOLS_DOCK_SIDE_UNDOCKED; |
| 1042 } | 1042 } |
| OLD | NEW |