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

Unified Diff: ios/chrome/browser/web/error_page_content.mm

Issue 2704383003: Error pages: Break retain cycle NativeContent/StaticHTMLViewController (Closed)
Patch Set: Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/browser/web/error_page_content.h ('k') | ios/chrome/browser/web/error_page_content_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/web/error_page_content.mm
diff --git a/ios/chrome/browser/web/error_page_content.mm b/ios/chrome/browser/web/error_page_content.mm
index fbd846d316c1c82a740d820beddd0463048d2cf7..0fe454398fcf07fc2c03549cfb83f3b1e0d96aac 100644
--- a/ios/chrome/browser/web/error_page_content.mm
+++ b/ios/chrome/browser/web/error_page_content.mm
@@ -6,18 +6,10 @@
#include <memory>
-#import "base/ios/ns_error_util.h"
-#include "base/strings/sys_string_conversions.h"
-#include "base/values.h"
-#include "components/error_page/common/error_page_params.h"
-#include "components/error_page/common/localized_error.h"
-#include "components/grit/components_resources.h"
-#include "ios/chrome/browser/application_context.h"
+#import "base/mac/scoped_nsobject.h"
+#import "ios/chrome/browser/web/error_page_generator.h"
#include "ios/web/public/referrer.h"
-#include "ui/base/l10n/l10n_util.h"
#include "ui/base/page_transition_types.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/base/webui/jstemplate_builder.h"
#include "url/gurl.h"
@implementation ErrorPageContent
@@ -36,52 +28,19 @@
rendererInitiated:YES];
}
-- (void)generateHtml:(HtmlCallback)callback {
- callback(html_.get());
-}
-
- (id)initWithLoader:(id<UrlLoader>)loader
browserState:(web::BrowserState*)browserState
url:(const GURL&)url
error:(NSError*)error
isPost:(BOOL)isPost
isIncognito:(BOOL)isIncognito {
- NSString* badURLString =
- [[error userInfo] objectForKey:NSURLErrorFailingURLStringErrorKey];
- NSError* originalError = base::ios::GetFinalUnderlyingErrorFromError(error);
- NSString* errorDomain = nil;
- int errorCode = 0;
-
- if (originalError) {
- errorDomain = [originalError domain];
- errorCode = [originalError code];
- } else {
- errorDomain = [error domain];
- errorCode = [error code];
- }
- DCHECK(errorCode != 0);
-
- base::DictionaryValue errorStrings;
- error_page::LocalizedError::GetStrings(
- errorCode, base::SysNSStringToUTF8(errorDomain),
- GURL(base::SysNSStringToUTF16(badURLString)), isPost, false, false,
- isIncognito, GetApplicationContext()->GetApplicationLocale(), nullptr,
- &errorStrings);
-
- ui::ScaleFactor scaleFactor =
- ResourceBundle::GetSharedInstance().GetMaxScaleFactor();
-
- const base::StringPiece templateHTML(
- ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
- IDR_NET_ERROR_HTML, scaleFactor));
- if (templateHTML.empty())
- NOTREACHED() << "unable to load template. ID: " << IDR_NET_ERROR_HTML;
- std::string errorHTML = webui::GetTemplatesHtml(
- templateHTML, &errorStrings, "t" /* IDR_NET_ERROR_HTML root id */);
- html_.reset([base::SysUTF8ToNSString(errorHTML) retain]);
+ ErrorPageGenerator* generator =
+ [[[ErrorPageGenerator alloc] initWithError:error
+ isPost:isPost
+ isIncognito:isIncognito] autorelease];
base::scoped_nsobject<StaticHtmlViewController> HTMLViewController(
- [[StaticHtmlViewController alloc] initWithGenerator:self
+ [[StaticHtmlViewController alloc] initWithGenerator:generator
browserState:browserState]);
return [super initWithLoader:loader
staticHTMLViewController:HTMLViewController
« no previous file with comments | « ios/chrome/browser/web/error_page_content.h ('k') | ios/chrome/browser/web/error_page_content_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698