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

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

Issue 1336823003: Move chrome::HostDesktopType to ui::HostDesktopType (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@base_session_service_delegate_impl
Patch Set: Fix build on Mac and CrOS Created 5 years, 3 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 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/web_contents.h" 12 #include "content/public/browser/web_contents.h"
13 13
14 HandoffActiveURLObserver::HandoffActiveURLObserver( 14 HandoffActiveURLObserver::HandoffActiveURLObserver(
15 HandoffActiveURLObserverDelegate* delegate) 15 HandoffActiveURLObserverDelegate* delegate)
16 : delegate_(delegate), 16 : delegate_(delegate),
17 active_tab_strip_model_(nullptr), 17 active_tab_strip_model_(nullptr),
18 active_browser_(nullptr) { 18 active_browser_(nullptr) {
19 DCHECK(delegate_); 19 DCHECK(delegate_);
20 20
21 active_browser_ = chrome::FindLastActiveWithHostDesktopType( 21 active_browser_ =
22 chrome::HOST_DESKTOP_TYPE_NATIVE); 22 chrome::FindLastActiveWithHostDesktopType(ui::HOST_DESKTOP_TYPE_NATIVE);
23 BrowserList::AddObserver(this); 23 BrowserList::AddObserver(this);
24 UpdateObservations(); 24 UpdateObservations();
25 } 25 }
26 26
27 HandoffActiveURLObserver::~HandoffActiveURLObserver() { 27 HandoffActiveURLObserver::~HandoffActiveURLObserver() {
28 BrowserList::RemoveObserver(this); 28 BrowserList::RemoveObserver(this);
29 StopObservingTabStripModel(); 29 StopObservingTabStripModel();
30 StopObservingWebContents(); 30 StopObservingWebContents();
31 } 31 }
32 32
33 void HandoffActiveURLObserver::OnBrowserSetLastActive(Browser* browser) { 33 void HandoffActiveURLObserver::OnBrowserSetLastActive(Browser* browser) {
34 active_browser_ = browser; 34 active_browser_ = browser;
35 UpdateObservations(); 35 UpdateObservations();
36 delegate_->HandoffActiveURLChanged(GetActiveWebContents()); 36 delegate_->HandoffActiveURLChanged(GetActiveWebContents());
37 } 37 }
38 38
39 void HandoffActiveURLObserver::OnBrowserRemoved(Browser* removed_browser) { 39 void HandoffActiveURLObserver::OnBrowserRemoved(Browser* removed_browser) {
40 if (active_browser_ != removed_browser) 40 if (active_browser_ != removed_browser)
41 return; 41 return;
42 42
43 active_browser_ = chrome::FindLastActiveWithHostDesktopType( 43 active_browser_ =
44 chrome::HOST_DESKTOP_TYPE_NATIVE); 44 chrome::FindLastActiveWithHostDesktopType(ui::HOST_DESKTOP_TYPE_NATIVE);
45 UpdateObservations(); 45 UpdateObservations();
46 delegate_->HandoffActiveURLChanged(GetActiveWebContents()); 46 delegate_->HandoffActiveURLChanged(GetActiveWebContents());
47 } 47 }
48 48
49 void HandoffActiveURLObserver::ActiveTabChanged( 49 void HandoffActiveURLObserver::ActiveTabChanged(
50 content::WebContents* old_contents, 50 content::WebContents* old_contents,
51 content::WebContents* new_contents, 51 content::WebContents* new_contents,
52 int index, 52 int index,
53 int reason) { 53 int reason) {
54 StartObservingWebContents(new_contents); 54 StartObservingWebContents(new_contents);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 void HandoffActiveURLObserver::StopObservingWebContents() { 115 void HandoffActiveURLObserver::StopObservingWebContents() {
116 Observe(nullptr); 116 Observe(nullptr);
117 } 117 }
118 118
119 content::WebContents* HandoffActiveURLObserver::GetActiveWebContents() { 119 content::WebContents* HandoffActiveURLObserver::GetActiveWebContents() {
120 if (!active_browser_) 120 if (!active_browser_)
121 return nullptr; 121 return nullptr;
122 122
123 return active_browser_->tab_strip_model()->GetActiveWebContents(); 123 return active_browser_->tab_strip_model()->GetActiveWebContents();
124 } 124 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698