Chromium Code Reviews| 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 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 5 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <numeric> | 8 #include <numeric> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 70 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 71 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" | 71 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" |
| 72 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" | 72 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" |
| 73 #include "chrome/browser/ui/window_sizer/window_sizer.h" | 73 #include "chrome/browser/ui/window_sizer/window_sizer.h" |
| 74 #include "chrome/common/chrome_switches.h" | 74 #include "chrome/common/chrome_switches.h" |
| 75 #include "chrome/common/url_constants.h" | 75 #include "chrome/common/url_constants.h" |
| 76 #include "content/public/browser/render_view_host.h" | 76 #include "content/public/browser/render_view_host.h" |
| 77 #include "content/public/browser/render_widget_host_view.h" | 77 #include "content/public/browser/render_widget_host_view.h" |
| 78 #include "content/public/browser/web_contents.h" | 78 #include "content/public/browser/web_contents.h" |
| 79 #include "grit/generated_resources.h" | 79 #include "grit/generated_resources.h" |
| 80 #include "grit/theme_resources.h" | |
| 80 #include "grit/locale_settings.h" | 81 #include "grit/locale_settings.h" |
| 81 #include "ui/base/l10n/l10n_util.h" | 82 #include "ui/base/l10n/l10n_util.h" |
| 82 #include "ui/base/l10n/l10n_util_mac.h" | 83 #include "ui/base/l10n/l10n_util_mac.h" |
| 83 #include "ui/gfx/mac/scoped_ns_disable_screen_updates.h" | 84 #include "ui/gfx/mac/scoped_ns_disable_screen_updates.h" |
| 84 | 85 |
| 85 // ORGANIZATION: This is a big file. It is (in principle) organized as follows | 86 // ORGANIZATION: This is a big file. It is (in principle) organized as follows |
| 86 // (in order): | 87 // (in order): |
| 87 // 1. Interfaces. Very short, one-time-use classes may include an implementation | 88 // 1. Interfaces. Very short, one-time-use classes may include an implementation |
| 88 // immediately after their interface. | 89 // immediately after their interface. |
| 89 // 2. The general implementation section, ordered as follows: | 90 // 2. The general implementation section, ordered as follows: |
| (...skipping 1551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1641 - (void)bookmarkBubbleWindowWillClose:(NSNotification*)notification { | 1642 - (void)bookmarkBubbleWindowWillClose:(NSNotification*)notification { |
| 1642 DCHECK_EQ([notification object], [bookmarkBubbleController_ window]); | 1643 DCHECK_EQ([notification object], [bookmarkBubbleController_ window]); |
| 1643 | 1644 |
| 1644 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; | 1645 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; |
| 1645 [center removeObserver:self | 1646 [center removeObserver:self |
| 1646 name:NSWindowWillCloseNotification | 1647 name:NSWindowWillCloseNotification |
| 1647 object:[bookmarkBubbleController_ window]]; | 1648 object:[bookmarkBubbleController_ window]]; |
| 1648 bookmarkBubbleController_ = nil; | 1649 bookmarkBubbleController_ = nil; |
| 1649 } | 1650 } |
| 1650 | 1651 |
| 1651 - (NSPoint)chromeToMobileBubblePoint { | |
| 1652 return [toolbarController_ chromeToMobileBubblePoint]; | |
| 1653 } | |
| 1654 | |
| 1655 // Show the Chrome To Mobile bubble (e.g. user just clicked on the icon). | 1652 // Show the Chrome To Mobile bubble (e.g. user just clicked on the icon). |
| 1656 - (void)showChromeToMobileBubble { | 1653 - (void)showChromeToMobileBubble { |
| 1657 // Do nothing if the bubble is already showing. | 1654 // Do nothing if the bubble is already showing. |
| 1658 if (chromeToMobileBubbleController_) | 1655 if (chromeToMobileBubbleController_) |
| 1659 return; | 1656 return; |
| 1660 | 1657 |
| 1661 chromeToMobileBubbleController_ = | 1658 chromeToMobileBubbleController_ = |
| 1662 [[ChromeToMobileBubbleController alloc] | 1659 [[ChromeToMobileBubbleController alloc] |
| 1663 initWithParentWindow:[self window] | 1660 initWithParentWindow:[self window] |
| 1664 browser:browser_.get()]; | 1661 browser:browser_.get()]; |
| 1665 [chromeToMobileBubbleController_ showWindow:self]; | 1662 [chromeToMobileBubbleController_ showWindow:self]; |
| 1666 | 1663 |
| 1667 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; | 1664 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; |
| 1668 [center addObserver:self | 1665 [center addObserver:self |
| 1669 selector:@selector(chromeToMobileBubbleWindowWillClose:) | 1666 selector:@selector(chromeToMobileBubbleWindowWillClose:) |
| 1670 name:NSWindowWillCloseNotification | 1667 name:NSWindowWillCloseNotification |
| 1671 object:[chromeToMobileBubbleController_ window]]; | 1668 object:[chromeToMobileBubbleController_ window]]; |
|
sail
2012/08/29 22:29:51
can you add a DCHECK() for window. If this is ever
msw
2012/08/29 23:11:57
Done (moved to ChromeToMobileBubbleController show
| |
| 1672 // Show the lit Chrome To Mobile icon while the bubble is visible. | 1669 // Show the lit Chrome To Mobile icon while the bubble is visible. |
| 1673 [self locationBarBridge]->SetChromeToMobileDecorationLit(true); | 1670 [self locationBarBridge]->SetActionBoxIcon(IDR_MOBILE_LIT); |
| 1674 } | 1671 } |
| 1675 | 1672 |
| 1676 // Nil out the weak Chrome To Mobile bubble controller reference. | 1673 // Nil out the weak Chrome To Mobile bubble controller reference. |
| 1677 - (void)chromeToMobileBubbleWindowWillClose:(NSNotification*)notification { | 1674 - (void)chromeToMobileBubbleWindowWillClose:(NSNotification*)notification { |
| 1678 DCHECK_EQ([notification object], [chromeToMobileBubbleController_ window]); | 1675 DCHECK_EQ([notification object], [chromeToMobileBubbleController_ window]); |
| 1679 | 1676 |
| 1680 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; | 1677 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; |
| 1681 [center removeObserver:self | 1678 [center removeObserver:self |
| 1682 name:NSWindowWillCloseNotification | 1679 name:NSWindowWillCloseNotification |
| 1683 object:[chromeToMobileBubbleController_ window]]; | 1680 object:[chromeToMobileBubbleController_ window]]; |
|
sail
2012/08/29 22:29:51
same, need DCHECK
msw
2012/08/29 23:11:57
Done (moved to ChromeToMobileBubbleController wind
| |
| 1684 chromeToMobileBubbleController_ = nil; | 1681 chromeToMobileBubbleController_ = nil; |
| 1685 // Restore the dimmed Chrome To Mobile icon when the bubble closes. | 1682 // Restore the Action Box icon when the bubble closes. |
| 1686 [self locationBarBridge]->SetChromeToMobileDecorationLit(false); | 1683 [self locationBarBridge]->SetActionBoxIcon(IDR_ACTION_BOX_BUTTON); |
| 1687 } | 1684 } |
| 1688 | 1685 |
| 1689 // Handle the editBookmarkNode: action sent from bookmark bubble controllers. | 1686 // Handle the editBookmarkNode: action sent from bookmark bubble controllers. |
| 1690 - (void)editBookmarkNode:(id)sender { | 1687 - (void)editBookmarkNode:(id)sender { |
| 1691 BOOL responds = [sender respondsToSelector:@selector(node)]; | 1688 BOOL responds = [sender respondsToSelector:@selector(node)]; |
| 1692 DCHECK(responds); | 1689 DCHECK(responds); |
| 1693 if (responds) { | 1690 if (responds) { |
| 1694 const BookmarkNode* node = [sender node]; | 1691 const BookmarkNode* node = [sender node]; |
| 1695 if (node) | 1692 if (node) |
| 1696 BookmarkEditor::Show([self window], browser_->profile(), | 1693 BookmarkEditor::Show([self window], browser_->profile(), |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2217 | 2214 |
| 2218 - (BOOL)supportsBookmarkBar { | 2215 - (BOOL)supportsBookmarkBar { |
| 2219 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; | 2216 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; |
| 2220 } | 2217 } |
| 2221 | 2218 |
| 2222 - (BOOL)isTabbedWindow { | 2219 - (BOOL)isTabbedWindow { |
| 2223 return browser_->is_type_tabbed(); | 2220 return browser_->is_type_tabbed(); |
| 2224 } | 2221 } |
| 2225 | 2222 |
| 2226 @end // @implementation BrowserWindowController(WindowType) | 2223 @end // @implementation BrowserWindowController(WindowType) |
| OLD | NEW |