Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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" |
| 55 #include "content/public/browser/browser_thread.h" | |
| 50 #endif | 56 #endif |
| 51 | 57 |
| 52 namespace { | 58 namespace { |
| 53 | 59 |
| 54 // Returns the browser that should handle accelerators. | 60 // Returns the browser that should handle accelerators. |
| 55 Browser* GetTargetBrowser() { | 61 Browser* GetTargetBrowser() { |
| 56 Browser* browser = browser::FindBrowserWithWindow(ash::wm::GetActiveWindow()); | 62 Browser* browser = browser::FindBrowserWithWindow(ash::wm::GetActiveWindow()); |
| 57 if (browser) | 63 if (browser) |
| 58 return browser; | 64 return browser; |
| 59 return browser::FindOrCreateTabbedBrowser( | 65 return browser::FindOrCreateTabbedBrowser( |
| 60 ProfileManager::GetDefaultProfileOrOffTheRecord()); | 66 ProfileManager::GetDefaultProfileOrOffTheRecord()); |
| 61 } | 67 } |
| 62 | 68 |
| 63 } // namespace | 69 } // namespace |
| 64 | 70 |
| 65 // static | 71 // static |
| 66 ChromeShellDelegate* ChromeShellDelegate::instance_ = NULL; | 72 ChromeShellDelegate* ChromeShellDelegate::instance_ = NULL; |
| 67 | 73 |
| 68 ChromeShellDelegate::ChromeShellDelegate() | 74 ChromeShellDelegate::ChromeShellDelegate() |
| 69 : window_positioner_(new WindowPositioner()), | 75 : window_positioner_(new WindowPositioner()), |
| 70 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 76 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
| 71 instance_ = this; | 77 instance_ = this; |
| 72 #if defined(OS_CHROMEOS) | 78 #if defined(OS_CHROMEOS) |
| 73 registrar_.Add( | 79 registrar_.Add( |
| 74 this, | 80 this, |
| 75 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 81 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
| 76 content::NotificationService::AllSources()); | 82 content::NotificationService::AllSources()); |
| 83 pref_registrar_.Init(g_browser_process->local_state()); | |
| 84 pref_registrar_.Add(prefs::kDisableScreenshots, this); | |
| 77 #endif | 85 #endif |
| 78 } | 86 } |
| 79 | 87 |
| 80 ChromeShellDelegate::~ChromeShellDelegate() { | 88 ChromeShellDelegate::~ChromeShellDelegate() { |
| 81 if (instance_ == this) | 89 if (instance_ == this) |
| 82 instance_ = NULL; | 90 instance_ = NULL; |
| 83 } | 91 } |
| 84 | 92 |
| 85 bool ChromeShellDelegate::IsUserLoggedIn() { | 93 bool ChromeShellDelegate::IsUserLoggedIn() { |
| 86 #if defined(OS_CHROMEOS) | 94 #if defined(OS_CHROMEOS) |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 } | 332 } |
| 325 | 333 |
| 326 void ChromeShellDelegate::Observe(int type, | 334 void ChromeShellDelegate::Observe(int type, |
| 327 const content::NotificationSource& source, | 335 const content::NotificationSource& source, |
| 328 const content::NotificationDetails& details) { | 336 const content::NotificationDetails& details) { |
| 329 #if defined(OS_CHROMEOS) | 337 #if defined(OS_CHROMEOS) |
| 330 switch (type) { | 338 switch (type) { |
| 331 case chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED: | 339 case chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED: |
| 332 ash::Shell::GetInstance()->CreateLauncher(); | 340 ash::Shell::GetInstance()->CreateLauncher(); |
| 333 break; | 341 break; |
| 342 case chrome::NOTIFICATION_PREF_CHANGED: | |
| 343 DCHECK(prefs::kDisableScreenshots == | |
|
Mattias Nissler (ping if slow)
2012/07/06 15:15:52
DCHECK_EQ
qfel
2012/07/06 17:00:39
Done
| |
| 344 *content::Details<std::string>(details).ptr()); | |
|
Mattias Nissler (ping if slow)
2012/07/06 15:15:52
4 spaces indentation after line breaks
qfel
2012/07/06 17:00:39
Done
| |
| 345 UpdateScreenshotDelegate(); | |
| 346 break; | |
| 334 default: | 347 default: |
| 335 NOTREACHED() << "Unexpected notification " << type; | 348 NOTREACHED() << "Unexpected notification " << type; |
| 336 } | 349 } |
| 337 #else | 350 #else |
| 338 // MSVC++ warns about switch statements without any cases. | 351 // MSVC++ warns about switch statements without any cases. |
| 339 NOTREACHED() << "Unexpected notification " << type; | 352 NOTREACHED() << "Unexpected notification " << type; |
| 340 #endif | 353 #endif |
| 341 } | 354 } |
| 355 | |
| 356 #if defined(OS_CHROMEOS) | |
| 357 void ChromeShellDelegate::UpdateScreenshotDelegate() | |
| 358 { | |
| 359 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | |
|
Mattias Nissler (ping if slow)
2012/07/06 15:15:52
I don't think we need this here, because the class
qfel
2012/07/06 17:00:39
Done
| |
| 360 ash::AcceleratorController* accelerator_controller = | |
| 361 ash::Shell::GetInstance()->accelerator_controller(); | |
|
Mattias Nissler (ping if slow)
2012/07/06 15:15:52
indentation
qfel
2012/07/06 17:00:39
Done
| |
| 362 PrefService* service = g_browser_process->local_state(); | |
| 363 DCHECK(service); | |
| 364 if (service->GetBoolean(prefs::kDisableScreenshots)) | |
|
Mattias Nissler (ping if slow)
2012/07/06 15:15:52
add curlies for multi-line block
qfel
2012/07/06 17:00:39
Done.
| |
| 365 accelerator_controller->SetScreenshotDelegate( | |
| 366 scoped_ptr<ash::ScreenshotDelegate>()); | |
| 367 else | |
| 368 accelerator_controller->SetScreenshotDelegate( | |
| 369 scoped_ptr<ash::ScreenshotDelegate>(new ScreenshotTaker).Pass()); | |
|
Mattias Nissler (ping if slow)
2012/07/06 15:15:52
Maybe this is shorter:
scoped_ptr<ash::Screenshot
qfel
2012/07/06 17:00:39
Done.
| |
| 370 } | |
| 371 #endif | |
| OLD | NEW |