| 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 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" | 27 #include "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" |
| 28 #import "chrome/browser/ui/cocoa/web_dialog_window_controller.h" | 28 #import "chrome/browser/ui/cocoa/web_dialog_window_controller.h" |
| 29 #import "chrome/browser/ui/cocoa/info_bubble_view.h" | 29 #import "chrome/browser/ui/cocoa/info_bubble_view.h" |
| 30 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" | 30 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
| 31 #import "chrome/browser/ui/cocoa/nsmenuitem_additions.h" | 31 #import "chrome/browser/ui/cocoa/nsmenuitem_additions.h" |
| 32 #include "chrome/browser/ui/cocoa/restart_browser.h" | 32 #include "chrome/browser/ui/cocoa/restart_browser.h" |
| 33 #include "chrome/browser/ui/cocoa/status_bubble_mac.h" | 33 #include "chrome/browser/ui/cocoa/status_bubble_mac.h" |
| 34 #include "chrome/browser/ui/cocoa/task_manager_mac.h" | 34 #include "chrome/browser/ui/cocoa/task_manager_mac.h" |
| 35 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | 35 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
| 36 #include "chrome/browser/ui/page_info_bubble.h" | 36 #include "chrome/browser/ui/page_info_bubble.h" |
| 37 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 37 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 38 #include "chrome/common/chrome_notification_types.h" | 38 #include "chrome/common/chrome_notification_types.h" |
| 39 #include "chrome/common/pref_names.h" | 39 #include "chrome/common/pref_names.h" |
| 40 #include "content/public/browser/notification_source.h" | 40 #include "content/public/browser/notification_source.h" |
| 41 #include "content/public/browser/native_web_keyboard_event.h" | 41 #include "content/public/browser/native_web_keyboard_event.h" |
| 42 #include "content/public/browser/notification_details.h" | 42 #include "content/public/browser/notification_details.h" |
| 43 #include "content/public/browser/web_contents.h" | 43 #include "content/public/browser/web_contents.h" |
| 44 #include "grit/chromium_strings.h" | 44 #include "grit/chromium_strings.h" |
| 45 #include "grit/generated_resources.h" | 45 #include "grit/generated_resources.h" |
| 46 #include "ui/base/l10n/l10n_util_mac.h" | 46 #include "ui/base/l10n/l10n_util_mac.h" |
| 47 #include "ui/gfx/rect.h" | 47 #include "ui/gfx/rect.h" |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 forWindow:window()]); | 230 forWindow:window()]); |
| 231 } | 231 } |
| 232 | 232 |
| 233 void BrowserWindowCocoa::BookmarkBarStateChanged( | 233 void BrowserWindowCocoa::BookmarkBarStateChanged( |
| 234 BookmarkBar::AnimateChangeType change_type) { | 234 BookmarkBar::AnimateChangeType change_type) { |
| 235 // TODO: route changes to state through this. | 235 // TODO: route changes to state through this. |
| 236 } | 236 } |
| 237 | 237 |
| 238 void BrowserWindowCocoa::UpdateDevTools() { | 238 void BrowserWindowCocoa::UpdateDevTools() { |
| 239 [controller_ updateDevToolsForContents: | 239 [controller_ updateDevToolsForContents: |
| 240 browser_->GetSelectedWebContents()]; | 240 browser_->GetActiveWebContents()]; |
| 241 } | 241 } |
| 242 | 242 |
| 243 void BrowserWindowCocoa::SetDevToolsDockSide(DevToolsDockSide side) { | 243 void BrowserWindowCocoa::SetDevToolsDockSide(DevToolsDockSide side) { |
| 244 [controller_ setDevToolsDockToRight:side == DEVTOOLS_DOCK_SIDE_RIGHT]; | 244 [controller_ setDevToolsDockToRight:side == DEVTOOLS_DOCK_SIDE_RIGHT]; |
| 245 } | 245 } |
| 246 | 246 |
| 247 void BrowserWindowCocoa::UpdateLoadingAnimations(bool should_animate) { | 247 void BrowserWindowCocoa::UpdateLoadingAnimations(bool should_animate) { |
| 248 // Do nothing on Mac. | 248 // Do nothing on Mac. |
| 249 } | 249 } |
| 250 | 250 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 } | 346 } |
| 347 | 347 |
| 348 void BrowserWindowCocoa::SetFocusToLocationBar(bool select_all) { | 348 void BrowserWindowCocoa::SetFocusToLocationBar(bool select_all) { |
| 349 [controller_ focusLocationBar:select_all ? YES : NO]; | 349 [controller_ focusLocationBar:select_all ? YES : NO]; |
| 350 } | 350 } |
| 351 | 351 |
| 352 void BrowserWindowCocoa::UpdateReloadStopState(bool is_loading, bool force) { | 352 void BrowserWindowCocoa::UpdateReloadStopState(bool is_loading, bool force) { |
| 353 [controller_ setIsLoading:is_loading force:force]; | 353 [controller_ setIsLoading:is_loading force:force]; |
| 354 } | 354 } |
| 355 | 355 |
| 356 void BrowserWindowCocoa::UpdateToolbar(TabContentsWrapper* contents, | 356 void BrowserWindowCocoa::UpdateToolbar(TabContents* contents, |
| 357 bool should_restore_state) { | 357 bool should_restore_state) { |
| 358 [controller_ updateToolbarWithContents:contents->web_contents() | 358 [controller_ updateToolbarWithContents:contents->web_contents() |
| 359 shouldRestoreState:should_restore_state ? YES : NO]; | 359 shouldRestoreState:should_restore_state ? YES : NO]; |
| 360 } | 360 } |
| 361 | 361 |
| 362 void BrowserWindowCocoa::FocusToolbar() { | 362 void BrowserWindowCocoa::FocusToolbar() { |
| 363 // Not needed on the Mac. | 363 // Not needed on the Mac. |
| 364 } | 364 } |
| 365 | 365 |
| 366 void BrowserWindowCocoa::FocusAppMenu() { | 366 void BrowserWindowCocoa::FocusAppMenu() { |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 void BrowserWindowCocoa::ShowPageInfo(Profile* profile, | 490 void BrowserWindowCocoa::ShowPageInfo(Profile* profile, |
| 491 const GURL& url, | 491 const GURL& url, |
| 492 const SSLStatus& ssl, | 492 const SSLStatus& ssl, |
| 493 bool show_history) { | 493 bool show_history) { |
| 494 browser::ShowPageInfoBubble(window(), profile, url, ssl, show_history, | 494 browser::ShowPageInfoBubble(window(), profile, url, ssl, show_history, |
| 495 browser_); | 495 browser_); |
| 496 } | 496 } |
| 497 | 497 |
| 498 void BrowserWindowCocoa::ShowWebsiteSettings( | 498 void BrowserWindowCocoa::ShowWebsiteSettings( |
| 499 Profile* profile, | 499 Profile* profile, |
| 500 TabContentsWrapper* tab_contents_wrapper, | 500 TabContents* tab_contents, |
| 501 const GURL& url, | 501 const GURL& url, |
| 502 const content::SSLStatus& ssl, | 502 const content::SSLStatus& ssl, |
| 503 bool show_history) { | 503 bool show_history) { |
| 504 } | 504 } |
| 505 | 505 |
| 506 void BrowserWindowCocoa::ShowAppMenu() { | 506 void BrowserWindowCocoa::ShowAppMenu() { |
| 507 // No-op. Mac doesn't support showing the menus via alt keys. | 507 // No-op. Mac doesn't support showing the menus via alt keys. |
| 508 } | 508 } |
| 509 | 509 |
| 510 bool BrowserWindowCocoa::PreHandleKeyboardEvent( | 510 bool BrowserWindowCocoa::PreHandleKeyboardEvent( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 526 return false; | 526 return false; |
| 527 } | 527 } |
| 528 | 528 |
| 529 void BrowserWindowCocoa::HandleKeyboardEvent( | 529 void BrowserWindowCocoa::HandleKeyboardEvent( |
| 530 const NativeWebKeyboardEvent& event) { | 530 const NativeWebKeyboardEvent& event) { |
| 531 if ([BrowserWindowUtils shouldHandleKeyboardEvent:event]) | 531 if ([BrowserWindowUtils shouldHandleKeyboardEvent:event]) |
| 532 [BrowserWindowUtils handleKeyboardEvent:event.os_event inWindow:window()]; | 532 [BrowserWindowUtils handleKeyboardEvent:event.os_event inWindow:window()]; |
| 533 } | 533 } |
| 534 | 534 |
| 535 void BrowserWindowCocoa::ShowCreateWebAppShortcutsDialog( | 535 void BrowserWindowCocoa::ShowCreateWebAppShortcutsDialog( |
| 536 TabContentsWrapper* tab_contents) { | 536 TabContents* tab_contents) { |
| 537 NOTIMPLEMENTED(); | 537 NOTIMPLEMENTED(); |
| 538 } | 538 } |
| 539 | 539 |
| 540 void BrowserWindowCocoa::ShowCreateChromeAppShortcutsDialog( | 540 void BrowserWindowCocoa::ShowCreateChromeAppShortcutsDialog( |
| 541 Profile* profile, const extensions::Extension* app) { | 541 Profile* profile, const extensions::Extension* app) { |
| 542 NOTIMPLEMENTED(); | 542 NOTIMPLEMENTED(); |
| 543 } | 543 } |
| 544 | 544 |
| 545 void BrowserWindowCocoa::Cut() { | 545 void BrowserWindowCocoa::Cut() { |
| 546 [NSApp sendAction:@selector(cut:) to:nil from:nil]; | 546 [NSApp sendAction:@selector(cut:) to:nil from:nil]; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 566 } | 566 } |
| 567 | 567 |
| 568 void BrowserWindowCocoa::ExitPresentationMode() { | 568 void BrowserWindowCocoa::ExitPresentationMode() { |
| 569 [controller_ exitPresentationMode]; | 569 [controller_ exitPresentationMode]; |
| 570 } | 570 } |
| 571 | 571 |
| 572 bool BrowserWindowCocoa::InPresentationMode() { | 572 bool BrowserWindowCocoa::InPresentationMode() { |
| 573 return [controller_ inPresentationMode]; | 573 return [controller_ inPresentationMode]; |
| 574 } | 574 } |
| 575 | 575 |
| 576 void BrowserWindowCocoa::ShowInstant(TabContentsWrapper* preview) { | 576 void BrowserWindowCocoa::ShowInstant(TabContents* preview) { |
| 577 [controller_ showInstant:preview->web_contents()]; | 577 [controller_ showInstant:preview->web_contents()]; |
| 578 } | 578 } |
| 579 | 579 |
| 580 void BrowserWindowCocoa::HideInstant() { | 580 void BrowserWindowCocoa::HideInstant() { |
| 581 [controller_ hideInstant]; | 581 [controller_ hideInstant]; |
| 582 } | 582 } |
| 583 | 583 |
| 584 gfx::Rect BrowserWindowCocoa::GetInstantBounds() { | 584 gfx::Rect BrowserWindowCocoa::GetInstantBounds() { |
| 585 // Flip coordinates based on the primary screen. | 585 // Flip coordinates based on the primary screen. |
| 586 NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; | 586 NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 AvatarMenuBubbleController* menu = | 652 AvatarMenuBubbleController* menu = |
| 653 [[AvatarMenuBubbleController alloc] initWithBrowser:browser_ | 653 [[AvatarMenuBubbleController alloc] initWithBrowser:browser_ |
| 654 anchoredAt:point]; | 654 anchoredAt:point]; |
| 655 [[menu bubble] setAlignment:info_bubble::kAlignEdgeToAnchorEdge]; | 655 [[menu bubble] setAlignment:info_bubble::kAlignEdgeToAnchorEdge]; |
| 656 [menu showWindow:nil]; | 656 [menu showWindow:nil]; |
| 657 } | 657 } |
| 658 | 658 |
| 659 void BrowserWindowCocoa::ShowAvatarBubbleFromAvatarButton() { | 659 void BrowserWindowCocoa::ShowAvatarBubbleFromAvatarButton() { |
| 660 [[controller_ avatarButtonController] showAvatarBubble]; | 660 [[controller_ avatarButtonController] showAvatarBubble]; |
| 661 } | 661 } |
| OLD | NEW |