| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/options/options_ui.h" | 5 #include "chrome/browser/ui/webui/options/options_ui.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 int render_process_id, | 137 int render_process_id, |
| 138 int render_frame_id, | 138 int render_frame_id, |
| 139 const content::URLDataSource::GotDataCallback& callback) override; | 139 const content::URLDataSource::GotDataCallback& callback) override; |
| 140 std::string GetMimeType(const std::string&) const override; | 140 std::string GetMimeType(const std::string&) const override; |
| 141 bool ShouldDenyXFrameOptions() const override; | 141 bool ShouldDenyXFrameOptions() const override; |
| 142 | 142 |
| 143 private: | 143 private: |
| 144 ~OptionsUIHTMLSource() override; | 144 ~OptionsUIHTMLSource() override; |
| 145 | 145 |
| 146 // Localized strings collection. | 146 // Localized strings collection. |
| 147 scoped_ptr<base::DictionaryValue> localized_strings_; | 147 std::unique_ptr<base::DictionaryValue> localized_strings_; |
| 148 | 148 |
| 149 DISALLOW_COPY_AND_ASSIGN(OptionsUIHTMLSource); | 149 DISALLOW_COPY_AND_ASSIGN(OptionsUIHTMLSource); |
| 150 }; | 150 }; |
| 151 | 151 |
| 152 OptionsUIHTMLSource::OptionsUIHTMLSource( | 152 OptionsUIHTMLSource::OptionsUIHTMLSource( |
| 153 base::DictionaryValue* localized_strings) { | 153 base::DictionaryValue* localized_strings) { |
| 154 DCHECK(localized_strings); | 154 DCHECK(localized_strings); |
| 155 localized_strings_.reset(localized_strings); | 155 localized_strings_.reset(localized_strings); |
| 156 } | 156 } |
| 157 | 157 |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 pointer_device_observer_->AddObserver(pointer_handler); | 384 pointer_device_observer_->AddObserver(pointer_handler); |
| 385 #endif | 385 #endif |
| 386 } | 386 } |
| 387 | 387 |
| 388 OptionsUI::~OptionsUI() { | 388 OptionsUI::~OptionsUI() { |
| 389 // Uninitialize all registered handlers. Deleted by WebUIImpl. | 389 // Uninitialize all registered handlers. Deleted by WebUIImpl. |
| 390 for (size_t i = 0; i < handlers_.size(); ++i) | 390 for (size_t i = 0; i < handlers_.size(); ++i) |
| 391 handlers_[i]->Uninitialize(); | 391 handlers_[i]->Uninitialize(); |
| 392 } | 392 } |
| 393 | 393 |
| 394 scoped_ptr<OptionsUI::OnFinishedLoadingCallbackList::Subscription> | 394 std::unique_ptr<OptionsUI::OnFinishedLoadingCallbackList::Subscription> |
| 395 OptionsUI::RegisterOnFinishedLoadingCallback(const base::Closure& callback) { | 395 OptionsUI::RegisterOnFinishedLoadingCallback(const base::Closure& callback) { |
| 396 return on_finished_loading_callbacks_.Add(callback); | 396 return on_finished_loading_callbacks_.Add(callback); |
| 397 } | 397 } |
| 398 | 398 |
| 399 // static | 399 // static |
| 400 void OptionsUI::ProcessAutocompleteSuggestions( | 400 void OptionsUI::ProcessAutocompleteSuggestions( |
| 401 const AutocompleteResult& result, | 401 const AutocompleteResult& result, |
| 402 base::ListValue* const suggestions) { | 402 base::ListValue* const suggestions) { |
| 403 for (size_t i = 0; i < result.size(); ++i) { | 403 for (size_t i = 0; i < result.size(); ++i) { |
| 404 const AutocompleteMatch& match = result.match_at(i); | 404 const AutocompleteMatch& match = result.match_at(i); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 "BrowserOptions.notifyInitializationComplete"); | 480 "BrowserOptions.notifyInitializationComplete"); |
| 481 } | 481 } |
| 482 | 482 |
| 483 void OptionsUI::OnFinishedLoading() { | 483 void OptionsUI::OnFinishedLoading() { |
| 484 on_finished_loading_callbacks_.Notify(); | 484 on_finished_loading_callbacks_.Notify(); |
| 485 } | 485 } |
| 486 | 486 |
| 487 void OptionsUI::AddOptionsPageUIHandler( | 487 void OptionsUI::AddOptionsPageUIHandler( |
| 488 base::DictionaryValue* localized_strings, | 488 base::DictionaryValue* localized_strings, |
| 489 OptionsPageUIHandler* handler_raw) { | 489 OptionsPageUIHandler* handler_raw) { |
| 490 scoped_ptr<OptionsPageUIHandler> handler(handler_raw); | 490 std::unique_ptr<OptionsPageUIHandler> handler(handler_raw); |
| 491 DCHECK(handler.get()); | 491 DCHECK(handler.get()); |
| 492 // Add only if handler's service is enabled. | 492 // Add only if handler's service is enabled. |
| 493 if (handler->IsEnabled()) { | 493 if (handler->IsEnabled()) { |
| 494 // Add handler to the list and also pass the ownership. | 494 // Add handler to the list and also pass the ownership. |
| 495 web_ui()->AddMessageHandler(handler.release()); | 495 web_ui()->AddMessageHandler(handler.release()); |
| 496 handler_raw->GetLocalizedValues(localized_strings); | 496 handler_raw->GetLocalizedValues(localized_strings); |
| 497 handlers_.push_back(handler_raw); | 497 handlers_.push_back(handler_raw); |
| 498 } | 498 } |
| 499 } | 499 } |
| 500 | 500 |
| 501 } // namespace options | 501 } // namespace options |
| OLD | NEW |