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/ui/cocoa/browser_window_cocoa.h" | 5 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #import "base/mac/sdk_forward_declarations.h" | 10 #import "base/mac/sdk_forward_declarations.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "base/strings/sys_string_conversions.h" | 14 #include "base/strings/sys_string_conversions.h" |
15 #include "chrome/app/chrome_command_ids.h" | 15 #include "chrome/app/chrome_command_ids.h" |
16 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
17 #include "chrome/browser/download/download_shelf.h" | 17 #include "chrome/browser/download/download_shelf.h" |
18 #include "chrome/browser/extensions/extension_util.h" | 18 #include "chrome/browser/extensions/extension_util.h" |
| 19 #include "chrome/browser/extensions/sidebar_container.h" |
19 #include "chrome/browser/extensions/tab_helper.h" | 20 #include "chrome/browser/extensions/tab_helper.h" |
20 #include "chrome/browser/fullscreen.h" | 21 #include "chrome/browser/fullscreen.h" |
21 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/browser/shell_integration.h" | 23 #include "chrome/browser/shell_integration.h" |
23 #include "chrome/browser/signin/chrome_signin_helper.h" | 24 #include "chrome/browser/signin/chrome_signin_helper.h" |
24 #include "chrome/browser/translate/chrome_translate_client.h" | 25 #include "chrome/browser/translate/chrome_translate_client.h" |
25 #include "chrome/browser/ui/browser.h" | 26 #include "chrome/browser/ui/browser.h" |
26 #include "chrome/browser/ui/browser_command_controller.h" | 27 #include "chrome/browser/ui/browser_command_controller.h" |
27 #include "chrome/browser/ui/browser_commands_mac.h" | 28 #include "chrome/browser/ui/browser_commands_mac.h" |
28 #include "chrome/browser/ui/browser_list.h" | 29 #include "chrome/browser/ui/browser_list.h" |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 void BrowserWindowCocoa::BookmarkBarStateChanged( | 310 void BrowserWindowCocoa::BookmarkBarStateChanged( |
310 BookmarkBar::AnimateChangeType change_type) { | 311 BookmarkBar::AnimateChangeType change_type) { |
311 [[controller_ bookmarkBarController] | 312 [[controller_ bookmarkBarController] |
312 updateState:browser_->bookmark_bar_state() | 313 updateState:browser_->bookmark_bar_state() |
313 changeType:change_type]; | 314 changeType:change_type]; |
314 } | 315 } |
315 | 316 |
316 void BrowserWindowCocoa::UpdateDevTools() { | 317 void BrowserWindowCocoa::UpdateDevTools() { |
317 [controller_ updateDevToolsForContents: | 318 [controller_ updateDevToolsForContents: |
318 browser_->tab_strip_model()->GetActiveWebContents()]; | 319 browser_->tab_strip_model()->GetActiveWebContents()]; |
| 320 UpdateSidebarForContents(nullptr); |
319 } | 321 } |
320 | 322 |
321 void BrowserWindowCocoa::UpdateLoadingAnimations(bool should_animate) { | 323 void BrowserWindowCocoa::UpdateLoadingAnimations(bool should_animate) { |
322 // Do nothing on Mac. | 324 // Do nothing on Mac. |
323 } | 325 } |
324 | 326 |
325 void BrowserWindowCocoa::SetStarredState(bool is_starred) { | 327 void BrowserWindowCocoa::SetStarredState(bool is_starred) { |
326 [controller_ setStarredState:is_starred]; | 328 [controller_ setStarredState:is_starred]; |
327 } | 329 } |
328 | 330 |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 const signin::ManageAccountsParams& manage_accounts_params) { | 825 const signin::ManageAccountsParams& manage_accounts_params) { |
824 AvatarBaseController* controller = [controller_ avatarButtonController]; | 826 AvatarBaseController* controller = [controller_ avatarButtonController]; |
825 NSView* anchor = [controller buttonView]; | 827 NSView* anchor = [controller buttonView]; |
826 if ([anchor isHiddenOrHasHiddenAncestor]) | 828 if ([anchor isHiddenOrHasHiddenAncestor]) |
827 anchor = [[controller_ toolbarController] wrenchButton]; | 829 anchor = [[controller_ toolbarController] wrenchButton]; |
828 [controller showAvatarBubbleAnchoredAt:anchor | 830 [controller showAvatarBubbleAnchoredAt:anchor |
829 withMode:mode | 831 withMode:mode |
830 withServiceType:manage_accounts_params.service_type]; | 832 withServiceType:manage_accounts_params.service_type]; |
831 } | 833 } |
832 | 834 |
| 835 void BrowserWindowCocoa::UpdateSidebarForContents( |
| 836 content::WebContents* sidebar_contents) { |
| 837 WebContents* web_contents = |
| 838 browser_->tab_strip_model()->GetActiveWebContents(); |
| 839 [controller_ updateSidebarForContents:web_contents |
| 840 sidebar_contents:sidebar_contents]; |
| 841 } |
| 842 |
833 int | 843 int |
834 BrowserWindowCocoa::GetRenderViewHeightInsetWithDetachedBookmarkBar() { | 844 BrowserWindowCocoa::GetRenderViewHeightInsetWithDetachedBookmarkBar() { |
835 if (browser_->bookmark_bar_state() != BookmarkBar::DETACHED) | 845 if (browser_->bookmark_bar_state() != BookmarkBar::DETACHED) |
836 return 0; | 846 return 0; |
837 return 40; | 847 return 40; |
838 } | 848 } |
839 | 849 |
840 void BrowserWindowCocoa::ExecuteExtensionCommand( | 850 void BrowserWindowCocoa::ExecuteExtensionCommand( |
841 const extensions::Extension* extension, | 851 const extensions::Extension* extension, |
842 const extensions::Command& command) { | 852 const extensions::Command& command) { |
(...skipping 15 matching lines...) Expand all Loading... |
858 void BrowserWindowCocoa::UnhideDownloadShelf() { | 868 void BrowserWindowCocoa::UnhideDownloadShelf() { |
859 GetDownloadShelf()->Unhide(); | 869 GetDownloadShelf()->Unhide(); |
860 } | 870 } |
861 | 871 |
862 void BrowserWindowCocoa::HideDownloadShelf() { | 872 void BrowserWindowCocoa::HideDownloadShelf() { |
863 GetDownloadShelf()->Hide(); | 873 GetDownloadShelf()->Hide(); |
864 StatusBubble* statusBubble = GetStatusBubble(); | 874 StatusBubble* statusBubble = GetStatusBubble(); |
865 if (statusBubble) | 875 if (statusBubble) |
866 statusBubble->Hide(); | 876 statusBubble->Hide(); |
867 } | 877 } |
| 878 |
| 879 void BrowserWindowCocoa::ShowSidebar(content::WebContents* sidebar_contents) { |
| 880 UpdateSidebarForContents(sidebar_contents); |
| 881 } |
| 882 |
| 883 void BrowserWindowCocoa::HideSidebar() { |
| 884 UpdateSidebarForContents(nullptr); |
| 885 } |
OLD | NEW |