Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Side by Side Diff: chrome/browser/debugger/devtools_window.cc

Issue 11272015: DevTools: “Dock to right” broken after turning a tab into a window of its own. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 const char kOldPrefRight[] = "right"; 73 const char kOldPrefRight[] = "right";
74 74
75 const char kPrefBottom[] = "dock_bottom"; 75 const char kPrefBottom[] = "dock_bottom";
76 const char kPrefRight[] = "dock_right"; 76 const char kPrefRight[] = "dock_right";
77 const char kPrefUndocked[] = "undocked"; 77 const char kPrefUndocked[] = "undocked";
78 78
79 const char kDockSideBottom[] = "bottom"; 79 const char kDockSideBottom[] = "bottom";
80 const char kDockSideRight[] = "right"; 80 const char kDockSideRight[] = "right";
81 const char kDockSideUndocked[] = "undocked"; 81 const char kDockSideUndocked[] = "undocked";
82 82
83 // Minimal height of devotools pane or content pane when devtools are docked
84 // to the browser window.
85 const int kMinDevToolsHeight = 50;
86 const int kMinDevToolsWidth = 150;
87 const int kMinContentsSize = 50;
88
83 // static 89 // static
84 void DevToolsWindow::RegisterUserPrefs(PrefService* prefs) { 90 void DevToolsWindow::RegisterUserPrefs(PrefService* prefs) {
85 prefs->RegisterBooleanPref(prefs::kDevToolsOpenDocked, 91 prefs->RegisterBooleanPref(prefs::kDevToolsOpenDocked,
86 true, 92 true,
87 PrefService::UNSYNCABLE_PREF); 93 PrefService::UNSYNCABLE_PREF);
88 prefs->RegisterStringPref(prefs::kDevToolsDockSide, 94 prefs->RegisterStringPref(prefs::kDevToolsDockSide,
89 kDockSideBottom, 95 kDockSideBottom,
90 PrefService::UNSYNCABLE_PREF); 96 PrefService::UNSYNCABLE_PREF);
91 prefs->RegisterDictionaryPref(prefs::kDevToolsEditedFiles, 97 prefs->RegisterDictionaryPref(prefs::kDevToolsEditedFiles,
92 PrefService::UNSYNCABLE_PREF); 98 PrefService::UNSYNCABLE_PREF);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 DevToolsWindow::DevToolsWindow(TabContents* tab_contents, 203 DevToolsWindow::DevToolsWindow(TabContents* tab_contents,
198 Profile* profile, 204 Profile* profile,
199 RenderViewHost* inspected_rvh, 205 RenderViewHost* inspected_rvh,
200 DevToolsDockSide dock_side) 206 DevToolsDockSide dock_side)
201 : profile_(profile), 207 : profile_(profile),
202 inspected_tab_(NULL), 208 inspected_tab_(NULL),
203 tab_contents_(tab_contents), 209 tab_contents_(tab_contents),
204 browser_(NULL), 210 browser_(NULL),
205 dock_side_(dock_side), 211 dock_side_(dock_side),
206 is_loaded_(false), 212 is_loaded_(false),
207 action_on_load_(DEVTOOLS_TOGGLE_ACTION_SHOW) { 213 action_on_load_(DEVTOOLS_TOGGLE_ACTION_SHOW),
214 width_(-1),
215 height_(-1) {
208 frontend_host_ = DevToolsClientHost::CreateDevToolsFrontendHost( 216 frontend_host_ = DevToolsClientHost::CreateDevToolsFrontendHost(
209 tab_contents->web_contents(), 217 tab_contents->web_contents(),
210 this); 218 this);
211 file_helper_.reset(new DevToolsFileHelper(profile, this)); 219 file_helper_.reset(new DevToolsFileHelper(profile, this));
212 220
213 g_instances.Get().push_back(this); 221 g_instances.Get().push_back(this);
214 // Wipe out page icon so that the default application icon is used. 222 // Wipe out page icon so that the default application icon is used.
215 NavigationEntry* entry = 223 NavigationEntry* entry =
216 tab_contents_->web_contents()->GetController().GetActiveEntry(); 224 tab_contents_->web_contents()->GetController().GetActiveEntry();
217 entry->GetFavicon().image = gfx::Image(); 225 entry->GetFavicon().image = gfx::Image();
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 CreateDevToolsBrowser(); 322 CreateDevToolsBrowser();
315 323
316 if (should_show_window) { 324 if (should_show_window) {
317 browser_->window()->Show(); 325 browser_->window()->Show();
318 tab_contents_->web_contents()->GetView()->SetInitialFocus(); 326 tab_contents_->web_contents()->GetView()->SetInitialFocus();
319 } 327 }
320 328
321 ScheduleAction(action); 329 ScheduleAction(action);
322 } 330 }
323 331
332 int DevToolsWindow::GetWidth(int container_width) {
333 if (width_ == -1) {
334 width_ = profile_->GetPrefs()->
335 GetInteger(prefs::kDevToolsVSplitLocation);
336 }
337
338 if (width_ == -1)
339 width_ = container_width * 1 / 3;
Peter Kasting 2012/10/24 21:18:09 Nit: Remove "* 1"
pfeldman 2012/10/25 15:17:40 Done.
340
341 width_ = std::max(kMinDevToolsWidth, width_);
342 width_ = std::min(container_width - kMinContentsSize, width_);
Peter Kasting 2012/10/24 21:18:09 This means that the minimum constant isn't a true
pfeldman 2012/10/25 15:17:40 Done.
343 if (width_ < 0)
344 width_ = width_ * 1 / 3;
Peter Kasting 2012/10/24 21:18:09 This makes no sense. If width is negative, leave
pfeldman 2012/10/25 15:17:40 Done. Thanks for spotting it, it should have been
345 return width_;
346 }
347
348 int DevToolsWindow::GetHeight(int container_height) {
Peter Kasting 2012/10/24 21:18:09 All the same comments apply.
pfeldman 2012/10/25 15:17:40 Done.
349 if (height_ == -1) {
350 height_ = profile_->GetPrefs()->
351 GetInteger(prefs::kDevToolsHSplitLocation);
352 }
353 if (height_ == -1)
354 height_ = container_height * 1 / 3;
355 height_ = std::max(kMinDevToolsHeight, height_);
356 height_ = std::min(container_height - kMinContentsSize, height_);
357 if (height_ < 0)
358 height_ = height_ * 1 / 3;
359 return height_;
360 }
361
362 void DevToolsWindow::SetWidth(int width) {
363 width_ = width;
Peter Kasting 2012/10/24 21:18:09 These setters need to clamp to the minima.
pfeldman 2012/10/25 15:17:40 Then scaling devtools window to say 100px will res
364 profile_->GetPrefs()->SetInteger(prefs::kDevToolsVSplitLocation, width);
365 }
366
367 void DevToolsWindow::SetHeight(int height) {
368 height_ = height;
369 profile_->GetPrefs()->SetInteger(prefs::kDevToolsHSplitLocation, height);
370 }
371
324 RenderViewHost* DevToolsWindow::GetRenderViewHost() { 372 RenderViewHost* DevToolsWindow::GetRenderViewHost() {
325 return tab_contents_->web_contents()->GetRenderViewHost(); 373 return tab_contents_->web_contents()->GetRenderViewHost();
326 } 374 }
327 375
328 void DevToolsWindow::CreateDevToolsBrowser() { 376 void DevToolsWindow::CreateDevToolsBrowser() {
329 // TODO(pfeldman): Make browser's getter for this key static. 377 // TODO(pfeldman): Make browser's getter for this key static.
330 std::string wp_key; 378 std::string wp_key;
331 wp_key.append(prefs::kBrowserWindowPlacement); 379 wp_key.append(prefs::kBrowserWindowPlacement);
332 wp_key.append("_"); 380 wp_key.append("_");
333 wp_key.append(kDevToolsApp); 381 wp_key.append(kDevToolsApp);
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 883
836 // static 884 // static
837 DevToolsDockSide DevToolsWindow::SideFromString( 885 DevToolsDockSide DevToolsWindow::SideFromString(
838 const std::string& dock_side) { 886 const std::string& dock_side) {
839 if (dock_side == kDockSideRight) 887 if (dock_side == kDockSideRight)
840 return DEVTOOLS_DOCK_SIDE_RIGHT; 888 return DEVTOOLS_DOCK_SIDE_RIGHT;
841 if (dock_side == kDockSideBottom) 889 if (dock_side == kDockSideBottom)
842 return DEVTOOLS_DOCK_SIDE_BOTTOM; 890 return DEVTOOLS_DOCK_SIDE_BOTTOM;
843 return DEVTOOLS_DOCK_SIDE_UNDOCKED; 891 return DEVTOOLS_DOCK_SIDE_UNDOCKED;
844 } 892 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698