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