OLD | NEW |
---|---|
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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/exclusive_access/exclusive_access_controller_base.h" | 5 #include "chrome/browser/ui/exclusive_access/exclusive_access_controller_base.h" |
6 | 6 |
7 #include "base/metrics/histogram_macros.h" | |
7 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
8 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" | 10 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" |
10 #include "content/public/browser/navigation_details.h" | 11 #include "content/public/browser/navigation_details.h" |
11 #include "content/public/browser/navigation_entry.h" | 12 #include "content/public/browser/navigation_entry.h" |
12 #include "content/public/browser/notification_service.h" | 13 #include "content/public/browser/notification_service.h" |
13 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
14 | 15 |
15 using content::WebContents; | 16 using content::WebContents; |
16 | 17 |
18 namespace { | |
19 | |
20 const char kBubbleReshowsHistogramPrefix[] = | |
21 "ExclusiveAccess.BubbleReshowsPerSession."; | |
22 | |
23 } // namespace | |
24 | |
17 ExclusiveAccessControllerBase::ExclusiveAccessControllerBase( | 25 ExclusiveAccessControllerBase::ExclusiveAccessControllerBase( |
18 ExclusiveAccessManager* manager) | 26 ExclusiveAccessManager* manager) |
19 : manager_(manager), tab_with_exclusive_access_(nullptr) { | 27 : manager_(manager) {} |
20 } | |
21 | 28 |
22 ExclusiveAccessControllerBase::~ExclusiveAccessControllerBase() { | 29 ExclusiveAccessControllerBase::~ExclusiveAccessControllerBase() { |
23 } | 30 } |
24 | 31 |
25 GURL ExclusiveAccessControllerBase::GetExclusiveAccessBubbleURL() const { | 32 GURL ExclusiveAccessControllerBase::GetExclusiveAccessBubbleURL() const { |
26 return manager_->GetExclusiveAccessBubbleURL(); | 33 return manager_->GetExclusiveAccessBubbleURL(); |
27 } | 34 } |
28 | 35 |
29 GURL ExclusiveAccessControllerBase::GetURLForExclusiveAccessBubble() const { | 36 GURL ExclusiveAccessControllerBase::GetURLForExclusiveAccessBubble() const { |
30 if (tab_with_exclusive_access_) | 37 if (tab_with_exclusive_access_) |
(...skipping 28 matching lines...) Expand all Loading... | |
59 void ExclusiveAccessControllerBase::Observe( | 66 void ExclusiveAccessControllerBase::Observe( |
60 int type, | 67 int type, |
61 const content::NotificationSource& source, | 68 const content::NotificationSource& source, |
62 const content::NotificationDetails& details) { | 69 const content::NotificationDetails& details) { |
63 DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_COMMITTED, type); | 70 DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_COMMITTED, type); |
64 if (content::Details<content::LoadCommittedDetails>(details) | 71 if (content::Details<content::LoadCommittedDetails>(details) |
65 ->is_navigation_to_different_page()) | 72 ->is_navigation_to_different_page()) |
66 ExitExclusiveAccessIfNecessary(); | 73 ExitExclusiveAccessIfNecessary(); |
67 } | 74 } |
68 | 75 |
76 void ExclusiveAccessControllerBase::BubbleReshown() { | |
77 ++bubble_reshow_count_; | |
78 } | |
79 | |
80 void ExclusiveAccessControllerBase::Exiting() { | |
81 // Record the number of bubble reshows during this session. Only if simplified | |
82 // fullscreen is enabled. | |
83 if (ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) { | |
84 std::string histogram_name = kBubbleReshowsHistogramPrefix; | |
85 histogram_name += HistogramSuffix(); | |
86 UMA_HISTOGRAM_COUNTS_100(histogram_name, bubble_reshow_count_); | |
Ilya Sherman
2016/02/24 01:08:20
The UMA_HISTOGRAM_* macros require that histogram
Matt Giuca
2016/02/24 03:00:31
They do? I could do that but I'm not sure why it's
Matt Giuca
2016/02/24 04:01:00
Oh right... I just hit the DCHECK in HistogramBase
Ilya Sherman
2016/02/24 06:42:34
Yeah, it is definitely a rather epic comment. I a
Matt Giuca
2016/02/25 04:27:08
I'd rather use the macro than manually inlining it
| |
87 } | |
88 | |
89 bubble_reshow_count_ = 0; | |
90 } | |
91 | |
69 void ExclusiveAccessControllerBase::SetTabWithExclusiveAccess( | 92 void ExclusiveAccessControllerBase::SetTabWithExclusiveAccess( |
70 WebContents* tab) { | 93 WebContents* tab) { |
71 // Tab should never be replaced with another tab, or | 94 // Tab should never be replaced with another tab, or |
72 // UpdateNotificationRegistrations would need updating. | 95 // UpdateNotificationRegistrations would need updating. |
73 DCHECK(tab_with_exclusive_access_ == tab || | 96 DCHECK(tab_with_exclusive_access_ == tab || |
74 tab_with_exclusive_access_ == nullptr || tab == nullptr); | 97 tab_with_exclusive_access_ == nullptr || tab == nullptr); |
75 tab_with_exclusive_access_ = tab; | 98 tab_with_exclusive_access_ = tab; |
76 UpdateNotificationRegistrations(); | 99 UpdateNotificationRegistrations(); |
77 } | 100 } |
78 | 101 |
79 void ExclusiveAccessControllerBase::UpdateNotificationRegistrations() { | 102 void ExclusiveAccessControllerBase::UpdateNotificationRegistrations() { |
80 if (tab_with_exclusive_access_ && registrar_.IsEmpty()) { | 103 if (tab_with_exclusive_access_ && registrar_.IsEmpty()) { |
81 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 104 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
82 content::Source<content::NavigationController>( | 105 content::Source<content::NavigationController>( |
83 &tab_with_exclusive_access_->GetController())); | 106 &tab_with_exclusive_access_->GetController())); |
84 } else if (!tab_with_exclusive_access_ && !registrar_.IsEmpty()) { | 107 } else if (!tab_with_exclusive_access_ && !registrar_.IsEmpty()) { |
85 registrar_.RemoveAll(); | 108 registrar_.RemoveAll(); |
86 } | 109 } |
87 } | 110 } |
OLD | NEW |