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

Side by Side Diff: chrome/browser/chromeos/display/output_protection_delegate.cc

Issue 2721883002: Use ash_util::IsRunningInMash in chromeos::OutputProtectionDelegate (Closed)
Patch Set: remove dependency Created 3 years, 9 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 | « no previous file | 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 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/chromeos/display/output_protection_delegate.h" 5 #include "chrome/browser/chromeos/display/output_protection_delegate.h"
6 6
7 #include "chrome/browser/chromeos/display/output_protection_controller_ash.h" 7 #include "chrome/browser/chromeos/display/output_protection_controller_ash.h"
8 #include "chrome/browser/chromeos/display/output_protection_controller_mus.h" 8 #include "chrome/browser/chromeos/display/output_protection_controller_mus.h"
9 #include "chrome/browser/ui/ash/ash_util.h"
9 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
10 #include "content/public/browser/render_frame_host.h" 11 #include "content/public/browser/render_frame_host.h"
11 #include "services/service_manager/runner/common/client_util.h"
12 #include "ui/display/display.h" 12 #include "ui/display/display.h"
13 #include "ui/display/screen.h" 13 #include "ui/display/screen.h"
14 #include "ui/display/types/display_constants.h" 14 #include "ui/display/types/display_constants.h"
15 15
16 namespace chromeos { 16 namespace chromeos {
17 17
18 namespace { 18 namespace {
19 19
20 bool IsRunningInMash() {
21 return service_manager::ServiceManagerIsRemote();
22 }
23
24 bool GetCurrentDisplayId(content::RenderFrameHost* rfh, int64_t* display_id) { 20 bool GetCurrentDisplayId(content::RenderFrameHost* rfh, int64_t* display_id) {
25 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 21 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
26 DCHECK(rfh); 22 DCHECK(rfh);
27 DCHECK(display_id); 23 DCHECK(display_id);
28 24
29 display::Screen* screen = display::Screen::GetScreen(); 25 display::Screen* screen = display::Screen::GetScreen();
30 if (!screen) 26 if (!screen)
31 return false; 27 return false;
32 display::Display display = 28 display::Display display =
33 screen->GetDisplayNearestWindow(rfh->GetNativeView()); 29 screen->GetDisplayNearestWindow(rfh->GetNativeView());
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 } 95 }
100 96
101 int64_t display_id = display::kInvalidDisplayId; 97 int64_t display_id = display::kInvalidDisplayId;
102 if (!GetCurrentDisplayId(rfh, &display_id)) 98 if (!GetCurrentDisplayId(rfh, &display_id))
103 return false; 99 return false;
104 100
105 aura::Window* window = rfh->GetNativeView(); 101 aura::Window* window = rfh->GetNativeView();
106 if (!window) 102 if (!window)
107 return false; 103 return false;
108 104
109 if (IsRunningInMash()) 105 if (chrome::IsRunningInMash())
110 controller_ = base::MakeUnique<OutputProtectionControllerMus>(); 106 controller_ = base::MakeUnique<OutputProtectionControllerMus>();
111 else 107 else
112 controller_ = base::MakeUnique<OutputProtectionControllerAsh>(); 108 controller_ = base::MakeUnique<OutputProtectionControllerAsh>();
113 109
114 display_id_ = display_id; 110 display_id_ = display_id;
115 window_ = window; 111 window_ = window;
116 window_->AddObserver(this); 112 window_->AddObserver(this);
117 return true; 113 return true;
118 } 114 }
119 115
(...skipping 24 matching lines...) Expand all
144 display_id_ = new_display_id; 140 display_id_ = new_display_id;
145 } 141 }
146 142
147 void OutputProtectionDelegate::OnWindowDestroying(aura::Window* window) { 143 void OutputProtectionDelegate::OnWindowDestroying(aura::Window* window) {
148 DCHECK_EQ(window, window_); 144 DCHECK_EQ(window, window_);
149 window_->RemoveObserver(this); 145 window_->RemoveObserver(this);
150 window_ = nullptr; 146 window_ = nullptr;
151 } 147 }
152 148
153 } // namespace chromeos 149 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698