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 "ui/app_list/test/app_list_test_view_delegate.h" | 5 #include "ui/app_list/test/app_list_test_view_delegate.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "ui/app_list/app_list_model.h" | 11 #include "ui/app_list/app_list_model.h" |
12 #include "ui/app_list/app_list_switches.h" | 12 #include "ui/app_list/app_list_switches.h" |
13 #include "ui/app_list/app_list_view_delegate_observer.h" | 13 #include "ui/app_list/app_list_view_delegate_observer.h" |
14 #include "ui/app_list/signin_delegate.h" | |
15 #include "ui/app_list/test/app_list_test_model.h" | 14 #include "ui/app_list/test/app_list_test_model.h" |
16 #include "ui/gfx/image/image_skia.h" | 15 #include "ui/gfx/image/image_skia.h" |
17 | 16 |
18 namespace app_list { | 17 namespace app_list { |
19 namespace test { | 18 namespace test { |
20 | 19 |
21 class TestSigninDelegate : public SigninDelegate { | |
22 public: | |
23 TestSigninDelegate() : signed_in_(true) {} | |
24 | |
25 void set_signed_in(bool signed_in) { signed_in_ = signed_in; } | |
26 | |
27 // SigninDelegate overrides: | |
28 virtual bool NeedSignin() OVERRIDE { return !signed_in_; } | |
29 virtual void ShowSignin() OVERRIDE {} | |
30 virtual void OpenLearnMore() OVERRIDE {} | |
31 virtual void OpenSettings() OVERRIDE {} | |
32 | |
33 virtual base::string16 GetSigninHeading() OVERRIDE { | |
34 return base::string16(); | |
35 } | |
36 virtual base::string16 GetSigninText() OVERRIDE { return base::string16(); } | |
37 virtual base::string16 GetSigninButtonText() OVERRIDE { | |
38 return base::string16(); | |
39 } | |
40 virtual base::string16 GetLearnMoreLinkText() OVERRIDE { | |
41 return base::string16(); | |
42 } | |
43 virtual base::string16 GetSettingsLinkText() OVERRIDE { | |
44 return base::string16(); | |
45 } | |
46 | |
47 private: | |
48 bool signed_in_; | |
49 | |
50 DISALLOW_COPY_AND_ASSIGN(TestSigninDelegate); | |
51 }; | |
52 | |
53 AppListTestViewDelegate::AppListTestViewDelegate() | 20 AppListTestViewDelegate::AppListTestViewDelegate() |
54 : dismiss_count_(0), | 21 : dismiss_count_(0), |
55 toggle_speech_recognition_count_(0), | 22 toggle_speech_recognition_count_(0), |
56 open_search_result_count_(0), | 23 open_search_result_count_(0), |
57 next_profile_app_count_(0), | 24 next_profile_app_count_(0), |
58 test_signin_delegate_(new TestSigninDelegate), | |
59 model_(new AppListTestModel), | 25 model_(new AppListTestModel), |
60 speech_ui_(SPEECH_RECOGNITION_OFF) { | 26 speech_ui_(SPEECH_RECOGNITION_OFF) { |
61 } | 27 } |
62 | 28 |
63 AppListTestViewDelegate::~AppListTestViewDelegate() {} | 29 AppListTestViewDelegate::~AppListTestViewDelegate() {} |
64 | 30 |
65 void AppListTestViewDelegate::SetSignedIn(bool signed_in) { | |
66 test_signin_delegate_->set_signed_in(signed_in); | |
67 FOR_EACH_OBSERVER(AppListViewDelegateObserver, | |
68 observers_, | |
69 OnProfilesChanged()); | |
70 } | |
71 | |
72 int AppListTestViewDelegate::GetToggleSpeechRecognitionCountAndReset() { | 31 int AppListTestViewDelegate::GetToggleSpeechRecognitionCountAndReset() { |
73 int count = toggle_speech_recognition_count_; | 32 int count = toggle_speech_recognition_count_; |
74 toggle_speech_recognition_count_ = 0; | 33 toggle_speech_recognition_count_ = 0; |
75 return count; | 34 return count; |
76 } | 35 } |
77 | 36 |
78 bool AppListTestViewDelegate::ForceNativeDesktop() const { | 37 bool AppListTestViewDelegate::ForceNativeDesktop() const { |
79 return false; | 38 return false; |
80 } | 39 } |
81 | 40 |
82 void AppListTestViewDelegate::SetProfileByPath( | 41 void AppListTestViewDelegate::SetProfileByPath( |
83 const base::FilePath& profile_path) { | 42 const base::FilePath& profile_path) { |
84 ReplaceTestModel(next_profile_app_count_); | 43 ReplaceTestModel(next_profile_app_count_); |
85 } | 44 } |
86 | 45 |
87 AppListModel* AppListTestViewDelegate::GetModel() { | 46 AppListModel* AppListTestViewDelegate::GetModel() { |
88 return model_.get(); | 47 return model_.get(); |
89 } | 48 } |
90 | 49 |
91 SigninDelegate* AppListTestViewDelegate::GetSigninDelegate() { | |
92 return test_signin_delegate_.get(); | |
93 } | |
94 | |
95 SpeechUIModel* AppListTestViewDelegate::GetSpeechUI() { | 50 SpeechUIModel* AppListTestViewDelegate::GetSpeechUI() { |
96 return &speech_ui_; | 51 return &speech_ui_; |
97 } | 52 } |
98 | 53 |
99 void AppListTestViewDelegate::GetShortcutPathForApp( | 54 void AppListTestViewDelegate::GetShortcutPathForApp( |
100 const std::string& app_id, | 55 const std::string& app_id, |
101 const base::Callback<void(const base::FilePath&)>& callback) { | 56 const base::Callback<void(const base::FilePath&)>& callback) { |
102 callback.Run(base::FilePath()); | 57 callback.Run(base::FilePath()); |
103 } | 58 } |
104 | 59 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 observers_.AddObserver(observer); | 116 observers_.AddObserver(observer); |
162 } | 117 } |
163 | 118 |
164 void AppListTestViewDelegate::RemoveObserver( | 119 void AppListTestViewDelegate::RemoveObserver( |
165 AppListViewDelegateObserver* observer) { | 120 AppListViewDelegateObserver* observer) { |
166 observers_.RemoveObserver(observer); | 121 observers_.RemoveObserver(observer); |
167 } | 122 } |
168 | 123 |
169 } // namespace test | 124 } // namespace test |
170 } // namespace app_list | 125 } // namespace app_list |
OLD | NEW |