Make hitting "Enter" submit the add/change profile dialog.
[chromium-blink-merge.git] / chrome / test / webdriver / frame_path.cc
blob2335d0bc2443507aba3bbfb73d4fc546e4e9b604
1 // Copyright (c) 2011 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.
5 #include "chrome/test/webdriver/frame_path.h"
7 #include "base/string_split.h"
9 namespace webdriver {
11 FramePath::FramePath() : path_("") {}
13 FramePath::FramePath(const FramePath& other) : path_(other.path_) {}
15 FramePath::FramePath(const std::string& path) : path_(path) {}
17 FramePath::~FramePath() {}
19 FramePath& FramePath::operator=(const FramePath& other) {
20 path_ = other.path_;
21 return *this;
24 bool FramePath::operator==(const FramePath& other) const {
25 return path_ == other.path_;
28 FramePath FramePath::Append(const FramePath& path) const {
29 return Append(path.path_);
32 FramePath FramePath::Append(const std::string& path) const {
33 // An empty path refers to the root frame, so just return it.
34 if (path.empty())
35 return *this;
37 // Don't append a separator if the current path is empty.
38 std::string new_path = path_;
39 if (path_.length())
40 new_path += "\n";
41 return FramePath(new_path + path);
44 FramePath FramePath::Parent() const {
45 size_t i = path_.find_last_of("\n");
46 if (i != std::string::npos)
47 return FramePath(path_.substr(0, i));
48 return FramePath();
51 FramePath FramePath::BaseName() const {
52 size_t i = path_.find_last_of("\n");
53 if (i != std::string::npos)
54 return FramePath(path_.substr(i + 1));
55 return *this;
58 void FramePath::GetComponents(std::vector<std::string>* components) const {
59 if (IsSubframe())
60 base::SplitString(path_, '\n', components);
63 bool FramePath::IsRootFrame() const {
64 return path_.empty();
67 bool FramePath::IsSubframe() const {
68 return path_.length();
71 const std::string& FramePath::value() const {
72 return path_;
75 } // namespace webdriver