Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: content/renderer/manifest/manifest_manager.cc

Issue 2140463002: Remove WebContents::HasManifest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/renderer/manifest/manifest_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/renderer/manifest/manifest_manager.h" 5 #include "content/renderer/manifest/manifest_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/strings/nullable_string16.h" 8 #include "base/strings/nullable_string16.h"
9 #include "content/common/manifest_manager_messages.h" 9 #include "content/common/manifest_manager_messages.h"
10 #include "content/public/renderer/render_frame.h" 10 #include "content/public/renderer/render_frame.h"
(...skipping 20 matching lines...) Expand all
31 // Consumers in the browser process will not receive this message but they 31 // Consumers in the browser process will not receive this message but they
32 // will be aware of the RenderFrame dying and should act on that. Consumers 32 // will be aware of the RenderFrame dying and should act on that. Consumers
33 // in the renderer process should be correctly notified. 33 // in the renderer process should be correctly notified.
34 ResolveCallbacks(ResolveStateFailure); 34 ResolveCallbacks(ResolveStateFailure);
35 } 35 }
36 36
37 bool ManifestManager::OnMessageReceived(const IPC::Message& message) { 37 bool ManifestManager::OnMessageReceived(const IPC::Message& message) {
38 bool handled = true; 38 bool handled = true;
39 39
40 IPC_BEGIN_MESSAGE_MAP(ManifestManager, message) 40 IPC_BEGIN_MESSAGE_MAP(ManifestManager, message)
41 IPC_MESSAGE_HANDLER(ManifestManagerMsg_HasManifest, OnHasManifest)
42 IPC_MESSAGE_HANDLER(ManifestManagerMsg_RequestManifest, OnRequestManifest) 41 IPC_MESSAGE_HANDLER(ManifestManagerMsg_RequestManifest, OnRequestManifest)
43 IPC_MESSAGE_UNHANDLED(handled = false) 42 IPC_MESSAGE_UNHANDLED(handled = false)
44 IPC_END_MESSAGE_MAP() 43 IPC_END_MESSAGE_MAP()
45 44
46 return handled; 45 return handled;
47 } 46 }
48 47
49 void ManifestManager::OnHasManifest(int request_id) {
50 GURL url(render_frame()->GetWebFrame()->document().manifestURL());
51
52 bool has_manifest = may_have_manifest_ && !url.is_empty();
53 Send(new ManifestManagerHostMsg_HasManifestResponse(
54 routing_id(), request_id, has_manifest));
55 }
56
57 void ManifestManager::OnRequestManifest(int request_id) { 48 void ManifestManager::OnRequestManifest(int request_id) {
58 GetManifest(base::Bind(&ManifestManager::OnRequestManifestComplete, 49 GetManifest(base::Bind(&ManifestManager::OnRequestManifestComplete,
59 base::Unretained(this), request_id)); 50 base::Unretained(this), request_id));
60 } 51 }
61 52
62 void ManifestManager::OnRequestManifestComplete(int request_id, 53 void ManifestManager::OnRequestManifestComplete(int request_id,
63 const GURL& manifest_url, 54 const GURL& manifest_url,
64 const Manifest& manifest, 55 const Manifest& manifest,
65 const ManifestDebugInfo&) { 56 const ManifestDebugInfo&) {
66 // When sent via IPC, the Manifest must follow certain security rules. 57 // When sent via IPC, the Manifest must follow certain security rules.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // Just wait for the running call to be done if there are other callbacks. 99 // Just wait for the running call to be done if there are other callbacks.
109 if (pending_callbacks_.size() > 1) 100 if (pending_callbacks_.size() > 1)
110 return; 101 return;
111 102
112 FetchManifest(); 103 FetchManifest();
113 } 104 }
114 105
115 void ManifestManager::DidChangeManifest() { 106 void ManifestManager::DidChangeManifest() {
116 may_have_manifest_ = true; 107 may_have_manifest_ = true;
117 manifest_dirty_ = true; 108 manifest_dirty_ = true;
109 manifest_url_ = GURL();
118 } 110 }
119 111
120 void ManifestManager::DidCommitProvisionalLoad( 112 void ManifestManager::DidCommitProvisionalLoad(
121 bool is_new_navigation, 113 bool is_new_navigation,
122 bool is_same_page_navigation) { 114 bool is_same_page_navigation) {
123 if (is_same_page_navigation) 115 if (is_same_page_navigation)
124 return; 116 return;
125 117
126 may_have_manifest_ = false; 118 may_have_manifest_ = false;
127 manifest_dirty_ = true; 119 manifest_dirty_ = true;
120 manifest_url_ = GURL();
128 } 121 }
129 122
130 void ManifestManager::FetchManifest() { 123 void ManifestManager::FetchManifest() {
131 GURL url(render_frame()->GetWebFrame()->document().manifestURL()); 124 manifest_url_ = render_frame()->GetWebFrame()->document().manifestURL();
132 125
133 if (url.is_empty()) { 126 if (manifest_url_.is_empty()) {
134 ManifestUmaUtil::FetchFailed(ManifestUmaUtil::FETCH_EMPTY_URL); 127 ManifestUmaUtil::FetchFailed(ManifestUmaUtil::FETCH_EMPTY_URL);
135 ResolveCallbacks(ResolveStateFailure); 128 ResolveCallbacks(ResolveStateFailure);
136 return; 129 return;
137 } 130 }
138 131
139 fetcher_.reset(new ManifestFetcher(url)); 132 fetcher_.reset(new ManifestFetcher(manifest_url_));
140 fetcher_->Start( 133 fetcher_->Start(
141 render_frame()->GetWebFrame(), 134 render_frame()->GetWebFrame(),
142 render_frame()->GetWebFrame()->document().manifestUseCredentials(), 135 render_frame()->GetWebFrame()->document().manifestUseCredentials(),
143 base::Bind(&ManifestManager::OnManifestFetchComplete, 136 base::Bind(&ManifestManager::OnManifestFetchComplete,
144 base::Unretained(this), 137 base::Unretained(this),
145 render_frame()->GetWebFrame()->document().url())); 138 render_frame()->GetWebFrame()->document().url()));
146 } 139 }
147 140
148 static const std::string& GetMessagePrefix() { 141 static const std::string& GetMessagePrefix() {
149 CR_DEFINE_STATIC_LOCAL(std::string, message_prefix, ("Manifest: ")); 142 CR_DEFINE_STATIC_LOCAL(std::string, message_prefix, ("Manifest: "));
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 ResolveCallbacks(ResolveStateFailure); 180 ResolveCallbacks(ResolveStateFailure);
188 return; 181 return;
189 } 182 }
190 183
191 manifest_url_ = response.url(); 184 manifest_url_ = response.url();
192 manifest_ = parser.manifest(); 185 manifest_ = parser.manifest();
193 ResolveCallbacks(ResolveStateSuccess); 186 ResolveCallbacks(ResolveStateSuccess);
194 } 187 }
195 188
196 void ManifestManager::ResolveCallbacks(ResolveState state) { 189 void ManifestManager::ResolveCallbacks(ResolveState state) {
197 if (state == ResolveStateFailure) { 190 if (state == ResolveStateFailure)
198 manifest_url_ = GURL();
199 manifest_ = Manifest(); 191 manifest_ = Manifest();
Mike West 2016/07/11 08:14:18 Why don't you need to clear out |manifest_url_| an
dominickn 2016/07/11 10:51:18 It's explicitly meant to not be cleared (it gets r
200 }
201 192
202 manifest_dirty_ = state != ResolveStateSuccess; 193 manifest_dirty_ = state != ResolveStateSuccess;
203 194
204 std::list<GetManifestCallback> callbacks; 195 std::list<GetManifestCallback> callbacks;
205 callbacks.swap(pending_callbacks_); 196 callbacks.swap(pending_callbacks_);
206 197
207 for (std::list<GetManifestCallback>::const_iterator it = callbacks.begin(); 198 for (std::list<GetManifestCallback>::const_iterator it = callbacks.begin();
208 it != callbacks.end(); ++it) { 199 it != callbacks.end(); ++it) {
209 it->Run(manifest_url_, manifest_, manifest_debug_info_); 200 it->Run(manifest_url_, manifest_, manifest_debug_info_);
210 } 201 }
211 } 202 }
212 203
213 void ManifestManager::OnDestruct() { 204 void ManifestManager::OnDestruct() {
214 delete this; 205 delete this;
215 } 206 }
216 207
217 } // namespace content 208 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/manifest/manifest_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698