diff options
23 files changed, 254 insertions, 239 deletions
diff --git a/chrome/browser/debugger/devtools_window.cc b/chrome/browser/debugger/devtools_window.cc index cb63bea..e0cfaed 100644 --- a/chrome/browser/debugger/devtools_window.cc +++ b/chrome/browser/debugger/devtools_window.cc @@ -69,8 +69,16 @@ using content::WebContents; const char DevToolsWindow::kDevToolsApp[] = "DevToolsApp"; +const char kOldPrefBottom[] = "bottom"; +const char kOldPrefRight[] = "right"; + +const char kPrefBottom[] = "dock_bottom"; +const char kPrefRight[] = "dock_right"; +const char kPrefUndocked[] = "undocked"; + const char kDockSideBottom[] = "bottom"; const char kDockSideRight[] = "right"; +const char kDockSideUndocked[] = "undocked"; // static void DevToolsWindow::RegisterUserPrefs(PrefService* prefs) { @@ -85,7 +93,8 @@ void DevToolsWindow::RegisterUserPrefs(PrefService* prefs) { } // static -TabContents* DevToolsWindow::GetDevToolsContents(WebContents* inspected_tab) { +DevToolsWindow* DevToolsWindow::GetDockedInstanceForInspectedTab( + WebContents* inspected_tab) { if (!inspected_tab) return NULL; @@ -97,9 +106,7 @@ TabContents* DevToolsWindow::GetDevToolsContents(WebContents* inspected_tab) { DevToolsManager* manager = DevToolsManager::GetInstance(); DevToolsClientHost* client_host = manager->GetDevToolsClientHostFor(agent); DevToolsWindow* window = AsDevToolsWindow(client_host); - if (!window || !window->is_docked()) - return NULL; - return window->tab_contents(); + return window && window->IsDocked() ? window : NULL; } // static @@ -131,7 +138,7 @@ DevToolsWindow* DevToolsWindow::OpenDevToolsWindowForWorker( // static DevToolsWindow* DevToolsWindow::CreateDevToolsWindowForWorker( Profile* profile) { - return Create(profile, NULL, false, true); + return Create(profile, NULL, DEVTOOLS_DOCK_SIDE_UNDOCKED, true); } // static @@ -172,7 +179,7 @@ void DevToolsWindow::InspectElement(RenderViewHost* inspected_rvh, DevToolsWindow* DevToolsWindow::Create( Profile* profile, RenderViewHost* inspected_rvh, - bool docked, + DevToolsDockSide dock_side, bool shared_worker_frontend) { // Create TabContents with devtools. TabContents* tab_contents = @@ -180,22 +187,22 @@ DevToolsWindow* DevToolsWindow::Create( tab_contents->web_contents()->GetRenderViewHost()->AllowBindings( content::BINDINGS_POLICY_WEB_UI); tab_contents->web_contents()->GetController().LoadURL( - GetDevToolsUrl(profile, docked, shared_worker_frontend), + GetDevToolsUrl(profile, dock_side, shared_worker_frontend), content::Referrer(), content::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string()); - return new DevToolsWindow(tab_contents, profile, inspected_rvh, docked); + return new DevToolsWindow(tab_contents, profile, inspected_rvh, dock_side); } DevToolsWindow::DevToolsWindow(TabContents* tab_contents, Profile* profile, RenderViewHost* inspected_rvh, - bool docked) + DevToolsDockSide dock_side) : profile_(profile), inspected_tab_(NULL), tab_contents_(tab_contents), browser_(NULL), - docked_(docked), + dock_side_(dock_side), is_loaded_(false), action_on_load_(DEVTOOLS_TOGGLE_ACTION_SHOW) { frontend_host_ = DevToolsClientHost::CreateDevToolsFrontendHost( @@ -246,7 +253,7 @@ DevToolsWindow::~DevToolsWindow() { void DevToolsWindow::InspectedContentsClosing() { UpdateBrowserToolbar(); - if (docked_) { + if (IsDocked()) { // Update dev tools to reflect removed dev tools window. BrowserWindow* inspected_window = GetInspectedBrowserWindow(); if (inspected_window) @@ -275,7 +282,7 @@ void DevToolsWindow::ContentsReplaced(WebContents* new_contents) { } void DevToolsWindow::Show(DevToolsToggleAction action) { - if (docked_) { + if (IsDocked()) { Browser* inspected_browser; int inspected_tab_index; // Tell inspected browser to update splitter and switch to inspected panel. @@ -284,10 +291,6 @@ void DevToolsWindow::Show(DevToolsToggleAction action) { &inspected_tab_index)) { BrowserWindow* inspected_window = inspected_browser->window(); tab_contents_->web_contents()->SetDelegate(this); - std::string dock_side = - profile_->GetPrefs()->GetString(prefs::kDevToolsDockSide); - inspected_window->SetDevToolsDockSide(dock_side == kDockSideRight ? - DEVTOOLS_DOCK_SIDE_RIGHT : DEVTOOLS_DOCK_SIDE_BOTTOM); inspected_window->UpdateDevTools(); tab_contents_->web_contents()->GetView()->SetInitialFocus(); inspected_window->Show(); @@ -297,8 +300,8 @@ void DevToolsWindow::Show(DevToolsToggleAction action) { return; } else { // Sometimes we don't know where to dock. Stay undocked. - docked_ = false; - UpdateFrontendAttachedState(); + dock_side_ = DEVTOOLS_DOCK_SIDE_UNDOCKED; + UpdateFrontendDockSide(); } } @@ -318,40 +321,6 @@ void DevToolsWindow::Show(DevToolsToggleAction action) { ScheduleAction(action); } -void DevToolsWindow::RequestSetDocked(bool docked) { - if (docked_ == docked) - return; - - if (!inspected_tab_) - return; - - profile_->GetPrefs()->SetBoolean(prefs::kDevToolsOpenDocked, docked); - - if (docked && (!GetInspectedBrowserWindow() || - IsInspectedBrowserPopupOrPanel())) { - // Cannot dock, avoid window flashing due to close-reopen cycle. - return; - } - docked_ = docked; - - if (docked) { - // Detach window from the external devtools browser. It will lead to - // the browser object's close and delete. Remove observer first. - TabStripModel* tab_strip_model = browser_->tab_strip_model(); - tab_strip_model->DetachTabContentsAt( - tab_strip_model->GetIndexOfTabContents(tab_contents_)); - browser_ = NULL; - } else { - // Update inspected window to hide split and reset it. - BrowserWindow* inspected_window = GetInspectedBrowserWindow(); - if (inspected_window) { - inspected_window->UpdateDevTools(); - inspected_window = NULL; - } - } - Show(DEVTOOLS_TOGGLE_ACTION_SHOW); -} - RenderViewHost* DevToolsWindow::GetRenderViewHost() { return tab_contents_->web_contents()->GetRenderViewHost(); } @@ -419,8 +388,10 @@ bool DevToolsWindow::IsInspectedBrowserPopupOrPanel() { return browser->is_type_popup() || browser->is_type_panel(); } -void DevToolsWindow::UpdateFrontendAttachedState() { - base::FundamentalValue docked(docked_); +void DevToolsWindow::UpdateFrontendDockSide() { + base::StringValue dock_side(SideToString(dock_side_)); + CallClientFunction("InspectorFrontendAPI.setDockSide", &dock_side); + base::FundamentalValue docked(IsDocked()); CallClientFunction("InspectorFrontendAPI.setAttachedWindow", &docked); } @@ -507,7 +478,7 @@ void DevToolsWindow::ScheduleAction(DevToolsToggleAction action) { } void DevToolsWindow::DoAction() { - UpdateFrontendAttachedState(); + UpdateFrontendDockSide(); // TODO: these messages should be pushed through the WebKit API instead. switch (action_on_load_) { case DEVTOOLS_TOGGLE_ACTION_SHOW_CONSOLE: @@ -534,7 +505,8 @@ std::string SkColorToRGBAString(SkColor color) { } // static -GURL DevToolsWindow::GetDevToolsUrl(Profile* profile, bool docked, +GURL DevToolsWindow::GetDevToolsUrl(Profile* profile, + DevToolsDockSide dock_side, bool shared_worker_frontend) { ThemeService* tp = ThemeServiceFactory::GetForProfile(profile); CHECK(tp); @@ -548,14 +520,13 @@ GURL DevToolsWindow::GetDevToolsUrl(Profile* profile, bool docked, bool experiments_enabled = command_line.HasSwitch(switches::kEnableDevToolsExperiments); - std::string dock_side = - profile->GetPrefs()->GetString(prefs::kDevToolsDockSide); - + // TODO(pfeldman): remove docked parameter once migrated to + // setDockSide. std::string url_string = StringPrintf("%sdevtools.html?" "docked=%s&dockSide=%s&toolbarColor=%s&textColor=%s%s%s", chrome::kChromeUIDevToolsURL, - docked ? "true" : "false", - dock_side.c_str(), + dock_side == DEVTOOLS_DOCK_SIDE_UNDOCKED ? "false" : "true", + SideToString(dock_side).c_str(), SkColorToRGBAString(color_toolbar).c_str(), SkColorToRGBAString(color_tab_text).c_str(), shared_worker_frontend ? "&isSharedWorker=true" : "", @@ -595,7 +566,7 @@ void DevToolsWindow::AddNewContents(WebContents* source, bool DevToolsWindow::PreHandleKeyboardEvent( content::WebContents* source, const NativeWebKeyboardEvent& event, bool* is_keyboard_shortcut) { - if (docked_) { + if (IsDocked()) { BrowserWindow* inspected_window = GetInspectedBrowserWindow(); if (inspected_window) return inspected_window->PreHandleKeyboardEvent( @@ -606,7 +577,7 @@ bool DevToolsWindow::PreHandleKeyboardEvent( void DevToolsWindow::HandleKeyboardEvent(content::WebContents* source, const NativeWebKeyboardEvent& event) { - if (docked_) { + if (IsDocked()) { if (event.windowsKeyCode == 0x08) { // Do not navigate back in history on Windows (http://crbug.com/74156). return; @@ -637,8 +608,8 @@ DevToolsWindow* DevToolsWindow::ToggleDevToolsWindow( if (!window) { Profile* profile = Profile::FromBrowserContext( inspected_rvh->GetProcess()->GetBrowserContext()); - bool docked = profile->GetPrefs()->GetBoolean(prefs::kDevToolsOpenDocked); - window = Create(profile, inspected_rvh, docked, false); + std::string dock_side = GetOrMigrateDockSidePref(profile); + window = Create(profile, inspected_rvh, SideFromString(dock_side), false); manager->RegisterDevToolsClientHostFor(agent, window->frontend_host_); do_open = true; } @@ -648,7 +619,7 @@ DevToolsWindow* DevToolsWindow::ToggleDevToolsWindow( // If window is docked and visible, we hide it on toggle. If window is // undocked, we show (activate) it. - if (!window->is_docked() || do_open) + if (!window->IsDocked() || do_open) window->Show(action); else manager->UnregisterDevToolsClientHostFor(agent); @@ -684,7 +655,7 @@ DevToolsWindow* DevToolsWindow::AsDevToolsWindow(RenderViewHost* window_rvh) { } void DevToolsWindow::ActivateWindow() { - if (!docked_) { + if (!IsDocked()) { if (!browser_->window()->IsActive()) { browser_->window()->Activate(); } @@ -696,38 +667,49 @@ void DevToolsWindow::ActivateWindow() { } void DevToolsWindow::CloseWindow() { - DCHECK(docked_); + DCHECK(IsDocked()); DevToolsManager::GetInstance()->ClientHostClosing(frontend_host_); InspectedContentsClosing(); } void DevToolsWindow::MoveWindow(int x, int y) { - if (!docked_) { + if (!IsDocked()) { gfx::Rect bounds = browser_->window()->GetBounds(); bounds.Offset(x, y); browser_->window()->SetBounds(bounds); } } -void DevToolsWindow::DockWindow() { - RequestSetDocked(true); -} - -void DevToolsWindow::UndockWindow() { - RequestSetDocked(false); -} - void DevToolsWindow::SetDockSide(const std::string& side) { - std::string pref_value = kDockSideBottom; - if (side == kDockSideRight) - pref_value = kDockSideRight; - profile_->GetPrefs()->SetString(prefs::kDevToolsDockSide, pref_value); + DevToolsDockSide requested_side = SideFromString(side); + bool dock_requested = requested_side != DEVTOOLS_DOCK_SIDE_UNDOCKED; + bool is_docked = IsDocked(); - BrowserWindow* inspected_window = GetInspectedBrowserWindow(); - if (inspected_window) { - inspected_window->SetDevToolsDockSide(pref_value == kDockSideRight ? - DEVTOOLS_DOCK_SIDE_RIGHT : DEVTOOLS_DOCK_SIDE_BOTTOM); + if (dock_requested && (!inspected_tab_ || !GetInspectedBrowserWindow() || + IsInspectedBrowserPopupOrPanel())) { + // Cannot dock, avoid window flashing due to close-reopen cycle. + return; + } + + dock_side_ = requested_side; + if (dock_requested) { + if (!is_docked) { + // Detach window from the external devtools browser. It will lead to + // the browser object's close and delete. Remove observer first. + TabStripModel* tab_strip_model = browser_->tab_strip_model(); + tab_strip_model->DetachTabContentsAt( + tab_strip_model->GetIndexOfTabContents(tab_contents_)); + browser_ = NULL; + } + } else if (is_docked) { + // Update inspected window to hide split and reset it. + BrowserWindow* inspected_window = GetInspectedBrowserWindow(); + if (inspected_window) + inspected_window->UpdateDevTools(); } + + profile_->GetPrefs()->SetString(prefs::kDevToolsDockSide, side); + Show(DEVTOOLS_TOGGLE_ACTION_SHOW); } void DevToolsWindow::OpenInNewTab(const std::string& url) { @@ -787,8 +769,8 @@ void DevToolsWindow::WebContentsFocused(WebContents* contents) { Browser* inspected_browser = NULL; int inspected_tab_index = -1; - if (docked_ && FindInspectedBrowserAndTabIndex(&inspected_browser, - &inspected_tab_index)) { + if (IsDocked() && FindInspectedBrowserAndTabIndex(&inspected_browser, + &inspected_tab_index)) { inspected_browser->window()->WebContentsFocused(contents); } } @@ -800,3 +782,42 @@ void DevToolsWindow::UpdateBrowserToolbar() { if (inspected_window) inspected_window->UpdateToolbar(inspected_tab_, false); } + +bool DevToolsWindow::IsDocked() { + return dock_side_ != DEVTOOLS_DOCK_SIDE_UNDOCKED; +} + +// static +std::string DevToolsWindow::GetOrMigrateDockSidePref(Profile* profile) { + std::string dock_side = + profile->GetPrefs()->GetString(prefs::kDevToolsDockSide); + if (dock_side == kOldPrefBottom || dock_side == kOldPrefRight) { + bool docked = profile->GetPrefs()->GetBoolean(prefs::kDevToolsOpenDocked); + if (dock_side == kOldPrefBottom) + return docked ? kDockSideBottom : kDockSideUndocked; + else + return docked ? kDockSideRight : kDockSideUndocked; + } + return dock_side; +} + +// static +std::string DevToolsWindow::SideToString(DevToolsDockSide dock_side) { + std::string dock_side_string; + switch (dock_side) { + case DEVTOOLS_DOCK_SIDE_UNDOCKED: return kDockSideUndocked; + case DEVTOOLS_DOCK_SIDE_RIGHT: return kDockSideRight; + case DEVTOOLS_DOCK_SIDE_BOTTOM: return kDockSideBottom; + } + return kDockSideUndocked; +} + +// static +DevToolsDockSide DevToolsWindow::SideFromString( + const std::string& dock_side) { + if (dock_side == kDockSideRight) + return DEVTOOLS_DOCK_SIDE_RIGHT; + if (dock_side == kDockSideBottom) + return DEVTOOLS_DOCK_SIDE_BOTTOM; + return DEVTOOLS_DOCK_SIDE_UNDOCKED; +} diff --git a/chrome/browser/debugger/devtools_window.h b/chrome/browser/debugger/devtools_window.h index 460a511..dbbc6f4 100644 --- a/chrome/browser/debugger/devtools_window.h +++ b/chrome/browser/debugger/devtools_window.h @@ -40,6 +40,12 @@ class RenderViewHost; class WebContents; } +enum DevToolsDockSide { + DEVTOOLS_DOCK_SIDE_UNDOCKED = 0, + DEVTOOLS_DOCK_SIDE_BOTTOM, + DEVTOOLS_DOCK_SIDE_RIGHT +}; + class DevToolsWindow : private content::NotificationObserver, private content::WebContentsDelegate, private content::DevToolsFrontendHostDelegate, @@ -47,7 +53,8 @@ class DevToolsWindow : private content::NotificationObserver, public: static const char kDevToolsApp[]; static void RegisterUserPrefs(PrefService* prefs); - static TabContents* GetDevToolsContents(content::WebContents* inspected_tab); + static DevToolsWindow* GetDockedInstanceForInspectedTab( + content::WebContents* inspected_tab); static bool IsDevToolsWindow(content::RenderViewHost* window_rvh); static DevToolsWindow* OpenDevToolsWindowForWorker( @@ -79,7 +86,7 @@ class DevToolsWindow : private content::NotificationObserver, TabContents* tab_contents() { return tab_contents_; } Browser* browser() { return browser_; } // For tests. - bool is_docked() { return docked_; } + DevToolsDockSide dock_side() { return dock_side_; } content::DevToolsClientHost* devtools_client_host() { return frontend_host_; } @@ -87,15 +94,18 @@ class DevToolsWindow : private content::NotificationObserver, private: static DevToolsWindow* Create(Profile* profile, content::RenderViewHost* inspected_rvh, - bool docked, bool shared_worker_frontend); - DevToolsWindow(TabContents* tab_contents, Profile* profile, - content::RenderViewHost* inspected_rvh, bool docked); + DevToolsDockSide dock_side, + bool shared_worker_frontend); + DevToolsWindow(TabContents* tab_contents, + Profile* profile, + content::RenderViewHost* inspected_rvh, + DevToolsDockSide dock_side); void CreateDevToolsBrowser(); bool FindInspectedBrowserAndTabIndex(Browser**, int* tab); BrowserWindow* GetInspectedBrowserWindow(); bool IsInspectedBrowserPopupOrPanel(); - void UpdateFrontendAttachedState(); + void UpdateFrontendDockSide(); // Overridden from content::NotificationObserver. virtual void Observe(int type, @@ -104,7 +114,8 @@ class DevToolsWindow : private content::NotificationObserver, void ScheduleAction(DevToolsToggleAction action); void DoAction(); - static GURL GetDevToolsUrl(Profile* profile, bool docked, + static GURL GetDevToolsUrl(Profile* profile, + DevToolsDockSide dock_side, bool shared_worker_frontend); void UpdateTheme(); void AddDevToolsExtensionsToClient(); @@ -144,8 +155,6 @@ class DevToolsWindow : private content::NotificationObserver, virtual void ActivateWindow() OVERRIDE; virtual void CloseWindow() OVERRIDE; virtual void MoveWindow(int x, int y) OVERRIDE; - virtual void DockWindow() OVERRIDE; - virtual void UndockWindow() OVERRIDE; virtual void SetDockSide(const std::string& side) OVERRIDE; virtual void OpenInNewTab(const std::string& url) OVERRIDE; virtual void SaveToFile(const std::string& url, @@ -158,15 +167,17 @@ class DevToolsWindow : private content::NotificationObserver, virtual void FileSavedAs(const std::string& url) OVERRIDE; virtual void AppendedTo(const std::string& url) OVERRIDE; - void RequestSetDocked(bool docked); - void UpdateBrowserToolbar(); + bool IsDocked(); + static std::string GetOrMigrateDockSidePref(Profile* profile); + static std::string SideToString(DevToolsDockSide dock_side); + static DevToolsDockSide SideFromString(const std::string& dock_side); Profile* profile_; TabContents* inspected_tab_; TabContents* tab_contents_; Browser* browser_; - bool docked_; + DevToolsDockSide dock_side_; bool is_loaded_; DevToolsToggleAction action_on_load_; content::NotificationRegistrar registrar_; diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc index a4c7bf8..c8b11df 100644 --- a/chrome/browser/policy/policy_browsertest.cc +++ b/chrome/browser/policy/policy_browsertest.cc @@ -935,7 +935,7 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, DeveloperToolsDisabled) { // Open devtools. EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_DEV_TOOLS)); content::WebContents* contents = chrome::GetActiveWebContents(browser()); - EXPECT_TRUE(DevToolsWindow::GetDevToolsContents(contents)); + EXPECT_TRUE(DevToolsWindow::GetDockedInstanceForInspectedTab(contents)); // Disable devtools via policy. PolicyMap policies; @@ -943,10 +943,10 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, DeveloperToolsDisabled) { POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true)); provider_.UpdateChromePolicy(policies); // The existing devtools window should have closed. - EXPECT_FALSE(DevToolsWindow::GetDevToolsContents(contents)); + EXPECT_FALSE(DevToolsWindow::GetDockedInstanceForInspectedTab(contents)); // And it's not possible to open it again. EXPECT_FALSE(chrome::ExecuteCommand(browser(), IDC_DEV_TOOLS)); - EXPECT_FALSE(DevToolsWindow::GetDevToolsContents(contents)); + EXPECT_FALSE(DevToolsWindow::GetDockedInstanceForInspectedTab(contents)); } // This policy isn't available on Chrome OS. diff --git a/chrome/browser/ui/browser_window.h b/chrome/browser/ui/browser_window.h index 212cc9b..9bc74cb 100644 --- a/chrome/browser/ui/browser_window.h +++ b/chrome/browser/ui/browser_window.h @@ -49,11 +49,6 @@ class Rect; class Size; } -enum DevToolsDockSide { - DEVTOOLS_DOCK_SIDE_BOTTOM = 0, - DEVTOOLS_DOCK_SIDE_RIGHT = 1 -}; - //////////////////////////////////////////////////////////////////////////////// // BrowserWindow interface // An interface implemented by the "view" of the Browser window. @@ -104,9 +99,6 @@ class BrowserWindow : public BaseWindow { // changed. virtual void UpdateDevTools() = 0; - // Requests that the docked dev tools window changes its dock mode. - virtual void SetDevToolsDockSide(DevToolsDockSide side) = 0; - // Update any loading animations running in the window. |should_animate| is // true if there are tabs loading and the animations should continue, false // if there are no active loads and the animations should end. diff --git a/chrome/browser/ui/cocoa/browser_window_cocoa.h b/chrome/browser/ui/cocoa/browser_window_cocoa.h index 822ec24..8908be4 100644 --- a/chrome/browser/ui/cocoa/browser_window_cocoa.h +++ b/chrome/browser/ui/cocoa/browser_window_cocoa.h @@ -56,7 +56,6 @@ class BrowserWindowCocoa : virtual void BookmarkBarStateChanged( BookmarkBar::AnimateChangeType change_type) OVERRIDE; virtual void UpdateDevTools() OVERRIDE; - virtual void SetDevToolsDockSide(DevToolsDockSide side) OVERRIDE; virtual void UpdateLoadingAnimations(bool should_animate) OVERRIDE; virtual void SetStarredState(bool is_starred) OVERRIDE; virtual void ZoomChangedForActiveTab(bool can_show_bubble) OVERRIDE; diff --git a/chrome/browser/ui/cocoa/browser_window_cocoa.mm b/chrome/browser/ui/cocoa/browser_window_cocoa.mm index df4f475..a637f6f 100644 --- a/chrome/browser/ui/cocoa/browser_window_cocoa.mm +++ b/chrome/browser/ui/cocoa/browser_window_cocoa.mm @@ -257,10 +257,6 @@ void BrowserWindowCocoa::UpdateDevTools() { chrome::GetActiveWebContents(browser_)]; } -void BrowserWindowCocoa::SetDevToolsDockSide(DevToolsDockSide side) { - [controller_ setDevToolsDockToRight:side == DEVTOOLS_DOCK_SIDE_RIGHT]; -} - void BrowserWindowCocoa::UpdateLoadingAnimations(bool should_animate) { // Do nothing on Mac. } diff --git a/chrome/browser/ui/cocoa/browser_window_controller.h b/chrome/browser/ui/cocoa/browser_window_controller.h index 3dbdd5d..018b5a5 100644 --- a/chrome/browser/ui/cocoa/browser_window_controller.h +++ b/chrome/browser/ui/cocoa/browser_window_controller.h @@ -307,9 +307,6 @@ class WebContents; // Shows or hides the docked web inspector depending on |contents|'s state. - (void)updateDevToolsForContents:(content::WebContents*)contents; -// Specifies whether devtools should dock to right. -- (void)setDevToolsDockToRight:(bool)dock_to_right; - // Gets the current theme provider. - (ui::ThemeProvider*)themeProvider; diff --git a/chrome/browser/ui/cocoa/browser_window_controller.mm b/chrome/browser/ui/cocoa/browser_window_controller.mm index 418ed1f..5bf5d07 100644 --- a/chrome/browser/ui/cocoa/browser_window_controller.mm +++ b/chrome/browser/ui/cocoa/browser_window_controller.mm @@ -539,11 +539,6 @@ enum { withProfile:browser_->profile()]; } -- (void)setDevToolsDockToRight:(bool)dock_to_right { - [devToolsController_ setDockToRight:dock_to_right - withProfile:browser_->profile()]; -} - // Called when the user wants to close a window or from the shutdown process. // The Browser object is in control of whether or not we're allowed to close. It // may defer closing due to several states, such as onUnload handlers needing to diff --git a/chrome/browser/ui/cocoa/dev_tools_controller.h b/chrome/browser/ui/cocoa/dev_tools_controller.h index 25702ee..b819195 100644 --- a/chrome/browser/ui/cocoa/dev_tools_controller.h +++ b/chrome/browser/ui/cocoa/dev_tools_controller.h @@ -8,6 +8,7 @@ #import <Cocoa/Cocoa.h> #include "base/memory/scoped_nsobject.h" +#include "chrome/browser/debugger/devtools_window.h" @class NSSplitView; @class NSView; @@ -26,7 +27,7 @@ class WebContents; // A view hosting docked devTools contents. scoped_nsobject<NSSplitView> splitView_; - BOOL dockToRight_; + DevToolsDockSide dockSide_; } - (id)init; @@ -43,10 +44,6 @@ class WebContents; // the actual resize). - (void)updateDevToolsForWebContents:(content::WebContents*)contents withProfile:(Profile*)profile; - -// Specifies whether devtools should dock to right. -- (void)setDockToRight:(BOOL)dock_to_right - withProfile:(Profile*)profile; @end #endif // CHROME_BROWSER_UI_COCOA_DEV_TOOLS_CONTROLLER_H_ diff --git a/chrome/browser/ui/cocoa/dev_tools_controller.mm b/chrome/browser/ui/cocoa/dev_tools_controller.mm index 103df1f..abf91b3 100644 --- a/chrome/browser/ui/cocoa/dev_tools_controller.mm +++ b/chrome/browser/ui/cocoa/dev_tools_controller.mm @@ -9,7 +9,6 @@ #include <Cocoa/Cocoa.h> #include "chrome/browser/browser_process.h" -#include "chrome/browser/debugger/devtools_window.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/tab_contents/tab_contents.h" @@ -43,10 +42,12 @@ const int kMinContentsSize = 50; @interface DevToolsController (Private) -- (void)showDevToolsContents:(WebContents*)devToolsContents - withProfile:(Profile*)profile; -- (void)showDevToolsContainer:(NSView*)container profile:(Profile*)profile; +- (void)showDevToolsContainer:(NSView*)container + dockSide:(DevToolsDockSide)dockSide + profile:(Profile*)profile; - (void)hideDevToolsContainer:(Profile*)profile; +- (void)setDockToRight:(BOOL)dock_to_right + withProfile:(Profile*)profile; - (void)resizeDevTools:(CGFloat)size; @end @@ -61,7 +62,7 @@ const int kMinContentsSize = 50; [splitView_ setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable]; [splitView_ setDelegate:self]; - dockToRight_ = NO; + dockSide_ = DEVTOOLS_DOCK_SIDE_BOTTOM; } return self; } @@ -82,33 +83,17 @@ const int kMinContentsSize = 50; - (void)updateDevToolsForWebContents:(WebContents*)contents withProfile:(Profile*)profile { // Get current devtools content. - TabContents* devToolsTab = contents ? - DevToolsWindow::GetDevToolsContents(contents) : NULL; - WebContents* devToolsContents = devToolsTab ? - devToolsTab->web_contents() : NULL; - - [self showDevToolsContents:devToolsContents withProfile:profile]; -} - -- (void)setDockToRight:(BOOL)dockToRight - withProfile:(Profile*)profile { - if (dockToRight_ == dockToRight) + DevToolsWindow* devToolsWindow = contents ? + DevToolsWindow::GetDockedInstanceForInspectedTab(contents) : NULL; + WebContents* devToolsContents = devToolsWindow ? + devToolsWindow->tab_contents()->web_contents() : NULL; + + if (devToolsContents && devToolsContents->GetNativeView() && + [devToolsContents->GetNativeView() superview] == splitView_.get()) { + [self setDockSide:devToolsWindow->dock_side() withProfile:profile]; return; - - NSArray* subviews = [splitView_ subviews]; - if ([subviews count] == 2) { - scoped_nsobject<NSView> devToolsContentsView( - [[subviews objectAtIndex:1] retain]); - [self hideDevToolsContainer:profile]; - dockToRight_ = dockToRight; - [self showDevToolsContainer:devToolsContentsView profile:profile]; - } else { - dockToRight_ = dockToRight; } -} -- (void)showDevToolsContents:(WebContents*)devToolsContents - withProfile:(Profile*)profile { NSArray* subviews = [splitView_ subviews]; if (devToolsContents) { // |devToolsView| is a TabContentsViewCocoa object, whose ViewID was @@ -116,29 +101,51 @@ const int kMinContentsSize = 50; // VIEW_ID_DEV_TOOLS_DOCKED here. NSView* devToolsView = devToolsContents->GetNativeView(); view_id_util::SetID(devToolsView, VIEW_ID_DEV_TOOLS_DOCKED); - [self showDevToolsContainer:devToolsView profile:profile]; + [self showDevToolsContainer:devToolsView + dockSide:devToolsWindow->dock_side() + profile:profile]; + } else if ([subviews count] > 1) { + [self hideDevToolsContainer:profile]; + } +} + +- (void)setDockSide:(DevToolsDockSide)dockSide + withProfile:(Profile*)profile { + if (dockSide_ == dockSide) + return; + + NSArray* subviews = [splitView_ subviews]; + if ([subviews count] == 2) { + scoped_nsobject<NSView> devToolsContentsView( + [[subviews objectAtIndex:1] retain]); + [self hideDevToolsContainer:profile]; + dockSide_ = dockSide; + [self showDevToolsContainer:devToolsContentsView + dockSide:dockSide + profile:profile]; } else { - if ([subviews count] > 1) { - [self hideDevToolsContainer:profile]; - } + dockSide_ = dockSide; } } -- (void)showDevToolsContainer:(NSView*)container profile:(Profile*)profile { +- (void)showDevToolsContainer:(NSView*)container + dockSide:(BOOL)dockSide + profile:(Profile*)profile { NSArray* subviews = [splitView_ subviews]; DCHECK_GE([subviews count], 1u); CGFloat splitOffset = 0; + BOOL dockToRight = dockSide_ == DEVTOOLS_DOCK_SIDE_RIGHT; CGFloat contentSize = - dockToRight_ ? NSWidth([splitView_ frame]) - : NSHeight([splitView_ frame]); + dockToRight ? NSWidth([splitView_ frame]) + : NSHeight([splitView_ frame]); if ([subviews count] == 1) { // Load the default split offset. splitOffset = profile->GetPrefs()-> - GetInteger(dockToRight_ ? prefs::kDevToolsVSplitLocation : - prefs::kDevToolsHSplitLocation); + GetInteger(dockToRight ? prefs::kDevToolsVSplitLocation : + prefs::kDevToolsHSplitLocation); if (splitOffset < 0) splitOffset = contentSize * 1 / 3; @@ -147,14 +154,14 @@ const int kMinContentsSize = 50; } else { DCHECK_EQ([subviews count], 2u); // If devtools are already visible, keep the current size. - splitOffset = dockToRight_ ? NSWidth([[subviews objectAtIndex:1] frame]) - : NSHeight([[subviews objectAtIndex:1] frame]); + splitOffset = dockToRight ? NSWidth([[subviews objectAtIndex:1] frame]) + : NSHeight([[subviews objectAtIndex:1] frame]); [splitView_ replaceSubview:[subviews objectAtIndex:1] with:container]; } // Make sure |splitOffset| isn't too large or too small. - CGFloat minSize = dockToRight_ ? kMinDevToolsWidth: kMinDevToolsHeight; + CGFloat minSize = dockToRight ? kMinDevToolsWidth: kMinDevToolsHeight; splitOffset = std::max(minSize, splitOffset); splitOffset = std::min(static_cast<CGFloat>(contentSize - kMinContentsSize), splitOffset); @@ -165,7 +172,7 @@ const int kMinContentsSize = 50; DCHECK_GE(splitOffset, 0) << "kMinWebHeight needs to be smaller than " << "smallest available tab contents space."; - [splitView_ setVertical: dockToRight_]; + [splitView_ setVertical: dockToRight]; [self resizeDevTools:splitOffset]; } @@ -173,12 +180,13 @@ const int kMinContentsSize = 50; NSArray* subviews = [splitView_ subviews]; NSView* oldDevToolsContentsView = [subviews objectAtIndex:1]; + BOOL dockToRight = dockSide_ == DEVTOOLS_DOCK_SIDE_RIGHT; // Store split offset when hiding devtools window only. - int splitOffset = dockToRight_ ? NSWidth([oldDevToolsContentsView frame]) - : NSHeight([oldDevToolsContentsView frame]); + int splitOffset = dockToRight ? NSWidth([oldDevToolsContentsView frame]) + : NSHeight([oldDevToolsContentsView frame]); profile->GetPrefs()->SetInteger( - dockToRight_ ? prefs::kDevToolsVSplitLocation : - prefs::kDevToolsHSplitLocation, + dockToRight ? prefs::kDevToolsVSplitLocation : + prefs::kDevToolsHSplitLocation, splitOffset); [oldDevToolsContentsView removeFromSuperview]; @@ -197,12 +205,13 @@ const int kMinContentsSize = 50; NSView* devToolsView = [subviews objectAtIndex:1]; NSRect devToolsFrame = [devToolsView frame]; - if (dockToRight_) + BOOL dockToRight = dockSide_ == DEVTOOLS_DOCK_SIDE_RIGHT; + if (dockToRight) devToolsFrame.size.width = size; else devToolsFrame.size.height = size; - if (dockToRight_) { + if (dockToRight) { webFrame.size.width = NSWidth([splitView_ frame]) - ([splitView_ dividerThickness] + size); } else { diff --git a/chrome/browser/ui/cocoa/tabpose_window.mm b/chrome/browser/ui/cocoa/tabpose_window.mm index 945e3da..b3a8bbe 100644 --- a/chrome/browser/ui/cocoa/tabpose_window.mm +++ b/chrome/browser/ui/cocoa/tabpose_window.mm @@ -241,17 +241,18 @@ void ThumbnailLoader::LoadThumbnail() { - (int)bottomOffset { int bottomOffset = 0; - TabContents* devToolsContents = - DevToolsWindow::GetDevToolsContents(contents_->web_contents()); - if (devToolsContents && devToolsContents->web_contents() && - devToolsContents->web_contents()->GetRenderViewHost() && - devToolsContents->web_contents()->GetRenderViewHost()->GetView()) { + DevToolsWindow* devToolsWindow = + DevToolsWindow::GetDockedInstanceForInspectedTab( + contents_->web_contents()); + content::WebContents* devToolsContents = devToolsWindow ? + devToolsWindow->tab_contents()->web_contents() : NULL; + if (devToolsContents->GetRenderViewHost() && + devToolsContents->GetRenderViewHost()->GetView()) { // The devtool's size might not be up-to-date, but since its height doesn't // change on window resize, and since most users don't use devtools, this is // good enough. - bottomOffset += - devToolsContents->web_contents()->GetRenderViewHost()->GetView()-> - GetViewBounds().height(); + bottomOffset += devToolsContents->GetRenderViewHost()->GetView()-> + GetViewBounds().height(); bottomOffset += 1; // :-( Divider line between web contents and devtools. } return bottomOffset; diff --git a/chrome/browser/ui/cocoa/view_id_util_browsertest.mm b/chrome/browser/ui/cocoa/view_id_util_browsertest.mm index 723e7f2..28a24c1 100644 --- a/chrome/browser/ui/cocoa/view_id_util_browsertest.mm +++ b/chrome/browser/ui/cocoa/view_id_util_browsertest.mm @@ -48,8 +48,8 @@ class ViewIDTest : public InProcessBrowserTest { chrome::ShowFindBar(browser()); // Make sure docked devtools is created to test VIEW_ID_DEV_TOOLS_DOCKED - browser()->profile()->GetPrefs()->SetBoolean(prefs::kDevToolsOpenDocked, - true); + browser()->profile()->GetPrefs()->SetString(prefs::kDevToolsDockSide, + "undocked"); chrome::ToggleDevToolsWindow(browser(), DEVTOOLS_TOGGLE_ACTION_INSPECT); // Make sure download shelf is created to test VIEW_ID_DOWNLOAD_SHELF diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc index df19e4f..314feac 100644 --- a/chrome/browser/ui/gtk/browser_window_gtk.cc +++ b/chrome/browser/ui/gtk/browser_window_gtk.cc @@ -27,7 +27,6 @@ #include "chrome/app/chrome_command_ids.h" #include "chrome/browser/bookmarks/bookmark_utils.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/debugger/devtools_window.h" #include "chrome/browser/download/download_item_model.h" #include "chrome/browser/extensions/tab_helper.h" #include "chrome/browser/infobars/infobar_tab_helper.h" @@ -744,8 +743,7 @@ void BrowserWindowGtk::SetDevToolsDockSide(DevToolsDockSide side) { if (devtools_container_->tab()) { HideDevToolsContainer(); - devtools_dock_side_ = side; - ShowDevToolsContainer(); + ShowDevToolsContainer(side); } else { devtools_dock_side_ = side; } @@ -1320,10 +1318,17 @@ extensions::ActiveTabPermissionGranter* void BrowserWindowGtk::UpdateDevToolsForContents(WebContents* contents) { TRACE_EVENT0("ui::gtk", "BrowserWindowGtk::UpdateDevToolsForContents"); TabContents* old_devtools = devtools_container_->tab(); - TabContents* devtools_contents = contents ? - DevToolsWindow::GetDevToolsContents(contents) : NULL; - if (old_devtools == devtools_contents) + DevToolsWindow* devtools_window = contents ? + DevToolsWindow::GetDockedInstanceForInspectedTab(contents) : NULL; + TabContents* devtools_contents = + devtools_window ? devtools_window->tab_contents() : NULL; + + if (old_devtools == devtools_contents) { + if (devtools_contents && + devtools_window->dock_side() != devtools_dock_side_) + SetDevToolsDockSide(devtools_window->dock_side()); return; + } if (old_devtools) devtools_container_->DetachTab(old_devtools); @@ -1341,13 +1346,14 @@ void BrowserWindowGtk::UpdateDevToolsForContents(WebContents* contents) { bool should_hide = old_devtools != NULL && devtools_contents == NULL; if (should_show) - ShowDevToolsContainer(); + ShowDevToolsContainer(devtools_window->dock_side()); else if (should_hide) HideDevToolsContainer(); } -void BrowserWindowGtk::ShowDevToolsContainer() { - bool dock_to_right = devtools_dock_side_ == DEVTOOLS_DOCK_SIDE_RIGHT; +void BrowserWindowGtk::ShowDevToolsContainer(DevToolsDockSide dock_side) { + devtools_dock_side_ = dock_side; + bool dock_to_right = dock_side == DEVTOOLS_DOCK_SIDE_RIGHT; GtkAllocation contents_rect; gtk_widget_get_allocation(contents_vsplit_, &contents_rect); diff --git a/chrome/browser/ui/gtk/browser_window_gtk.h b/chrome/browser/ui/gtk/browser_window_gtk.h index d283a5e..234a3cf 100644 --- a/chrome/browser/ui/gtk/browser_window_gtk.h +++ b/chrome/browser/ui/gtk/browser_window_gtk.h @@ -15,6 +15,7 @@ #include "base/timer.h" #include "build/build_config.h" #include "chrome/browser/api/prefs/pref_member.h" +#include "chrome/browser/debugger/devtools_window.h" #include "chrome/browser/extensions/extension_keybinding_registry.h" #include "chrome/browser/infobars/infobar_container.h" #include "chrome/browser/ui/browser_window.h" @@ -86,7 +87,6 @@ class BrowserWindowGtk virtual void BookmarkBarStateChanged( BookmarkBar::AnimateChangeType change_type) OVERRIDE; virtual void UpdateDevTools() OVERRIDE; - virtual void SetDevToolsDockSide(DevToolsDockSide side) OVERRIDE; virtual void UpdateLoadingAnimations(bool should_animate) OVERRIDE; virtual void SetStarredState(bool is_starred) OVERRIDE; virtual void ZoomChangedForActiveTab(bool can_show_bubble) OVERRIDE; @@ -204,11 +204,14 @@ class BrowserWindowGtk void UpdateDevToolsForContents(content::WebContents* contents); // Shows docked devtools. - void ShowDevToolsContainer(); + void ShowDevToolsContainer(DevToolsDockSide dock_side); // Hides docked devtools. void HideDevToolsContainer(); + // Updates dock side orientation for the devtools. + void SetDevToolsDockSide(DevToolsDockSide side); + void OnDebouncedBoundsChanged(); // Request the underlying window to unmaximize. diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index 02addb8..4be1070 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc @@ -16,7 +16,6 @@ #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/bookmarks/bookmark_utils.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/debugger/devtools_window.h" #include "chrome/browser/extensions/tab_helper.h" #include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/instant/instant_controller.h" @@ -688,8 +687,7 @@ void BrowserView::SetDevToolsDockSide(DevToolsDockSide side) { if (devtools_container_->visible()) { HideDevToolsContainer(); - devtools_dock_side_ = side; - ShowDevToolsContainer(); + ShowDevToolsContainer(side); } else { devtools_dock_side_ = side; } @@ -2100,12 +2098,19 @@ bool BrowserView::MaybeShowInfoBar(TabContents* contents) { } void BrowserView::UpdateDevToolsForContents(TabContents* tab_contents) { - WebContents* devtools_contents = NULL; - if (tab_contents) { - TabContents* devtools_tab_contents = - DevToolsWindow::GetDevToolsContents(tab_contents->web_contents()); - if (devtools_tab_contents) - devtools_contents = devtools_tab_contents->web_contents(); + DevToolsWindow* devtools_window = tab_contents ? + DevToolsWindow::GetDockedInstanceForInspectedTab( + tab_contents->web_contents()) : NULL; + TabContents* devtools_tab_contents = + devtools_window ? devtools_window->tab_contents() : NULL; + WebContents* devtools_contents = devtools_tab_contents ? + devtools_tab_contents->web_contents() : NULL; + + if (devtools_contents == devtools_container_->web_contents()) { + if (devtools_contents && + devtools_window->dock_side() != devtools_dock_side_) + SetDevToolsDockSide(devtools_window->dock_side()); + return; } bool should_show = devtools_contents && !devtools_container_->visible(); @@ -2115,12 +2120,13 @@ void BrowserView::UpdateDevToolsForContents(TabContents* tab_contents) { RestackLocationBarContainer(); if (should_show) - ShowDevToolsContainer(); + ShowDevToolsContainer(devtools_window->dock_side()); else if (should_hide) HideDevToolsContainer(); } -void BrowserView::ShowDevToolsContainer() { +void BrowserView::ShowDevToolsContainer(DevToolsDockSide dock_side) { + devtools_dock_side_ = dock_side; if (!devtools_focus_tracker_.get()) { // Install devtools focus tracker when dev tools window is shown for the // first time. diff --git a/chrome/browser/ui/views/frame/browser_view.h b/chrome/browser/ui/views/frame/browser_view.h index a5a26cd..9a7073a 100644 --- a/chrome/browser/ui/views/frame/browser_view.h +++ b/chrome/browser/ui/views/frame/browser_view.h @@ -13,6 +13,7 @@ #include "base/memory/scoped_ptr.h" #include "base/timer.h" #include "build/build_config.h" +#include "chrome/browser/debugger/devtools_window.h" #include "chrome/browser/infobars/infobar_container.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_window.h" @@ -258,7 +259,6 @@ class BrowserView : public BrowserWindow, virtual void BookmarkBarStateChanged( BookmarkBar::AnimateChangeType change_type) OVERRIDE; virtual void UpdateDevTools() OVERRIDE; - virtual void SetDevToolsDockSide(DevToolsDockSide side) OVERRIDE; virtual void UpdateLoadingAnimations(bool should_animate) OVERRIDE; virtual void SetStarredState(bool is_starred) OVERRIDE; virtual void ZoomChangedForActiveTab(bool can_show_bubble) OVERRIDE; @@ -508,11 +508,14 @@ class BrowserView : public BrowserWindow, bool MaybeShowInfoBar(TabContents* contents); // Shows docked devtools. - void ShowDevToolsContainer(); + void ShowDevToolsContainer(DevToolsDockSide side); // Hides docked devtools. void HideDevToolsContainer(); + // Updates devtools dock side. + void SetDevToolsDockSide(DevToolsDockSide side); + // Updated devtools window for given contents. void UpdateDevToolsForContents(TabContents* tab_contents); diff --git a/chrome/test/base/test_browser_window.h b/chrome/test/base/test_browser_window.h index 567550f..eb3e34a 100644 --- a/chrome/test/base/test_browser_window.h +++ b/chrome/test/base/test_browser_window.h @@ -42,7 +42,6 @@ class TestBrowserWindow : public BrowserWindow { virtual void BookmarkBarStateChanged( BookmarkBar::AnimateChangeType change_type) OVERRIDE {} virtual void UpdateDevTools() OVERRIDE {} - virtual void SetDevToolsDockSide(DevToolsDockSide side) OVERRIDE {} virtual void UpdateLoadingAnimations(bool should_animate) OVERRIDE {} virtual void SetStarredState(bool is_starred) OVERRIDE {} virtual void ZoomChangedForActiveTab(bool can_show_bubble) OVERRIDE {} diff --git a/content/browser/debugger/devtools_frontend_host.cc b/content/browser/debugger/devtools_frontend_host.cc index f55cc9a..5df013a 100644 --- a/content/browser/debugger/devtools_frontend_host.cc +++ b/content/browser/debugger/devtools_frontend_host.cc @@ -70,9 +70,6 @@ bool DevToolsFrontendHost::OnMessageReceived( IPC_MESSAGE_HANDLER(DevToolsHostMsg_ActivateWindow, OnActivateWindow) IPC_MESSAGE_HANDLER(DevToolsHostMsg_CloseWindow, OnCloseWindow) IPC_MESSAGE_HANDLER(DevToolsHostMsg_MoveWindow, OnMoveWindow) - IPC_MESSAGE_HANDLER(DevToolsHostMsg_RequestDockWindow, OnRequestDockWindow) - IPC_MESSAGE_HANDLER(DevToolsHostMsg_RequestUndockWindow, - OnRequestUndockWindow) IPC_MESSAGE_HANDLER(DevToolsHostMsg_RequestSetDockSide, OnRequestSetDockSide) IPC_MESSAGE_HANDLER(DevToolsHostMsg_OpenInNewTab, OnOpenInNewTab) @@ -118,14 +115,6 @@ void DevToolsFrontendHost::OnAppend( delegate_->AppendToFile(url, content); } -void DevToolsFrontendHost::OnRequestDockWindow() { - delegate_->DockWindow(); -} - -void DevToolsFrontendHost::OnRequestUndockWindow() { - delegate_->UndockWindow(); -} - void DevToolsFrontendHost::OnRequestSetDockSide(const std::string& side) { delegate_->SetDockSide(side); } diff --git a/content/browser/debugger/devtools_frontend_host.h b/content/browser/debugger/devtools_frontend_host.h index fc60556..5c2a936 100644 --- a/content/browser/debugger/devtools_frontend_host.h +++ b/content/browser/debugger/devtools_frontend_host.h @@ -44,8 +44,6 @@ class DevToolsFrontendHost : public DevToolsClientHost, void OnActivateWindow(); void OnCloseWindow(); void OnMoveWindow(int x, int y); - void OnRequestDockWindow(); - void OnRequestUndockWindow(); void OnRequestSetDockSide(const std::string& side); void OnOpenInNewTab(const std::string& url); void OnSave(const std::string& url, const std::string& content, bool save_as); diff --git a/content/common/devtools_messages.h b/content/common/devtools_messages.h index 9acaf5d..a472e35 100644 --- a/content/common/devtools_messages.h +++ b/content/common/devtools_messages.h @@ -118,12 +118,6 @@ IPC_MESSAGE_ROUTED2(DevToolsHostMsg_MoveWindow, int /* x */, int /* y */) -// Attaches dev tools window that is inspecting current render_view_host. -IPC_MESSAGE_ROUTED0(DevToolsHostMsg_RequestDockWindow) - -// Detaches dev tools window that is inspecting current render_view_host. -IPC_MESSAGE_ROUTED0(DevToolsHostMsg_RequestUndockWindow) - // Specifies side for devtools to dock to. IPC_MESSAGE_ROUTED1(DevToolsHostMsg_RequestSetDockSide, std::string /* side */) diff --git a/content/public/browser/devtools_frontend_host_delegate.h b/content/public/browser/devtools_frontend_host_delegate.h index 34d065a..265f3d1 100644 --- a/content/public/browser/devtools_frontend_host_delegate.h +++ b/content/public/browser/devtools_frontend_host_delegate.h @@ -25,13 +25,6 @@ class DevToolsFrontendHostDelegate { // Moves DevTols front-end windo. virtual void MoveWindow(int x, int y) = 0; - // Attaches DevTools front-end to the inspected page. - virtual void DockWindow() = 0; - - // Detaches DevTools front-end from the inspected page and places it in its - // own window. - virtual void UndockWindow() = 0; - // Specifies side for devtools to dock to. virtual void SetDockSide(const std::string& side) = 0; diff --git a/content/renderer/devtools_client.cc b/content/renderer/devtools_client.cc index ae293e3..5a2677c 100644 --- a/content/renderer/devtools_client.cc +++ b/content/renderer/devtools_client.cc @@ -62,15 +62,20 @@ void DevToolsClient::moveWindowBy(const WebKit::WebFloatPoint& offset) { Send(new DevToolsHostMsg_MoveWindow(routing_id(), offset.x, offset.y)); } +// TODO(pfeldman): remove once migrated to SetDockSide. void DevToolsClient::requestDockWindow() { - Send(new DevToolsHostMsg_RequestDockWindow(routing_id())); + if (last_dock_side_.empty()) + last_dock_side_ = "bottom"; + Send(new DevToolsHostMsg_RequestSetDockSide(routing_id(), last_dock_side_)); } +// TODO(pfeldman): remove once migration to SetDockSide. void DevToolsClient::requestUndockWindow() { - Send(new DevToolsHostMsg_RequestUndockWindow(routing_id())); + Send(new DevToolsHostMsg_RequestSetDockSide(routing_id(), "undocked")); } void DevToolsClient::requestSetDockSide(const WebKit::WebString& side) { + last_dock_side_ = side.utf8(); Send(new DevToolsHostMsg_RequestSetDockSide(routing_id(), side.utf8())); } diff --git a/content/renderer/devtools_client.h b/content/renderer/devtools_client.h index 0fdb3f1..e5113260 100644 --- a/content/renderer/devtools_client.h +++ b/content/renderer/devtools_client.h @@ -54,6 +54,7 @@ class DevToolsClient : public content::RenderViewObserver, void OnDispatchOnInspectorFrontend(const std::string& message); scoped_ptr<WebKit::WebDevToolsFrontend> web_tools_frontend_; + std::string last_dock_side_; DISALLOW_COPY_AND_ASSIGN(DevToolsClient); }; |