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

Side by Side Diff: chrome/browser/ui/cocoa/handoff_active_url_observer.cc

Issue 2682723002: Convert HandoffActiveURLObserver to use the new navigation callbacks. (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « chrome/browser/ui/cocoa/handoff_active_url_observer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/cocoa/handoff_active_url_observer.h" 5 #include "chrome/browser/ui/cocoa/handoff_active_url_observer.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/ui/browser_finder.h" 8 #include "chrome/browser/ui/browser_finder.h"
9 #include "chrome/browser/ui/browser_list.h" 9 #include "chrome/browser/ui/browser_list.h"
10 #include "chrome/browser/ui/cocoa/handoff_active_url_observer_delegate.h" 10 #include "chrome/browser/ui/cocoa/handoff_active_url_observer_delegate.h"
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" 11 #include "chrome/browser/ui/tabs/tab_strip_model.h"
12 #include "content/public/browser/navigation_handle.h"
12 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
13 14
14 HandoffActiveURLObserver::HandoffActiveURLObserver( 15 HandoffActiveURLObserver::HandoffActiveURLObserver(
15 HandoffActiveURLObserverDelegate* delegate) 16 HandoffActiveURLObserverDelegate* delegate)
16 : delegate_(delegate), 17 : delegate_(delegate),
17 active_browser_(nullptr) { 18 active_browser_(nullptr) {
18 DCHECK(delegate_); 19 DCHECK(delegate_);
19 20
20 BrowserList::AddObserver(this); 21 BrowserList::AddObserver(this);
21 SetActiveBrowser(chrome::FindLastActive()); 22 SetActiveBrowser(chrome::FindLastActive());
(...skipping 19 matching lines...) Expand all
41 42
42 void HandoffActiveURLObserver::ActiveTabChanged( 43 void HandoffActiveURLObserver::ActiveTabChanged(
43 content::WebContents* old_contents, 44 content::WebContents* old_contents,
44 content::WebContents* new_contents, 45 content::WebContents* new_contents,
45 int index, 46 int index,
46 int reason) { 47 int reason) {
47 StartObservingWebContents(new_contents); 48 StartObservingWebContents(new_contents);
48 delegate_->HandoffActiveURLChanged(new_contents); 49 delegate_->HandoffActiveURLChanged(new_contents);
49 } 50 }
50 51
51 void HandoffActiveURLObserver::DidNavigateMainFrame( 52 void HandoffActiveURLObserver::DidFinishNavigation(
52 const content::LoadCommittedDetails& details, 53 content::NavigationHandle* navigation_handle) {
53 const content::FrameNavigateParams& params) { 54 if (!navigation_handle->IsInMainFrame() || !navigation_handle->HasCommitted())
55 return;
56
54 delegate_->HandoffActiveURLChanged(web_contents()); 57 delegate_->HandoffActiveURLChanged(web_contents());
55 } 58 }
56 59
57 void HandoffActiveURLObserver::SetActiveBrowser(Browser* active_browser) { 60 void HandoffActiveURLObserver::SetActiveBrowser(Browser* active_browser) {
58 if (active_browser == active_browser_) 61 if (active_browser == active_browser_)
59 return; 62 return;
60 63
61 if (active_browser_) { 64 if (active_browser_) {
62 active_browser_->tab_strip_model()->RemoveObserver(this); 65 active_browser_->tab_strip_model()->RemoveObserver(this);
63 StopObservingWebContents(); 66 StopObservingWebContents();
(...skipping 18 matching lines...) Expand all
82 void HandoffActiveURLObserver::StopObservingWebContents() { 85 void HandoffActiveURLObserver::StopObservingWebContents() {
83 Observe(nullptr); 86 Observe(nullptr);
84 } 87 }
85 88
86 content::WebContents* HandoffActiveURLObserver::GetActiveWebContents() { 89 content::WebContents* HandoffActiveURLObserver::GetActiveWebContents() {
87 if (!active_browser_) 90 if (!active_browser_)
88 return nullptr; 91 return nullptr;
89 92
90 return active_browser_->tab_strip_model()->GetActiveWebContents(); 93 return active_browser_->tab_strip_model()->GetActiveWebContents();
91 } 94 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/handoff_active_url_observer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698