Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / ui / app_list / test / app_list_test_view_delegate.cc
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 "ui/app_list/test/app_list_test_view_delegate.h"
6
7 #include <string>
8
9 #include "base/callback.h"
10 #include "base/files/file_path.h"
11 #include "ui/app_list/app_list_model.h"
12 #include "ui/app_list/app_list_view_delegate_observer.h"
13 #include "ui/app_list/signin_delegate.h"
14 #include "ui/app_list/test/app_list_test_model.h"
15 #include "ui/gfx/image/image_skia.h"
16
17 namespace app_list {
18 namespace test {
19
20 class TestSigninDelegate : public SigninDelegate {
21  public:
22   TestSigninDelegate() : signed_in_(true) {}
23
24   void set_signed_in(bool signed_in) { signed_in_ = signed_in; }
25
26   // SigninDelegate overrides:
27   virtual bool NeedSignin() OVERRIDE { return !signed_in_; }
28   virtual void ShowSignin() OVERRIDE {}
29   virtual void OpenLearnMore() OVERRIDE {}
30   virtual void OpenSettings() OVERRIDE {}
31
32   virtual base::string16 GetSigninHeading() OVERRIDE {
33     return base::string16();
34   }
35   virtual base::string16 GetSigninText() OVERRIDE { return base::string16(); }
36   virtual base::string16 GetSigninButtonText() OVERRIDE {
37     return base::string16();
38   }
39   virtual base::string16 GetLearnMoreLinkText() OVERRIDE {
40     return base::string16();
41   }
42   virtual base::string16 GetSettingsLinkText() OVERRIDE {
43     return base::string16();
44   }
45
46  private:
47   bool signed_in_;
48
49   DISALLOW_COPY_AND_ASSIGN(TestSigninDelegate);
50 };
51
52 AppListTestViewDelegate::AppListTestViewDelegate()
53     : dismiss_count_(0),
54       open_search_result_count_(0),
55       test_signin_delegate_(new TestSigninDelegate),
56       model_(new AppListTestModel),
57       speech_ui_(SPEECH_RECOGNITION_OFF) {
58 }
59
60 AppListTestViewDelegate::~AppListTestViewDelegate() {}
61
62 void AppListTestViewDelegate::SetSignedIn(bool signed_in) {
63   test_signin_delegate_->set_signed_in(signed_in);
64   FOR_EACH_OBSERVER(AppListViewDelegateObserver,
65                     observers_,
66                     OnProfilesChanged());
67 }
68
69 bool AppListTestViewDelegate::ForceNativeDesktop() const {
70   return false;
71 }
72
73 AppListModel* AppListTestViewDelegate::GetModel() {
74   return model_.get();
75 }
76
77 SigninDelegate* AppListTestViewDelegate::GetSigninDelegate() {
78   return test_signin_delegate_.get();
79 }
80
81 SpeechUIModel* AppListTestViewDelegate::GetSpeechUI() {
82   return &speech_ui_;
83 }
84
85 void AppListTestViewDelegate::GetShortcutPathForApp(
86     const std::string& app_id,
87     const base::Callback<void(const base::FilePath&)>& callback) {
88   callback.Run(base::FilePath());
89 }
90
91 void AppListTestViewDelegate::OpenSearchResult(SearchResult* result,
92                                                bool auto_launch,
93                                                int event_flags) {
94   ++open_search_result_count_;
95 }
96
97 base::TimeDelta AppListTestViewDelegate::GetAutoLaunchTimeout() {
98   return auto_launch_timeout_;
99 }
100
101 void AppListTestViewDelegate::AutoLaunchCanceled() {
102   auto_launch_timeout_ = base::TimeDelta();
103 }
104
105 void AppListTestViewDelegate::Dismiss() {
106   ++dismiss_count_;
107 }
108
109 gfx::ImageSkia AppListTestViewDelegate::GetWindowIcon() {
110   return gfx::ImageSkia();
111 }
112
113 content::WebContents* AppListTestViewDelegate::GetStartPageContents() {
114   return NULL;
115 }
116
117 content::WebContents* AppListTestViewDelegate::GetSpeechRecognitionContents() {
118   return NULL;
119 }
120
121 const AppListViewDelegate::Users& AppListTestViewDelegate::GetUsers() const {
122   return users_;
123 }
124
125 void AppListTestViewDelegate::ReplaceTestModel(int item_count) {
126   model_.reset(new AppListTestModel);
127   model_->PopulateApps(item_count);
128 }
129
130 void AppListTestViewDelegate::AddObserver(
131     AppListViewDelegateObserver* observer) {
132   observers_.AddObserver(observer);
133 }
134
135 void AppListTestViewDelegate::RemoveObserver(
136     AppListViewDelegateObserver* observer) {
137   observers_.RemoveObserver(observer);
138 }
139
140 }  // namespace test
141 }  // namespace app_list