| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/snapshot_tab_helper.h" | |
| 6 | |
| 7 #include "chrome/common/chrome_notification_types.h" | |
| 8 #include "chrome/common/render_messages.h" | |
| 9 #include "content/public/browser/notification_service.h" | |
| 10 #include "content/public/browser/web_contents.h" | |
| 11 | |
| 12 using content::WebContents; | |
| 13 | |
| 14 DEFINE_WEB_CONTENTS_USER_DATA_KEY(SnapshotTabHelper); | |
| 15 | |
| 16 SnapshotTabHelper::SnapshotTabHelper(WebContents* web_contents) | |
| 17 : content::WebContentsObserver(web_contents) { | |
| 18 } | |
| 19 | |
| 20 SnapshotTabHelper::~SnapshotTabHelper() { | |
| 21 } | |
| 22 | |
| 23 void SnapshotTabHelper::CaptureSnapshot() { | |
| 24 Send(new ChromeViewMsg_CaptureSnapshot(routing_id())); | |
| 25 } | |
| 26 | |
| 27 //////////////////////////////////////////////////////////////////////////////// | |
| 28 // WebContentsObserver overrides | |
| 29 | |
| 30 bool SnapshotTabHelper::OnMessageReceived(const IPC::Message& message) { | |
| 31 bool handled = true; | |
| 32 IPC_BEGIN_MESSAGE_MAP(SnapshotTabHelper, message) | |
| 33 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_Snapshot, OnSnapshot) | |
| 34 IPC_MESSAGE_UNHANDLED(handled = false) | |
| 35 IPC_END_MESSAGE_MAP() | |
| 36 return handled; | |
| 37 } | |
| 38 | |
| 39 //////////////////////////////////////////////////////////////////////////////// | |
| 40 // Internal helpers | |
| 41 | |
| 42 void SnapshotTabHelper::OnSnapshot(const SkBitmap& bitmap) { | |
| 43 content::NotificationService::current()->Notify( | |
| 44 chrome::NOTIFICATION_TAB_SNAPSHOT_TAKEN, | |
| 45 content::Source<WebContents>(web_contents()), | |
| 46 content::Details<const SkBitmap>(&bitmap)); | |
| 47 } | |
| OLD | NEW |