OLD | NEW |
| (Empty) |
1 // Copyright 2009 Google Inc. | |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 // you may not use this file except in compliance with the License. | |
5 // You may obtain a copy of the License at | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 // ======================================================================== | |
15 | |
16 #include "omaha/goopdate/app_state_update_available.h" | |
17 #include "omaha/base/debug.h" | |
18 #include "omaha/base/error.h" | |
19 #include "omaha/base/logging.h" | |
20 #include "omaha/goopdate/app_state_waiting_to_download.h" | |
21 #include "omaha/goopdate/model.h" | |
22 #include "omaha/goopdate/server_resource.h" | |
23 #include "omaha/goopdate/string_formatter.h" | |
24 | |
25 namespace omaha { | |
26 | |
27 namespace fsm { | |
28 | |
29 AppStateUpdateAvailable::AppStateUpdateAvailable() | |
30 : AppState(STATE_UPDATE_AVAILABLE) { | |
31 } | |
32 | |
33 void AppStateUpdateAvailable::QueueDownload(App* app) { | |
34 CORE_LOG(L3, (_T("[AppStateUpdateAvailable::QueueDownload][0x%p]"), app)); | |
35 ASSERT1(app); | |
36 | |
37 HRESULT policy_hr = app->CheckGroupPolicy(); | |
38 if (FAILED(policy_hr)) { | |
39 HandleGroupPolicyError(app, policy_hr); | |
40 return; | |
41 } | |
42 | |
43 ChangeState(app, new AppStateWaitingToDownload); | |
44 } | |
45 | |
46 void AppStateUpdateAvailable::QueueDownloadOrInstall(App* app) { | |
47 CORE_LOG(L3, (_T("[AppStateUpdateAvailable::QueueDownloadOrInstall][0x%p]"), | |
48 app)); | |
49 ASSERT1(app); | |
50 | |
51 QueueDownload(app); | |
52 } | |
53 | |
54 void AppStateUpdateAvailable::HandleGroupPolicyError(App* app, HRESULT code) { | |
55 ASSERT1(app); | |
56 ASSERT1(code == GOOPDATE_E_APP_INSTALL_DISABLED_BY_POLICY || | |
57 code == GOOPDATE_E_APP_UPDATE_DISABLED_BY_POLICY); | |
58 CORE_LOG(L1, (_T("[Update available for disabled app][%s]"), | |
59 app->app_guid_string())); | |
60 app->LogTextAppendFormat(_T("Status=%s-disabled"), | |
61 app->is_update() ? _T("update") : _T("install")); | |
62 | |
63 StringFormatter formatter(app->app_bundle()->display_language()); | |
64 CString error_message; | |
65 VERIFY1(SUCCEEDED(formatter.LoadString( | |
66 IDS_APP_INSTALL_DISABLED_BY_GROUP_POLICY, | |
67 &error_message))); | |
68 Error(app, ErrorContext(code), error_message); | |
69 } | |
70 | |
71 } // namespace fsm | |
72 | |
73 } // namespace omaha | |
OLD | NEW |