| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 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 "content/public/common/desktop_media_id.h" | |
| 6 | |
| 7 namespace content { | |
| 8 | |
| 9 // static | |
| 10 DesktopMediaID DesktopMediaID::Parse(const std::string& str) { | |
| 11 if (str == "screen") | |
| 12 return DesktopMediaID(TYPE_SCREEN, 0); | |
| 13 | |
| 14 std::string window_prefix("window:"); | |
| 15 if (StartsWithASCII(str, window_prefix, true)) { | |
| 16 int64 id; | |
| 17 if (!base::StringToInt64(str.substr(window_prefix.size()), &id)) | |
| 18 return DesktopMediaID(TYPE_NONE, 0); | |
| 19 return DesktopMediaID(TYPE_WINDOW, id); | |
| 20 } | |
| 21 | |
| 22 return DesktopMediaID(TYPE_NONE, 0); | |
| 23 } | |
| 24 | |
| 25 std::string DesktopMediaID::ToString() { | |
| 26 switch (type) { | |
| 27 case TYPE_NONE: | |
| 28 NOTREACHED(); | |
| 29 return std::string(); | |
| 30 | |
| 31 case TYPE_SCREEN: | |
| 32 return "screen"; | |
| 33 | |
| 34 case TYPE_WINDOW: | |
| 35 return "window:" + base::Int64ToString(id); | |
| 36 } | |
| 37 NOTREACHED(); | |
| 38 return std::string(); | |
| 39 } | |
| 40 | |
| 41 } // namespace content | |
| OLD | NEW |