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

Side by Side Diff: chrome/browser/ui/exclusive_access/exclusive_access_controller_base.cc

Issue 836933005: Refactor fullscreen_controller. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
OLDNEW
1 // Copyright (c) 2014 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/google/google_search_counter_android.h" 5 #include "chrome/browser/ui/exclusive_access/exclusive_access_controller_base.h"
6 6
7 #include "base/logging.h" 7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/google/google_search_counter.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/prerender/prerender_manager.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/prerender/prerender_manager_factory.h" 10 #include "chrome/browser/ui/browser_window.h"
11 #include "components/google/core/browser/google_search_metrics.h"
12 #include "content/public/browser/navigation_details.h" 11 #include "content/public/browser/navigation_details.h"
13 #include "content/public/browser/navigation_entry.h" 12 #include "content/public/browser/navigation_entry.h"
14 #include "content/public/browser/notification_service.h" 13 #include "content/public/browser/notification_service.h"
15 #include "content/public/browser/notification_types.h" 14 #include "content/public/browser/web_contents.h"
16 15
17 GoogleSearchCounterAndroid::GoogleSearchCounterAndroid(Profile* profile) 16 using content::WebContents;
18 : profile_(profile) { 17
19 // We always listen for all COMMITTED navigations from all sources, as any 18 ExclusiveAccessControllerBase::ExclusiveAccessControllerBase(
20 // one of them could be a navigation of interest. 19 ExclusiveAccessControllerManager* manager,
21 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, 20 Browser* browser)
22 content::NotificationService::AllSources()); 21 : manager_(manager),
22 browser_(browser),
23 window_(browser->window()),
24 profile_(browser->profile()),
25 tab_with_exclusive_access_(nullptr) {
26 DCHECK(window_);
27 DCHECK(profile_);
23 } 28 }
24 29
25 GoogleSearchCounterAndroid::~GoogleSearchCounterAndroid() { 30 ExclusiveAccessControllerBase::~ExclusiveAccessControllerBase() {
26 } 31 }
27 32
28 void GoogleSearchCounterAndroid::ProcessCommittedEntry( 33 GURL ExclusiveAccessControllerBase::GetExclusiveAccessBubbleURL() const {
29 const content::NotificationSource& source, 34 return manager_->GetExclusiveAccessBubbleURL();
30 const content::NotificationDetails& details) {
31 GoogleSearchCounter* counter = GoogleSearchCounter::GetInstance();
32 DCHECK(counter);
33 if (!counter->ShouldRecordCommittedDetails(details))
34 return;
35
36 const content::NavigationEntry& entry =
37 *content::Details<content::LoadCommittedDetails>(details)->entry;
38 prerender::PrerenderManager* prerender_manager =
39 prerender::PrerenderManagerFactory::GetForProfile(profile_);
40 // |prerender_manager| is NULL when prerendering is disabled.
41 bool prerender_enabled =
42 prerender_manager ? prerender_manager->IsEnabled() : false;
43 counter->search_metrics()->RecordAndroidGoogleSearch(
44 counter->GetGoogleSearchAccessPointForSearchNavEntry(entry),
45 prerender_enabled);
46 } 35 }
47 36
48 void GoogleSearchCounterAndroid::Observe( 37 GURL ExclusiveAccessControllerBase::GetURLForExclusiveAccessBubble() const {
38 if (tab_with_exclusive_access_)
39 return tab_with_exclusive_access_->GetURL();
40 return GURL();
41 }
42
43 void ExclusiveAccessControllerBase::OnTabDeactivated(
44 WebContents* web_contents) {
45 if (web_contents == tab_with_exclusive_access_)
46 ExitExclusiveAccessIfNecessary();
47 }
48
49 void ExclusiveAccessControllerBase::OnTabDetachedFromView(
50 WebContents* old_contents) {
51 // Derived class will to actually implement if necessary.
scheib 2015/01/14 22:37:59 "will have to implement if"
Sriram 2015/01/15 00:34:28 Done.
52 }
53
54 void ExclusiveAccessControllerBase::OnTabClosing(
55 content::WebContents* web_contents) {
56 if (web_contents == tab_with_exclusive_access_) {
57 ExitExclusiveAccessIfNecessary();
58
59 // The call to exit exclusive access may result in asynchronous notification
60 // of state change (e.g. fullscreen change on Linux). We don't want to rely
61 // on it to call NotifyTabOfExitIfNecessary(), because at that point
62 // |tab_with_exclusive_access_| may not be valid. Instead, we call it here
63 // to clean up tab fullscreen related state.
64 NotifyTabOfExclusiveAccessChange();
65 }
66 }
67
68 void ExclusiveAccessControllerBase::Observe(
49 int type, 69 int type,
50 const content::NotificationSource& source, 70 const content::NotificationSource& source,
51 const content::NotificationDetails& details) { 71 const content::NotificationDetails& details) {
52 DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_COMMITTED, type); 72 DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_COMMITTED, type);
53 ProcessCommittedEntry(source, details); 73 if (content::Details<content::LoadCommittedDetails>(details)
74 ->is_navigation_to_different_page())
75 ExitExclusiveAccessIfNecessary();
54 } 76 }
77
78 void ExclusiveAccessControllerBase::SetTabWithExclusiveAccess(
79 WebContents* tab) {
80 tab_with_exclusive_access_ = tab;
81 UpdateNotificationRegistrations();
82 }
83
84 WebContents* ExclusiveAccessControllerBase::GetExclusiveAccessTab() const {
85 return tab_with_exclusive_access_;
86 }
87
88 ExclusiveAccessControllerManager* ExclusiveAccessControllerBase::GetManager()
89 const {
90 return manager_;
91 }
92
93 Browser* ExclusiveAccessControllerBase::GetBrowser() const {
94 return browser_;
95 }
96
97 Profile* ExclusiveAccessControllerBase::GetProfile() const {
98 return profile_;
99 }
100
101 BrowserWindow* ExclusiveAccessControllerBase::GetWindow() const {
102 return window_;
103 }
104
105 void ExclusiveAccessControllerBase::UpdateExclusiveAccessExitBubbleContent() {
106 manager_->UpdateExclusiveAccessExitBubbleContent();
scheib 2015/01/14 22:37:59 For any Base method that just calls to a manager m
Sriram 2015/01/15 00:34:28 Done.
107 }
108
109 ExclusiveAccessBubbleType
110 ExclusiveAccessControllerBase::GetExclusiveAccessExitBubbleType() {
111 return manager_->GetExclusiveAccessExitBubbleType();
112 }
113
114 void ExclusiveAccessControllerBase::UpdateNotificationRegistrations() {
115 if (tab_with_exclusive_access_ && registrar_.IsEmpty()) {
116 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
117 content::Source<content::NavigationController>(
118 &tab_with_exclusive_access_->GetController()));
119 } else if (!tab_with_exclusive_access_ && !registrar_.IsEmpty()) {
120 registrar_.RemoveAll();
121 }
122 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698