| OLD | NEW |
| 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 "chrome/browser/chooser_controller/mock_chooser_controller.h" | 5 #include "chrome/browser/chooser_controller/mock_chooser_controller.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/grit/generated_resources.h" | 9 #include "chrome/grit/generated_resources.h" |
| 10 #include "ui/base/l10n/l10n_util.h" | 10 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 if (view()) { | 82 if (view()) { |
| 83 view()->OnRefreshStateChanged( | 83 view()->OnRefreshStateChanged( |
| 84 false /* Refreshing options is complete */); | 84 false /* Refreshing options is complete */); |
| 85 } | 85 } |
| 86 break; | 86 break; |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 | 89 |
| 90 void MockChooserController::OptionAdded(const base::string16 option_name) { | 90 void MockChooserController::OptionAdded(const base::string16 option_name) { |
| 91 option_names_.push_back(option_name); | 91 option_names_.push_back(option_name); |
| 92 if (view()) | 92 if (view()) { |
| 93 view()->OnOptionAdded(option_names_.size() - 1); | 93 view()->OnOptionAdded(option_names_.size() - 1); |
| 94 if (option_names_.size() == 1) |
| 95 view()->OnOptionAvailableDuringRefresh(); |
| 96 } |
| 94 } | 97 } |
| 95 | 98 |
| 96 void MockChooserController::OptionRemoved(const base::string16 option_name) { | 99 void MockChooserController::OptionRemoved(const base::string16 option_name) { |
| 97 for (auto it = option_names_.begin(); it != option_names_.end(); ++it) { | 100 for (auto it = option_names_.begin(); it != option_names_.end(); ++it) { |
| 98 if (*it == option_name) { | 101 if (*it == option_name) { |
| 99 size_t index = it - option_names_.begin(); | 102 size_t index = it - option_names_.begin(); |
| 100 option_names_.erase(it); | 103 option_names_.erase(it); |
| 101 if (view()) | 104 if (view()) |
| 102 view()->OnOptionRemoved(index); | 105 view()->OnOptionRemoved(index); |
| 103 return; | 106 return; |
| 104 } | 107 } |
| 105 } | 108 } |
| 106 } | 109 } |
| 107 | 110 |
| 108 void MockChooserController::ClearAllOptions() { | 111 void MockChooserController::ClearAllOptions() { |
| 109 option_names_.clear(); | 112 option_names_.clear(); |
| 110 } | 113 } |
| OLD | NEW |