| 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 "chrome/browser/devtools/devtools_window.h" | 5 #include "chrome/browser/devtools/devtools_window.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 // This will prevent any activity after frontend is loaded. | 491 // This will prevent any activity after frontend is loaded. |
| 492 action_on_load_ = DevToolsToggleAction::NoOp(); | 492 action_on_load_ = DevToolsToggleAction::NoOp(); |
| 493 ignore_set_is_docked_ = true; | 493 ignore_set_is_docked_ = true; |
| 494 web_contents_->GetRenderViewHost()->ClosePage(); | 494 web_contents_->GetRenderViewHost()->ClosePage(); |
| 495 } | 495 } |
| 496 | 496 |
| 497 content::RenderViewHost* DevToolsWindow::GetRenderViewHost() { | 497 content::RenderViewHost* DevToolsWindow::GetRenderViewHost() { |
| 498 return web_contents_->GetRenderViewHost(); | 498 return web_contents_->GetRenderViewHost(); |
| 499 } | 499 } |
| 500 | 500 |
| 501 gfx::Insets DevToolsWindow::GetContentsInsets() const { | 501 const DevToolsContentsResizingStrategy& |
| 502 return contents_insets_; | 502 DevToolsWindow::GetContentsResizingStrategy() const { |
| 503 return contents_resizing_strategy_; |
| 503 } | 504 } |
| 504 | 505 |
| 505 gfx::Size DevToolsWindow::GetMinimumSize() const { | 506 gfx::Size DevToolsWindow::GetMinimumSize() const { |
| 506 const gfx::Size kMinDevToolsSize = gfx::Size(200, 100); | 507 const gfx::Size kMinDevToolsSize = gfx::Size(200, 100); |
| 507 return kMinDevToolsSize; | 508 return kMinDevToolsSize; |
| 508 } | 509 } |
| 509 | 510 |
| 510 void DevToolsWindow::ScheduleShow(const DevToolsToggleAction& action) { | 511 void DevToolsWindow::ScheduleShow(const DevToolsToggleAction& action) { |
| 511 if (load_state_ == kLoadCompleted) { | 512 if (load_state_ == kLoadCompleted) { |
| 512 Show(action); | 513 Show(action); |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 996 void DevToolsWindow::CloseWindow() { | 997 void DevToolsWindow::CloseWindow() { |
| 997 DCHECK(is_docked_); | 998 DCHECK(is_docked_); |
| 998 // This will prevent any activity after frontend is loaded. | 999 // This will prevent any activity after frontend is loaded. |
| 999 action_on_load_ = DevToolsToggleAction::NoOp(); | 1000 action_on_load_ = DevToolsToggleAction::NoOp(); |
| 1000 ignore_set_is_docked_ = true; | 1001 ignore_set_is_docked_ = true; |
| 1001 web_contents_->GetRenderViewHost()->FirePageBeforeUnload(false); | 1002 web_contents_->GetRenderViewHost()->FirePageBeforeUnload(false); |
| 1002 } | 1003 } |
| 1003 | 1004 |
| 1004 void DevToolsWindow::SetContentsInsets( | 1005 void DevToolsWindow::SetContentsInsets( |
| 1005 int top, int left, int bottom, int right) { | 1006 int top, int left, int bottom, int right) { |
| 1006 if (contents_insets_.top() == top && | 1007 gfx::Insets insets(top, left, bottom, right); |
| 1007 contents_insets_.left() == left && | 1008 SetContentsResizingStrategy(insets, contents_resizing_strategy_.min_size()); |
| 1008 contents_insets_.bottom() == bottom && | 1009 } |
| 1009 contents_insets_.right() == right) { | 1010 |
| 1011 void DevToolsWindow::SetContentsResizingStrategy( |
| 1012 const gfx::Insets& insets, const gfx::Size& min_size) { |
| 1013 DevToolsContentsResizingStrategy strategy(insets, min_size); |
| 1014 if (contents_resizing_strategy_ == strategy) |
| 1010 return; | 1015 return; |
| 1011 } | |
| 1012 | 1016 |
| 1013 contents_insets_ = gfx::Insets(top, left, bottom, right); | 1017 contents_resizing_strategy_ = strategy; |
| 1014 if (is_docked_) { | 1018 if (is_docked_) { |
| 1015 // Update inspected window. | 1019 // Update inspected window. |
| 1016 BrowserWindow* inspected_window = GetInspectedBrowserWindow(); | 1020 BrowserWindow* inspected_window = GetInspectedBrowserWindow(); |
| 1017 if (inspected_window) | 1021 if (inspected_window) |
| 1018 inspected_window->UpdateDevTools(); | 1022 inspected_window->UpdateDevTools(); |
| 1019 } | 1023 } |
| 1020 } | 1024 } |
| 1021 | 1025 |
| 1022 void DevToolsWindow::InspectElementCompleted() { | 1026 void DevToolsWindow::InspectElementCompleted() { |
| 1023 if (!inspect_element_start_time_.is_null()) { | 1027 if (!inspect_element_start_time_.is_null()) { |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1504 if (load_state_ == kLoadCompleted) | 1508 if (load_state_ == kLoadCompleted) |
| 1505 LoadCompleted(); | 1509 LoadCompleted(); |
| 1506 } | 1510 } |
| 1507 | 1511 |
| 1508 void DevToolsWindow::LoadCompleted() { | 1512 void DevToolsWindow::LoadCompleted() { |
| 1509 Show(action_on_load_); | 1513 Show(action_on_load_); |
| 1510 action_on_load_ = DevToolsToggleAction::NoOp(); | 1514 action_on_load_ = DevToolsToggleAction::NoOp(); |
| 1511 UpdateTheme(); | 1515 UpdateTheme(); |
| 1512 AddDevToolsExtensionsToClient(); | 1516 AddDevToolsExtensionsToClient(); |
| 1513 } | 1517 } |
| OLD | NEW |