| 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/sidebar_container.h" |
| 19 #include "chrome/browser/extensions/sidebar_manager.h" |
| 18 #include "chrome/browser/extensions/tab_helper.h" | 20 #include "chrome/browser/extensions/tab_helper.h" |
| 19 #include "chrome/browser/fullscreen.h" | 21 #include "chrome/browser/fullscreen.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/shell_integration.h" | 23 #include "chrome/browser/shell_integration.h" |
| 22 #include "chrome/browser/signin/signin_header_helper.h" | 24 #include "chrome/browser/signin/signin_header_helper.h" |
| 23 #include "chrome/browser/translate/chrome_translate_client.h" | 25 #include "chrome/browser/translate/chrome_translate_client.h" |
| 24 #include "chrome/browser/ui/browser.h" | 26 #include "chrome/browser/ui/browser.h" |
| 25 #include "chrome/browser/ui/browser_command_controller.h" | 27 #include "chrome/browser/ui/browser_command_controller.h" |
| 26 #include "chrome/browser/ui/browser_commands_mac.h" | 28 #include "chrome/browser/ui/browser_commands_mac.h" |
| 27 #include "chrome/browser/ui/browser_list.h" | 29 #include "chrome/browser/ui/browser_list.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 controller_(controller), | 132 controller_(controller), |
| 131 initial_show_state_(ui::SHOW_STATE_DEFAULT), | 133 initial_show_state_(ui::SHOW_STATE_DEFAULT), |
| 132 attention_request_id_(0) { | 134 attention_request_id_(0) { |
| 133 | 135 |
| 134 gfx::Rect bounds; | 136 gfx::Rect bounds; |
| 135 chrome::GetSavedWindowBoundsAndShowState(browser_, | 137 chrome::GetSavedWindowBoundsAndShowState(browser_, |
| 136 &bounds, | 138 &bounds, |
| 137 &initial_show_state_); | 139 &initial_show_state_); |
| 138 | 140 |
| 139 browser_->search_model()->AddObserver(this); | 141 browser_->search_model()->AddObserver(this); |
| 142 |
| 143 extensions::SidebarManager* sidebar_manager = |
| 144 extensions::SidebarManager::GetFromContext(browser_->profile()); |
| 145 sidebar_manager->AddObserver(this); |
| 140 } | 146 } |
| 141 | 147 |
| 142 BrowserWindowCocoa::~BrowserWindowCocoa() { | 148 BrowserWindowCocoa::~BrowserWindowCocoa() { |
| 143 browser_->search_model()->RemoveObserver(this); | 149 browser_->search_model()->RemoveObserver(this); |
| 144 } | 150 } |
| 145 | 151 |
| 146 void BrowserWindowCocoa::Show() { | 152 void BrowserWindowCocoa::Show() { |
| 147 // The Browser associated with this browser window must become the active | 153 // The Browser associated with this browser window must become the active |
| 148 // browser at the time |Show()| is called. This is the natural behaviour under | 154 // browser at the time |Show()| is called. This is the natural behaviour under |
| 149 // Windows, but |-makeKeyAndOrderFront:| won't send |-windowDidBecomeMain:| | 155 // Windows, but |-makeKeyAndOrderFront:| won't send |-windowDidBecomeMain:| |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 void BrowserWindowCocoa::BookmarkBarStateChanged( | 311 void BrowserWindowCocoa::BookmarkBarStateChanged( |
| 306 BookmarkBar::AnimateChangeType change_type) { | 312 BookmarkBar::AnimateChangeType change_type) { |
| 307 [[controller_ bookmarkBarController] | 313 [[controller_ bookmarkBarController] |
| 308 updateState:browser_->bookmark_bar_state() | 314 updateState:browser_->bookmark_bar_state() |
| 309 changeType:change_type]; | 315 changeType:change_type]; |
| 310 } | 316 } |
| 311 | 317 |
| 312 void BrowserWindowCocoa::UpdateDevTools() { | 318 void BrowserWindowCocoa::UpdateDevTools() { |
| 313 [controller_ updateDevToolsForContents: | 319 [controller_ updateDevToolsForContents: |
| 314 browser_->tab_strip_model()->GetActiveWebContents()]; | 320 browser_->tab_strip_model()->GetActiveWebContents()]; |
| 321 UpdateSidebarForContents(browser_->tab_strip_model()->GetActiveWebContents()); |
| 315 } | 322 } |
| 316 | 323 |
| 317 void BrowserWindowCocoa::UpdateLoadingAnimations(bool should_animate) { | 324 void BrowserWindowCocoa::UpdateLoadingAnimations(bool should_animate) { |
| 318 // Do nothing on Mac. | 325 // Do nothing on Mac. |
| 319 } | 326 } |
| 320 | 327 |
| 321 void BrowserWindowCocoa::SetStarredState(bool is_starred) { | 328 void BrowserWindowCocoa::SetStarredState(bool is_starred) { |
| 322 [controller_ setStarredState:is_starred]; | 329 [controller_ setStarredState:is_starred]; |
| 323 } | 330 } |
| 324 | 331 |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 anchor = [[controller_ toolbarController] wrenchButton]; | 809 anchor = [[controller_ toolbarController] wrenchButton]; |
| 803 [controller showAvatarBubbleAnchoredAt:anchor | 810 [controller showAvatarBubbleAnchoredAt:anchor |
| 804 withMode:mode | 811 withMode:mode |
| 805 withServiceType:manage_accounts_params.service_type]; | 812 withServiceType:manage_accounts_params.service_type]; |
| 806 } | 813 } |
| 807 | 814 |
| 808 void BrowserWindowCocoa::CloseAvatarBubbleFromAvatarButton() { | 815 void BrowserWindowCocoa::CloseAvatarBubbleFromAvatarButton() { |
| 809 [[controller_ avatarButtonController] closeAvatarBubble]; | 816 [[controller_ avatarButtonController] closeAvatarBubble]; |
| 810 } | 817 } |
| 811 | 818 |
| 819 void BrowserWindowCocoa::UpdateSidebarForContents( |
| 820 content::WebContents* tab_contents) { |
| 821 if (tab_contents == browser_->tab_strip_model()->GetActiveWebContents()) { |
| 822 [controller_ updateSidebarForContents:tab_contents]; |
| 823 } |
| 824 } |
| 825 |
| 812 int | 826 int |
| 813 BrowserWindowCocoa::GetRenderViewHeightInsetWithDetachedBookmarkBar() { | 827 BrowserWindowCocoa::GetRenderViewHeightInsetWithDetachedBookmarkBar() { |
| 814 if (browser_->bookmark_bar_state() != BookmarkBar::DETACHED) | 828 if (browser_->bookmark_bar_state() != BookmarkBar::DETACHED) |
| 815 return 0; | 829 return 0; |
| 816 return 40; | 830 return 40; |
| 817 } | 831 } |
| 818 | 832 |
| 819 void BrowserWindowCocoa::ExecuteExtensionCommand( | 833 void BrowserWindowCocoa::ExecuteExtensionCommand( |
| 820 const extensions::Extension* extension, | 834 const extensions::Extension* extension, |
| 821 const extensions::Command& command) { | 835 const extensions::Command& command) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 837 void BrowserWindowCocoa::UnhideDownloadShelf() { | 851 void BrowserWindowCocoa::UnhideDownloadShelf() { |
| 838 GetDownloadShelf()->Unhide(); | 852 GetDownloadShelf()->Unhide(); |
| 839 } | 853 } |
| 840 | 854 |
| 841 void BrowserWindowCocoa::HideDownloadShelf() { | 855 void BrowserWindowCocoa::HideDownloadShelf() { |
| 842 GetDownloadShelf()->Hide(); | 856 GetDownloadShelf()->Hide(); |
| 843 StatusBubble* statusBubble = GetStatusBubble(); | 857 StatusBubble* statusBubble = GetStatusBubble(); |
| 844 if (statusBubble) | 858 if (statusBubble) |
| 845 statusBubble->Hide(); | 859 statusBubble->Hide(); |
| 846 } | 860 } |
| 861 |
| 862 void BrowserWindowCocoa::OnSidebarShown(content::WebContents* tab, |
| 863 const std::string& content_id) { |
| 864 UpdateSidebarForContents(tab); |
| 865 } |
| 866 |
| 867 void BrowserWindowCocoa::OnSidebarHidden(content::WebContents* tab, |
| 868 const std::string& content_id) { |
| 869 UpdateSidebarForContents(tab); |
| 870 } |
| OLD | NEW |