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 24 matching lines...) Expand all Loading... |
35 #import "chrome/browser/ui/cocoa/info_bubble_view.h" | 35 #import "chrome/browser/ui/cocoa/info_bubble_view.h" |
36 #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" |
37 #import "chrome/browser/ui/cocoa/nsmenuitem_additions.h" | 37 #import "chrome/browser/ui/cocoa/nsmenuitem_additions.h" |
38 #include "chrome/browser/ui/cocoa/restart_browser.h" | 38 #include "chrome/browser/ui/cocoa/restart_browser.h" |
39 #include "chrome/browser/ui/cocoa/status_bubble_mac.h" | 39 #include "chrome/browser/ui/cocoa/status_bubble_mac.h" |
40 #include "chrome/browser/ui/cocoa/task_manager_mac.h" | 40 #include "chrome/browser/ui/cocoa/task_manager_mac.h" |
41 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | 41 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
42 #import "chrome/browser/ui/cocoa/web_dialog_window_controller.h" | 42 #import "chrome/browser/ui/cocoa/web_dialog_window_controller.h" |
43 #import "chrome/browser/ui/cocoa/website_settings_bubble_controller.h" | 43 #import "chrome/browser/ui/cocoa/website_settings_bubble_controller.h" |
44 #include "chrome/browser/ui/page_info_bubble.h" | 44 #include "chrome/browser/ui/page_info_bubble.h" |
| 45 #include "chrome/browser/ui/search/search_model.h" |
45 #include "chrome/common/chrome_notification_types.h" | 46 #include "chrome/common/chrome_notification_types.h" |
46 #include "chrome/common/pref_names.h" | 47 #include "chrome/common/pref_names.h" |
47 #include "content/public/browser/native_web_keyboard_event.h" | 48 #include "content/public/browser/native_web_keyboard_event.h" |
48 #include "content/public/browser/notification_details.h" | 49 #include "content/public/browser/notification_details.h" |
49 #include "content/public/browser/notification_source.h" | 50 #include "content/public/browser/notification_source.h" |
50 #include "content/public/browser/web_contents.h" | 51 #include "content/public/browser/web_contents.h" |
51 #include "content/public/common/password_form.h" | 52 #include "content/public/common/password_form.h" |
52 #include "grit/chromium_strings.h" | 53 #include "grit/chromium_strings.h" |
53 #include "grit/generated_resources.h" | 54 #include "grit/generated_resources.h" |
54 #include "ui/base/l10n/l10n_util_mac.h" | 55 #include "ui/base/l10n/l10n_util_mac.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 : browser_(browser), | 106 : browser_(browser), |
106 controller_(controller), | 107 controller_(controller), |
107 confirm_close_factory_(browser), | 108 confirm_close_factory_(browser), |
108 initial_show_state_(ui::SHOW_STATE_DEFAULT), | 109 initial_show_state_(ui::SHOW_STATE_DEFAULT), |
109 attention_request_id_(0) { | 110 attention_request_id_(0) { |
110 | 111 |
111 gfx::Rect bounds; | 112 gfx::Rect bounds; |
112 chrome::GetSavedWindowBoundsAndShowState(browser_, | 113 chrome::GetSavedWindowBoundsAndShowState(browser_, |
113 &bounds, | 114 &bounds, |
114 &initial_show_state_); | 115 &initial_show_state_); |
| 116 |
| 117 browser_->search_model()->AddObserver(this); |
115 } | 118 } |
116 | 119 |
117 BrowserWindowCocoa::~BrowserWindowCocoa() { | 120 BrowserWindowCocoa::~BrowserWindowCocoa() { |
| 121 browser_->search_model()->RemoveObserver(this); |
118 } | 122 } |
119 | 123 |
120 void BrowserWindowCocoa::Show() { | 124 void BrowserWindowCocoa::Show() { |
121 // The Browser associated with this browser window must become the active | 125 // The Browser associated with this browser window must become the active |
122 // browser at the time |Show()| is called. This is the natural behaviour under | 126 // browser at the time |Show()| is called. This is the natural behaviour under |
123 // Windows, but |-makeKeyAndOrderFront:| won't send |-windowDidBecomeMain:| | 127 // Windows, but |-makeKeyAndOrderFront:| won't send |-windowDidBecomeMain:| |
124 // until we return to the runloop. Therefore any calls to | 128 // until we return to the runloop. Therefore any calls to |
125 // |chrome::FindLastActiveWithHostDesktopType| will return the previous | 129 // |chrome::FindLastActiveWithHostDesktopType| will return the previous |
126 // browser instead if we don't explicitly set it here. | 130 // browser instead if we don't explicitly set it here. |
127 BrowserList::SetLastActive(browser_); | 131 BrowserList::SetLastActive(browser_); |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 BrowserWindowCocoa::GetActiveTabPermissionGranter() { | 643 BrowserWindowCocoa::GetActiveTabPermissionGranter() { |
640 WebContents* web_contents = | 644 WebContents* web_contents = |
641 browser_->tab_strip_model()->GetActiveWebContents(); | 645 browser_->tab_strip_model()->GetActiveWebContents(); |
642 if (!web_contents) | 646 if (!web_contents) |
643 return NULL; | 647 return NULL; |
644 extensions::TabHelper* tab_helper = | 648 extensions::TabHelper* tab_helper = |
645 extensions::TabHelper::FromWebContents(web_contents); | 649 extensions::TabHelper::FromWebContents(web_contents); |
646 return tab_helper ? tab_helper->active_tab_permission_granter() : NULL; | 650 return tab_helper ? tab_helper->active_tab_permission_granter() : NULL; |
647 } | 651 } |
648 | 652 |
| 653 void BrowserWindowCocoa::ModeChanged( |
| 654 const chrome::search::Mode& old_mode, |
| 655 const chrome::search::Mode& new_mode) { |
| 656 [controller_ updateBookmarkBarStateForInstantPreview]; |
| 657 } |
| 658 |
649 void BrowserWindowCocoa::DestroyBrowser() { | 659 void BrowserWindowCocoa::DestroyBrowser() { |
650 [controller_ destroyBrowser]; | 660 [controller_ destroyBrowser]; |
651 | 661 |
652 // at this point the controller is dead (autoreleased), so | 662 // at this point the controller is dead (autoreleased), so |
653 // make sure we don't try to reference it any more. | 663 // make sure we don't try to reference it any more. |
654 } | 664 } |
655 | 665 |
656 NSWindow* BrowserWindowCocoa::window() const { | 666 NSWindow* BrowserWindowCocoa::window() const { |
657 return [controller_ window]; | 667 return [controller_ window]; |
658 } | 668 } |
(...skipping 27 matching lines...) Expand all Loading... |
686 PasswordGenerationBubbleController* controller = | 696 PasswordGenerationBubbleController* controller = |
687 [[PasswordGenerationBubbleController alloc] | 697 [[PasswordGenerationBubbleController alloc] |
688 initWithWindow:browser_->window()->GetNativeWindow() | 698 initWithWindow:browser_->window()->GetNativeWindow() |
689 anchoredAt:point | 699 anchoredAt:point |
690 renderViewHost:web_contents->GetRenderViewHost() | 700 renderViewHost:web_contents->GetRenderViewHost() |
691 passwordManager:PasswordManager::FromWebContents(web_contents) | 701 passwordManager:PasswordManager::FromWebContents(web_contents) |
692 usingGenerator:password_generator | 702 usingGenerator:password_generator |
693 forForm:form]; | 703 forForm:form]; |
694 [controller showWindow:nil]; | 704 [controller showWindow:nil]; |
695 } | 705 } |
OLD | NEW |