Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_cocoa.mm

Issue 11416047: Add mac UI for password generation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add some comments. Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/sys_string_conversions.h" 12 #include "base/sys_string_conversions.h"
13 #include "chrome/app/chrome_command_ids.h" 13 #include "chrome/app/chrome_command_ids.h"
14 #include "chrome/browser/bookmarks/bookmark_utils.h" 14 #include "chrome/browser/bookmarks/bookmark_utils.h"
15 #include "chrome/browser/download/download_shelf.h" 15 #include "chrome/browser/download/download_shelf.h"
16 #include "chrome/browser/extensions/tab_helper.h" 16 #include "chrome/browser/extensions/tab_helper.h"
17 #include "chrome/browser/password_manager/password_manager.h"
17 #include "chrome/browser/prefs/pref_service.h" 18 #include "chrome/browser/prefs/pref_service.h"
18 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/ui/browser.h" 20 #include "chrome/browser/ui/browser.h"
20 #include "chrome/browser/ui/browser_command_controller.h" 21 #include "chrome/browser/ui/browser_command_controller.h"
21 #include "chrome/browser/ui/browser_commands.h" 22 #include "chrome/browser/ui/browser_commands.h"
22 #include "chrome/browser/ui/browser_list.h" 23 #include "chrome/browser/ui/browser_list.h"
23 #include "chrome/browser/ui/browser_tabstrip.h" 24 #include "chrome/browser/ui/browser_tabstrip.h"
24 #include "chrome/browser/ui/browser_window_state.h" 25 #include "chrome/browser/ui/browser_window_state.h"
25 #import "chrome/browser/ui/cocoa/browser/avatar_button_controller.h" 26 #import "chrome/browser/ui/cocoa/browser/avatar_button_controller.h"
26 #import "chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller.h" 27 #import "chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller.h"
27 #import "chrome/browser/ui/cocoa/browser/edit_search_engine_cocoa_controller.h" 28 #import "chrome/browser/ui/cocoa/browser/edit_search_engine_cocoa_controller.h"
29 #import "chrome/browser/ui/cocoa/browser/password_generation_bubble_controller.h "
28 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 30 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
29 #import "chrome/browser/ui/cocoa/browser_window_utils.h" 31 #import "chrome/browser/ui/cocoa/browser_window_utils.h"
30 #import "chrome/browser/ui/cocoa/chrome_event_processing_window.h" 32 #import "chrome/browser/ui/cocoa/chrome_event_processing_window.h"
31 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h" 33 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h"
32 #include "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" 34 #include "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h"
33 #import "chrome/browser/ui/cocoa/info_bubble_view.h" 35 #import "chrome/browser/ui/cocoa/info_bubble_view.h"
34 #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"
35 #import "chrome/browser/ui/cocoa/nsmenuitem_additions.h" 37 #import "chrome/browser/ui/cocoa/nsmenuitem_additions.h"
36 #include "chrome/browser/ui/cocoa/restart_browser.h" 38 #include "chrome/browser/ui/cocoa/restart_browser.h"
37 #include "chrome/browser/ui/cocoa/status_bubble_mac.h" 39 #include "chrome/browser/ui/cocoa/status_bubble_mac.h"
38 #include "chrome/browser/ui/cocoa/task_manager_mac.h" 40 #include "chrome/browser/ui/cocoa/task_manager_mac.h"
39 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" 41 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
40 #import "chrome/browser/ui/cocoa/web_dialog_window_controller.h" 42 #import "chrome/browser/ui/cocoa/web_dialog_window_controller.h"
41 #import "chrome/browser/ui/cocoa/website_settings_bubble_controller.h" 43 #import "chrome/browser/ui/cocoa/website_settings_bubble_controller.h"
42 #include "chrome/browser/ui/page_info_bubble.h" 44 #include "chrome/browser/ui/page_info_bubble.h"
43 #include "chrome/browser/ui/tab_contents/tab_contents.h" 45 #include "chrome/browser/ui/tab_contents/tab_contents.h"
44 #include "chrome/common/chrome_notification_types.h" 46 #include "chrome/common/chrome_notification_types.h"
45 #include "chrome/common/pref_names.h" 47 #include "chrome/common/pref_names.h"
46 #include "content/public/browser/native_web_keyboard_event.h" 48 #include "content/public/browser/native_web_keyboard_event.h"
47 #include "content/public/browser/notification_details.h" 49 #include "content/public/browser/notification_details.h"
48 #include "content/public/browser/notification_source.h" 50 #include "content/public/browser/notification_source.h"
49 #include "content/public/browser/web_contents.h" 51 #include "content/public/browser/web_contents.h"
52 #include "content/public/common/password_form.h"
50 #include "grit/chromium_strings.h" 53 #include "grit/chromium_strings.h"
51 #include "grit/generated_resources.h" 54 #include "grit/generated_resources.h"
52 #include "ui/base/l10n/l10n_util_mac.h" 55 #include "ui/base/l10n/l10n_util_mac.h"
53 #include "ui/gfx/rect.h" 56 #include "ui/gfx/rect.h"
54 57
55 #if defined(ENABLE_ONE_CLICK_SIGNIN) 58 #if defined(ENABLE_ONE_CLICK_SIGNIN)
56 #import "chrome/browser/ui/cocoa/one_click_signin_bubble_controller.h" 59 #import "chrome/browser/ui/cocoa/one_click_signin_bubble_controller.h"
57 #endif 60 #endif
58 61
59 using content::NativeWebKeyboardEvent; 62 using content::NativeWebKeyboardEvent;
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 [controller_ destroyBrowser]; 638 [controller_ destroyBrowser];
636 639
637 // at this point the controller is dead (autoreleased), so 640 // at this point the controller is dead (autoreleased), so
638 // make sure we don't try to reference it any more. 641 // make sure we don't try to reference it any more.
639 } 642 }
640 643
641 NSWindow* BrowserWindowCocoa::window() const { 644 NSWindow* BrowserWindowCocoa::window() const {
642 return [controller_ window]; 645 return [controller_ window];
643 } 646 }
644 647
645 void BrowserWindowCocoa::ShowAvatarBubble(WebContents* web_contents, 648 NSPoint BrowserWindowCocoa::GetPointForBubble(
646 const gfx::Rect& rect) { 649 content::WebContents* web_contents,
650 const gfx::Rect& rect) const {
Scott Hess - ex-Googler 2012/11/17 01:22:41 This seems to only need the passed parameters - su
Garrett Casto 2012/11/19 22:17:42 Done.
647 NSView* view = web_contents->GetNativeView(); 651 NSView* view = web_contents->GetNativeView();
648 NSRect bounds = [view bounds]; 652 NSRect bounds = [view bounds];
649 NSPoint point; 653 NSPoint point;
650 point.x = NSMinX(bounds) + rect.right(); 654 point.x = NSMinX(bounds) + rect.right();
651 // The view's origin is at the bottom but |rect|'s origin is at the top. 655 // The view's origin is at the bottom but |rect|'s origin is at the top.
652 point.y = NSMaxY(bounds) - rect.bottom(); 656 point.y = NSMaxY(bounds) - rect.bottom();
653 point = [view convertPoint:point toView:nil]; 657 point = [view convertPoint:point toView:nil];
654 point = [[view window] convertBaseToScreen:point]; 658 point = [[view window] convertBaseToScreen:point];
659 return point;
660 }
661
662 void BrowserWindowCocoa::ShowAvatarBubble(WebContents* web_contents,
663 const gfx::Rect& rect) {
664 NSPoint point = GetPointForBubble(web_contents, rect);
655 665
656 // |menu| will automatically release itself on close. 666 // |menu| will automatically release itself on close.
657 AvatarMenuBubbleController* menu = 667 AvatarMenuBubbleController* menu =
658 [[AvatarMenuBubbleController alloc] initWithBrowser:browser_ 668 [[AvatarMenuBubbleController alloc] initWithBrowser:browser_
659 anchoredAt:point]; 669 anchoredAt:point];
660 [[menu bubble] setAlignment:info_bubble::kAlignEdgeToAnchorEdge]; 670 [[menu bubble] setAlignment:info_bubble::kAlignEdgeToAnchorEdge];
661 [menu showWindow:nil]; 671 [menu showWindow:nil];
662 } 672 }
663 673
664 void BrowserWindowCocoa::ShowAvatarBubbleFromAvatarButton() { 674 void BrowserWindowCocoa::ShowAvatarBubbleFromAvatarButton() {
665 [[controller_ avatarButtonController] showAvatarBubble]; 675 [[controller_ avatarButtonController] showAvatarBubble];
666 } 676 }
677
678 void BrowserWindowCocoa::ShowPasswordGenerationBubble(
679 const gfx::Rect& rect,
680 const content::PasswordForm& form,
681 autofill::PasswordGenerator* password_generator) {
682 TabContents* tab_contents = chrome::GetActiveTabContents(browser_);
683 WebContents* web_contents = tab_contents->web_contents();
684 NSPoint point = GetPointForBubble(web_contents, rect);
685 // We want to point to the middle of the rect instead of the right side.
686 point.x -= rect.width()/2;
Scott Hess - ex-Googler 2012/11/17 01:22:41 This is expressing a bit more knowledge of the int
Garrett Casto 2012/11/19 22:17:42 Done.
Garrett Casto 2012/11/19 22:17:42 Done.
687
688 PasswordGenerationBubbleController* controller =
689 [[PasswordGenerationBubbleController alloc]
690 initWithBrowser:browser_
691 anchoredAt:point
692 renderViewHost:web_contents->GetRenderViewHost()
693 passwordManager:PasswordManager::FromWebContents(web_contents)
694 usingGenerator:password_generator
695 forForm:form];
696 [controller showWindow:nil];
697 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698