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

Side by Side Diff: chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc

Issue 322253006: Password bubble: Add an "active" icon state, and a new disabled icon. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 500s. Created 6 years, 6 months 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/views/passwords/manage_passwords_bubble_view.h" 5 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h"
6 6
7 #include "chrome/browser/chrome_notification_types.h" 7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_finder.h" 9 #include "chrome/browser/ui/browser_finder.h"
10 #include "chrome/browser/ui/browser_window.h" 10 #include "chrome/browser/ui/browser_window.h"
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); 366 Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
367 DCHECK(browser); 367 DCHECK(browser);
368 DCHECK(browser->window()); 368 DCHECK(browser->window());
369 DCHECK(browser->fullscreen_controller()); 369 DCHECK(browser->fullscreen_controller());
370 370
371 if (IsShowing()) 371 if (IsShowing())
372 return; 372 return;
373 373
374 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); 374 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser);
375 bool is_fullscreen = browser_view->IsFullscreen(); 375 bool is_fullscreen = browser_view->IsFullscreen();
376 views::View* anchor_view = is_fullscreen ? 376 ManagePasswordsIconView* anchor_view =
377 NULL : browser_view->GetLocationBarView()->manage_passwords_icon_view(); 377 is_fullscreen
378 ? NULL
379 : browser_view->GetLocationBarView()->manage_passwords_icon_view();
378 manage_passwords_bubble_ = new ManagePasswordsBubbleView( 380 manage_passwords_bubble_ = new ManagePasswordsBubbleView(
379 web_contents, anchor_view, reason); 381 web_contents, anchor_view, reason);
380 382
381 if (is_fullscreen) { 383 if (is_fullscreen) {
382 manage_passwords_bubble_->set_parent_window( 384 manage_passwords_bubble_->set_parent_window(
383 web_contents->GetTopLevelNativeWindow()); 385 web_contents->GetTopLevelNativeWindow());
384 } 386 }
385 387
386 views::BubbleDelegateView::CreateBubble(manage_passwords_bubble_); 388 views::BubbleDelegateView::CreateBubble(manage_passwords_bubble_);
387 389
388 // Adjust for fullscreen after creation as it relies on the content size. 390 // Adjust for fullscreen after creation as it relies on the content size.
389 if (is_fullscreen) { 391 if (is_fullscreen) {
390 manage_passwords_bubble_->AdjustForFullscreen( 392 manage_passwords_bubble_->AdjustForFullscreen(
391 browser_view->GetBoundsInScreen()); 393 browser_view->GetBoundsInScreen());
392 } 394 }
393
394 manage_passwords_bubble_->GetWidget()->Show(); 395 manage_passwords_bubble_->GetWidget()->Show();
395 manage_passwords_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); 396 manage_passwords_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_NONE);
396 } 397 }
397 398
398 // static 399 // static
399 void ManagePasswordsBubbleView::CloseBubble() { 400 void ManagePasswordsBubbleView::CloseBubble() {
400 if (manage_passwords_bubble_) 401 if (manage_passwords_bubble_)
401 manage_passwords_bubble_->Close(); 402 manage_passwords_bubble_->Close();
402 } 403 }
403 404
404 // static 405 // static
405 bool ManagePasswordsBubbleView::IsShowing() { 406 bool ManagePasswordsBubbleView::IsShowing() {
406 // The bubble may be in the process of closing. 407 // The bubble may be in the process of closing.
407 return (manage_passwords_bubble_ != NULL) && 408 return (manage_passwords_bubble_ != NULL) &&
408 manage_passwords_bubble_->GetWidget()->IsVisible(); 409 manage_passwords_bubble_->GetWidget()->IsVisible();
409 } 410 }
410 411
411 ManagePasswordsBubbleView::ManagePasswordsBubbleView( 412 ManagePasswordsBubbleView::ManagePasswordsBubbleView(
412 content::WebContents* web_contents, 413 content::WebContents* web_contents,
413 views::View* anchor_view, 414 ManagePasswordsIconView* anchor_view,
414 DisplayReason reason) 415 DisplayReason reason)
415 : ManagePasswordsBubble(web_contents, reason), 416 : ManagePasswordsBubble(web_contents, reason),
416 BubbleDelegateView(anchor_view, 417 BubbleDelegateView(anchor_view,
417 anchor_view ? views::BubbleBorder::TOP_RIGHT 418 anchor_view ? views::BubbleBorder::TOP_RIGHT
418 : views::BubbleBorder::NONE) { 419 : views::BubbleBorder::NONE),
420 anchor_view_(anchor_view) {
419 // Compensate for built-in vertical padding in the anchor view's image. 421 // Compensate for built-in vertical padding in the anchor view's image.
420 set_anchor_view_insets(gfx::Insets(2, 0, 2, 0)); 422 set_anchor_view_insets(gfx::Insets(2, 0, 2, 0));
421 set_notify_enter_exit_on_child(true); 423 set_notify_enter_exit_on_child(true);
424 if (anchor_view)
425 anchor_view->SetActive(true);
422 } 426 }
423 427
424 ManagePasswordsBubbleView::~ManagePasswordsBubbleView() {} 428 ManagePasswordsBubbleView::~ManagePasswordsBubbleView() {
429 if (anchor_view_)
430 anchor_view_->SetActive(false);
431 }
425 432
426 void ManagePasswordsBubbleView::AdjustForFullscreen( 433 void ManagePasswordsBubbleView::AdjustForFullscreen(
427 const gfx::Rect& screen_bounds) { 434 const gfx::Rect& screen_bounds) {
428 if (GetAnchorView()) 435 if (GetAnchorView())
429 return; 436 return;
430 437
431 // The bubble's padding from the screen edge, used in fullscreen. 438 // The bubble's padding from the screen edge, used in fullscreen.
432 const int kFullscreenPaddingEnd = 20; 439 const int kFullscreenPaddingEnd = 20;
433 const size_t bubble_half_width = width() / 2; 440 const size_t bubble_half_width = width() / 2;
434 const int x_pos = base::i18n::IsRTL() ? 441 const int x_pos = base::i18n::IsRTL() ?
(...skipping 18 matching lines...) Expand all
453 else 460 else
454 AddChildView(new ManageView(this)); 461 AddChildView(new ManageView(this));
455 } 462 }
456 463
457 void ManagePasswordsBubbleView::WindowClosing() { 464 void ManagePasswordsBubbleView::WindowClosing() {
458 // Close() closes the window asynchronously, so by the time we reach here, 465 // Close() closes the window asynchronously, so by the time we reach here,
459 // |manage_passwords_bubble_| may have already been reset. 466 // |manage_passwords_bubble_| may have already been reset.
460 if (manage_passwords_bubble_ == this) 467 if (manage_passwords_bubble_ == this)
461 manage_passwords_bubble_ = NULL; 468 manage_passwords_bubble_ = NULL;
462 } 469 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698