Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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::ReadyToCommitNavigation( |
|
Devlin
2017/01/21 02:01:17
The cheatsheet linked in the bug and the comments
jam
2017/01/21 05:30:56
Generally that's the replacement. In this case, th
jam
2017/01/21 07:17:54
actually, turns out that my change for ContentFavi
| |
| 173 const GURL& url, | 174 content::NavigationHandle* navigation_handle) { |
| 174 content::ReloadType reload_type) { | 175 if (!navigation_handle->IsInMainFrame() || navigation_handle->IsSamePage()) |
|
Devlin
2017/01/21 02:01:17
Why do we need the IsInMainFrame() check? And won
jam
2017/01/21 05:30:56
To keep the same behavior as before, since DidStar
| |
| 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 bool is_reload = ui::PageTransitionCoreTypeIs( |
| 183 navigation_handle->GetPageTransition(), ui::PAGE_TRANSITION_RELOAD); | |
| 184 if (is_reload) | |
| 180 ui_ready_ = false; | 185 ui_ready_ = false; |
| 181 } | 186 } |
| 182 | 187 |
| 183 void ExtensionLoaderHandler::AddFailure( | 188 void ExtensionLoaderHandler::AddFailure( |
| 184 const base::FilePath& file_path, | 189 const base::FilePath& file_path, |
| 185 const std::string& error, | 190 const std::string& error, |
| 186 size_t line_number, | 191 size_t line_number, |
| 187 const std::string& manifest) { | 192 const std::string& manifest) { |
| 188 failed_paths_.push_back(file_path); | 193 failed_paths_.push_back(file_path); |
| 189 base::FilePath prettified_path = path_util::PrettifyPath(file_path); | 194 base::FilePath prettified_path = path_util::PrettifyPath(file_path); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 207 NotifyFrontendOfFailure(); | 212 NotifyFrontendOfFailure(); |
| 208 } | 213 } |
| 209 | 214 |
| 210 void ExtensionLoaderHandler::NotifyFrontendOfFailure() { | 215 void ExtensionLoaderHandler::NotifyFrontendOfFailure() { |
| 211 web_ui()->CallJavascriptFunctionUnsafe( | 216 web_ui()->CallJavascriptFunctionUnsafe( |
| 212 "extensions.ExtensionLoader.notifyLoadFailed", failures_); | 217 "extensions.ExtensionLoader.notifyLoadFailed", failures_); |
| 213 failures_.Clear(); | 218 failures_.Clear(); |
| 214 } | 219 } |
| 215 | 220 |
| 216 } // namespace extensions | 221 } // namespace extensions |
| OLD | NEW |