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

Side by Side Diff: chrome/browser/ui/ash/screenshot_taker.cc

Issue 22715006: Suppressing screenshot messages as long as the login screen is shown and no user is logged in. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/ui/ash/screenshot_taker_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ash/screenshot_taker.h" 5 #include "chrome/browser/ui/ash/screenshot_taker.h"
6 6
7 #include <climits> 7 #include <climits>
8 #include <string> 8 #include <string>
9 9
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 21 matching lines...) Expand all
32 #include "ui/base/l10n/l10n_util.h" 32 #include "ui/base/l10n/l10n_util.h"
33 #include "ui/base/resource/resource_bundle.h" 33 #include "ui/base/resource/resource_bundle.h"
34 #include "ui/gfx/image/image.h" 34 #include "ui/gfx/image/image.h"
35 35
36 #if defined(OS_CHROMEOS) 36 #if defined(OS_CHROMEOS)
37 #include "chrome/browser/chromeos/drive/file_system_util.h" 37 #include "chrome/browser/chromeos/drive/file_system_util.h"
38 #include "chrome/browser/chromeos/extensions/file_manager/file_manager_util.h" 38 #include "chrome/browser/chromeos/extensions/file_manager/file_manager_util.h"
39 #include "chrome/browser/chromeos/login/user_manager.h" 39 #include "chrome/browser/chromeos/login/user_manager.h"
40 #include "chrome/browser/notifications/desktop_notification_service.h" 40 #include "chrome/browser/notifications/desktop_notification_service.h"
41 #include "chrome/browser/notifications/desktop_notification_service_factory.h" 41 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
42 #include "chromeos/login/login_state.h"
42 #endif 43 #endif
43 44
44 namespace { 45 namespace {
45 // The minimum interval between two screenshot commands. It has to be 46 // The minimum interval between two screenshot commands. It has to be
46 // more than 1000 to prevent the conflict of filenames. 47 // more than 1000 to prevent the conflict of filenames.
47 const int kScreenshotMinimumIntervalInMS = 1000; 48 const int kScreenshotMinimumIntervalInMS = 1000;
48 49
49 const char kNotificationId[] = "screenshot"; 50 const char kNotificationId[] = "screenshot";
50 51
51 const char kNotificationOriginUrl[] = "chrome://screenshot"; 52 const char kNotificationOriginUrl[] = "chrome://screenshot";
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_NOTIFIER_SCREENSHOT_NAME), 346 l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_NOTIFIER_SCREENSHOT_NAME),
346 replace_id, 347 replace_id,
347 new ScreenshotTakerNotificationDelegate(success, screenshot_path)); 348 new ScreenshotTakerNotificationDelegate(success, screenshot_path));
348 } 349 }
349 350
350 void ScreenshotTaker::ShowNotification( 351 void ScreenshotTaker::ShowNotification(
351 ScreenshotTakerObserver::Result screenshot_result, 352 ScreenshotTakerObserver::Result screenshot_result,
352 const base::FilePath& screenshot_path) { 353 const base::FilePath& screenshot_path) {
353 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 354 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
354 #if defined(OS_CHROMEOS) 355 #if defined(OS_CHROMEOS)
356 // Do not show a notification that a screenshot was taken while no user is
357 // logged in, since it is confusing for the user to get a message about it
358 // after he logs in (crbug.com/235217).
359 if (!chromeos::LoginState::Get()->IsUserLoggedIn())
360 return;
361
355 // TODO(sschmitz): make this work for Windows. 362 // TODO(sschmitz): make this work for Windows.
356 DesktopNotificationService* const service = 363 DesktopNotificationService* const service =
357 DesktopNotificationServiceFactory::GetForProfile(GetProfile()); 364 DesktopNotificationServiceFactory::GetForProfile(GetProfile());
358 if (service->IsNotifierEnabled( 365 if (service->IsNotifierEnabled(
359 message_center::NotifierId(message_center::NotifierId::SCREENSHOT))) { 366 message_center::NotifierId(message_center::NotifierId::SCREENSHOT))) {
360 scoped_ptr<Notification> notification( 367 scoped_ptr<Notification> notification(
361 CreateNotification(screenshot_result, screenshot_path)); 368 CreateNotification(screenshot_result, screenshot_path));
362 g_browser_process->notification_ui_manager()->Add(*notification, 369 g_browser_process->notification_ui_manager()->Add(*notification,
363 GetProfile()); 370 GetProfile());
364 } 371 }
(...skipping 26 matching lines...) Expand all
391 } 398 }
392 399
393 void ScreenshotTaker::SetScreenshotBasenameForTest( 400 void ScreenshotTaker::SetScreenshotBasenameForTest(
394 const std::string& basename) { 401 const std::string& basename) {
395 screenshot_basename_for_test_ = basename; 402 screenshot_basename_for_test_ = basename;
396 } 403 }
397 404
398 void ScreenshotTaker::SetScreenshotProfileForTest(Profile* profile) { 405 void ScreenshotTaker::SetScreenshotProfileForTest(Profile* profile) {
399 profile_for_test_ = profile; 406 profile_for_test_ = profile;
400 } 407 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/ash/screenshot_taker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698