Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 5 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <numeric> | 8 #include <numeric> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 644 [floatingBarBackingView_ setNeedsDisplay:YES]; // Okay even if nil. | 644 [floatingBarBackingView_ setNeedsDisplay:YES]; // Okay even if nil. |
| 645 } | 645 } |
| 646 | 646 |
| 647 // Called when we are activated (when we gain focus). | 647 // Called when we are activated (when we gain focus). |
| 648 - (void)windowDidBecomeKey:(NSNotification*)notification { | 648 - (void)windowDidBecomeKey:(NSNotification*)notification { |
| 649 // We need to activate the controls (in the "WebView"). To do this, get the | 649 // We need to activate the controls (in the "WebView"). To do this, get the |
| 650 // selected WebContents's RenderWidgetHostView and tell it to activate. | 650 // selected WebContents's RenderWidgetHostView and tell it to activate. |
| 651 if (WebContents* contents = | 651 if (WebContents* contents = |
| 652 browser_->tab_strip_model()->GetActiveWebContents()) { | 652 browser_->tab_strip_model()->GetActiveWebContents()) { |
| 653 | 653 |
| 654 DevToolsWindow* devtoolsWindow = | 654 WebContents* devtools = DevToolsWindow::GetInTabWebContents( |
| 655 DevToolsWindow::GetDockedInstanceForInspectedTab(contents); | 655 contents, NULL); |
|
Avi (use Gerrit)
2014/05/29 15:18:07
Can you fit this on the previous line?
dgozman
2014/05/30 09:59:49
I tried, but no.
| |
| 656 if (devtoolsWindow) { | 656 if (devtools) { |
| 657 RenderWidgetHostView* devtoolsView = | 657 RenderWidgetHostView* devtoolsView = devtools->GetRenderWidgetHostView(); |
| 658 devtoolsWindow->web_contents()->GetRenderWidgetHostView(); | |
| 659 if (devtoolsView && devtoolsView->HasFocus()) { | 658 if (devtoolsView && devtoolsView->HasFocus()) { |
| 660 devtoolsView->SetActive(true); | 659 devtoolsView->SetActive(true); |
| 661 return; | 660 return; |
| 662 } | 661 } |
| 663 } | 662 } |
| 664 | 663 |
| 665 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) | 664 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) |
| 666 rwhv->SetActive(true); | 665 rwhv->SetActive(true); |
| 667 } | 666 } |
| 668 } | 667 } |
| 669 | 668 |
| 670 // Called when we are deactivated (when we lose focus). | 669 // Called when we are deactivated (when we lose focus). |
| 671 - (void)windowDidResignKey:(NSNotification*)notification { | 670 - (void)windowDidResignKey:(NSNotification*)notification { |
| 672 // If our app is still active and we're still the key window, ignore this | 671 // If our app is still active and we're still the key window, ignore this |
| 673 // message, since it just means that a menu extra (on the "system status bar") | 672 // message, since it just means that a menu extra (on the "system status bar") |
| 674 // was activated; we'll get another |-windowDidResignKey| if we ever really | 673 // was activated; we'll get another |-windowDidResignKey| if we ever really |
| 675 // lose key window status. | 674 // lose key window status. |
| 676 if ([NSApp isActive] && ([NSApp keyWindow] == [self window])) | 675 if ([NSApp isActive] && ([NSApp keyWindow] == [self window])) |
| 677 return; | 676 return; |
| 678 | 677 |
| 679 // We need to deactivate the controls (in the "WebView"). To do this, get the | 678 // We need to deactivate the controls (in the "WebView"). To do this, get the |
| 680 // selected WebContents's RenderWidgetHostView and tell it to deactivate. | 679 // selected WebContents's RenderWidgetHostView and tell it to deactivate. |
| 681 if (WebContents* contents = | 680 if (WebContents* contents = |
| 682 browser_->tab_strip_model()->GetActiveWebContents()) { | 681 browser_->tab_strip_model()->GetActiveWebContents()) { |
| 683 | 682 |
| 684 DevToolsWindow* devtoolsWindow = | 683 WebContents* devtools = DevToolsWindow::GetInTabWebContents( |
| 685 DevToolsWindow::GetDockedInstanceForInspectedTab(contents); | 684 contents, NULL); |
| 686 if (devtoolsWindow) { | 685 if (devtools) { |
| 687 RenderWidgetHostView* devtoolsView = | 686 RenderWidgetHostView* devtoolsView = devtools->GetRenderWidgetHostView(); |
| 688 devtoolsWindow->web_contents()->GetRenderWidgetHostView(); | |
| 689 if (devtoolsView && devtoolsView->HasFocus()) { | 687 if (devtoolsView && devtoolsView->HasFocus()) { |
| 690 devtoolsView->SetActive(false); | 688 devtoolsView->SetActive(false); |
| 691 return; | 689 return; |
| 692 } | 690 } |
| 693 } | 691 } |
| 694 | 692 |
| 695 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) | 693 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) |
| 696 rwhv->SetActive(false); | 694 rwhv->SetActive(false); |
| 697 } | 695 } |
| 698 } | 696 } |
| (...skipping 1605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2304 | 2302 |
| 2305 - (BOOL)supportsBookmarkBar { | 2303 - (BOOL)supportsBookmarkBar { |
| 2306 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; | 2304 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; |
| 2307 } | 2305 } |
| 2308 | 2306 |
| 2309 - (BOOL)isTabbedWindow { | 2307 - (BOOL)isTabbedWindow { |
| 2310 return browser_->is_type_tabbed(); | 2308 return browser_->is_type_tabbed(); |
| 2311 } | 2309 } |
| 2312 | 2310 |
| 2313 @end // @implementation BrowserWindowController(WindowType) | 2311 @end // @implementation BrowserWindowController(WindowType) |
| OLD | NEW |