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

Side by Side Diff: chrome/browser/ui/webui/extensions/extension_loader_handler.cc

Issue 2648803002: Convert ExtensionLoaderHandler to use the new navigation callbacks. (Closed)
Patch Set: use GetReloadType Created 3 years, 11 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 | « chrome/browser/ui/webui/extensions/extension_loader_handler.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 "chrome/browser/ui/webui/extensions/extension_loader_handler.h" 5 #include "chrome/browser/ui/webui/extensions/extension_loader_handler.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "chrome/browser/extensions/path_util.h" 17 #include "chrome/browser/extensions/path_util.h"
18 #include "chrome/browser/extensions/unpacked_installer.h" 18 #include "chrome/browser/extensions/unpacked_installer.h"
19 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/grit/generated_resources.h" 20 #include "chrome/grit/generated_resources.h"
21 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
22 #include "content/public/browser/navigation_handle.h"
22 #include "content/public/browser/web_contents.h" 23 #include "content/public/browser/web_contents.h"
23 #include "content/public/browser/web_ui.h" 24 #include "content/public/browser/web_ui.h"
24 #include "content/public/browser/web_ui_data_source.h" 25 #include "content/public/browser/web_ui_data_source.h"
25 #include "extensions/browser/extension_system.h" 26 #include "extensions/browser/extension_system.h"
26 #include "extensions/browser/file_highlighter.h" 27 #include "extensions/browser/file_highlighter.h"
27 #include "extensions/common/constants.h" 28 #include "extensions/common/constants.h"
28 #include "extensions/common/extension.h" 29 #include "extensions/common/extension.h"
29 #include "extensions/common/manifest_constants.h" 30 #include "extensions/common/manifest_constants.h"
30 #include "third_party/re2/src/re2/re2.h" 31 #include "third_party/re2/src/re2/re2.h"
31 #include "ui/base/l10n/l10n_util.h" 32 #include "ui/base/l10n/l10n_util.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 content::BrowserThread::GetBlockingPool(), 163 content::BrowserThread::GetBlockingPool(),
163 FROM_HERE, 164 FROM_HERE,
164 base::Bind(&ReadFileToString, file_path.Append(kManifestFilename)), 165 base::Bind(&ReadFileToString, file_path.Append(kManifestFilename)),
165 base::Bind(&ExtensionLoaderHandler::AddFailure, 166 base::Bind(&ExtensionLoaderHandler::AddFailure,
166 weak_ptr_factory_.GetWeakPtr(), 167 weak_ptr_factory_.GetWeakPtr(),
167 file_path, 168 file_path,
168 error, 169 error,
169 line)); 170 line));
170 } 171 }
171 172
172 void ExtensionLoaderHandler::DidStartNavigationToPendingEntry( 173 void ExtensionLoaderHandler::DidStartNavigation(
173 const GURL& url, 174 content::NavigationHandle* navigation_handle) {
174 content::ReloadType reload_type) { 175 if (!navigation_handle->IsInMainFrame())
176 return;
177
175 // In the event of a page reload, we ensure that the frontend is not notified 178 // In the event of a page reload, we ensure that the frontend is not notified
176 // until the UI finishes loading, so we set |ui_ready_| to false. This is 179 // until the UI finishes loading, so we set |ui_ready_| to false. This is
177 // balanced in HandleDisplayFailures, which is called when the frontend is 180 // balanced in HandleDisplayFailures, which is called when the frontend is
178 // ready to receive failure notifications. 181 // ready to receive failure notifications.
179 if (reload_type != content::ReloadType::NONE) 182 if (navigation_handle->GetReloadType() != content::ReloadType::NONE)
180 ui_ready_ = false; 183 ui_ready_ = false;
181 } 184 }
182 185
183 void ExtensionLoaderHandler::AddFailure( 186 void ExtensionLoaderHandler::AddFailure(
184 const base::FilePath& file_path, 187 const base::FilePath& file_path,
185 const std::string& error, 188 const std::string& error,
186 size_t line_number, 189 size_t line_number,
187 const std::string& manifest) { 190 const std::string& manifest) {
188 failed_paths_.push_back(file_path); 191 failed_paths_.push_back(file_path);
189 base::FilePath prettified_path = path_util::PrettifyPath(file_path); 192 base::FilePath prettified_path = path_util::PrettifyPath(file_path);
(...skipping 17 matching lines...) Expand all
207 NotifyFrontendOfFailure(); 210 NotifyFrontendOfFailure();
208 } 211 }
209 212
210 void ExtensionLoaderHandler::NotifyFrontendOfFailure() { 213 void ExtensionLoaderHandler::NotifyFrontendOfFailure() {
211 web_ui()->CallJavascriptFunctionUnsafe( 214 web_ui()->CallJavascriptFunctionUnsafe(
212 "extensions.ExtensionLoader.notifyLoadFailed", failures_); 215 "extensions.ExtensionLoader.notifyLoadFailed", failures_);
213 failures_.Clear(); 216 failures_.Clear();
214 } 217 }
215 218
216 } // namespace extensions 219 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/extensions/extension_loader_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698