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

Side by Side Diff: chrome/browser/ui/views/ash/chrome_shell_delegate.cc

Issue 10692110: screenshot disabling policy (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Addressed comments Created 8 years, 5 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/views/ash/chrome_shell_delegate.h" 5 #include "chrome/browser/ui/views/ash/chrome_shell_delegate.h"
6 6
7 #include "ash/launcher/launcher_types.h" 7 #include "ash/launcher/launcher_types.h"
8 #include "ash/system/tray/system_tray_delegate.h" 8 #include "ash/system/tray/system_tray_delegate.h"
9 #include "ash/wm/partial_screenshot_view.h" 9 #include "ash/wm/partial_screenshot_view.h"
10 #include "ash/wm/window_util.h" 10 #include "ash/wm/window_util.h"
(...skipping 16 matching lines...) Expand all
27 #include "chrome/common/chrome_switches.h" 27 #include "chrome/common/chrome_switches.h"
28 #include "chrome/common/url_constants.h" 28 #include "chrome/common/url_constants.h"
29 #include "content/public/browser/notification_service.h" 29 #include "content/public/browser/notification_service.h"
30 #include "content/public/browser/user_metrics.h" 30 #include "content/public/browser/user_metrics.h"
31 #include "content/public/browser/web_contents.h" 31 #include "content/public/browser/web_contents.h"
32 #include "grit/generated_resources.h" 32 #include "grit/generated_resources.h"
33 #include "ui/aura/client/user_action_client.h" 33 #include "ui/aura/client/user_action_client.h"
34 #include "ui/aura/window.h" 34 #include "ui/aura/window.h"
35 35
36 #if defined(OS_CHROMEOS) 36 #if defined(OS_CHROMEOS)
37 #include "ash/accelerators/accelerator_controller.h"
37 #include "base/chromeos/chromeos_version.h" 38 #include "base/chromeos/chromeos_version.h"
39 #include "chrome/browser/browser_process.h"
38 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" 40 #include "chrome/browser/chromeos/accessibility/accessibility_util.h"
39 #include "chrome/browser/chromeos/background/ash_user_wallpaper_delegate.h" 41 #include "chrome/browser/chromeos/background/ash_user_wallpaper_delegate.h"
40 #include "chrome/browser/chromeos/extensions/file_manager_util.h" 42 #include "chrome/browser/chromeos/extensions/file_manager_util.h"
41 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" 43 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h"
42 #include "chrome/browser/chromeos/login/user_manager.h" 44 #include "chrome/browser/chromeos/login/user_manager.h"
43 #include "chrome/browser/chromeos/login/webui_login_display_host.h" 45 #include "chrome/browser/chromeos/login/webui_login_display_host.h"
44 #include "chrome/browser/chromeos/system/ash_system_tray_delegate.h" 46 #include "chrome/browser/chromeos/system/ash_system_tray_delegate.h"
47 #include "chrome/browser/prefs/pref_service.h"
48 #include "chrome/browser/ui/views/ash/screenshot_taker.h"
45 #include "chrome/browser/ui/views/keyboard_overlay_dialog_view.h" 49 #include "chrome/browser/ui/views/keyboard_overlay_dialog_view.h"
46 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" 50 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
47 #include "chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h" 51 #include "chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h"
52 #include "chrome/common/pref_names.h"
48 #include "chromeos/dbus/dbus_thread_manager.h" 53 #include "chromeos/dbus/dbus_thread_manager.h"
49 #include "chromeos/dbus/power_manager_client.h" 54 #include "chromeos/dbus/power_manager_client.h"
50 #endif 55 #endif
51 56
52 namespace { 57 namespace {
53 58
54 // Returns the browser that should handle accelerators. 59 // Returns the browser that should handle accelerators.
55 Browser* GetTargetBrowser() { 60 Browser* GetTargetBrowser() {
56 Browser* browser = browser::FindBrowserWithWindow(ash::wm::GetActiveWindow()); 61 Browser* browser = browser::FindBrowserWithWindow(ash::wm::GetActiveWindow());
57 if (browser) 62 if (browser)
58 return browser; 63 return browser;
59 return browser::FindOrCreateTabbedBrowser( 64 return browser::FindOrCreateTabbedBrowser(
60 ProfileManager::GetDefaultProfileOrOffTheRecord()); 65 ProfileManager::GetDefaultProfileOrOffTheRecord());
61 } 66 }
62 67
63 } // namespace 68 } // namespace
64 69
65 // static 70 // static
66 ChromeShellDelegate* ChromeShellDelegate::instance_ = NULL; 71 ChromeShellDelegate* ChromeShellDelegate::instance_ = NULL;
67 72
68 ChromeShellDelegate::ChromeShellDelegate() 73 ChromeShellDelegate::ChromeShellDelegate()
69 : window_positioner_(new WindowPositioner()), 74 : window_positioner_(new WindowPositioner()),
70 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { 75 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
71 instance_ = this; 76 instance_ = this;
72 #if defined(OS_CHROMEOS) 77 #if defined(OS_CHROMEOS)
73 registrar_.Add( 78 registrar_.Add(
74 this, 79 this,
75 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, 80 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED,
76 content::NotificationService::AllSources()); 81 content::NotificationService::AllSources());
82 pref_registrar_.Init(g_browser_process->local_state());
83 pref_registrar_.Add(prefs::kDisableScreenshots, this);
77 #endif 84 #endif
78 } 85 }
79 86
80 ChromeShellDelegate::~ChromeShellDelegate() { 87 ChromeShellDelegate::~ChromeShellDelegate() {
81 if (instance_ == this) 88 if (instance_ == this)
82 instance_ = NULL; 89 instance_ = NULL;
83 } 90 }
84 91
85 bool ChromeShellDelegate::IsUserLoggedIn() { 92 bool ChromeShellDelegate::IsUserLoggedIn() {
86 #if defined(OS_CHROMEOS) 93 #if defined(OS_CHROMEOS)
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 } 331 }
325 332
326 void ChromeShellDelegate::Observe(int type, 333 void ChromeShellDelegate::Observe(int type,
327 const content::NotificationSource& source, 334 const content::NotificationSource& source,
328 const content::NotificationDetails& details) { 335 const content::NotificationDetails& details) {
329 #if defined(OS_CHROMEOS) 336 #if defined(OS_CHROMEOS)
330 switch (type) { 337 switch (type) {
331 case chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED: 338 case chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED:
332 ash::Shell::GetInstance()->CreateLauncher(); 339 ash::Shell::GetInstance()->CreateLauncher();
333 break; 340 break;
341 case chrome::NOTIFICATION_PREF_CHANGED:
342 DCHECK_EQ(prefs::kDisableScreenshots,
343 *content::Details<std::string>(details).ptr());
Mattias Nissler (ping if slow) 2012/07/09 09:30:12 align parameters at (
qfel 2012/07/11 12:34:49 Done.
344 UpdateScreenshotDelegate();
345 break;
334 default: 346 default:
335 NOTREACHED() << "Unexpected notification " << type; 347 NOTREACHED() << "Unexpected notification " << type;
336 } 348 }
337 #else 349 #else
338 // MSVC++ warns about switch statements without any cases. 350 // MSVC++ warns about switch statements without any cases.
339 NOTREACHED() << "Unexpected notification " << type; 351 NOTREACHED() << "Unexpected notification " << type;
340 #endif 352 #endif
341 } 353 }
354
355 #if defined(OS_CHROMEOS)
356 void ChromeShellDelegate::RegisterLocalPrefs(PrefService* service) {
357 service->RegisterBooleanPref(prefs::kDisableScreenshots, false);
358 }
359
360 void ChromeShellDelegate::RegisterUserPrefs(PrefService* service) {
361 service->RegisterBooleanPref(prefs::kDisableScreenshots, false,
362 PrefService::UNSYNCABLE_PREF);
Mattias Nissler (ping if slow) 2012/07/09 09:30:12 align at (
qfel 2012/07/11 12:34:49 Done.
363 }
364
365 void ChromeShellDelegate::UpdateScreenshotDelegate() {
366 ash::AcceleratorController* accelerator_controller =
367 ash::Shell::GetInstance()->accelerator_controller();
368 PrefService* service = g_browser_process->local_state();
369 DCHECK(service);
370 scoped_ptr<ash::ScreenshotDelegate> delegate;
371 if (!service->GetBoolean(prefs::kDisableScreenshots))
372 delegate.reset(new ScreenshotTaker);
373 accelerator_controller->SetScreenshotDelegate(delegate.Pass());
374 }
375 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698