| 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" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/devtools/devtools_window.h" | 15 #include "chrome/browser/devtools/devtools_window.h" |
| 16 #include "chrome/browser/extensions/api/debugger/debugger_api.h" | 16 #include "chrome/browser/extensions/api/debugger/debugger_api.h" |
| 17 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
| 18 #include "chrome/browser/extensions/extension_system.h" | 18 #include "chrome/browser/extensions/extension_system.h" |
| 19 #include "chrome/browser/file_select_helper.h" | 19 #include "chrome/browser/file_select_helper.h" |
| 20 #include "chrome/browser/prefs/pref_service.h" | 20 #include "chrome/browser/prefs/pref_registry_syncable.h" |
| 21 #include "chrome/browser/prefs/pref_service_syncable.h" |
| 21 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 22 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 22 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/browser/sessions/session_tab_helper.h" | 24 #include "chrome/browser/sessions/session_tab_helper.h" |
| 24 #include "chrome/browser/themes/theme_service.h" | 25 #include "chrome/browser/themes/theme_service.h" |
| 25 #include "chrome/browser/themes/theme_service_factory.h" | 26 #include "chrome/browser/themes/theme_service_factory.h" |
| 26 #include "chrome/browser/ui/browser.h" | 27 #include "chrome/browser/ui/browser.h" |
| 27 #include "chrome/browser/ui/browser_list.h" | 28 #include "chrome/browser/ui/browser_list.h" |
| 28 #include "chrome/browser/ui/browser_list_impl.h" | 29 #include "chrome/browser/ui/browser_list_impl.h" |
| 29 #include "chrome/browser/ui/browser_window.h" | 30 #include "chrome/browser/ui/browser_window.h" |
| 30 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 31 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 const char kDockSideRight[] = "right"; | 85 const char kDockSideRight[] = "right"; |
| 85 const char kDockSideUndocked[] = "undocked"; | 86 const char kDockSideUndocked[] = "undocked"; |
| 86 | 87 |
| 87 // Minimal height of devtools pane or content pane when devtools are docked | 88 // Minimal height of devtools pane or content pane when devtools are docked |
| 88 // to the browser window. | 89 // to the browser window. |
| 89 const int kMinDevToolsHeight = 50; | 90 const int kMinDevToolsHeight = 50; |
| 90 const int kMinDevToolsWidth = 150; | 91 const int kMinDevToolsWidth = 150; |
| 91 const int kMinContentsSize = 50; | 92 const int kMinContentsSize = 50; |
| 92 | 93 |
| 93 // static | 94 // static |
| 94 void DevToolsWindow::RegisterUserPrefs(PrefServiceSyncable* prefs) { | 95 void DevToolsWindow::RegisterUserPrefs(PrefRegistrySyncable* registry) { |
| 95 prefs->RegisterBooleanPref(prefs::kDevToolsOpenDocked, | 96 registry->RegisterBooleanPref(prefs::kDevToolsOpenDocked, |
| 96 true, | 97 true, |
| 97 PrefServiceSyncable::UNSYNCABLE_PREF); | 98 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 98 prefs->RegisterStringPref(prefs::kDevToolsDockSide, | 99 registry->RegisterStringPref(prefs::kDevToolsDockSide, |
| 99 kDockSideBottom, | 100 kDockSideBottom, |
| 100 PrefServiceSyncable::UNSYNCABLE_PREF); | 101 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 101 prefs->RegisterDictionaryPref(prefs::kDevToolsEditedFiles, | 102 registry->RegisterDictionaryPref(prefs::kDevToolsEditedFiles, |
| 102 PrefServiceSyncable::UNSYNCABLE_PREF); | 103 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 103 prefs->RegisterDictionaryPref(prefs::kDevToolsFileSystemPaths, | 104 registry->RegisterDictionaryPref(prefs::kDevToolsFileSystemPaths, |
| 104 PrefServiceSyncable::UNSYNCABLE_PREF); | 105 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 105 } | 106 } |
| 106 | 107 |
| 107 // static | 108 // static |
| 108 DevToolsWindow* DevToolsWindow::GetDockedInstanceForInspectedTab( | 109 DevToolsWindow* DevToolsWindow::GetDockedInstanceForInspectedTab( |
| 109 WebContents* inspected_web_contents) { | 110 WebContents* inspected_web_contents) { |
| 110 if (!inspected_web_contents) | 111 if (!inspected_web_contents) |
| 111 return NULL; | 112 return NULL; |
| 112 | 113 |
| 113 if (!DevToolsAgentHost::HasFor(inspected_web_contents->GetRenderViewHost())) | 114 if (!DevToolsAgentHost::HasFor(inspected_web_contents->GetRenderViewHost())) |
| 114 return NULL; | 115 return NULL; |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 return web_contents_->GetRenderViewHost(); | 380 return web_contents_->GetRenderViewHost(); |
| 380 } | 381 } |
| 381 | 382 |
| 382 void DevToolsWindow::CreateDevToolsBrowser() { | 383 void DevToolsWindow::CreateDevToolsBrowser() { |
| 383 // TODO(pfeldman): Make browser's getter for this key static. | 384 // TODO(pfeldman): Make browser's getter for this key static. |
| 384 std::string wp_key; | 385 std::string wp_key; |
| 385 wp_key.append(prefs::kBrowserWindowPlacement); | 386 wp_key.append(prefs::kBrowserWindowPlacement); |
| 386 wp_key.append("_"); | 387 wp_key.append("_"); |
| 387 wp_key.append(kDevToolsApp); | 388 wp_key.append(kDevToolsApp); |
| 388 | 389 |
| 389 PrefServiceSyncable* prefs = profile_->GetPrefs(); | 390 PrefService* prefs = profile_->GetPrefs(); |
| 391 scoped_refptr<PrefRegistrySyncable> registry( |
| 392 static_cast<PrefRegistrySyncable*>(prefs->DeprecatedGetPrefRegistry())); |
| 393 // TODO(joi): All registration should be done up front. |
| 390 if (!prefs->FindPreference(wp_key.c_str())) { | 394 if (!prefs->FindPreference(wp_key.c_str())) { |
| 391 prefs->RegisterDictionaryPref(wp_key.c_str(), | 395 registry->RegisterDictionaryPref(wp_key.c_str(), |
| 392 PrefServiceSyncable::UNSYNCABLE_PREF); | 396 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 393 } | 397 } |
| 394 | 398 |
| 395 const DictionaryValue* wp_pref = prefs->GetDictionary(wp_key.c_str()); | 399 const DictionaryValue* wp_pref = prefs->GetDictionary(wp_key.c_str()); |
| 396 if (!wp_pref || wp_pref->empty()) { | 400 if (!wp_pref || wp_pref->empty()) { |
| 397 DictionaryPrefUpdate update(prefs, wp_key.c_str()); | 401 DictionaryPrefUpdate update(prefs, wp_key.c_str()); |
| 398 DictionaryValue* defaults = update.Get(); | 402 DictionaryValue* defaults = update.Get(); |
| 399 defaults->SetInteger("left", 100); | 403 defaults->SetInteger("left", 100); |
| 400 defaults->SetInteger("top", 100); | 404 defaults->SetInteger("top", 100); |
| 401 defaults->SetInteger("right", 740); | 405 defaults->SetInteger("right", 740); |
| 402 defaults->SetInteger("bottom", 740); | 406 defaults->SetInteger("bottom", 740); |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 994 | 998 |
| 995 // static | 999 // static |
| 996 DevToolsDockSide DevToolsWindow::SideFromString( | 1000 DevToolsDockSide DevToolsWindow::SideFromString( |
| 997 const std::string& dock_side) { | 1001 const std::string& dock_side) { |
| 998 if (dock_side == kDockSideRight) | 1002 if (dock_side == kDockSideRight) |
| 999 return DEVTOOLS_DOCK_SIDE_RIGHT; | 1003 return DEVTOOLS_DOCK_SIDE_RIGHT; |
| 1000 if (dock_side == kDockSideBottom) | 1004 if (dock_side == kDockSideBottom) |
| 1001 return DEVTOOLS_DOCK_SIDE_BOTTOM; | 1005 return DEVTOOLS_DOCK_SIDE_BOTTOM; |
| 1002 return DEVTOOLS_DOCK_SIDE_UNDOCKED; | 1006 return DEVTOOLS_DOCK_SIDE_UNDOCKED; |
| 1003 } | 1007 } |
| OLD | NEW |