Make USB permissions work in the new permission message system
[chromium-blink-merge.git] / content / child / appcache / appcache_frontend_impl.cc
blob76b4b1f4e54626fad136e6f4832ed7642251e0b7
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.
5 #include "content/child/appcache/appcache_frontend_impl.h"
7 #include "base/logging.h"
8 #include "content/child/appcache/web_application_cache_host_impl.h"
9 #include "third_party/WebKit/public/web/WebConsoleMessage.h"
11 using blink::WebApplicationCacheHost;
12 using blink::WebConsoleMessage;
14 namespace content {
16 // Inline helper to keep the lines shorter and unwrapped.
17 inline WebApplicationCacheHostImpl* GetHost(int id) {
18 return WebApplicationCacheHostImpl::FromId(id);
21 void AppCacheFrontendImpl::OnCacheSelected(int host_id,
22 const AppCacheInfo& info) {
23 WebApplicationCacheHostImpl* host = GetHost(host_id);
24 if (host)
25 host->OnCacheSelected(info);
28 void AppCacheFrontendImpl::OnStatusChanged(const std::vector<int>& host_ids,
29 AppCacheStatus status) {
30 for (std::vector<int>::const_iterator i = host_ids.begin();
31 i != host_ids.end(); ++i) {
32 WebApplicationCacheHostImpl* host = GetHost(*i);
33 if (host)
34 host->OnStatusChanged(status);
38 void AppCacheFrontendImpl::OnEventRaised(const std::vector<int>& host_ids,
39 AppCacheEventID event_id) {
40 DCHECK(event_id !=
41 APPCACHE_PROGRESS_EVENT); // See OnProgressEventRaised.
42 DCHECK(event_id != APPCACHE_ERROR_EVENT); // See OnErrorEventRaised.
43 for (std::vector<int>::const_iterator i = host_ids.begin();
44 i != host_ids.end(); ++i) {
45 WebApplicationCacheHostImpl* host = GetHost(*i);
46 if (host)
47 host->OnEventRaised(event_id);
51 void AppCacheFrontendImpl::OnProgressEventRaised(
52 const std::vector<int>& host_ids,
53 const GURL& url,
54 int num_total,
55 int num_complete) {
56 for (std::vector<int>::const_iterator i = host_ids.begin();
57 i != host_ids.end(); ++i) {
58 WebApplicationCacheHostImpl* host = GetHost(*i);
59 if (host)
60 host->OnProgressEventRaised(url, num_total, num_complete);
64 void AppCacheFrontendImpl::OnErrorEventRaised(
65 const std::vector<int>& host_ids,
66 const AppCacheErrorDetails& details) {
67 for (std::vector<int>::const_iterator i = host_ids.begin();
68 i != host_ids.end(); ++i) {
69 WebApplicationCacheHostImpl* host = GetHost(*i);
70 if (host)
71 host->OnErrorEventRaised(details);
75 void AppCacheFrontendImpl::OnLogMessage(int host_id,
76 AppCacheLogLevel log_level,
77 const std::string& message) {
78 WebApplicationCacheHostImpl* host = GetHost(host_id);
79 if (host)
80 host->OnLogMessage(log_level, message);
83 void AppCacheFrontendImpl::OnContentBlocked(int host_id,
84 const GURL& manifest_url) {
85 WebApplicationCacheHostImpl* host = GetHost(host_id);
86 if (host)
87 host->OnContentBlocked(manifest_url);
90 // Ensure that enum values never get out of sync with the
91 // ones declared for use within the WebKit api
93 #define STATIC_ASSERT_ENUM(a, b, desc) \
94 static_assert((int)a == (int)b, desc)
96 // Confirm that WebApplicationCacheHost::<a> == APPCACHE_<b>.
97 #define STATIC_ASSERT_WAC_ENUM(a, b) \
98 STATIC_ASSERT_ENUM(WebApplicationCacheHost:: a, APPCACHE_##b, #a)
100 STATIC_ASSERT_WAC_ENUM(Uncached, STATUS_UNCACHED);
101 STATIC_ASSERT_WAC_ENUM(Idle, STATUS_IDLE);
102 STATIC_ASSERT_WAC_ENUM(Checking, STATUS_CHECKING);
103 STATIC_ASSERT_WAC_ENUM(Downloading, STATUS_DOWNLOADING);
104 STATIC_ASSERT_WAC_ENUM(UpdateReady, STATUS_UPDATE_READY);
105 STATIC_ASSERT_WAC_ENUM(Obsolete, STATUS_OBSOLETE);
107 STATIC_ASSERT_WAC_ENUM(CheckingEvent, CHECKING_EVENT);
108 STATIC_ASSERT_WAC_ENUM(ErrorEvent, ERROR_EVENT);
109 STATIC_ASSERT_WAC_ENUM(NoUpdateEvent, NO_UPDATE_EVENT);
110 STATIC_ASSERT_WAC_ENUM(DownloadingEvent, DOWNLOADING_EVENT);
111 STATIC_ASSERT_WAC_ENUM(ProgressEvent, PROGRESS_EVENT);
112 STATIC_ASSERT_WAC_ENUM(UpdateReadyEvent, UPDATE_READY_EVENT);
113 STATIC_ASSERT_WAC_ENUM(CachedEvent, CACHED_EVENT);
114 STATIC_ASSERT_WAC_ENUM(ObsoleteEvent, OBSOLETE_EVENT);
116 STATIC_ASSERT_WAC_ENUM(ManifestError, MANIFEST_ERROR);
117 STATIC_ASSERT_WAC_ENUM(SignatureError, SIGNATURE_ERROR);
118 STATIC_ASSERT_WAC_ENUM(ResourceError, RESOURCE_ERROR);
119 STATIC_ASSERT_WAC_ENUM(ChangedError, CHANGED_ERROR);
120 STATIC_ASSERT_WAC_ENUM(AbortError, ABORT_ERROR);
121 STATIC_ASSERT_WAC_ENUM(QuotaError, QUOTA_ERROR);
122 STATIC_ASSERT_WAC_ENUM(PolicyError, POLICY_ERROR);
123 STATIC_ASSERT_WAC_ENUM(UnknownError, UNKNOWN_ERROR);
125 // Confirm that WebConsoleMessage::<a> == APPCACHE_<b>.
126 #define STATIC_ASSERT_WCM_ENUM(a, b) \
127 STATIC_ASSERT_ENUM(WebConsoleMessage:: a, APPCACHE_##b, #a)
129 STATIC_ASSERT_WCM_ENUM(LevelDebug, LOG_DEBUG);
130 STATIC_ASSERT_WCM_ENUM(LevelLog, LOG_INFO);
131 STATIC_ASSERT_WCM_ENUM(LevelWarning, LOG_WARNING);
132 STATIC_ASSERT_WCM_ENUM(LevelError, LOG_ERROR);
134 } // namespace content