Index: chrome/browser/ui/webui/options2/options_ui2.cc |
=================================================================== |
--- chrome/browser/ui/webui/options2/options_ui2.cc (revision 117871) |
+++ chrome/browser/ui/webui/options2/options_ui2.cc (working copy) |
@@ -42,6 +42,7 @@ |
#include "chrome/common/time_format.h" |
#include "chrome/common/url_constants.h" |
#include "content/browser/renderer_host/render_view_host.h" |
+#include "content/browser/webui/web_ui.h" |
#include "content/public/browser/browser_thread.h" |
#include "content/public/browser/notification_types.h" |
#include "content/public/browser/web_contents.h" |
@@ -196,8 +197,8 @@ |
// |
//////////////////////////////////////////////////////////////////////////////// |
-OptionsUI::OptionsUI(WebContents* contents) |
- : WebUI(contents, this), |
+OptionsUI::OptionsUI(WebUI* web_ui) |
+ : WebUIController(web_ui), |
initialized_handlers_(false) { |
DictionaryValue* localized_strings = new DictionaryValue(); |
@@ -272,7 +273,8 @@ |
new OptionsUIHTMLSource(localized_strings); |
// Set up the chrome://settings-frame/ source. |
- Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); |
+ Profile* profile = Profile::FromBrowserContext( |
+ web_ui->web_contents()->GetBrowserContext()); |
profile->GetChromeURLDataManager()->AddDataSource(html_source); |
// Set up the chrome://theme/ source. |
@@ -290,11 +292,8 @@ |
OptionsUI::~OptionsUI() { |
// Uninitialize all registered handlers. The base class owns them and it will |
// eventually delete them. Skip over the generic handler. |
- for (std::vector<WebUIMessageHandler*>::iterator iter = handlers_.begin() + 1; |
- iter != handlers_.end(); |
- ++iter) { |
- static_cast<OptionsPageUIHandler*>(*iter)->Uninitialize(); |
- } |
+ for (size_t i = 0; i < handlers_.size(); ++i) |
+ handlers_[i]->Uninitialize(); |
} |
void OptionsUI::RenderViewCreated(RenderViewHost* render_view_host) { |
@@ -312,7 +311,7 @@ |
// won't fire to initilize the handlers. To make sure initialization always |
// happens, call reinitializeCore (which is a no-op unless the DOM was already |
// initialized). |
- CallJavascriptFunction("OptionsPage.reinitializeCore"); |
+ web_ui()->CallJavascriptFunction("OptionsPage.reinitializeCore"); |
} |
// static |
@@ -322,8 +321,8 @@ |
} |
void OptionsUI::InitializeHandlers() { |
- Profile* profile = |
- Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
+ Profile* profile = Profile::FromBrowserContext( |
+ web_ui()->web_contents()->GetBrowserContext()); |
DCHECK(!profile->IsOffTheRecord() || Profile::IsGuestSession()); |
// The reinitialize call from DidBecomeActiveForReusedRenderView end up being |
@@ -335,10 +334,8 @@ |
initialized_handlers_ = true; |
std::vector<WebUIMessageHandler*>::iterator iter; |
- // Skip over the generic handler. |
- for (iter = handlers_.begin() + 1; iter != handlers_.end(); ++iter) { |
- (static_cast<OptionsPageUIHandler*>(*iter))->Initialize(); |
- } |
+ for (size_t i = 0; i < handlers_.size(); ++i) |
+ handlers_[i]->Initialize(); |
} |
void OptionsUI::AddOptionsPageUIHandler(DictionaryValue* localized_strings, |
@@ -349,7 +346,8 @@ |
if (handler->IsEnabled()) { |
handler->GetLocalizedValues(localized_strings); |
// Add handler to the list and also pass the ownership. |
- AddMessageHandler(handler.release()); |
+ web_ui()->AddMessageHandler(handler.release()); |
+ handlers_.push_back(handler_raw); |
} |
} |