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

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

Issue 11106007: drive: Rename 'gdata' namespace to 'drive' in chrome/browser/chromeos/drive (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 2 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 | « chrome/browser/profiles/profile_io_data.cc ('k') | chrome/browser/ui/browser.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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 LOG(ERROR) << "Failed to ensure the existence of " 66 LOG(ERROR) << "Failed to ensure the existence of "
67 << screenshot_path.DirName().value(); 67 << screenshot_path.DirName().value();
68 return; 68 return;
69 } 69 }
70 SaveScreenshotInternal(screenshot_path, png_data); 70 SaveScreenshotInternal(screenshot_path, png_data);
71 } 71 }
72 72
73 // TODO(kinaba): crbug.com/140425, remove this ungly #ifdef dispatch. 73 // TODO(kinaba): crbug.com/140425, remove this ungly #ifdef dispatch.
74 #ifdef OS_CHROMEOS 74 #ifdef OS_CHROMEOS
75 void SaveScreenshotToDrive(scoped_refptr<base::RefCountedBytes> png_data, 75 void SaveScreenshotToDrive(scoped_refptr<base::RefCountedBytes> png_data,
76 gdata::DriveFileError error, 76 drive::DriveFileError error,
77 const FilePath& local_path) { 77 const FilePath& local_path) {
78 if (error != gdata::DRIVE_FILE_OK) { 78 if (error != drive::DRIVE_FILE_OK) {
79 LOG(ERROR) << "Failed to write screenshot image to Google Drive: " << error; 79 LOG(ERROR) << "Failed to write screenshot image to Google Drive: " << error;
80 return; 80 return;
81 } 81 }
82 SaveScreenshotInternal(local_path, png_data); 82 SaveScreenshotInternal(local_path, png_data);
83 } 83 }
84 84
85 void EnsureDirectoryExistsCallback( 85 void EnsureDirectoryExistsCallback(
86 Profile* profile, 86 Profile* profile,
87 const FilePath& screenshot_path, 87 const FilePath& screenshot_path,
88 scoped_refptr<base::RefCountedBytes> png_data, 88 scoped_refptr<base::RefCountedBytes> png_data,
89 gdata::DriveFileError error) { 89 drive::DriveFileError error) {
90 // It is okay to fail with DRIVE_FILE_ERROR_EXISTS since anyway the directory 90 // It is okay to fail with DRIVE_FILE_ERROR_EXISTS since anyway the directory
91 // of the target file exists. 91 // of the target file exists.
92 if (error == gdata::DRIVE_FILE_OK || 92 if (error == drive::DRIVE_FILE_OK ||
93 error == gdata::DRIVE_FILE_ERROR_EXISTS) { 93 error == drive::DRIVE_FILE_ERROR_EXISTS) {
94 gdata::util::PrepareWritableFileAndRun( 94 drive::util::PrepareWritableFileAndRun(
95 profile, 95 profile,
96 screenshot_path, 96 screenshot_path,
97 base::Bind(&SaveScreenshotToDrive, png_data)); 97 base::Bind(&SaveScreenshotToDrive, png_data));
98 } else { 98 } else {
99 LOG(ERROR) << "Failed to ensure the existence of the specified directory " 99 LOG(ERROR) << "Failed to ensure the existence of the specified directory "
100 << "in Google Drive: " << error; 100 << "in Google Drive: " << error;
101 } 101 }
102 } 102 }
103 103
104 void PostSaveScreenshotTask(const FilePath& screenshot_path, 104 void PostSaveScreenshotTask(const FilePath& screenshot_path,
105 scoped_refptr<base::RefCountedBytes> png_data) { 105 scoped_refptr<base::RefCountedBytes> png_data) {
106 if (gdata::util::IsUnderDriveMountPoint(screenshot_path)) { 106 if (drive::util::IsUnderDriveMountPoint(screenshot_path)) {
107 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); 107 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord();
108 if (profile) { 108 if (profile) {
109 gdata::util::EnsureDirectoryExists( 109 drive::util::EnsureDirectoryExists(
110 profile, 110 profile,
111 screenshot_path.DirName(), 111 screenshot_path.DirName(),
112 base::Bind(&EnsureDirectoryExistsCallback, 112 base::Bind(&EnsureDirectoryExistsCallback,
113 profile, 113 profile,
114 screenshot_path, 114 screenshot_path,
115 png_data)); 115 png_data));
116 } 116 }
117 } else { 117 } else {
118 content::BrowserThread::GetBlockingPool()->PostTask( 118 content::BrowserThread::GetBlockingPool()->PostTask(
119 FROM_HERE, base::Bind(&SaveScreenshot, screenshot_path, png_data)); 119 FROM_HERE, base::Bind(&SaveScreenshot, screenshot_path, png_data));
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 ash::internal::kShellWindowId_OverlayContainer)->layer(); 224 ash::internal::kShellWindowId_OverlayContainer)->layer();
225 parent->Add(visual_feedback_layer_.get()); 225 parent->Add(visual_feedback_layer_.get());
226 visual_feedback_layer_->SetVisible(true); 226 visual_feedback_layer_->SetVisible(true);
227 227
228 MessageLoopForUI::current()->PostDelayedTask( 228 MessageLoopForUI::current()->PostDelayedTask(
229 FROM_HERE, 229 FROM_HERE,
230 base::Bind(&ScreenshotTaker::CloseVisualFeedbackLayer, 230 base::Bind(&ScreenshotTaker::CloseVisualFeedbackLayer,
231 base::Unretained(this)), 231 base::Unretained(this)),
232 base::TimeDelta::FromMilliseconds(kVisualFeedbackLayerDisplayTimeMs)); 232 base::TimeDelta::FromMilliseconds(kVisualFeedbackLayerDisplayTimeMs));
233 } 233 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_io_data.cc ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698