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

Side by Side Diff: chrome/browser/ui/passwords/manage_passwords_bubble_model.cc

Issue 1409223005: Change the password bubble on Mac so the columns are resized dynamically. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix the crash Created 5 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
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/passwords/manage_passwords_bubble_model.h" 5 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 16 matching lines...) Expand all
27 #include "components/feedback/feedback_util.h" 27 #include "components/feedback/feedback_util.h"
28 #include "components/password_manager/core/browser/password_bubble_experiment.h" 28 #include "components/password_manager/core/browser/password_bubble_experiment.h"
29 #include "components/password_manager/core/browser/password_store.h" 29 #include "components/password_manager/core/browser/password_store.h"
30 #include "components/password_manager/core/common/credential_manager_types.h" 30 #include "components/password_manager/core/common/credential_manager_types.h"
31 #include "components/password_manager/core/common/password_manager_pref_names.h" 31 #include "components/password_manager/core/common/password_manager_pref_names.h"
32 #include "components/password_manager/core/common/password_manager_ui.h" 32 #include "components/password_manager/core/common/password_manager_ui.h"
33 #include "components/signin/core/browser/signin_manager.h" 33 #include "components/signin/core/browser/signin_manager.h"
34 #include "content/public/browser/browser_thread.h" 34 #include "content/public/browser/browser_thread.h"
35 #include "content/public/common/content_switches.h" 35 #include "content/public/common/content_switches.h"
36 #include "ui/base/l10n/l10n_util.h" 36 #include "ui/base/l10n/l10n_util.h"
37 #include "ui/base/resource/resource_bundle.h"
38 37
39 using autofill::PasswordFormMap; 38 using autofill::PasswordFormMap;
40 using feedback::FeedbackData; 39 using feedback::FeedbackData;
41 using content::WebContents; 40 using content::WebContents;
42 namespace metrics_util = password_manager::metrics_util; 41 namespace metrics_util = password_manager::metrics_util;
43 42
44 namespace { 43 namespace {
45 44
46 enum FieldType { USERNAME_FIELD, PASSWORD_FIELD };
47
48 const int kUsernameFieldSize = 30;
49 const int kPasswordFieldSize = 22;
50
51 // Returns the width of |type| field.
52 int GetFieldWidth(FieldType type) {
53 return ui::ResourceBundle::GetSharedInstance()
54 .GetFontList(ui::ResourceBundle::SmallFont)
55 .GetExpectedTextWidth(type == USERNAME_FIELD ? kUsernameFieldSize
56 : kPasswordFieldSize);
57 }
58
59 Profile* GetProfileFromWebContents(content::WebContents* web_contents) { 45 Profile* GetProfileFromWebContents(content::WebContents* web_contents) {
60 if (!web_contents) 46 if (!web_contents)
61 return nullptr; 47 return nullptr;
62 return Profile::FromBrowserContext(web_contents->GetBrowserContext()); 48 return Profile::FromBrowserContext(web_contents->GetBrowserContext());
63 } 49 }
64 50
65 void RecordExperimentStatistics(content::WebContents* web_contents, 51 void RecordExperimentStatistics(content::WebContents* web_contents,
66 metrics_util::UIDismissalReason reason) { 52 metrics_util::UIDismissalReason reason) {
67 // TODO(vasilii): revive the function while implementing the smart bubble. 53 // TODO(vasilii): revive the function while implementing the smart bubble.
68 } 54 }
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 Profile* profile = GetProfile(); 345 Profile* profile = GetProfile();
360 if (GetSmartLockBrandingState(profile) == 346 if (GetSmartLockBrandingState(profile) ==
361 password_bubble_experiment::SmartLockBranding::FULL) { 347 password_bubble_experiment::SmartLockBranding::FULL) {
362 PrefService* prefs = profile->GetPrefs(); 348 PrefService* prefs = profile->GetPrefs();
363 return !prefs->GetBoolean( 349 return !prefs->GetBoolean(
364 password_manager::prefs::kWasSavePrompFirstRunExperienceShown); 350 password_manager::prefs::kWasSavePrompFirstRunExperienceShown);
365 } 351 }
366 return false; 352 return false;
367 } 353 }
368 354
369 // static
370 int ManagePasswordsBubbleModel::UsernameFieldWidth() {
371 return GetFieldWidth(USERNAME_FIELD);
372 }
373
374 // static
375 int ManagePasswordsBubbleModel::PasswordFieldWidth() {
376 return GetFieldWidth(PASSWORD_FIELD);
377 }
378
379 void ManagePasswordsBubbleModel::UpdatePendingStateTitle() { 355 void ManagePasswordsBubbleModel::UpdatePendingStateTitle() {
380 title_brand_link_range_ = gfx::Range(); 356 title_brand_link_range_ = gfx::Range();
381 GetSavePasswordDialogTitleTextAndLinkRange( 357 GetSavePasswordDialogTitleTextAndLinkRange(
382 web_contents()->GetVisibleURL(), origin(), 358 web_contents()->GetVisibleURL(), origin(),
383 GetSmartLockBrandingState(GetProfile()) != 359 GetSmartLockBrandingState(GetProfile()) !=
384 password_bubble_experiment::SmartLockBranding::NONE, 360 password_bubble_experiment::SmartLockBranding::NONE,
385 state_ == password_manager::ui::PENDING_PASSWORD_UPDATE_STATE, &title_, 361 state_ == password_manager::ui::PENDING_PASSWORD_UPDATE_STATE, &title_,
386 &title_brand_link_range_); 362 &title_brand_link_range_);
387 } 363 }
388 364
(...skipping 25 matching lines...) Expand all
414 return metrics_util::NO_UPDATE_SUBMISSION; 390 return metrics_util::NO_UPDATE_SUBMISSION;
415 } 391 }
416 if (state_ != password_manager::ui::PENDING_PASSWORD_UPDATE_STATE) 392 if (state_ != password_manager::ui::PENDING_PASSWORD_UPDATE_STATE)
417 return metrics_util::NO_UPDATE_SUBMISSION; 393 return metrics_util::NO_UPDATE_SUBMISSION;
418 if (password_overridden_) 394 if (password_overridden_)
419 return update_events[3][behavior]; 395 return update_events[3][behavior];
420 if (ShouldShowMultipleAccountUpdateUI()) 396 if (ShouldShowMultipleAccountUpdateUI())
421 return update_events[2][behavior]; 397 return update_events[2][behavior];
422 return update_events[1][behavior]; 398 return update_events[1][behavior];
423 } 399 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/passwords/manage_passwords_bubble_model.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698