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

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

Issue 2526893003: chromeos: Add NoteTakingHelper class. (Closed)
Patch Set: drop is-note-taking-app-window stuff Created 4 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/chrome_screenshot_grabber.h" 5 #include "chrome/browser/ui/ash/chrome_screenshot_grabber.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "ash/common/strings/grit/ash_strings.h" 9 #include "ash/common/strings/grit/ash_strings.h"
10 #include "ash/common/system/system_notifier.h" 10 #include "ash/common/system/system_notifier.h"
11 #include "ash/shell.h" 11 #include "ash/shell.h"
12 #include "base/base64.h" 12 #include "base/base64.h"
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/files/file_util.h" 15 #include "base/files/file_util.h"
16 #include "base/i18n/time_formatting.h" 16 #include "base/i18n/time_formatting.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
19 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
20 #include "build/build_config.h" 20 #include "build/build_config.h"
21 #include "chrome/browser/browser_process.h" 21 #include "chrome/browser/browser_process.h"
22 #include "chrome/browser/chromeos/drive/file_system_util.h" 22 #include "chrome/browser/chromeos/drive/file_system_util.h"
23 #include "chrome/browser/chromeos/file_manager/open_util.h" 23 #include "chrome/browser/chromeos/file_manager/open_util.h"
24 #include "chrome/browser/chromeos/note_taking_app_utils.h" 24 #include "chrome/browser/chromeos/note_taking_helper.h"
25 #include "chrome/browser/download/download_prefs.h" 25 #include "chrome/browser/download/download_prefs.h"
26 #include "chrome/browser/notifications/notification_ui_manager.h" 26 #include "chrome/browser/notifications/notification_ui_manager.h"
27 #include "chrome/browser/notifications/notifier_state_tracker.h" 27 #include "chrome/browser/notifications/notifier_state_tracker.h"
28 #include "chrome/browser/notifications/notifier_state_tracker_factory.h" 28 #include "chrome/browser/notifications/notifier_state_tracker_factory.h"
29 #include "chrome/browser/platform_util.h" 29 #include "chrome/browser/platform_util.h"
30 #include "chrome/browser/profiles/profile.h" 30 #include "chrome/browser/profiles/profile.h"
31 #include "chrome/browser/profiles/profile_manager.h" 31 #include "chrome/browser/profiles/profile_manager.h"
32 #include "chrome/common/pref_names.h" 32 #include "chrome/common/pref_names.h"
33 #include "chrome/grit/theme_resources.h" 33 #include "chrome/grit/theme_resources.h"
34 #include "chromeos/login/login_state.h" 34 #include "chromeos/login/login_state.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 file_system->GetFile(drive::util::ExtractDrivePath(screenshot_path_), 129 file_system->GetFile(drive::util::ExtractDrivePath(screenshot_path_),
130 base::Bind(&ReadFileAndCopyToClipboardDrive)); 130 base::Bind(&ReadFileAndCopyToClipboardDrive));
131 return; 131 return;
132 } 132 }
133 content::BrowserThread::GetBlockingPool()->PostTask( 133 content::BrowserThread::GetBlockingPool()->PostTask(
134 FROM_HERE, 134 FROM_HERE,
135 base::Bind(&ReadFileAndCopyToClipboardLocal, screenshot_path_)); 135 base::Bind(&ReadFileAndCopyToClipboardLocal, screenshot_path_));
136 break; 136 break;
137 } 137 }
138 case BUTTON_ANNOTATE: { 138 case BUTTON_ANNOTATE: {
139 if (chromeos::IsNoteTakingAppAvailable(profile_)) { 139 chromeos::NoteTakingHelper* helper = chromeos::NoteTakingHelper::Get();
140 chromeos::LaunchNoteTakingAppForNewNote(profile_, screenshot_path_); 140 if (helper->IsAppAvailable(profile_)) {
141 helper->LaunchAppForNewNote(profile_, screenshot_path_);
141 content::RecordAction(base::UserMetricsAction("Screenshot_Annotate")); 142 content::RecordAction(base::UserMetricsAction("Screenshot_Annotate"));
142 } 143 }
143 break; 144 break;
144 } 145 }
145 default: 146 default:
146 NOTREACHED() << "Unhandled button index " << button_index; 147 NOTREACHED() << "Unhandled button index " << button_index;
147 } 148 }
148 } 149 }
149 bool HasClickedListener() override { return success_; } 150 bool HasClickedListener() override { return success_; }
150 std::string id() const override { return std::string(kNotificationId); } 151 std::string id() const override { return std::string(kNotificationId); }
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 message_center::RichNotificationData optional_field; 431 message_center::RichNotificationData optional_field;
431 if (success) { 432 if (success) {
432 // The order in which these buttons are added must be reflected by 433 // The order in which these buttons are added must be reflected by
433 // ScreenshotGrabberNotificationDelegate::ButtonIndex. 434 // ScreenshotGrabberNotificationDelegate::ButtonIndex.
434 message_center::ButtonInfo copy_button(l10n_util::GetStringUTF16( 435 message_center::ButtonInfo copy_button(l10n_util::GetStringUTF16(
435 IDS_MESSAGE_CENTER_NOTIFICATION_BUTTON_COPY_SCREENSHOT_TO_CLIPBOARD)); 436 IDS_MESSAGE_CENTER_NOTIFICATION_BUTTON_COPY_SCREENSHOT_TO_CLIPBOARD));
436 copy_button.icon = ui::ResourceBundle::GetSharedInstance().GetImageNamed( 437 copy_button.icon = ui::ResourceBundle::GetSharedInstance().GetImageNamed(
437 IDR_NOTIFICATION_SCREENSHOT_COPY_TO_CLIPBOARD); 438 IDR_NOTIFICATION_SCREENSHOT_COPY_TO_CLIPBOARD);
438 optional_field.buttons.push_back(copy_button); 439 optional_field.buttons.push_back(copy_button);
439 440
440 if (chromeos::IsNoteTakingAppAvailable(GetProfile())) { 441 if (chromeos::NoteTakingHelper::Get()->IsAppAvailable(GetProfile())) {
441 message_center::ButtonInfo annotate_button(l10n_util::GetStringUTF16( 442 message_center::ButtonInfo annotate_button(l10n_util::GetStringUTF16(
442 IDS_MESSAGE_CENTER_NOTIFICATION_BUTTON_ANNOTATE_SCREENSHOT)); 443 IDS_MESSAGE_CENTER_NOTIFICATION_BUTTON_ANNOTATE_SCREENSHOT));
443 annotate_button.icon = 444 annotate_button.icon =
444 ui::ResourceBundle::GetSharedInstance().GetImageNamed( 445 ui::ResourceBundle::GetSharedInstance().GetImageNamed(
445 IDR_NOTIFICATION_SCREENSHOT_ANNOTATE); 446 IDR_NOTIFICATION_SCREENSHOT_ANNOTATE);
446 optional_field.buttons.push_back(annotate_button); 447 optional_field.buttons.push_back(annotate_button);
447 } 448 }
448 } 449 }
449 450
450 return new Notification( 451 return new Notification(
(...skipping 13 matching lines...) Expand all
464 } 465 }
465 466
466 void ChromeScreenshotGrabber::SetProfileForTest(Profile* profile) { 467 void ChromeScreenshotGrabber::SetProfileForTest(Profile* profile) {
467 profile_for_test_ = profile; 468 profile_for_test_ = profile;
468 } 469 }
469 470
470 Profile* ChromeScreenshotGrabber::GetProfile() { 471 Profile* ChromeScreenshotGrabber::GetProfile() {
471 return profile_for_test_ ? profile_for_test_ 472 return profile_for_test_ ? profile_for_test_
472 : ProfileManager::GetActiveUserProfile(); 473 : ProfileManager::GetActiveUserProfile();
473 } 474 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698