| 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/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 | 544 |
| 545 // Tell inspected browser to update splitter and switch to inspected panel. | 545 // Tell inspected browser to update splitter and switch to inspected panel. |
| 546 BrowserWindow* inspected_window = inspected_browser->window(); | 546 BrowserWindow* inspected_window = inspected_browser->window(); |
| 547 main_web_contents_->SetDelegate(this); | 547 main_web_contents_->SetDelegate(this); |
| 548 | 548 |
| 549 TabStripModel* tab_strip_model = inspected_browser->tab_strip_model(); | 549 TabStripModel* tab_strip_model = inspected_browser->tab_strip_model(); |
| 550 tab_strip_model->ActivateTabAt(inspected_tab_index, true); | 550 tab_strip_model->ActivateTabAt(inspected_tab_index, true); |
| 551 | 551 |
| 552 inspected_window->UpdateDevTools(); | 552 inspected_window->UpdateDevTools(); |
| 553 main_web_contents_->SetInitialFocus(); | 553 main_web_contents_->SetInitialFocus(); |
| 554 inspected_window->Show(); | 554 inspected_window->Show(true /* user_gesture */); |
| 555 // On Aura, focusing once is not enough. Do it again. | 555 // On Aura, focusing once is not enough. Do it again. |
| 556 // Note that focusing only here but not before isn't enough either. We just | 556 // Note that focusing only here but not before isn't enough either. We just |
| 557 // need to focus twice. | 557 // need to focus twice. |
| 558 main_web_contents_->SetInitialFocus(); | 558 main_web_contents_->SetInitialFocus(); |
| 559 | 559 |
| 560 PrefsTabHelper::CreateForWebContents(main_web_contents_); | 560 PrefsTabHelper::CreateForWebContents(main_web_contents_); |
| 561 main_web_contents_->GetRenderViewHost()->SyncRendererPrefs(); | 561 main_web_contents_->GetRenderViewHost()->SyncRendererPrefs(); |
| 562 | 562 |
| 563 DoAction(action); | 563 DoAction(action); |
| 564 return; | 564 return; |
| 565 } | 565 } |
| 566 | 566 |
| 567 // Avoid consecutive window switching if the devtools window has been opened | 567 // Avoid consecutive window switching if the devtools window has been opened |
| 568 // and the Inspect Element shortcut is pressed in the inspected tab. | 568 // and the Inspect Element shortcut is pressed in the inspected tab. |
| 569 bool should_show_window = | 569 bool should_show_window = |
| 570 !browser_ || (action.type() != DevToolsToggleAction::kInspect); | 570 !browser_ || (action.type() != DevToolsToggleAction::kInspect); |
| 571 | 571 |
| 572 if (!browser_) | 572 if (!browser_) |
| 573 CreateDevToolsBrowser(); | 573 CreateDevToolsBrowser(); |
| 574 | 574 |
| 575 if (should_show_window) { | 575 if (should_show_window) { |
| 576 browser_->window()->Show(); | 576 browser_->window()->Show(true /* user_gesture */); |
| 577 main_web_contents_->SetInitialFocus(); | 577 main_web_contents_->SetInitialFocus(); |
| 578 } | 578 } |
| 579 if (toolbox_web_contents_) | 579 if (toolbox_web_contents_) |
| 580 UpdateBrowserWindow(); | 580 UpdateBrowserWindow(); |
| 581 | 581 |
| 582 DoAction(action); | 582 DoAction(action); |
| 583 } | 583 } |
| 584 | 584 |
| 585 // static | 585 // static |
| 586 bool DevToolsWindow::HandleBeforeUnload(WebContents* frontend_contents, | 586 bool DevToolsWindow::HandleBeforeUnload(WebContents* frontend_contents, |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1205 closure.Run(); | 1205 closure.Run(); |
| 1206 return; | 1206 return; |
| 1207 } | 1207 } |
| 1208 load_completed_callback_ = closure; | 1208 load_completed_callback_ = closure; |
| 1209 } | 1209 } |
| 1210 | 1210 |
| 1211 bool DevToolsWindow::ForwardKeyboardEvent( | 1211 bool DevToolsWindow::ForwardKeyboardEvent( |
| 1212 const content::NativeWebKeyboardEvent& event) { | 1212 const content::NativeWebKeyboardEvent& event) { |
| 1213 return event_forwarder_->ForwardEvent(event); | 1213 return event_forwarder_->ForwardEvent(event); |
| 1214 } | 1214 } |
| OLD | NEW |