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

Unified Diff: chrome/browser/extensions/extension_clipboard_api.cc

Issue 882003: Implement chrome.experimental.clipboard extension API. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 10 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_clipboard_api.cc
===================================================================
--- chrome/browser/extensions/extension_clipboard_api.cc (revision 0)
+++ chrome/browser/extensions/extension_clipboard_api.cc (revision 0)
@@ -0,0 +1,53 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/extensions/extension_clipboard_api.h"
+
+#include "base/string_util.h"
+#include "base/values.h"
+#include "chrome/browser/extensions/extension_tabs_module.h"
+#include "chrome/browser/renderer_host/render_view_host.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/common/extensions/extension_error_utils.h"
+
+namespace {
+// Errors.
+const char kNoTabError[] = "No tab with id: *.";
+}
+
+bool ClipboardFunction::RunImpl() {
+ int tab_id;
+ EXTENSION_FUNCTION_VALIDATE(args_->GetAsInteger(&tab_id));
+
+ TabContents* contents = NULL;
+ if (!ExtensionTabUtil::GetTabById(tab_id, profile(), include_incognito(),
+ NULL, NULL, &contents, NULL)) {
+ error_ = ExtensionErrorUtils::FormatErrorMessage(kNoTabError,
+ IntToString(tab_id));
+ return false;
+ }
+
+ RenderViewHost* render_view_host = contents->render_view_host();
+ if (!render_view_host) {
+ return false;
+ }
+
+ return RunImpl(render_view_host);
+}
+
+bool ExecuteCopyClipboardFunction::RunImpl(RenderViewHost* render_view_host) {
+ render_view_host->Copy();
+ return true;
+}
+
+bool ExecuteCutClipboardFunction::RunImpl(RenderViewHost* render_view_host) {
+ render_view_host->Cut();
+ return true;
+}
+
+bool ExecutePasteClipboardFunction::RunImpl(RenderViewHost* render_view_host) {
+ render_view_host->Paste();
+ return true;
+}
+
Property changes on: chrome\browser\extensions\extension_clipboard_api.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « chrome/browser/extensions/extension_clipboard_api.h ('k') | chrome/browser/extensions/extension_clipboard_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698