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

Side by Side Diff: ui/views/mus/clipboard_mus.cc

Issue 2503063003: Add service name constant for UI service. (Closed)
Patch Set: . Created 4 years, 1 month 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
« no previous file with comments | « ui/ozone/platform/drm/cursor_proxy_mojo.cc ('k') | ui/views/mus/input_method_mus.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 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 #include "ui/views/mus/clipboard_mus.h" 5 #include "ui/views/mus/clipboard_mus.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "mojo/common/common_type_converters.h" 14 #include "mojo/common/common_type_converters.h"
15 #include "mojo/public/cpp/bindings/sync_call_restrictions.h" 15 #include "mojo/public/cpp/bindings/sync_call_restrictions.h"
16 #include "services/service_manager/public/cpp/connector.h" 16 #include "services/service_manager/public/cpp/connector.h"
17 #include "services/ui/public/interfaces/constants.mojom.h"
17 #include "third_party/skia/include/core/SkBitmap.h" 18 #include "third_party/skia/include/core/SkBitmap.h"
18 #include "ui/base/clipboard/custom_data_helper.h" 19 #include "ui/base/clipboard/custom_data_helper.h"
19 #include "ui/gfx/codec/png_codec.h" 20 #include "ui/gfx/codec/png_codec.h"
20 21
21 namespace views { 22 namespace views {
22 namespace { 23 namespace {
23 24
24 ui::mojom::Clipboard::Type GetType(ui::ClipboardType type) { 25 ui::mojom::Clipboard::Type GetType(ui::ClipboardType type) {
25 switch (type) { 26 switch (type) {
26 case ui::CLIPBOARD_TYPE_COPY_PASTE: 27 case ui::CLIPBOARD_TYPE_COPY_PASTE:
(...skipping 12 matching lines...) Expand all
39 // The source URL of copied HTML. 40 // The source URL of copied HTML.
40 const char kInternalSourceURL[] = "chromium/internal-url"; 41 const char kInternalSourceURL[] = "chromium/internal-url";
41 42
42 } // namespace 43 } // namespace
43 44
44 ClipboardMus::ClipboardMus() {} 45 ClipboardMus::ClipboardMus() {}
45 46
46 ClipboardMus::~ClipboardMus() {} 47 ClipboardMus::~ClipboardMus() {}
47 48
48 void ClipboardMus::Init(service_manager::Connector* connector) { 49 void ClipboardMus::Init(service_manager::Connector* connector) {
49 connector->ConnectToInterface("ui", &clipboard_); 50 connector->ConnectToInterface(ui::mojom::kServiceName, &clipboard_);
50 } 51 }
51 52
52 // TODO(erg): This isn't optimal. It would be better to move the entire 53 // TODO(erg): This isn't optimal. It would be better to move the entire
53 // FormatType system to mime types throughout chrome, but that's a very large 54 // FormatType system to mime types throughout chrome, but that's a very large
54 // change. 55 // change.
55 mojo::String ClipboardMus::GetMimeTypeFor(const FormatType& format) { 56 mojo::String ClipboardMus::GetMimeTypeFor(const FormatType& format) {
56 if (format.Equals(GetUrlFormatType()) || format.Equals(GetUrlWFormatType())) 57 if (format.Equals(GetUrlFormatType()) || format.Equals(GetUrlWFormatType()))
57 return ui::mojom::kMimeTypeURIList; 58 return ui::mojom::kMimeTypeURIList;
58 if (format.Equals(GetMozUrlFormatType())) 59 if (format.Equals(GetMozUrlFormatType()))
59 return ui::mojom::kMimeTypeMozillaURL; 60 return ui::mojom::kMimeTypeMozillaURL;
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 void ClipboardMus::WriteData(const FormatType& format, 336 void ClipboardMus::WriteData(const FormatType& format,
336 const char* data_data, 337 const char* data_data,
337 size_t data_len) { 338 size_t data_len) {
338 DCHECK(current_clipboard_); 339 DCHECK(current_clipboard_);
339 current_clipboard_->insert( 340 current_clipboard_->insert(
340 GetMimeTypeFor(format), 341 GetMimeTypeFor(format),
341 mojo::Array<uint8_t>::From(base::StringPiece(data_data, data_len))); 342 mojo::Array<uint8_t>::From(base::StringPiece(data_data, data_len)));
342 } 343 }
343 344
344 } // namespace views 345 } // namespace views
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/cursor_proxy_mojo.cc ('k') | ui/views/mus/input_method_mus.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698