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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/browser_window_cocoa.mm
diff --git a/chrome/browser/ui/cocoa/browser_window_cocoa.mm b/chrome/browser/ui/cocoa/browser_window_cocoa.mm
index 1c875c6f7327da2e15e2576d9baac8267edfe507..83efa50698b76a3cdca466549643db4d90b2e334 100644
--- a/chrome/browser/ui/cocoa/browser_window_cocoa.mm
+++ b/chrome/browser/ui/cocoa/browser_window_cocoa.mm
@@ -14,6 +14,7 @@
#include "chrome/browser/bookmarks/bookmark_utils.h"
#include "chrome/browser/download/download_shelf.h"
#include "chrome/browser/extensions/tab_helper.h"
+#include "chrome/browser/password_manager/password_manager.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
@@ -25,6 +26,7 @@
#import "chrome/browser/ui/cocoa/browser/avatar_button_controller.h"
#import "chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller.h"
#import "chrome/browser/ui/cocoa/browser/edit_search_engine_cocoa_controller.h"
+#import "chrome/browser/ui/cocoa/browser/password_generation_bubble_controller.h"
#import "chrome/browser/ui/cocoa/browser_window_controller.h"
#import "chrome/browser/ui/cocoa/browser_window_utils.h"
#import "chrome/browser/ui/cocoa/chrome_event_processing_window.h"
@@ -47,6 +49,7 @@
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/web_contents.h"
+#include "content/public/common/password_form.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util_mac.h"
@@ -642,8 +645,9 @@ NSWindow* BrowserWindowCocoa::window() const {
return [controller_ window];
}
-void BrowserWindowCocoa::ShowAvatarBubble(WebContents* web_contents,
- const gfx::Rect& rect) {
+NSPoint BrowserWindowCocoa::GetPointForBubble(
+ content::WebContents* web_contents,
+ 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.
NSView* view = web_contents->GetNativeView();
NSRect bounds = [view bounds];
NSPoint point;
@@ -652,6 +656,12 @@ void BrowserWindowCocoa::ShowAvatarBubble(WebContents* web_contents,
point.y = NSMaxY(bounds) - rect.bottom();
point = [view convertPoint:point toView:nil];
point = [[view window] convertBaseToScreen:point];
+ return point;
+}
+
+void BrowserWindowCocoa::ShowAvatarBubble(WebContents* web_contents,
+ const gfx::Rect& rect) {
+ NSPoint point = GetPointForBubble(web_contents, rect);
// |menu| will automatically release itself on close.
AvatarMenuBubbleController* menu =
@@ -664,3 +674,24 @@ void BrowserWindowCocoa::ShowAvatarBubble(WebContents* web_contents,
void BrowserWindowCocoa::ShowAvatarBubbleFromAvatarButton() {
[[controller_ avatarButtonController] showAvatarBubble];
}
+
+void BrowserWindowCocoa::ShowPasswordGenerationBubble(
+ const gfx::Rect& rect,
+ const content::PasswordForm& form,
+ autofill::PasswordGenerator* password_generator) {
+ TabContents* tab_contents = chrome::GetActiveTabContents(browser_);
+ WebContents* web_contents = tab_contents->web_contents();
+ NSPoint point = GetPointForBubble(web_contents, rect);
+ // We want to point to the middle of the rect instead of the right side.
+ 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.
+
+ PasswordGenerationBubbleController* controller =
+ [[PasswordGenerationBubbleController alloc]
+ initWithBrowser:browser_
+ anchoredAt:point
+ renderViewHost:web_contents->GetRenderViewHost()
+ passwordManager:PasswordManager::FromWebContents(web_contents)
+ usingGenerator:password_generator
+ forForm:form];
+ [controller showWindow:nil];
+}

Powered by Google App Engine
This is Rietveld 408576698