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