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" |
11 #import "base/mac/sdk_forward_declarations.h" | 11 #import "base/mac/sdk_forward_declarations.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.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/tab_helper.h" | 18 #include "chrome/browser/extensions/tab_helper.h" |
19 #include "chrome/browser/fullscreen.h" | 19 #include "chrome/browser/fullscreen.h" |
20 #include "chrome/browser/password_manager/chrome_password_manager_client.h" | |
21 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/browser/shell_integration.h" | 21 #include "chrome/browser/shell_integration.h" |
23 #include "chrome/browser/signin/signin_header_helper.h" | 22 #include "chrome/browser/signin/signin_header_helper.h" |
24 #include "chrome/browser/translate/chrome_translate_client.h" | 23 #include "chrome/browser/translate/chrome_translate_client.h" |
25 #include "chrome/browser/ui/browser.h" | 24 #include "chrome/browser/ui/browser.h" |
26 #include "chrome/browser/ui/browser_command_controller.h" | 25 #include "chrome/browser/ui/browser_command_controller.h" |
27 #include "chrome/browser/ui/browser_commands_mac.h" | 26 #include "chrome/browser/ui/browser_commands_mac.h" |
28 #include "chrome/browser/ui/browser_list.h" | 27 #include "chrome/browser/ui/browser_list.h" |
29 #include "chrome/browser/ui/browser_window_state.h" | 28 #include "chrome/browser/ui/browser_window_state.h" |
30 #import "chrome/browser/ui/cocoa/browser/edit_search_engine_cocoa_controller.h" | 29 #import "chrome/browser/ui/cocoa/browser/edit_search_engine_cocoa_controller.h" |
31 #import "chrome/browser/ui/cocoa/browser/password_generation_bubble_controller.h
" | |
32 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 30 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
33 #import "chrome/browser/ui/cocoa/browser_window_utils.h" | 31 #import "chrome/browser/ui/cocoa/browser_window_utils.h" |
34 #import "chrome/browser/ui/cocoa/chrome_event_processing_window.h" | 32 #import "chrome/browser/ui/cocoa/chrome_event_processing_window.h" |
35 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h" | 33 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h" |
36 #include "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" | 34 #include "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" |
37 #import "chrome/browser/ui/cocoa/info_bubble_view.h" | 35 #import "chrome/browser/ui/cocoa/info_bubble_view.h" |
38 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" | 36 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
39 #import "chrome/browser/ui/cocoa/nsmenuitem_additions.h" | 37 #import "chrome/browser/ui/cocoa/nsmenuitem_additions.h" |
40 #import "chrome/browser/ui/cocoa/profiles/avatar_base_controller.h" | 38 #import "chrome/browser/ui/cocoa/profiles/avatar_base_controller.h" |
41 #import "chrome/browser/ui/cocoa/profiles/avatar_menu_bubble_controller.h" | 39 #import "chrome/browser/ui/cocoa/profiles/avatar_menu_bubble_controller.h" |
42 #include "chrome/browser/ui/cocoa/restart_browser.h" | 40 #include "chrome/browser/ui/cocoa/restart_browser.h" |
43 #include "chrome/browser/ui/cocoa/status_bubble_mac.h" | 41 #include "chrome/browser/ui/cocoa/status_bubble_mac.h" |
44 #include "chrome/browser/ui/cocoa/task_manager_mac.h" | 42 #include "chrome/browser/ui/cocoa/task_manager_mac.h" |
45 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | 43 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
46 #import "chrome/browser/ui/cocoa/web_dialog_window_controller.h" | 44 #import "chrome/browser/ui/cocoa/web_dialog_window_controller.h" |
47 #import "chrome/browser/ui/cocoa/website_settings/website_settings_bubble_contro
ller.h" | 45 #import "chrome/browser/ui/cocoa/website_settings/website_settings_bubble_contro
ller.h" |
48 #include "chrome/browser/ui/search/search_model.h" | 46 #include "chrome/browser/ui/search/search_model.h" |
49 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 47 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
50 #include "chrome/browser/web_applications/web_app.h" | 48 #include "chrome/browser/web_applications/web_app.h" |
51 #include "chrome/common/chrome_switches.h" | 49 #include "chrome/common/chrome_switches.h" |
52 #include "chrome/common/pref_names.h" | 50 #include "chrome/common/pref_names.h" |
53 #include "components/autofill/core/common/password_form.h" | |
54 #include "components/translate/core/browser/language_state.h" | 51 #include "components/translate/core/browser/language_state.h" |
55 #include "content/public/browser/native_web_keyboard_event.h" | 52 #include "content/public/browser/native_web_keyboard_event.h" |
56 #include "content/public/browser/notification_details.h" | 53 #include "content/public/browser/notification_details.h" |
57 #include "content/public/browser/notification_source.h" | 54 #include "content/public/browser/notification_source.h" |
58 #include "content/public/browser/web_contents.h" | 55 #include "content/public/browser/web_contents.h" |
59 #include "ui/base/l10n/l10n_util_mac.h" | 56 #include "ui/base/l10n/l10n_util_mac.h" |
60 #include "ui/gfx/rect.h" | 57 #include "ui/gfx/rect.h" |
61 | 58 |
62 #if defined(ENABLE_ONE_CLICK_SIGNIN) | 59 #if defined(ENABLE_ONE_CLICK_SIGNIN) |
63 #import "chrome/browser/ui/cocoa/one_click_signin_bubble_controller.h" | 60 #import "chrome/browser/ui/cocoa/one_click_signin_bubble_controller.h" |
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 const signin::ManageAccountsParams& manage_accounts_params) { | 711 const signin::ManageAccountsParams& manage_accounts_params) { |
715 AvatarBaseController* controller = [controller_ avatarButtonController]; | 712 AvatarBaseController* controller = [controller_ avatarButtonController]; |
716 NSView* anchor = [controller buttonView]; | 713 NSView* anchor = [controller buttonView]; |
717 if ([anchor isHiddenOrHasHiddenAncestor]) | 714 if ([anchor isHiddenOrHasHiddenAncestor]) |
718 anchor = [[controller_ toolbarController] wrenchButton]; | 715 anchor = [[controller_ toolbarController] wrenchButton]; |
719 [controller showAvatarBubbleAnchoredAt:anchor | 716 [controller showAvatarBubbleAnchoredAt:anchor |
720 withMode:mode | 717 withMode:mode |
721 withServiceType:manage_accounts_params.service_type]; | 718 withServiceType:manage_accounts_params.service_type]; |
722 } | 719 } |
723 | 720 |
724 void BrowserWindowCocoa::ShowPasswordGenerationBubble( | |
725 const gfx::Rect& rect, | |
726 const autofill::PasswordForm& form, | |
727 autofill::PasswordGenerator* password_generator) { | |
728 WebContents* web_contents = | |
729 browser_->tab_strip_model()->GetActiveWebContents(); | |
730 // We want to point to the middle of the rect instead of the right side. | |
731 NSPoint point = GetPointForBubble(web_contents, | |
732 rect.x() + rect.width()/2, | |
733 rect.bottom()); | |
734 | |
735 PasswordGenerationBubbleController* controller = [ | |
736 [PasswordGenerationBubbleController alloc] | |
737 initWithWindow:browser_->window()->GetNativeWindow() | |
738 anchoredAt:point | |
739 renderViewHost:web_contents->GetRenderViewHost() | |
740 passwordManager:ChromePasswordManagerClient::GetManagerFromWebContents( | |
741 web_contents) | |
742 usingGenerator:password_generator | |
743 forForm:form]; | |
744 [controller showWindow:nil]; | |
745 } | |
746 | |
747 int | 721 int |
748 BrowserWindowCocoa::GetRenderViewHeightInsetWithDetachedBookmarkBar() { | 722 BrowserWindowCocoa::GetRenderViewHeightInsetWithDetachedBookmarkBar() { |
749 if (browser_->bookmark_bar_state() != BookmarkBar::DETACHED) | 723 if (browser_->bookmark_bar_state() != BookmarkBar::DETACHED) |
750 return 0; | 724 return 0; |
751 return 40; | 725 return 40; |
752 } | 726 } |
753 | 727 |
754 void BrowserWindowCocoa::ExecuteExtensionCommand( | 728 void BrowserWindowCocoa::ExecuteExtensionCommand( |
755 const extensions::Extension* extension, | 729 const extensions::Extension* extension, |
756 const extensions::Command& command) { | 730 const extensions::Command& command) { |
757 [cocoa_controller() executeExtensionCommand:extension->id() command:command]; | 731 [cocoa_controller() executeExtensionCommand:extension->id() command:command]; |
758 } | 732 } |
OLD | NEW |