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

Side by Side Diff: extensions/browser/api/clipboard/clipboard_api.h

Issue 2379573008: Add SetImageData api to chrome.clipboard. (Closed)
Patch Set: Address code review comments and add test cases. 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 (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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 #ifndef EXTENSIONS_BROWSER_API_CLIPBOARD_CLIPBOARD_API_H_ 5 #ifndef EXTENSIONS_BROWSER_API_CLIPBOARD_CLIPBOARD_API_H_
6 #define EXTENSIONS_BROWSER_API_CLIPBOARD_CLIPBOARD_API_H_ 6 #define EXTENSIONS_BROWSER_API_CLIPBOARD_CLIPBOARD_API_H_
7 7
8 #include "extensions/browser/browser_context_keyed_api_factory.h" 8 #include "extensions/browser/browser_context_keyed_api_factory.h"
9 #include "extensions/browser/extension_function.h" 9 #include "extensions/browser/extension_function.h"
10 #include "extensions/common/api/clipboard.h"
10 #include "ui/base/clipboard/clipboard_observer.h" 11 #include "ui/base/clipboard/clipboard_observer.h"
11 12
12 namespace extensions { 13 namespace extensions {
13 14
15 namespace clipboard = api::clipboard;
Devlin 2016/12/09 15:23:53 See comment here. https://codereview.chromium.org
jennyz 2016/12/14 01:15:36 Done.
16
14 class ClipboardAPI : public BrowserContextKeyedAPI, 17 class ClipboardAPI : public BrowserContextKeyedAPI,
15 public ui::ClipboardObserver { 18 public ui::ClipboardObserver {
16 public: 19 public:
17 explicit ClipboardAPI(content::BrowserContext* context); 20 explicit ClipboardAPI(content::BrowserContext* context);
18 ~ClipboardAPI() override; 21 ~ClipboardAPI() override;
19 22
20 // BrowserContextKeyedAPI implementation. 23 // BrowserContextKeyedAPI implementation.
21 static BrowserContextKeyedAPIFactory<ClipboardAPI>* GetFactoryInstance(); 24 static BrowserContextKeyedAPIFactory<ClipboardAPI>* GetFactoryInstance();
22 25
23 // ui::ClipboardObserver implementation. 26 // ui::ClipboardObserver implementation.
24 void OnClipboardDataChanged() override; 27 void OnClipboardDataChanged() override;
25 28
26 private: 29 private:
27 friend class BrowserContextKeyedAPIFactory<ClipboardAPI>; 30 friend class BrowserContextKeyedAPIFactory<ClipboardAPI>;
28 31
29 // BrowserContextKeyedAPI implementation. 32 // BrowserContextKeyedAPI implementation.
30 static const char* service_name() { return "ClipboardAPI"; } 33 static const char* service_name() { return "ClipboardAPI"; }
31 34
32 content::BrowserContext* const browser_context_; 35 content::BrowserContext* const browser_context_;
33 }; 36 };
34 37
38 class ClipboardSetImageDataFunction : public UIThreadExtensionFunction {
39 public:
40 DECLARE_EXTENSION_FUNCTION("clipboard.setImageData", CLIPBOARD_SETIMAGEDATA);
41
42 protected:
43 ~ClipboardSetImageDataFunction() override;
44 ResponseAction Run() override;
45
46 void SaveImageData(const std::vector<char>& image_data,
47 clipboard::ImageType type);
48 void OnSaveImageDataSuccess();
49 void OnSaveImageDataError();
50 };
51
35 } // namespace extensions 52 } // namespace extensions
36 53
37 #endif // EXTENSIONS_BROWSER_API_CLIPBOARD_CLIPBOARD_API_H_ 54 #endif // EXTENSIONS_BROWSER_API_CLIPBOARD_CLIPBOARD_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698