diff options
69 files changed, 647 insertions, 1136 deletions
diff --git a/chrome/browser/chromeos/dom_ui/internet_options_handler.cc b/chrome/browser/chromeos/dom_ui/internet_options_handler.cc index c32defa..bbb370e 100644 --- a/chrome/browser/chromeos/dom_ui/internet_options_handler.cc +++ b/chrome/browser/chromeos/dom_ui/internet_options_handler.cc @@ -104,19 +104,14 @@ void InternetOptionsHandler::CreateModalPopup(views::WindowDelegate* view) { window->Show(); } -void InternetOptionsHandler::ButtonClickCallback(const Value* value) { - if (!value || !value->IsType(Value::TYPE_LIST)) { - NOTREACHED(); - return; - } - const ListValue* list_value = static_cast<const ListValue*>(value); +void InternetOptionsHandler::ButtonClickCallback(const ListValue* args) { std::string str_type; std::string service_path; std::string command; - if (list_value->GetSize() != 3 || - !list_value->GetString(0, &str_type) || - !list_value->GetString(1, &service_path) || - !list_value->GetString(2, &command)) { + if (args->GetSize() != 3 || + !args->GetString(0, &str_type) || + !args->GetString(1, &service_path) || + !args->GetString(2, &command)) { NOTREACHED(); return; } diff --git a/chrome/browser/chromeos/dom_ui/internet_options_handler.h b/chrome/browser/chromeos/dom_ui/internet_options_handler.h index d004066..a581bc3 100644 --- a/chrome/browser/chromeos/dom_ui/internet_options_handler.h +++ b/chrome/browser/chromeos/dom_ui/internet_options_handler.h @@ -35,9 +35,9 @@ class InternetOptionsHandler : public OptionsPageUIHandler, // Open a modal popup dialog. void CreateModalPopup(views::WindowDelegate* view); // Open options dialog for network. - // |value| will be [ network_type, service_path, command ] + // |args| will be [ network_type, service_path, command ] // And command is one of 'options', 'connect', disconnect', or 'forget' - void ButtonClickCallback(const Value* value); + void ButtonClickCallback(const ListValue* args); // Creates the map of a network ListValue* GetNetwork(const std::string& service_path, const SkBitmap& icon, diff --git a/chrome/browser/chromeos/dom_ui/language_options_handler.cc b/chrome/browser/chromeos/dom_ui/language_options_handler.cc index f5b7a78..ff7caf2 100644 --- a/chrome/browser/chromeos/dom_ui/language_options_handler.cc +++ b/chrome/browser/chromeos/dom_ui/language_options_handler.cc @@ -216,20 +216,9 @@ DictionaryValue* LanguageOptionsHandler::GetUiLanguageCodeSet() { } void LanguageOptionsHandler::UiLanguageChangeCallback( - const Value* value) { - if (!value || !value->IsType(Value::TYPE_LIST)) { - NOTREACHED(); - LOG(INFO) << "NOTREACHED"; - return; - } - const ListValue* list_value = static_cast<const ListValue*>(value); - std::string language_code; - if (list_value->GetSize() != 1 || - !list_value->GetString(0, &language_code)) { - NOTREACHED(); - LOG(INFO) << "NOTREACHED"; - return; - } + const ListValue* args) { + std::string language_code = WideToASCII(ExtractStringValue(args)); + CHECK(!language_code.empty()); PrefService* prefs = g_browser_process->local_state(); prefs->SetString(prefs::kApplicationLocale, language_code); prefs->SavePersistentPrefs(); @@ -237,7 +226,7 @@ void LanguageOptionsHandler::UiLanguageChangeCallback( L"options.LanguageOptions.uiLanguageSaved"); } -void LanguageOptionsHandler::RestartCallback(const Value* value) { +void LanguageOptionsHandler::RestartCallback(const ListValue* args) { Browser* browser = Browser::GetBrowserForController( &dom_ui_->tab_contents()->controller(), NULL); // TODO(kochi): For ChromiumOS, just exiting means browser restart. diff --git a/chrome/browser/chromeos/dom_ui/language_options_handler.h b/chrome/browser/chromeos/dom_ui/language_options_handler.h index 2862cf5..5a45dd8 100644 --- a/chrome/browser/chromeos/dom_ui/language_options_handler.h +++ b/chrome/browser/chromeos/dom_ui/language_options_handler.h @@ -54,11 +54,11 @@ class LanguageOptionsHandler : public OptionsPageUIHandler { private: // Called when the UI language is changed. - // |value| will be the language code as string (ex. "fr"). - void UiLanguageChangeCallback(const Value* value); + // |args| will be the language code as string (ex. "fr"). + void UiLanguageChangeCallback(const ListValue* args); // Called when the restart button is clicked. - void RestartCallback(const Value* value); + void RestartCallback(const ListValue* args); DISALLOW_COPY_AND_ASSIGN(LanguageOptionsHandler); }; diff --git a/chrome/browser/dom_ui/about_page_handler.cc b/chrome/browser/dom_ui/about_page_handler.cc index f96f1ac..6275b7d 100644 --- a/chrome/browser/dom_ui/about_page_handler.cc +++ b/chrome/browser/dom_ui/about_page_handler.cc @@ -246,7 +246,7 @@ void AboutPageHandler::RegisterMessages() { #endif } -void AboutPageHandler::PageReady(const Value* value) { +void AboutPageHandler::PageReady(const ListValue* args) { #if defined(OS_CHROMEOS) // Version information is loaded from a callback loader_.GetVersion(&consumer_, @@ -262,7 +262,7 @@ void AboutPageHandler::PageReady(const Value* value) { #if defined(OS_CHROMEOS) -void AboutPageHandler::CheckNow(const Value* value) { +void AboutPageHandler::CheckNow(const ListValue* args) { if (chromeos::InitiateUpdateCheck) chromeos::InitiateUpdateCheck(); } diff --git a/chrome/browser/dom_ui/about_page_handler.h b/chrome/browser/dom_ui/about_page_handler.h index 06417a8..aa0c5bc 100644 --- a/chrome/browser/dom_ui/about_page_handler.h +++ b/chrome/browser/dom_ui/about_page_handler.h @@ -26,10 +26,10 @@ class AboutPageHandler : public OptionsPageUIHandler { private: - void PageReady(const Value* value); + void PageReady(const ListValue* args); #if defined(OS_CHROMEOS) - void CheckNow(const Value* value); + void CheckNow(const ListValue* args); // Callback from chromeos::VersionLoader giving the version. void OnOSVersion(chromeos::VersionLoader::Handle handle, std::string version); diff --git a/chrome/browser/dom_ui/add_startup_page_handler.cc b/chrome/browser/dom_ui/add_startup_page_handler.cc index 5e222c6..56e7788 100644 --- a/chrome/browser/dom_ui/add_startup_page_handler.cc +++ b/chrome/browser/dom_ui/add_startup_page_handler.cc @@ -52,9 +52,9 @@ void AddStartupPageHandler::RegisterMessages() { NewCallback(this, &AddStartupPageHandler::UpdateFieldWithRecentPage)); } -void AddStartupPageHandler::UpdateFieldWithRecentPage(const Value* value) { +void AddStartupPageHandler::UpdateFieldWithRecentPage(const ListValue* args) { int index; - if (!ExtractIntegerValue(value, &index)) { + if (!ExtractIntegerValue(args, &index)) { NOTREACHED(); return; } diff --git a/chrome/browser/dom_ui/add_startup_page_handler.h b/chrome/browser/dom_ui/add_startup_page_handler.h index d252e8a..5499d67 100644 --- a/chrome/browser/dom_ui/add_startup_page_handler.h +++ b/chrome/browser/dom_ui/add_startup_page_handler.h @@ -32,7 +32,7 @@ class AddStartupPageHandler : public OptionsPageUIHandler, private: // Request to update the text field with the URL of the recent page at the // given index, formatted for user input. Called from DOMUI. - void UpdateFieldWithRecentPage(const Value* value); + void UpdateFieldWithRecentPage(const ListValue* args); scoped_ptr<PossibleURLModel> url_table_model_; diff --git a/chrome/browser/dom_ui/advanced_options_handler.cc b/chrome/browser/dom_ui/advanced_options_handler.cc index 6672946..5fd4053 100644 --- a/chrome/browser/dom_ui/advanced_options_handler.cc +++ b/chrome/browser/dom_ui/advanced_options_handler.cc @@ -197,7 +197,8 @@ void AdvancedOptionsHandler::Observe(NotificationType type, } } -void AdvancedOptionsHandler::HandleSelectDownloadLocation(const Value* value) { +void AdvancedOptionsHandler::HandleSelectDownloadLocation( + const ListValue* args) { PrefService* pref_service = dom_ui_->GetProfile()->GetPrefs(); select_folder_dialog_ = SelectFileDialog::Create(this); select_folder_dialog_->SelectFile( @@ -214,58 +215,33 @@ void AdvancedOptionsHandler::FileSelected(const FilePath& path, int index, SetupDownloadLocationPath(); } -void AdvancedOptionsHandler::HandleAutoOpenButton(const Value* value) { +void AdvancedOptionsHandler::HandleAutoOpenButton(const ListValue* args) { DCHECK(dom_ui_); DownloadManager* manager = dom_ui_->GetProfile()->GetDownloadManager(); if (manager) manager->ResetAutoOpenFiles(); } #if defined(OS_WIN) -void AdvancedOptionsHandler::HandleCheckRevocationCheckbox(const Value* value) { - if (!value || !value->IsType(Value::TYPE_LIST)) { - LOG(WARNING) << "checkRevocationCheckboxAction called with missing or " << - "invalid value"; - return; - } - const ListValue* list = static_cast<const ListValue*>(value); - if (list->GetSize() < 1) { - LOG(WARNING) << "checkRevocationCheckboxAction called with too few " << - "arguments"; - return; - } - std::string checked_str; - if (list->GetString(0, &checked_str)) { - net::SSLConfigServiceWin::SetRevCheckingEnabled(checked_str == "true"); - } +void AdvancedOptionsHandler::HandleCheckRevocationCheckbox( + const ListValue* args) { + std::string checked_str = WideToUTF8(ExtractStringValue(args)); + net::SSLConfigServiceWin::SetRevCheckingEnabled(checked_str == "true"); } -void AdvancedOptionsHandler::HandleUseSSL2Checkbox(const Value* value) { - if (!value || !value->IsType(Value::TYPE_LIST)) { - LOG(WARNING) << "useSSL2CheckboxAction called with missing or " << - "invalid value"; - return; - } - const ListValue* list = static_cast<const ListValue*>(value); - if (list->GetSize() < 1) { - LOG(WARNING) << "useSSL2CheckboxAction called with too few " << - "arguments"; - return; - } - std::string checked_str; - if (list->GetString(0, &checked_str)) { - net::SSLConfigServiceWin::SetSSL2Enabled(checked_str == "true"); - } +void AdvancedOptionsHandler::HandleUseSSL2Checkbox(const ListValue* args) { + std::string checked_str = WideToUTF8(ExtractStringValue(args)); + net::SSLConfigServiceWin::SetSSL2Enabled(checked_str == "true"); } #endif #if !defined(OS_CHROMEOS) -void AdvancedOptionsHandler::ShowNetworkProxySettings(const Value* value) { +void AdvancedOptionsHandler::ShowNetworkProxySettings(const ListValue* args) { UserMetricsRecordAction(UserMetricsAction("Options_ShowProxySettings"), NULL); DCHECK(dom_ui_); AdvancedOptionsUtilities::ShowNetworkProxySettings(dom_ui_->tab_contents()); } -void AdvancedOptionsHandler::ShowManageSSLCertificates(const Value* value) { +void AdvancedOptionsHandler::ShowManageSSLCertificates(const ListValue* args) { UserMetricsRecordAction(UserMetricsAction("Options_ManageSSLCertificates"), NULL); DCHECK(dom_ui_); diff --git a/chrome/browser/dom_ui/advanced_options_handler.h b/chrome/browser/dom_ui/advanced_options_handler.h index 295b6cb..66b9813 100644 --- a/chrome/browser/dom_ui/advanced_options_handler.h +++ b/chrome/browser/dom_ui/advanced_options_handler.h @@ -40,30 +40,30 @@ class AdvancedOptionsHandler private: // Callback for the "selectDownloadLocation" message. This will prompt // the user for a destination folder using platform-specific APIs. - void HandleSelectDownloadLocation(const Value* value); + void HandleSelectDownloadLocation(const ListValue* args); // Callback for the "autoOpenFileTypesResetToDefault" message. This will // remove all auto-open file-type settings. - void HandleAutoOpenButton(const Value* value); + void HandleAutoOpenButton(const ListValue* args); #if defined(OS_WIN) // Callback for the "Check SSL Revocation" checkbox. This is needed so we // can support manual handling on Windows. - void HandleCheckRevocationCheckbox(const Value* value); + void HandleCheckRevocationCheckbox(const ListValue* args); // Callback for the "Use SSL2" checkbox. This is needed so we can support // manual handling on Windows. - void HandleUseSSL2Checkbox(const Value* value); + void HandleUseSSL2Checkbox(const ListValue* args); #endif #if !defined(OS_CHROMEOS) // Callback for the "showNetworkProxySettings" message. This will invoke // an appropriate dialog for configuring proxy settings. - void ShowNetworkProxySettings(const Value* value); + void ShowNetworkProxySettings(const ListValue* args); // Callback for the "showManageSSLCertificates" message. This will invoke // an appropriate certificate management action based on the platform. - void ShowManageSSLCertificates(const Value* value); + void ShowManageSSLCertificates(const ListValue* args); #endif // Setup the download path based on user preferences. diff --git a/chrome/browser/dom_ui/app_launcher_handler.cc b/chrome/browser/dom_ui/app_launcher_handler.cc index 8fd40e7..825be90 100644 --- a/chrome/browser/dom_ui/app_launcher_handler.cc +++ b/chrome/browser/dom_ui/app_launcher_handler.cc @@ -98,7 +98,7 @@ void AppLauncherHandler::CreateAppInfo(Extension* extension, value->SetString("icon", icon_url.spec()); } -void AppLauncherHandler::HandleGetApps(const Value* value) { +void AppLauncherHandler::HandleGetApps(const ListValue* args) { bool show_debug_link = CommandLine::ForCurrentProcess()->HasSwitch( switches::kAppsDebug); @@ -129,12 +129,7 @@ void AppLauncherHandler::HandleGetApps(const Value* value) { } } -void AppLauncherHandler::HandleLaunchApp(const Value* value) { - if (!value->IsType(Value::TYPE_LIST)) { - NOTREACHED(); - return; - } - +void AppLauncherHandler::HandleLaunchApp(const ListValue* args) { std::string extension_id; std::string launch_container; int left = 0; @@ -142,13 +137,12 @@ void AppLauncherHandler::HandleLaunchApp(const Value* value) { int width = 0; int height = 0; - const ListValue* list = static_cast<const ListValue*>(value); - if (!list->GetString(0, &extension_id) || - !list->GetString(1, &launch_container) || - !ExtractInt(list, 2, &left) || - !ExtractInt(list, 3, &top) || - !ExtractInt(list, 4, &width) || - !ExtractInt(list, 5, &height)) { + if (!args->GetString(0, &extension_id) || + !args->GetString(1, &launch_container) || + !ExtractInt(args, 2, &left) || + !ExtractInt(args, 3, &top) || + !ExtractInt(args, 4, &width) || + !ExtractInt(args, 5, &height)) { NOTREACHED(); return; } @@ -207,18 +201,8 @@ void AppLauncherHandler::AnimateAppIcon(Extension* extension, } } -void AppLauncherHandler::HandleUninstallApp(const Value* value) { - if (!value->IsType(Value::TYPE_LIST)) { - NOTREACHED(); - return; - } - - std::string extension_id; - const ListValue* list = static_cast<const ListValue*>(value); - if (!list->GetString(0, &extension_id)) { - NOTREACHED(); - return; - } +void AppLauncherHandler::HandleUninstallApp(const ListValue* args) { + std::string extension_id = WideToUTF8(ExtractStringValue(args)); // Make sure that the extension exists. Extension* extension = diff --git a/chrome/browser/dom_ui/app_launcher_handler.h b/chrome/browser/dom_ui/app_launcher_handler.h index 1195d49..b79ebb8 100644 --- a/chrome/browser/dom_ui/app_launcher_handler.h +++ b/chrome/browser/dom_ui/app_launcher_handler.h @@ -37,13 +37,13 @@ class AppLauncherHandler static void CreateAppInfo(Extension* extension, DictionaryValue* value); // Callback for the "getApps" message. - void HandleGetApps(const Value* value); + void HandleGetApps(const ListValue* args); // Callback for the "launchApp" message. - void HandleLaunchApp(const Value* value); + void HandleLaunchApp(const ListValue* args); // Callback for the "uninstallApp" message. - void HandleUninstallApp(const Value* value); + void HandleUninstallApp(const ListValue* args); private: // Starts the animation of the app icon. diff --git a/chrome/browser/dom_ui/browser_options_handler.cc b/chrome/browser/dom_ui/browser_options_handler.cc index 387ebdd..bcad24b 100644 --- a/chrome/browser/dom_ui/browser_options_handler.cc +++ b/chrome/browser/dom_ui/browser_options_handler.cc @@ -138,7 +138,7 @@ void BrowserOptionsHandler::UpdateDefaultBrowserState() { #endif } -void BrowserOptionsHandler::BecomeDefaultBrowser(const Value* value) { +void BrowserOptionsHandler::BecomeDefaultBrowser(const ListValue* args) { #if defined(OS_MACOSX) if (ShellIntegration::SetAsDefaultBrowser()) UpdateDefaultBrowserState(); @@ -214,20 +214,12 @@ void BrowserOptionsHandler::OnTemplateURLModelChanged() { search_engines, *(default_value.get())); } -void BrowserOptionsHandler::SetDefaultSearchEngine(const Value* value) { - if (!value || !value->IsType(Value::TYPE_LIST)) { +void BrowserOptionsHandler::SetDefaultSearchEngine(const ListValue* args) { + int selected_index = -1; + if (!ExtractIntegerValue(args, &selected_index)) { NOTREACHED(); return; } - const ListValue* param_values = static_cast<const ListValue*>(value); - std::string string_value; - if (param_values->GetSize() != 1 || - !param_values->GetString(0, &string_value)) { - NOTREACHED(); - return; - } - int selected_index; - base::StringToInt(string_value, &selected_index); std::vector<const TemplateURL*> model_urls = template_url_model_->GetTemplateURLs(); @@ -286,20 +278,16 @@ void BrowserOptionsHandler::OnItemsRemoved(int start, int length) { OnModelChanged(); } -void BrowserOptionsHandler::SetStartupPagesToCurrentPages(const Value* value) { +void BrowserOptionsHandler::SetStartupPagesToCurrentPages( + const ListValue* args) { startup_custom_pages_table_model_->SetToCurrentlyOpenPages(); SaveStartupPagesPref(); } -void BrowserOptionsHandler::RemoveStartupPages(const Value* value) { - if (!value || !value->IsType(Value::TYPE_LIST)) { - NOTREACHED(); - return; - } - const ListValue* param_values = static_cast<const ListValue*>(value); - for (int i = param_values->GetSize() - 1; i >= 0; --i) { +void BrowserOptionsHandler::RemoveStartupPages(const ListValue* args) { + for (int i = args->GetSize() - 1; i >= 0; --i) { std::string string_value; - if (!param_values->GetString(i, &string_value)) { + if (!args->GetString(i, &string_value)) { NOTREACHED(); return; } @@ -316,18 +304,13 @@ void BrowserOptionsHandler::RemoveStartupPages(const Value* value) { SaveStartupPagesPref(); } -void BrowserOptionsHandler::AddStartupPage(const Value* value) { - if (!value || !value->IsType(Value::TYPE_LIST)) { - NOTREACHED(); - return; - } - const ListValue* param_values = static_cast<const ListValue*>(value); +void BrowserOptionsHandler::AddStartupPage(const ListValue* args) { std::string url_string; std::string index_string; int index; - if (param_values->GetSize() != 2 || - !param_values->GetString(0, &url_string) || - !param_values->GetString(1, &index_string) || + if (args->GetSize() != 2 || + !args->GetString(0, &url_string) || + !args->GetString(1, &index_string) || !base::StringToInt(index_string, &index)) { NOTREACHED(); return; diff --git a/chrome/browser/dom_ui/browser_options_handler.h b/chrome/browser/dom_ui/browser_options_handler.h index 70ac061..722e811 100644 --- a/chrome/browser/dom_ui/browser_options_handler.h +++ b/chrome/browser/dom_ui/browser_options_handler.h @@ -44,20 +44,20 @@ class BrowserOptionsHandler : public OptionsPageUIHandler, private: // Makes this the default browser. Called from DOMUI. - void BecomeDefaultBrowser(const Value* value); + void BecomeDefaultBrowser(const ListValue* args); // Sets the search engine at the given index to be default. Called from DOMUI. - void SetDefaultSearchEngine(const Value* value); + void SetDefaultSearchEngine(const ListValue* args); // Removes the startup page at the given indexes. Called from DOMUI. - void RemoveStartupPages(const Value* value); + void RemoveStartupPages(const ListValue* args); // Adds a startup page with the given URL after the given index. // Called from DOMUI. - void AddStartupPage(const Value* value); + void AddStartupPage(const ListValue* args); // Sets the startup page set to the current pages. Called from DOMUI. - void SetStartupPagesToCurrentPages(const Value* value); + void SetStartupPagesToCurrentPages(const ListValue* args); // Returns the string ID for the given default browser state. int StatusStringIdForState(ShellIntegration::DefaultBrowserState state); diff --git a/chrome/browser/dom_ui/clear_browser_data_handler.cc b/chrome/browser/dom_ui/clear_browser_data_handler.cc index 4d94ff8..f5302eb 100644 --- a/chrome/browser/dom_ui/clear_browser_data_handler.cc +++ b/chrome/browser/dom_ui/clear_browser_data_handler.cc @@ -89,7 +89,7 @@ void ClearBrowserDataHandler::RegisterMessages() { NewCallback(this, &ClearBrowserDataHandler::HandleClearBrowserData)); } -void ClearBrowserDataHandler::HandleClearBrowserData(const Value* value) { +void ClearBrowserDataHandler::HandleClearBrowserData(const ListValue* value) { Profile *profile = dom_ui_->GetProfile(); PrefService *prefs = profile->GetPrefs(); diff --git a/chrome/browser/dom_ui/clear_browser_data_handler.h b/chrome/browser/dom_ui/clear_browser_data_handler.h index 8345598..7c29b79 100644 --- a/chrome/browser/dom_ui/clear_browser_data_handler.h +++ b/chrome/browser/dom_ui/clear_browser_data_handler.h @@ -23,7 +23,7 @@ class ClearBrowserDataHandler : public OptionsPageUIHandler, virtual void RegisterMessages(); private: - void HandleClearBrowserData(const Value* value); + void HandleClearBrowserData(const ListValue* value); // Callback from BrowsingDataRemover. Closes the dialog. virtual void OnBrowsingDataRemoverDone(); diff --git a/chrome/browser/dom_ui/content_settings_handler.cc b/chrome/browser/dom_ui/content_settings_handler.cc index 01c8c55..2bdb915 100644 --- a/chrome/browser/dom_ui/content_settings_handler.cc +++ b/chrome/browser/dom_ui/content_settings_handler.cc @@ -317,12 +317,11 @@ void ContentSettingsHandler::RegisterMessages() { &ContentSettingsHandler::CheckExceptionPatternValidity)); } -void ContentSettingsHandler::SetContentFilter(const Value* value) { - const ListValue* list_value = static_cast<const ListValue*>(value); - DCHECK_EQ(2U, list_value->GetSize()); +void ContentSettingsHandler::SetContentFilter(const ListValue* args) { + DCHECK_EQ(2U, args->GetSize()); std::string group, setting; - if (!(list_value->GetString(0, &group) && - list_value->GetString(1, &setting))) { + if (!(args->GetString(0, &group) && + args->GetString(1, &setting))) { NOTREACHED(); return; } @@ -332,24 +331,23 @@ void ContentSettingsHandler::SetContentFilter(const Value* value) { ContentSettingFromString(setting)); } -void ContentSettingsHandler::SetAllowThirdPartyCookies(const Value* value) { - std::wstring allow = ExtractStringValue(value); +void ContentSettingsHandler::SetAllowThirdPartyCookies(const ListValue* args) { + std::wstring allow = ExtractStringValue(args); dom_ui_->GetProfile()->GetHostContentSettingsMap()->SetBlockThirdPartyCookies( allow == L"true"); } -void ContentSettingsHandler::RemoveExceptions(const Value* value) { - const ListValue* list_value = static_cast<const ListValue*>(value); +void ContentSettingsHandler::RemoveExceptions(const ListValue* args) { size_t arg_i = 0; std::string type_string; - CHECK(list_value->GetString(arg_i++, &type_string)); + CHECK(args->GetString(arg_i++, &type_string)); HostContentSettingsMap* settings_map = dom_ui_->GetProfile()->GetHostContentSettingsMap(); - while (arg_i < list_value->GetSize()) { + while (arg_i < args->GetSize()) { std::string pattern; - bool rv = list_value->GetString(arg_i++, &pattern); + bool rv = args->GetString(arg_i++, &pattern); DCHECK(rv); settings_map->SetContentSetting( HostContentSettingsMap::Pattern(pattern), @@ -359,15 +357,14 @@ void ContentSettingsHandler::RemoveExceptions(const Value* value) { } } -void ContentSettingsHandler::SetException(const Value* value) { - const ListValue* list_value = static_cast<const ListValue*>(value); +void ContentSettingsHandler::SetException(const ListValue* args) { size_t arg_i = 0; std::string type_string; - CHECK(list_value->GetString(arg_i++, &type_string)); + CHECK(args->GetString(arg_i++, &type_string)); std::string pattern; - CHECK(list_value->GetString(arg_i++, &pattern)); + CHECK(args->GetString(arg_i++, &pattern)); std::string setting; - CHECK(list_value->GetString(arg_i++, &setting)); + CHECK(args->GetString(arg_i++, &setting)); HostContentSettingsMap* settings_map = dom_ui_->GetProfile()->GetHostContentSettingsMap(); @@ -377,13 +374,13 @@ void ContentSettingsHandler::SetException(const Value* value) { ContentSettingFromString(setting)); } -void ContentSettingsHandler::CheckExceptionPatternValidity(const Value* value) { - const ListValue* list_value = static_cast<const ListValue*>(value); +void ContentSettingsHandler::CheckExceptionPatternValidity( + const ListValue* args) { size_t arg_i = 0; Value* type; - CHECK(list_value->Get(arg_i++, &type)); + CHECK(args->Get(arg_i++, &type)); std::string pattern_string; - CHECK(list_value->GetString(arg_i++, &pattern_string)); + CHECK(args->GetString(arg_i++, &pattern_string)); HostContentSettingsMap::Pattern pattern(pattern_string); diff --git a/chrome/browser/dom_ui/content_settings_handler.h b/chrome/browser/dom_ui/content_settings_handler.h index 3e72aab..3895f0b 100644 --- a/chrome/browser/dom_ui/content_settings_handler.h +++ b/chrome/browser/dom_ui/content_settings_handler.h @@ -31,11 +31,11 @@ class ContentSettingsHandler : public OptionsPageUIHandler { private: void UpdateAllExceptionsViewsFromModel(); void UpdateExceptionsViewFromModel(ContentSettingsType type); - void SetContentFilter(const Value* value); - void SetAllowThirdPartyCookies(const Value* value); - void RemoveExceptions(const Value* value); - void SetException(const Value* value); - void CheckExceptionPatternValidity(const Value* value); + void SetContentFilter(const ListValue* args); + void SetAllowThirdPartyCookies(const ListValue* args); + void RemoveExceptions(const ListValue* args); + void SetException(const ListValue* args); + void CheckExceptionPatternValidity(const ListValue* args); NotificationRegistrar notification_registrar_; diff --git a/chrome/browser/dom_ui/core_options_handler.cc b/chrome/browser/dom_ui/core_options_handler.cc index 5e12ff5..9137326 100644 --- a/chrome/browser/dom_ui/core_options_handler.cc +++ b/chrome/browser/dom_ui/core_options_handler.cc @@ -112,8 +112,8 @@ void CoreOptionsHandler::RegisterMessages() { NewCallback(this, &CoreOptionsHandler::HandleSetObjectPref)); } -void CoreOptionsHandler::HandleInitialize(const Value* value) { - (static_cast<OptionsUI*>(dom_ui_))->InitializeHandlers(); +void CoreOptionsHandler::HandleInitialize(const ListValue* args) { + static_cast<OptionsUI*>(dom_ui_)->InitializeHandlers(); } Value* CoreOptionsHandler::FetchPref(const std::string& pref_name) { @@ -164,21 +164,16 @@ void CoreOptionsHandler::SetPref(const std::string& pref_name, } } -void CoreOptionsHandler::HandleFetchPrefs(const Value* value) { - if (!value || !value->IsType(Value::TYPE_LIST)) - return; - - const ListValue* param_values = static_cast<const ListValue*>(value); - +void CoreOptionsHandler::HandleFetchPrefs(const ListValue* args) { // First param is name of callback function, so, there needs to be at least // one more element for the actual preference identifier. const size_t kMinFetchPrefsParamCount = 2; - if (param_values->GetSize() < kMinFetchPrefsParamCount) + if (args->GetSize() < kMinFetchPrefsParamCount) return; // Get callback JS function name. Value* callback; - if (!param_values->Get(0, &callback) || !callback->IsType(Value::TYPE_STRING)) + if (!args->Get(0, &callback) || !callback->IsType(Value::TYPE_STRING)) return; string16 callback_function; @@ -189,8 +184,8 @@ void CoreOptionsHandler::HandleFetchPrefs(const Value* value) { DictionaryValue result_value; Value* list_member; - for (size_t i = 1; i < param_values->GetSize(); i++) { - if (!param_values->Get(i, &list_member)) + for (size_t i = 1; i < args->GetSize(); i++) { + if (!args->Get(i, &list_member)) break; if (!list_member->IsType(Value::TYPE_STRING)) @@ -206,27 +201,24 @@ void CoreOptionsHandler::HandleFetchPrefs(const Value* value) { result_value); } -void CoreOptionsHandler::HandleObservePrefs(const Value* value) { - if (!value || !value->IsType(Value::TYPE_LIST)) - return; - - const ListValue* list_value = static_cast<const ListValue*>(value); +void CoreOptionsHandler::HandleObservePrefs(const ListValue* args) { + DictionaryValue result_value; // First param is name is JS callback function name, the rest are pref // identifiers that we are observing. const size_t kMinObservePrefsParamCount = 2; - if (list_value->GetSize() < kMinObservePrefsParamCount) + if (args->GetSize() < kMinObservePrefsParamCount) return; // Get preference change callback function name. string16 callback_func_name; - if (!list_value->GetString(0, &callback_func_name)) + if (!args->GetString(0, &callback_func_name)) return; // Get all other parameters - pref identifiers. - for (size_t i = 1; i < list_value->GetSize(); i++) { + for (size_t i = 1; i < args->GetSize(); i++) { Value* list_member; - if (!list_value->Get(i, &list_member)) + if (!args->Get(i, &list_member)) break; // Just ignore bad pref identifiers for now. @@ -244,36 +236,33 @@ void CoreOptionsHandler::HandleObservePrefs(const Value* value) { } } -void CoreOptionsHandler::HandleSetBooleanPref(const Value* value) { - HandleSetPref(value, Value::TYPE_BOOLEAN); +void CoreOptionsHandler::HandleSetBooleanPref(const ListValue* args) { + HandleSetPref(args, Value::TYPE_BOOLEAN); } -void CoreOptionsHandler::HandleSetIntegerPref(const Value* value) { - HandleSetPref(value, Value::TYPE_INTEGER); +void CoreOptionsHandler::HandleSetIntegerPref(const ListValue* args) { + HandleSetPref(args, Value::TYPE_INTEGER); } -void CoreOptionsHandler::HandleSetStringPref(const Value* value) { - HandleSetPref(value, Value::TYPE_STRING); +void CoreOptionsHandler::HandleSetStringPref(const ListValue* args) { + HandleSetPref(args, Value::TYPE_STRING); } -void CoreOptionsHandler::HandleSetObjectPref(const Value* value) { - HandleSetPref(value, Value::TYPE_NULL); +void CoreOptionsHandler::HandleSetObjectPref(const ListValue* args) { + HandleSetPref(args, Value::TYPE_NULL); } -void CoreOptionsHandler::HandleSetPref(const Value* value, +void CoreOptionsHandler::HandleSetPref(const ListValue* args, Value::ValueType type) { - if (!value || !value->IsType(Value::TYPE_LIST)) - return; - const ListValue* param_values = static_cast<const ListValue*>(value); - if (param_values->GetSize() != 2) + if (args->GetSize() != 2) return; std::string pref_name; - if (!param_values->GetString(0, &pref_name)) + if (!args->GetString(0, &pref_name)) return; std::string value_string; - if (!param_values->GetString(1, &value_string)) + if (!args->GetString(1, &value_string)) return; SetPref(pref_name, type, value_string); diff --git a/chrome/browser/dom_ui/core_options_handler.h b/chrome/browser/dom_ui/core_options_handler.h index 3f21e1b..4a51cad 100644 --- a/chrome/browser/dom_ui/core_options_handler.h +++ b/chrome/browser/dom_ui/core_options_handler.h @@ -49,27 +49,27 @@ class CoreOptionsHandler : public OptionsPageUIHandler { // Callback for the "coreOptionsInitialize" message. This message will // trigger the Initialize() method of all other handlers so that final // setup can be performed before the page is shown. - void HandleInitialize(const Value* value); + void HandleInitialize(const ListValue* args); // Callback for the "fetchPrefs" message. This message accepts the list of // preference names passed as |value| parameter (ListValue). It passes results // dictionary of preference values by calling prefsFetched() JS method on the // page. - void HandleFetchPrefs(const Value* value); + void HandleFetchPrefs(const ListValue* args); // Callback for the "observePrefs" message. This message initiates // notification observing for given array of preference names. - void HandleObservePrefs(const Value* value); + void HandleObservePrefs(const ListValue* args); // Callbacks for the "set<type>Pref" message. This message saves the new // preference value. The input value is an array of strings representing // name-value preference pair. - void HandleSetBooleanPref(const Value* value); - void HandleSetIntegerPref(const Value* value); - void HandleSetStringPref(const Value* value); - void HandleSetObjectPref(const Value* value); + void HandleSetBooleanPref(const ListValue* args); + void HandleSetIntegerPref(const ListValue* args); + void HandleSetStringPref(const ListValue* args); + void HandleSetObjectPref(const ListValue* args); - void HandleSetPref(const Value* value, Value::ValueType type); + void HandleSetPref(const ListValue* args, Value::ValueType type); void NotifyPrefChanged(const std::string* pref_name); diff --git a/chrome/browser/dom_ui/dom_ui.cc b/chrome/browser/dom_ui/dom_ui.cc index a5b965a..5fb2fb8 100644 --- a/chrome/browser/dom_ui/dom_ui.cc +++ b/chrome/browser/dom_ui/dom_ui.cc @@ -161,25 +161,20 @@ void DOMMessageHandler::SetURLAndTitle(DictionaryValue* dictionary, dictionary->SetString("title", title_to_set); } -bool DOMMessageHandler::ExtractIntegerValue(const Value* value, int* out_int) { - if (value && value->GetType() == Value::TYPE_LIST) { - const ListValue* list_value = static_cast<const ListValue*>(value); - std::string string_value; - if (list_value->GetString(0, &string_value)) { - base::StringToInt(string_value, out_int); - return true; - } - } +bool DOMMessageHandler::ExtractIntegerValue(const ListValue* value, + int* out_int) { + std::string string_value; + if (value->GetString(0, &string_value)) + return base::StringToInt(string_value, out_int); + NOTREACHED(); return false; } // TODO(viettrungluu): convert to string16 (or UTF-8 std::string?). -std::wstring DOMMessageHandler::ExtractStringValue(const Value* value) { - if (value && value->GetType() == Value::TYPE_LIST) { - const ListValue* list_value = static_cast<const ListValue*>(value); - string16 string16_value; - if (list_value->GetString(0, &string16_value)) - return UTF16ToWideHack(string16_value); - } +std::wstring DOMMessageHandler::ExtractStringValue(const ListValue* value) { + string16 string16_value; + if (value->GetString(0, &string16_value)) + return UTF16ToWideHack(string16_value); + NOTREACHED(); return std::wstring(); } diff --git a/chrome/browser/dom_ui/dom_ui.h b/chrome/browser/dom_ui/dom_ui.h index d805921..9eb5b78 100644 --- a/chrome/browser/dom_ui/dom_ui.h +++ b/chrome/browser/dom_ui/dom_ui.h @@ -46,7 +46,7 @@ class DOMUI { virtual void ProcessDOMUIMessage(const ViewHostMsg_DomMessage_Params& params); // Used by DOMMessageHandlers. - typedef Callback1<const Value*>::Type MessageCallback; + typedef Callback1<const ListValue*>::Type MessageCallback; void RegisterMessageCallback(const std::string& message, MessageCallback* callback); @@ -168,10 +168,10 @@ class DOMMessageHandler { virtual void RegisterMessages() = 0; // Extract an integer value from a list Value. - bool ExtractIntegerValue(const Value* value, int* out_int); + bool ExtractIntegerValue(const ListValue* value, int* out_int); // Extract a string value from a list Value. - std::wstring ExtractStringValue(const Value* value); + std::wstring ExtractStringValue(const ListValue* value); DOMUI* dom_ui_; diff --git a/chrome/browser/dom_ui/dom_ui_util.cc b/chrome/browser/dom_ui/dom_ui_util.cc index e247655..d2030e4 100644 --- a/chrome/browser/dom_ui/dom_ui_util.cc +++ b/chrome/browser/dom_ui/dom_ui_util.cc @@ -9,19 +9,13 @@ namespace dom_ui_util { -std::string GetJsonResponseFromFirstArgumentInList(const Value* content) { - return GetJsonResponseFromArgumentList(content, 0); +std::string GetJsonResponseFromFirstArgumentInList(const ListValue* args) { + return GetJsonResponseFromArgumentList(args, 0); } -std::string GetJsonResponseFromArgumentList(const Value* content, +std::string GetJsonResponseFromArgumentList(const ListValue* args, size_t list_index) { std::string result; - - if (!content || !content->IsType(Value::TYPE_LIST)) { - NOTREACHED(); - return result; - } - const ListValue* args = static_cast<const ListValue*>(content); if (args->GetSize() <= list_index) { NOTREACHED(); return result; @@ -30,6 +24,8 @@ std::string GetJsonResponseFromArgumentList(const Value* content, Value* value = NULL; if (args->Get(list_index, &value)) value->GetAsString(&result); + else + NOTREACHED(); return result; } diff --git a/chrome/browser/dom_ui/dom_ui_util.h b/chrome/browser/dom_ui/dom_ui_util.h index 99a5cc0..2219d18 100644 --- a/chrome/browser/dom_ui/dom_ui_util.h +++ b/chrome/browser/dom_ui/dom_ui_util.h @@ -8,7 +8,7 @@ #include <string> -class Value; +class ListValue; namespace dom_ui_util { @@ -18,7 +18,7 @@ namespace dom_ui_util { // one entry in it, and that first entry must be a string, which is // returned. The parameter is a Value for convenience. Returns an // empty string on error or if the parameter is not a ListValue. -std::string GetJsonResponseFromFirstArgumentInList(const Value* content); +std::string GetJsonResponseFromFirstArgumentInList(const ListValue* args); // Convenience routine to get one of the response strings from an // argument list. content must be a ListValue, with at least @@ -27,7 +27,7 @@ std::string GetJsonResponseFromFirstArgumentInList(const Value* content); // which is returned. The parameter is a Value for convenience. // Returns an empty string on error or if the parameter is not a // ListValue. -std::string GetJsonResponseFromArgumentList(const Value* content, +std::string GetJsonResponseFromArgumentList(const ListValue* args, size_t list_index); } // end of namespace diff --git a/chrome/browser/dom_ui/downloads_dom_handler.cc b/chrome/browser/dom_ui/downloads_dom_handler.cc index 54d6f36..50fa502 100644 --- a/chrome/browser/dom_ui/downloads_dom_handler.cc +++ b/chrome/browser/dom_ui/downloads_dom_handler.cc @@ -139,8 +139,8 @@ void DownloadsDOMHandler::ModelChanged() { SendCurrentDownloads(); } -void DownloadsDOMHandler::HandleGetDownloads(const Value* value) { - std::wstring new_search = ExtractStringValue(value); +void DownloadsDOMHandler::HandleGetDownloads(const ListValue* args) { + std::wstring new_search = ExtractStringValue(args); if (search_text_.compare(new_search) != 0) { search_text_ = new_search; ModelChanged(); @@ -149,14 +149,14 @@ void DownloadsDOMHandler::HandleGetDownloads(const Value* value) { } } -void DownloadsDOMHandler::HandleOpenFile(const Value* value) { - DownloadItem* file = GetDownloadByValue(value); +void DownloadsDOMHandler::HandleOpenFile(const ListValue* args) { + DownloadItem* file = GetDownloadByValue(args); if (file) download_manager_->OpenDownload(file, NULL); } -void DownloadsDOMHandler::HandleDrag(const Value* value) { - DownloadItem* file = GetDownloadByValue(value); +void DownloadsDOMHandler::HandleDrag(const ListValue* args) { + DownloadItem* file = GetDownloadByValue(args); if (file) { IconManager* im = g_browser_process->icon_manager(); SkBitmap* icon = im->LookupIcon(file->full_path(), IconLoader::NORMAL); @@ -165,43 +165,43 @@ void DownloadsDOMHandler::HandleDrag(const Value* value) { } } -void DownloadsDOMHandler::HandleSaveDangerous(const Value* value) { - DownloadItem* file = GetDownloadByValue(value); +void DownloadsDOMHandler::HandleSaveDangerous(const ListValue* args) { + DownloadItem* file = GetDownloadByValue(args); if (file) download_manager_->DangerousDownloadValidated(file); } -void DownloadsDOMHandler::HandleDiscardDangerous(const Value* value) { - DownloadItem* file = GetDownloadByValue(value); +void DownloadsDOMHandler::HandleDiscardDangerous(const ListValue* args) { + DownloadItem* file = GetDownloadByValue(args); if (file) file->Remove(true); } -void DownloadsDOMHandler::HandleShow(const Value* value) { - DownloadItem* file = GetDownloadByValue(value); +void DownloadsDOMHandler::HandleShow(const ListValue* args) { + DownloadItem* file = GetDownloadByValue(args); if (file) download_manager_->ShowDownloadInShell(file); } -void DownloadsDOMHandler::HandlePause(const Value* value) { - DownloadItem* file = GetDownloadByValue(value); +void DownloadsDOMHandler::HandlePause(const ListValue* args) { + DownloadItem* file = GetDownloadByValue(args); if (file) file->TogglePause(); } -void DownloadsDOMHandler::HandleRemove(const Value* value) { - DownloadItem* file = GetDownloadByValue(value); +void DownloadsDOMHandler::HandleRemove(const ListValue* args) { + DownloadItem* file = GetDownloadByValue(args); if (file) file->Remove(false); } -void DownloadsDOMHandler::HandleCancel(const Value* value) { - DownloadItem* file = GetDownloadByValue(value); +void DownloadsDOMHandler::HandleCancel(const ListValue* args) { + DownloadItem* file = GetDownloadByValue(args); if (file) file->Cancel(true); } -void DownloadsDOMHandler::HandleClearAll(const Value* value) { +void DownloadsDOMHandler::HandleClearAll(const ListValue* args) { download_manager_->RemoveAllDownloads(); } @@ -240,9 +240,9 @@ DownloadItem* DownloadsDOMHandler::GetDownloadById(int id) { return NULL; } -DownloadItem* DownloadsDOMHandler::GetDownloadByValue(const Value* value) { +DownloadItem* DownloadsDOMHandler::GetDownloadByValue(const ListValue* args) { int id; - if (ExtractIntegerValue(value, &id)) { + if (ExtractIntegerValue(args, &id)) { return GetDownloadById(id); } return NULL; diff --git a/chrome/browser/dom_ui/downloads_dom_handler.h b/chrome/browser/dom_ui/downloads_dom_handler.h index 73efa56..5013db5 100644 --- a/chrome/browser/dom_ui/downloads_dom_handler.h +++ b/chrome/browser/dom_ui/downloads_dom_handler.h @@ -13,7 +13,7 @@ #include "chrome/browser/download/download_item.h" #include "chrome/browser/download/download_manager.h" -class Value; +class ListValue; // The handler for Javascript messages related to the "downloads" view, // also observes changes to the download manager. @@ -38,37 +38,37 @@ class DownloadsDOMHandler : public DOMMessageHandler, virtual void ModelChanged(); // Callback for the "getDownloads" message. - void HandleGetDownloads(const Value* value); + void HandleGetDownloads(const ListValue* args); // Callback for the "openFile" message - opens the file in the shell. - void HandleOpenFile(const Value* value); + void HandleOpenFile(const ListValue* args); // Callback for the "drag" message - initiates a file object drag. - void HandleDrag(const Value* value); + void HandleDrag(const ListValue* args); // Callback for the "saveDangerous" message - specifies that the user // wishes to save a dangerous file. - void HandleSaveDangerous(const Value* value); + void HandleSaveDangerous(const ListValue* args); // Callback for the "discardDangerous" message - specifies that the user // wishes to discard (remove) a dangerous file. - void HandleDiscardDangerous(const Value* value); + void HandleDiscardDangerous(const ListValue* args); // Callback for the "show" message - shows the file in explorer. - void HandleShow(const Value* value); + void HandleShow(const ListValue* args); // Callback for the "pause" message - pauses the file download. - void HandlePause(const Value* value); + void HandlePause(const ListValue* args); // Callback for the "remove" message - removes the file download from shelf // and list. - void HandleRemove(const Value* value); + void HandleRemove(const ListValue* args); // Callback for the "cancel" message - cancels the download. - void HandleCancel(const Value* value); + void HandleCancel(const ListValue* args); // Callback for the "clearAll" message - clears all the downloads. - void HandleClearAll(const Value* value); + void HandleClearAll(const ListValue* args); private: // Send the current list of downloads to the page. @@ -81,7 +81,7 @@ class DownloadsDOMHandler : public DOMMessageHandler, DownloadItem* GetDownloadById(int id); // Return the download that is referred to in a given value. - DownloadItem* GetDownloadByValue(const Value* value); + DownloadItem* GetDownloadByValue(const ListValue* args); // Current search text. std::wstring search_text_; diff --git a/chrome/browser/dom_ui/filebrowse_ui.cc b/chrome/browser/dom_ui/filebrowse_ui.cc index 899cc06..17d760f 100644 --- a/chrome/browser/dom_ui/filebrowse_ui.cc +++ b/chrome/browser/dom_ui/filebrowse_ui.cc @@ -129,7 +129,7 @@ class FilebrowseHandler : public net::DirectoryLister::DirectoryListerDelegate, virtual void ModelChanged(); // Callback for the "getRoots" message. - void HandleGetRoots(const Value* value); + void HandleGetRoots(const ListValue* args); void GetChildrenForPath(FilePath& path, bool is_refresh); @@ -141,37 +141,37 @@ class FilebrowseHandler : public net::DirectoryLister::DirectoryListerDelegate, const std::string& data); // Callback for the "getChildren" message. - void HandleGetChildren(const Value* value); + void HandleGetChildren(const ListValue* args); // Callback for the "refreshDirectory" message. - void HandleRefreshDirectory(const Value* value); - void HandleIsAdvancedEnabled(const Value* value); + void HandleRefreshDirectory(const ListValue* args); + void HandleIsAdvancedEnabled(const ListValue* args); // Callback for the "getMetadata" message. - void HandleGetMetadata(const Value* value); + void HandleGetMetadata(const ListValue* args); // Callback for the "openNewWindow" message. - void OpenNewFullWindow(const Value* value); - void OpenNewPopupWindow(const Value* value); + void OpenNewFullWindow(const ListValue* args); + void OpenNewPopupWindow(const ListValue* args); // Callback for the "uploadToPicasaweb" message. - void UploadToPicasaweb(const Value* value); + void UploadToPicasaweb(const ListValue* args); // Callback for the "getDownloads" message. - void HandleGetDownloads(const Value* value); + void HandleGetDownloads(const ListValue* args); - void HandleCreateNewFolder(const Value* value); + void HandleCreateNewFolder(const ListValue* args); - void PlayMediaFile(const Value* value); - void EnqueueMediaFile(const Value* value); + void PlayMediaFile(const ListValue* args); + void EnqueueMediaFile(const ListValue* args); - void HandleDeleteFile(const Value* value); + void HandleDeleteFile(const ListValue* args); void DeleteFile(const FilePath& path); void FireDeleteComplete(const FilePath& path); - void HandlePauseToggleDownload(const Value* value); + void HandlePauseToggleDownload(const ListValue* args); - void HandleCancelDownload(const Value* value); - void HandleAllowDownload(const Value* value); + void HandleCancelDownload(const ListValue* args); + void HandleAllowDownload(const ListValue* args); void ReadInFile(); void FireUploadComplete(); @@ -179,7 +179,7 @@ class FilebrowseHandler : public net::DirectoryLister::DirectoryListerDelegate, void SendPicasawebRequest(); private: - void OpenNewWindow(const Value* value, bool popup); + void OpenNewWindow(const ListValue* args, bool popup); // Clear all download items and their observers. void ClearDownloadItems(); @@ -501,7 +501,7 @@ void FilebrowseHandler::OnURLFetchComplete(const URLFetcher* source, fetch_.reset(); } -void FilebrowseHandler::HandleGetRoots(const Value* value) { +void FilebrowseHandler::HandleGetRoots(const ListValue* args) { ListValue results_value; DictionaryValue info_value; // TODO(dhg): add other entries, make this more general @@ -514,8 +514,7 @@ void FilebrowseHandler::HandleGetRoots(const Value* value) { if (!disks[i].mount_path.empty()) { DictionaryValue* page_value = new DictionaryValue(); page_value->SetString(kPropertyPath, disks[i].mount_path); - FilePath currentpath; - currentpath = FilePath(disks[i].mount_path); + FilePath currentpath(disks[i].mount_path); std::string filename; filename = currentpath.BaseName().value(); page_value->SetString(kPropertyTitle, filename); @@ -550,82 +549,41 @@ void FilebrowseHandler::HandleGetRoots(const Value* value) { info_value, results_value); } -void FilebrowseHandler::HandleCreateNewFolder(const Value* value) { +void FilebrowseHandler::HandleCreateNewFolder(const ListValue* args) { #if defined(OS_CHROMEOS) - if (value && value->GetType() == Value::TYPE_LIST) { - const ListValue* list_value = static_cast<const ListValue*>(value); - std::string path; + std::string path = WideToUTF8(ExtractStringValue(args)); + FilePath currentpath(path); - // Get path string. - if (list_value->GetString(0, &path)) { - - FilePath currentpath; - currentpath = FilePath(path); - - if (!file_util::CreateDirectory(currentpath)) { - LOG(ERROR) << "unable to create directory"; - } - } else { - LOG(ERROR) << "Unable to get string"; - return; - } - } + if (!file_util::CreateDirectory(currentpath)) + LOG(ERROR) << "unable to create directory"; #endif } -void FilebrowseHandler::PlayMediaFile(const Value* value) { +void FilebrowseHandler::PlayMediaFile(const ListValue* args) { #if defined(OS_CHROMEOS) - if (value && value->GetType() == Value::TYPE_LIST) { - const ListValue* list_value = static_cast<const ListValue*>(value); - std::string path; - - // Get path string. - if (list_value->GetString(0, &path)) { - FilePath currentpath; - currentpath = FilePath(path); - - MediaPlayer* mediaplayer = MediaPlayer::Get(); - std::string url = currentpath.value(); - - GURL gurl(url); - Browser* browser = Browser::GetBrowserForController( - &tab_contents_->controller(), NULL); - mediaplayer->ForcePlayMediaURL(gurl, browser); - } else { - LOG(ERROR) << "Unable to get string"; - return; - } - } + std::string url = WideToUTF8(ExtractStringValue(args)); + GURL gurl(url); + + Browser* browser = Browser::GetBrowserForController( + &tab_contents_->controller(), NULL); + MediaPlayer* mediaplayer = MediaPlayer::Get(); + mediaplayer->ForcePlayMediaURL(gurl, browser); #endif } -void FilebrowseHandler::EnqueueMediaFile(const Value* value) { +void FilebrowseHandler::EnqueueMediaFile(const ListValue* args) { #if defined(OS_CHROMEOS) - if (value && value->GetType() == Value::TYPE_LIST) { - const ListValue* list_value = static_cast<const ListValue*>(value); - std::string path; - - // Get path string. - if (list_value->GetString(0, &path)) { - FilePath currentpath; - currentpath = FilePath(path); - - MediaPlayer* mediaplayer = MediaPlayer::Get(); - std::string url = currentpath.value(); - - GURL gurl(url); - Browser* browser = Browser::GetBrowserForController( - &tab_contents_->controller(), NULL); - mediaplayer->EnqueueMediaURL(gurl, browser); - } else { - LOG(ERROR) << "Unable to get string"; - return; - } - } + std::string url = WideToUTF8(ExtractStringValue(args)); + GURL gurl(url); + + Browser* browser = Browser::GetBrowserForController( + &tab_contents_->controller(), NULL); + MediaPlayer* mediaplayer = MediaPlayer::Get(); + mediaplayer->EnqueueMediaURL(gurl, browser); #endif } -void FilebrowseHandler::HandleIsAdvancedEnabled(const Value* value) { +void FilebrowseHandler::HandleIsAdvancedEnabled(const ListValue* args) { #if defined(OS_CHROMEOS) Browser* browser = BrowserList::GetLastActive(); bool is_enabled = false; @@ -645,131 +603,68 @@ void FilebrowseHandler::HandleIsAdvancedEnabled(const Value* value) { #endif } -void FilebrowseHandler::HandleRefreshDirectory(const Value* value) { - if (value && value->GetType() == Value::TYPE_LIST) { - const ListValue* list_value = static_cast<const ListValue*>(value); - std::string path; - - // Get path string. - if (list_value->GetString(0, &path)) { - FilePath currentpath; -#if defined(OS_WIN) - currentpath = FilePath(ASCIIToWide(path)); -#else - currentpath = FilePath(path); + +void FilebrowseHandler::HandleRefreshDirectory(const ListValue* args) { +#if defined(OS_CHROMEOS) + std::string path = WideToUTF8(ExtractStringValue(args)); + FilePath currentpath(path); + GetChildrenForPath(currentpath, true); #endif - GetChildrenForPath(currentpath, true); - } else { - LOG(ERROR) << "Unable to get string"; - return; - } - } } -void FilebrowseHandler::HandlePauseToggleDownload(const Value* value) { +void FilebrowseHandler::HandlePauseToggleDownload(const ListValue* args) { #if defined(OS_CHROMEOS) - if (value && value->GetType() == Value::TYPE_LIST) { - const ListValue* list_value = static_cast<const ListValue*>(value); - int id; - std::string str_id; - - if (list_value->GetString(0, &str_id)) { - id = atoi(str_id.c_str()); - DownloadItem* item = active_download_items_[id]; - item->TogglePause(); - } else { - LOG(ERROR) << "Unable to get id for download to pause"; - return; - } - } + int id; + ExtractIntegerValue(args, &id); + DownloadItem* item = active_download_items_[id]; + item->TogglePause(); #endif } -void FilebrowseHandler::HandleAllowDownload(const Value* value) { +void FilebrowseHandler::HandleAllowDownload(const ListValue* args) { #if defined(OS_CHROMEOS) - if (value && value->GetType() == Value::TYPE_LIST) { - const ListValue* list_value = static_cast<const ListValue*>(value); - int id; - std::string str_id; - - if (list_value->GetString(0, &str_id)) { - id = atoi(str_id.c_str()); - DownloadItem* item = active_download_items_[id]; - download_manager_->DangerousDownloadValidated(item); - } else { - LOG(ERROR) << "Unable to get id for download to pause"; - return; - } - } + int id; + ExtractIntegerValue(args, &id); + DownloadItem* item = active_download_items_[id]; + download_manager_->DangerousDownloadValidated(item); #endif } -void FilebrowseHandler::HandleCancelDownload(const Value* value) { +void FilebrowseHandler::HandleCancelDownload(const ListValue* args) { #if defined(OS_CHROMEOS) - if (value && value->GetType() == Value::TYPE_LIST) { - const ListValue* list_value = static_cast<const ListValue*>(value); - int id; - std::string str_id; - - if (list_value->GetString(0, &str_id)) { - id = atoi(str_id.c_str()); - DownloadItem* item = active_download_items_[id]; - item->Cancel(true); - FilePath path = item->full_path(); - FilePath dir_path = path.DirName(); - item->Remove(true); - GetChildrenForPath(dir_path, true); - } else { - LOG(ERROR) << "Unable to get id for download to pause"; - return; - } - } + int id; + ExtractIntegerValue(args, &id); + DownloadItem* item = active_download_items_[id]; + item->Cancel(true); + FilePath path = item->full_path(); + FilePath dir_path = path.DirName(); + item->Remove(true); + GetChildrenForPath(dir_path, true); #endif } -void FilebrowseHandler::OpenNewFullWindow(const Value* value) { - OpenNewWindow(value, false); +void FilebrowseHandler::OpenNewFullWindow(const ListValue* args) { + OpenNewWindow(args, false); } -void FilebrowseHandler::OpenNewPopupWindow(const Value* value) { - OpenNewWindow(value, true); +void FilebrowseHandler::OpenNewPopupWindow(const ListValue* args) { + OpenNewWindow(args, true); } -void FilebrowseHandler::OpenNewWindow(const Value* value, bool popup) { - if (value && value->GetType() == Value::TYPE_LIST) { - const ListValue* list_value = static_cast<const ListValue*>(value); - Value* list_member; - std::string path; - - // Get path string. - if (list_value->Get(0, &list_member) && - list_member->GetType() == Value::TYPE_STRING) { - const StringValue* string_value = - static_cast<const StringValue*>(list_member); - string_value->GetAsString(&path); - } else { - LOG(ERROR) << "Unable to get string"; - return; - } - Browser* browser; - if (popup) { - browser = Browser::CreateForType(Browser::TYPE_APP_PANEL, profile_); - } else { - browser = BrowserList::GetLastActive(); - } - browser->AddTabWithURL(GURL(path), GURL(), PageTransition::LINK, -1, - TabStripModel::ADD_SELECTED, NULL, std::string(), - &browser); - if (popup) { - // TODO(dhg): Remove these from being hardcoded. Allow javascript - // to specify. - browser->window()->SetBounds(gfx::Rect(0, 0, 400, 300)); - } - browser->window()->Show(); - } else { - LOG(ERROR) << "Wasn't able to get the List if requested files."; - return; +void FilebrowseHandler::OpenNewWindow(const ListValue* args, bool popup) { + std::string url = WideToUTF8(ExtractStringValue(args)); + Browser* browser = popup ? + Browser::CreateForType(Browser::TYPE_APP_PANEL, profile_) : + BrowserList::GetLastActive(); + browser->AddTabWithURL(GURL(url), GURL(), PageTransition::LINK, -1, + TabStripModel::ADD_SELECTED, NULL, std::string(), + &browser); + if (popup) { + // TODO(dhg): Remove these from being hardcoded. Allow javascript + // to specify. + browser->window()->SetBounds(gfx::Rect(0, 0, 400, 300)); } + browser->window()->Show(); } void FilebrowseHandler::SendPicasawebRequest() { @@ -812,8 +707,7 @@ void FilebrowseHandler::ReadInFile() { url += username; url += kPicasawebDefault; - FilePath currentpath; - currentpath = FilePath(current_file_uploaded_); + FilePath currentpath(current_file_uploaded_); // Get the filename std::string filename; filename = currentpath.BaseName().value(); @@ -838,28 +732,12 @@ void FilebrowseHandler::ReadInFile() { // This is just a prototype for allowing generic uploads to various sites // TODO(dhg): Remove this and implement general upload. -void FilebrowseHandler::UploadToPicasaweb(const Value* value) { - std::string path; +void FilebrowseHandler::UploadToPicasaweb(const ListValue* args) { #if defined(OS_CHROMEOS) - if (value && value->GetType() == Value::TYPE_LIST) { - const ListValue* list_value = static_cast<const ListValue*>(value); - Value* list_member; - - // Get search string. - if (list_value->Get(0, &list_member) && - list_member->GetType() == Value::TYPE_STRING) { - const StringValue* string_value = - static_cast<const StringValue*>(list_member); - string_value->GetAsString(&path); - } - - } else { - LOG(ERROR) << "Wasn't able to get the List if requested files."; - return; - } - current_file_uploaded_ = path; + std::string search_string = WideToUTF8(ExtractStringValue(args)); + current_file_uploaded_ = search_string; // ReadInFile(); - FilePath current_path(path); + FilePath current_path(search_string); TaskProxy* task = new TaskProxy(AsWeakPtr(), current_path); task->AddRef(); current_task_ = task; @@ -872,7 +750,7 @@ void FilebrowseHandler::UploadToPicasaweb(const Value* value) { void FilebrowseHandler::GetChildrenForPath(FilePath& path, bool is_refresh) { filelist_value_.reset(new ListValue()); - currentpath_ = FilePath(path); + currentpath_ = path; if (lister_.get()) { lister_->Cancel(); @@ -896,33 +774,14 @@ void FilebrowseHandler::GetChildrenForPath(FilePath& path, bool is_refresh) { lister_->Start(); } -void FilebrowseHandler::HandleGetChildren(const Value* value) { - std::string path; - if (value && value->GetType() == Value::TYPE_LIST) { - const ListValue* list_value = static_cast<const ListValue*>(value); - Value* list_member; - - // Get search string. - if (list_value->Get(0, &list_member) && - list_member->GetType() == Value::TYPE_STRING) { - const StringValue* string_value = - static_cast<const StringValue*>(list_member); - string_value->GetAsString(&path); - } - - } else { - LOG(ERROR) << "Wasn't able to get the List if requested files."; - return; - } +void FilebrowseHandler::HandleGetChildren(const ListValue* args) { +#if defined(OS_CHROMEOS) + std::string path = WideToUTF8(ExtractStringValue(args)); + FilePath currentpath(path); filelist_value_.reset(new ListValue()); - FilePath currentpath; -#if defined(OS_WIN) - currentpath = FilePath(ASCIIToWide(path)); -#else - currentpath = FilePath(path); -#endif GetChildrenForPath(currentpath, false); +#endif } void FilebrowseHandler::OnListFile( @@ -947,7 +806,6 @@ void FilebrowseHandler::OnListFile( currentpath_.Append(data.cFileName).value()); file_value->SetBoolean(kPropertyDirectory, (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? true : false); - #elif defined(OS_POSIX) file_value->SetString(kPropertyTitle, data.filename); file_value->SetString(kPropertyPath, @@ -970,10 +828,10 @@ void FilebrowseHandler::OnListDone(int error) { SendCurrentDownloads(); } -void FilebrowseHandler::HandleGetMetadata(const Value* value) { +void FilebrowseHandler::HandleGetMetadata(const ListValue* args) { } -void FilebrowseHandler::HandleGetDownloads(const Value* value) { +void FilebrowseHandler::HandleGetDownloads(const ListValue* args) { ModelChanged(); } @@ -1023,39 +881,27 @@ void FilebrowseHandler::DeleteFile(const FilePath& path) { NewRunnableMethod(current_task_, &TaskProxy::FireDeleteCompleteProxy)); } -void FilebrowseHandler::HandleDeleteFile(const Value* value) { - #if defined(OS_CHROMEOS) - if (value && value->GetType() == Value::TYPE_LIST) { - const ListValue* list_value = static_cast<const ListValue*>(value); - std::string path; - - // Get path string. - if (list_value->GetString(0, &path)) { - - FilePath currentpath; - currentpath = FilePath(path); - for (unsigned int x = 0; x < active_download_items_.size(); x++) { - FilePath item = active_download_items_[x]->full_path(); - if (item == currentpath) { - active_download_items_[x]->Cancel(true); - active_download_items_[x]->Remove(true); - FilePath dir_path = item.DirName(); - GetChildrenForPath(dir_path, true); - return; - } - } - TaskProxy* task = new TaskProxy(AsWeakPtr(), currentpath); - task->AddRef(); - current_task_ = task; - ChromeThread::PostTask( - ChromeThread::FILE, FROM_HERE, - NewRunnableMethod( - task, &TaskProxy::DeleteFileProxy)); - } else { - LOG(ERROR) << "Unable to get string"; +void FilebrowseHandler::HandleDeleteFile(const ListValue* args) { +#if defined(OS_CHROMEOS) + std::string path = WideToUTF8(ExtractStringValue(args)); + FilePath currentpath(path); + for (unsigned int x = 0; x < active_download_items_.size(); x++) { + FilePath item = active_download_items_[x]->full_path(); + if (item == currentpath) { + active_download_items_[x]->Cancel(true); + active_download_items_[x]->Remove(true); + FilePath dir_path = item.DirName(); + GetChildrenForPath(dir_path, true); return; } } + TaskProxy* task = new TaskProxy(AsWeakPtr(), currentpath); + task->AddRef(); + current_task_ = task; + ChromeThread::PostTask( + ChromeThread::FILE, FROM_HERE, + NewRunnableMethod( + task, &TaskProxy::DeleteFileProxy)); #endif } diff --git a/chrome/browser/dom_ui/foreign_session_handler.cc b/chrome/browser/dom_ui/foreign_session_handler.cc index 7e08fae..a341f47 100644 --- a/chrome/browser/dom_ui/foreign_session_handler.cc +++ b/chrome/browser/dom_ui/foreign_session_handler.cc @@ -5,6 +5,7 @@ #include "chrome/browser/dom_ui/foreign_session_handler.h" #include "base/scoped_vector.h" +#include "base/utf_string_conversions.h" #include "chrome/browser/browser.h" #include "chrome/browser/dom_ui/value_helper.h" #include "chrome/browser/sessions/session_restore.h" @@ -70,32 +71,21 @@ SessionModelAssociator* ForeignSessionHandler::GetModelAssociator() { GetSessionModelAssociator(); } -void ForeignSessionHandler::HandleGetForeignSessions(const Value* content) { +void ForeignSessionHandler::HandleGetForeignSessions(const ListValue* args) { SessionModelAssociator* associator = GetModelAssociator(); if (associator) GetForeignSessions(associator); } void ForeignSessionHandler::HandleReopenForeignSession( - const Value* content) { + const ListValue* args) { // Extract the machine tag and use it to obtain the id for the node we are // looking for. Send it along with a valid associator to OpenForeignSessions. - if (content->GetType() == Value::TYPE_LIST) { - const ListValue* list_value = static_cast<const ListValue*>(content); - Value* list_member; - if (list_value->Get(0, &list_member) && - list_member->GetType() == Value::TYPE_STRING) { - const StringValue* string_value = - static_cast<const StringValue*>(list_member); - std::string session_string_value; - if (string_value->GetAsString(&session_string_value)) { - SessionModelAssociator* associator = GetModelAssociator(); - if (associator) { - int64 id = associator->GetSyncIdFromChromeId(session_string_value); - OpenForeignSession(associator, id); - } - } - } + std::string session_string_value = WideToUTF8(ExtractStringValue(args)); + SessionModelAssociator* associator = GetModelAssociator(); + if (associator && !session_string_value.empty()) { + int64 id = associator->GetSyncIdFromChromeId(session_string_value); + OpenForeignSession(associator, id); } } diff --git a/chrome/browser/dom_ui/foreign_session_handler.h b/chrome/browser/dom_ui/foreign_session_handler.h index 10fd61c..1c4751d 100644 --- a/chrome/browser/dom_ui/foreign_session_handler.h +++ b/chrome/browser/dom_ui/foreign_session_handler.h @@ -37,7 +37,7 @@ class ForeignSessionHandler : public DOMMessageHandler, // Determines whether foreign sessions should be obtained from the sync model. // This is a javascript callback handler, and it is also called when the sync // model has changed and the new tab page needs to reflect the changes. - void HandleGetForeignSessions(const Value* content); + void HandleGetForeignSessions(const ListValue* args); // Helper for reopening a foreign session in a new browser window. void OpenForeignSession(SessionModelAssociator* associator, int64 id); @@ -48,7 +48,7 @@ class ForeignSessionHandler : public DOMMessageHandler, // Determines which session is to be opened, and then calls // OpenForeignSession, to begin the process of opening a new browser window. // This is a javascript callback handler. - void HandleReopenForeignSession(const Value* content); + void HandleReopenForeignSession(const ListValue* args); // The Registrar used to register ForeignSessionHandler for notifications. NotificationRegistrar registrar_; diff --git a/chrome/browser/dom_ui/history2_ui.cc b/chrome/browser/dom_ui/history2_ui.cc index 114a5b9..f2107a1 100644 --- a/chrome/browser/dom_ui/history2_ui.cc +++ b/chrome/browser/dom_ui/history2_ui.cc @@ -147,13 +147,13 @@ void BrowsingHistoryHandler2::RegisterMessages() { NewCallback(this, &BrowsingHistoryHandler2::HandleClearBrowsingData)); } -void BrowsingHistoryHandler2::HandleGetHistory(const Value* value) { +void BrowsingHistoryHandler2::HandleGetHistory(const ListValue* args) { // Anything in-flight is invalid. cancelable_search_consumer_.CancelAllRequests(); // Get arguments (if any). int day = 0; - ExtractIntegerValue(value, &day); + ExtractIntegerValue(args, &day); // Set our query options. history::QueryOptions options; @@ -173,14 +173,14 @@ void BrowsingHistoryHandler2::HandleGetHistory(const Value* value) { NewCallback(this, &BrowsingHistoryHandler2::QueryComplete)); } -void BrowsingHistoryHandler2::HandleSearchHistory(const Value* value) { +void BrowsingHistoryHandler2::HandleSearchHistory(const ListValue* args) { // Anything in-flight is invalid. cancelable_search_consumer_.CancelAllRequests(); // Get arguments (if any). int month = 0; string16 query; - ExtractSearchHistoryArguments(value, &month, &query); + ExtractSearchHistoryArguments(args, &month, &query); // Set the query ranges for the given month. history::QueryOptions options = CreateMonthQueryOptions(month); @@ -198,17 +198,15 @@ void BrowsingHistoryHandler2::HandleSearchHistory(const Value* value) { NewCallback(this, &BrowsingHistoryHandler2::QueryComplete)); } -void BrowsingHistoryHandler2::HandleRemoveURLsOnOneDay(const Value* value) { +void BrowsingHistoryHandler2::HandleRemoveURLsOnOneDay(const ListValue* args) { if (cancelable_delete_consumer_.HasPendingRequests()) { dom_ui_->CallJavascriptFunction(L"deleteFailed"); return; } - DCHECK(value && value->GetType() == Value::TYPE_LIST); - // Get day to delete data from. int visit_time = 0; - ExtractIntegerValue(value, &visit_time); + ExtractIntegerValue(args, &visit_time); base::Time::Exploded exploded; base::Time::FromTimeT( static_cast<time_t>(visit_time)).LocalExplode(&exploded); @@ -218,9 +216,8 @@ void BrowsingHistoryHandler2::HandleRemoveURLsOnOneDay(const Value* value) { // Get URLs. std::set<GURL> urls; - const ListValue* list_value = static_cast<const ListValue*>(value); - for (ListValue::const_iterator v = list_value->begin() + 1; - v != list_value->end(); ++v) { + for (ListValue::const_iterator v = args->begin() + 1; + v != args->end(); ++v) { if ((*v)->GetType() != Value::TYPE_STRING) continue; const StringValue* string_value = static_cast<const StringValue*>(*v); @@ -237,7 +234,7 @@ void BrowsingHistoryHandler2::HandleRemoveURLsOnOneDay(const Value* value) { NewCallback(this, &BrowsingHistoryHandler2::RemoveComplete)); } -void BrowsingHistoryHandler2::HandleClearBrowsingData(const Value* value) { +void BrowsingHistoryHandler2::HandleClearBrowsingData(const ListValue* args) { // TODO(beng): This is an improper direct dependency on Browser. Route this // through some sort of delegate. Browser* browser = BrowserList::FindBrowserWithProfile(dom_ui_->GetProfile()); @@ -305,32 +302,29 @@ void BrowsingHistoryHandler2::RemoveComplete() { dom_ui_->CallJavascriptFunction(L"deleteComplete"); } -void BrowsingHistoryHandler2::ExtractSearchHistoryArguments(const Value* value, - int* month, - string16* query) { +void BrowsingHistoryHandler2::ExtractSearchHistoryArguments( + const ListValue* args, + int* month, + string16* query) { *month = 0; + Value* list_member; + + // Get search string. + if (args->Get(0, &list_member) && + list_member->GetType() == Value::TYPE_STRING) { + const StringValue* string_value = + static_cast<const StringValue*>(list_member); + string_value->GetAsString(query); + } - if (value && value->GetType() == Value::TYPE_LIST) { - const ListValue* list_value = static_cast<const ListValue*>(value); - Value* list_member; - - // Get search string. - if (list_value->Get(0, &list_member) && - list_member->GetType() == Value::TYPE_STRING) { - const StringValue* string_value = - static_cast<const StringValue*>(list_member); - string_value->GetAsString(query); - } - - // Get search month. - if (list_value->Get(1, &list_member) && - list_member->GetType() == Value::TYPE_STRING) { - const StringValue* string_value = - static_cast<const StringValue*>(list_member); - string16 string16_value; - string_value->GetAsString(&string16_value); - base::StringToInt(string16_value, month); - } + // Get search month. + if (args->Get(1, &list_member) && + list_member->GetType() == Value::TYPE_STRING) { + const StringValue* string_value = + static_cast<const StringValue*>(list_member); + string16 string16_value; + string_value->GetAsString(&string16_value); + base::StringToInt(string16_value, month); } } diff --git a/chrome/browser/dom_ui/history2_ui.h b/chrome/browser/dom_ui/history2_ui.h index 2ca6ba6..b38650e 100644 --- a/chrome/browser/dom_ui/history2_ui.h +++ b/chrome/browser/dom_ui/history2_ui.h @@ -52,16 +52,16 @@ class BrowsingHistoryHandler2 : public DOMMessageHandler, virtual void RegisterMessages(); // Callback for the "getHistory" message. - void HandleGetHistory(const Value* value); + void HandleGetHistory(const ListValue* args); // Callback for the "searchHistory" message. - void HandleSearchHistory(const Value* value); + void HandleSearchHistory(const ListValue* args); // Callback for the "removeURLsOnOneDay" message. - void HandleRemoveURLsOnOneDay(const Value* value); + void HandleRemoveURLsOnOneDay(const ListValue* args); // Handle for "clearBrowsingData" message. - void HandleClearBrowsingData(const Value* value); + void HandleClearBrowsingData(const ListValue* args); // NotificationObserver implementation. virtual void Observe(NotificationType type, @@ -77,7 +77,7 @@ class BrowsingHistoryHandler2 : public DOMMessageHandler, void RemoveComplete(); // Extract the arguments from the call to HandleSearchHistory. - void ExtractSearchHistoryArguments(const Value* value, + void ExtractSearchHistoryArguments(const ListValue* args, int* month, string16* query); diff --git a/chrome/browser/dom_ui/history_ui.cc b/chrome/browser/dom_ui/history_ui.cc index bb4f210..60ff39f 100644 --- a/chrome/browser/dom_ui/history_ui.cc +++ b/chrome/browser/dom_ui/history_ui.cc @@ -147,13 +147,13 @@ void BrowsingHistoryHandler::RegisterMessages() { NewCallback(this, &BrowsingHistoryHandler::HandleClearBrowsingData)); } -void BrowsingHistoryHandler::HandleGetHistory(const Value* value) { +void BrowsingHistoryHandler::HandleGetHistory(const ListValue* args) { // Anything in-flight is invalid. cancelable_search_consumer_.CancelAllRequests(); // Get arguments (if any). int day = 0; - ExtractIntegerValue(value, &day); + ExtractIntegerValue(args, &day); // Set our query options. history::QueryOptions options; @@ -173,14 +173,14 @@ void BrowsingHistoryHandler::HandleGetHistory(const Value* value) { NewCallback(this, &BrowsingHistoryHandler::QueryComplete)); } -void BrowsingHistoryHandler::HandleSearchHistory(const Value* value) { +void BrowsingHistoryHandler::HandleSearchHistory(const ListValue* args) { // Anything in-flight is invalid. cancelable_search_consumer_.CancelAllRequests(); // Get arguments (if any). int month = 0; string16 query; - ExtractSearchHistoryArguments(value, &month, &query); + ExtractSearchHistoryArguments(args, &month, &query); // Set the query ranges for the given month. history::QueryOptions options = CreateMonthQueryOptions(month); @@ -198,17 +198,15 @@ void BrowsingHistoryHandler::HandleSearchHistory(const Value* value) { NewCallback(this, &BrowsingHistoryHandler::QueryComplete)); } -void BrowsingHistoryHandler::HandleRemoveURLsOnOneDay(const Value* value) { +void BrowsingHistoryHandler::HandleRemoveURLsOnOneDay(const ListValue* args) { if (cancelable_delete_consumer_.HasPendingRequests()) { dom_ui_->CallJavascriptFunction(L"deleteFailed"); return; } - DCHECK(value && value->GetType() == Value::TYPE_LIST); - // Get day to delete data from. int visit_time = 0; - ExtractIntegerValue(value, &visit_time); + ExtractIntegerValue(args, &visit_time); base::Time::Exploded exploded; base::Time::FromTimeT( static_cast<time_t>(visit_time)).LocalExplode(&exploded); @@ -218,9 +216,8 @@ void BrowsingHistoryHandler::HandleRemoveURLsOnOneDay(const Value* value) { // Get URLs. std::set<GURL> urls; - const ListValue* list_value = static_cast<const ListValue*>(value); - for (ListValue::const_iterator v = list_value->begin() + 1; - v != list_value->end(); ++v) { + for (ListValue::const_iterator v = args->begin() + 1; + v != args->end(); ++v) { if ((*v)->GetType() != Value::TYPE_STRING) continue; const StringValue* string_value = static_cast<const StringValue*>(*v); @@ -237,7 +234,7 @@ void BrowsingHistoryHandler::HandleRemoveURLsOnOneDay(const Value* value) { NewCallback(this, &BrowsingHistoryHandler::RemoveComplete)); } -void BrowsingHistoryHandler::HandleClearBrowsingData(const Value* value) { +void BrowsingHistoryHandler::HandleClearBrowsingData(const ListValue* args) { // TODO(beng): This is an improper direct dependency on Browser. Route this // through some sort of delegate. Browser* browser = BrowserList::FindBrowserWithProfile(dom_ui_->GetProfile()); @@ -305,33 +302,18 @@ void BrowsingHistoryHandler::RemoveComplete() { dom_ui_->CallJavascriptFunction(L"deleteComplete"); } -void BrowsingHistoryHandler::ExtractSearchHistoryArguments(const Value* value, - int* month, - string16* query) { - *month = 0; - - if (value && value->GetType() == Value::TYPE_LIST) { - const ListValue* list_value = static_cast<const ListValue*>(value); - Value* list_member; - - // Get search string. - if (list_value->Get(0, &list_member) && - list_member->GetType() == Value::TYPE_STRING) { - const StringValue* string_value = - static_cast<const StringValue*>(list_member); - string_value->GetAsString(query); - } +void BrowsingHistoryHandler::ExtractSearchHistoryArguments( + const ListValue* args, + int* month, + string16* query) { + CHECK(args->GetSize() == 2); + query->clear(); + CHECK(args->GetString(0, query)); - // Get search month. - if (list_value->Get(1, &list_member) && - list_member->GetType() == Value::TYPE_STRING) { - const StringValue* string_value = - static_cast<const StringValue*>(list_member); - string16 string16_value; - string_value->GetAsString(&string16_value); - base::StringToInt(string16_value, month); - } - } + string16 string16_value; + CHECK(args->GetString(1, &string16_value)); + *month = 0; + base::StringToInt(string16_value, month); } history::QueryOptions BrowsingHistoryHandler::CreateMonthQueryOptions( diff --git a/chrome/browser/dom_ui/history_ui.h b/chrome/browser/dom_ui/history_ui.h index c6cf74b..8d33afe 100644 --- a/chrome/browser/dom_ui/history_ui.h +++ b/chrome/browser/dom_ui/history_ui.h @@ -48,16 +48,16 @@ class BrowsingHistoryHandler : public DOMMessageHandler, virtual void RegisterMessages(); // Callback for the "getHistory" message. - void HandleGetHistory(const Value* value); + void HandleGetHistory(const ListValue* args); // Callback for the "searchHistory" message. - void HandleSearchHistory(const Value* value); + void HandleSearchHistory(const ListValue* args); // Callback for the "removeURLsOnOneDay" message. - void HandleRemoveURLsOnOneDay(const Value* value); + void HandleRemoveURLsOnOneDay(const ListValue* args); // Handle for "clearBrowsingData" message. - void HandleClearBrowsingData(const Value* value); + void HandleClearBrowsingData(const ListValue* args); // NotificationObserver implementation. virtual void Observe(NotificationType type, @@ -73,7 +73,7 @@ class BrowsingHistoryHandler : public DOMMessageHandler, void RemoveComplete(); // Extract the arguments from the call to HandleSearchHistory. - void ExtractSearchHistoryArguments(const Value* value, + void ExtractSearchHistoryArguments(const ListValue* args, int* month, string16* query); diff --git a/chrome/browser/dom_ui/html_dialog_ui.cc b/chrome/browser/dom_ui/html_dialog_ui.cc index f93e9ca..ff49805 100644 --- a/chrome/browser/dom_ui/html_dialog_ui.cc +++ b/chrome/browser/dom_ui/html_dialog_ui.cc @@ -59,12 +59,13 @@ void HtmlDialogUI::RenderViewCreated(RenderViewHost* render_view_host) { } } -void HtmlDialogUI::OnDialogClosed(const Value* content) { +void HtmlDialogUI::OnDialogClosed(const ListValue* args) { HtmlDialogUIDelegate** delegate = GetPropertyAccessor().GetProperty( tab_contents()->property_bag()); - if (delegate) + if (delegate) { (*delegate)->OnDialogClosed( - dom_ui_util::GetJsonResponseFromFirstArgumentInList(content)); + dom_ui_util::GetJsonResponseFromFirstArgumentInList(args)); + } } ExternalHtmlDialogUI::ExternalHtmlDialogUI(TabContents* tab_contents) diff --git a/chrome/browser/dom_ui/html_dialog_ui.h b/chrome/browser/dom_ui/html_dialog_ui.h index e4220ed..38673c4 100644 --- a/chrome/browser/dom_ui/html_dialog_ui.h +++ b/chrome/browser/dom_ui/html_dialog_ui.h @@ -91,7 +91,7 @@ class HtmlDialogUI : public DOMUI { virtual void RenderViewCreated(RenderViewHost* render_view_host); // JS message handler. - void OnDialogClosed(const Value* content); + void OnDialogClosed(const ListValue* args); DISALLOW_COPY_AND_ASSIGN(HtmlDialogUI); }; diff --git a/chrome/browser/dom_ui/import_data_handler.cc b/chrome/browser/dom_ui/import_data_handler.cc index 73108f4..08332df 100644 --- a/chrome/browser/dom_ui/import_data_handler.cc +++ b/chrome/browser/dom_ui/import_data_handler.cc @@ -77,19 +77,9 @@ void ImportDataHandler::DetectSupportedBrowsers() { supported_browsers); } -void ImportDataHandler::ImportData(const Value* value) { - if (!value || !value->IsType(Value::TYPE_LIST)) { - NOTREACHED(); - return; - } - - const ListValue* param_values = static_cast<const ListValue*>(value); - std::string string_value; - if (param_values->GetSize() != 1 || - !param_values->GetString(0, &string_value)) { - NOTREACHED(); - return; - } +void ImportDataHandler::ImportData(const ListValue* args) { + std::string string_value = WideToUTF8(ExtractStringValue(args)); + CHECK(!string_value.empty()); int browser_index = string_value[0] - '0'; uint16 items = importer::NONE; diff --git a/chrome/browser/dom_ui/import_data_handler.h b/chrome/browser/dom_ui/import_data_handler.h index c630bd2..bd8b72b 100644 --- a/chrome/browser/dom_ui/import_data_handler.h +++ b/chrome/browser/dom_ui/import_data_handler.h @@ -25,7 +25,7 @@ class ImportDataHandler : public OptionsPageUIHandler, private: void DetectSupportedBrowsers(); - void ImportData(const Value* value); + void ImportData(const ListValue* args); //Callback from ImporterHost. Close the Dialog. virtual void ImportStarted(); diff --git a/chrome/browser/dom_ui/mediaplayer_ui.cc b/chrome/browser/dom_ui/mediaplayer_ui.cc index df6b6eb..16aa9b2 100644 --- a/chrome/browser/dom_ui/mediaplayer_ui.cc +++ b/chrome/browser/dom_ui/mediaplayer_ui.cc @@ -106,7 +106,7 @@ class MediaplayerHandler : public DOMMessageHandler, virtual void RegisterMessages(); // Callback for the "currentOffsetChanged" message. - void HandleCurrentOffsetChanged(const Value* value); + void HandleCurrentOffsetChanged(const ListValue* args); void FirePlaylistChanged(const std::string& path, bool force, @@ -116,18 +116,18 @@ class MediaplayerHandler : public DOMMessageHandler, void EnqueueMediaFile(const GURL& url); - void GetPlaylistValue(ListValue& value); + void GetPlaylistValue(ListValue& args); // Callback for the "playbackError" message. - void HandlePlaybackError(const Value* value); + void HandlePlaybackError(const ListValue* args); // Callback for the "getCurrentPlaylist" message. - void HandleGetCurrentPlaylist(const Value* value); + void HandleGetCurrentPlaylist(const ListValue* args); - void HandleTogglePlaylist(const Value* value); - void HandleShowPlaylist(const Value* value); - void HandleSetCurrentPlaylistOffset(const Value* value); - void HandleToggleFullscreen(const Value* value); + void HandleTogglePlaylist(const ListValue* args); + void HandleShowPlaylist(const ListValue* args); + void HandleSetCurrentPlaylistOffset(const ListValue* args); + void HandleToggleFullscreen(const ListValue* args); const UrlVector& GetCurrentPlaylist(); @@ -245,12 +245,12 @@ void MediaplayerHandler::RegisterMessages() { NewCallback(this, &MediaplayerHandler::HandleShowPlaylist)); } -void MediaplayerHandler::GetPlaylistValue(ListValue& value) { +void MediaplayerHandler::GetPlaylistValue(ListValue& urls) { for (size_t x = 0; x < current_playlist_.size(); x++) { DictionaryValue* url_value = new DictionaryValue(); url_value->SetString(kPropertyPath, current_playlist_[x].url.spec()); url_value->SetBoolean(kPropertyError, current_playlist_[x].haderror); - value.Append(url_value); + urls.Append(url_value); } } @@ -269,22 +269,14 @@ int MediaplayerHandler::GetCurrentPlaylistOffset() { return current_offset_; } -void MediaplayerHandler::HandleToggleFullscreen(const Value* value) { +void MediaplayerHandler::HandleToggleFullscreen(const ListValue* args) { MediaPlayer::Get()->ToggleFullscreen(); } -void MediaplayerHandler::HandleSetCurrentPlaylistOffset(const Value* value) { - ListValue results_value; - DictionaryValue info_value; - if (value && value->GetType() == Value::TYPE_LIST) { - // Get the new playlist offset; - const ListValue* list_value = static_cast<const ListValue*>(value); - std::string val; - if (list_value->GetString(0, &val)) { - int id = atoi(val.c_str()); - MediaPlayer::Get()->SetPlaylistOffset(id); - } - } +void MediaplayerHandler::HandleSetCurrentPlaylistOffset(const ListValue* args) { + int id; + CHECK(ExtractIntegerValue(args, &id)); + MediaPlayer::Get()->SetPlaylistOffset(id); } void MediaplayerHandler::FirePlaylistChanged(const std::string& path, @@ -317,51 +309,36 @@ void MediaplayerHandler::EnqueueMediaFile(const GURL& url) { MediaPlayer::Get()->NotifyPlaylistChanged(); } -void MediaplayerHandler::HandleCurrentOffsetChanged(const Value* value) { - ListValue results_value; - DictionaryValue info_value; - if (value && value->GetType() == Value::TYPE_LIST) { - const ListValue* list_value = static_cast<const ListValue*>(value); - std::string val; - - // Get the new playlist offset; - if (list_value->GetString(0, &val)) { - int id = atoi(val.c_str()); - current_offset_ = id; - MediaPlayer::Get()->NotifyPlaylistChanged(); - } - } +void MediaplayerHandler::HandleCurrentOffsetChanged(const ListValue* args) { + CHECK(ExtractIntegerValue(args, ¤t_offset_)); + MediaPlayer::Get()->NotifyPlaylistChanged(); } -void MediaplayerHandler::HandlePlaybackError(const Value* value) { - if (value && value->GetType() == Value::TYPE_LIST) { - const ListValue* list_value = static_cast<const ListValue*>(value); - std::string error; - std::string url; - // Get path string. - if (list_value->GetString(0, &error)) { - LOG(ERROR) << "Playback error" << error; - } - if (list_value->GetString(1, &url)) { - for (size_t x = 0; x < current_playlist_.size(); x++) { - if (current_playlist_[x].url == GURL(url)) { - current_playlist_[x].haderror = true; - } +void MediaplayerHandler::HandlePlaybackError(const ListValue* args) { + std::string error; + std::string url; + // Get path string. + if (args->GetString(0, &error)) + LOG(ERROR) << "Playback error" << error; + if (args->GetString(1, &url)) { + for (size_t x = 0; x < current_playlist_.size(); x++) { + if (current_playlist_[x].url == GURL(url)) { + current_playlist_[x].haderror = true; } - FirePlaylistChanged(std::string(), false, current_offset_); } + FirePlaylistChanged(std::string(), false, current_offset_); } } -void MediaplayerHandler::HandleGetCurrentPlaylist(const Value* value) { +void MediaplayerHandler::HandleGetCurrentPlaylist(const ListValue* args) { FirePlaylistChanged(std::string(), false, current_offset_); } -void MediaplayerHandler::HandleTogglePlaylist(const Value* value) { +void MediaplayerHandler::HandleTogglePlaylist(const ListValue* args) { MediaPlayer::Get()->TogglePlaylistWindowVisible(); } -void MediaplayerHandler::HandleShowPlaylist(const Value* value) { +void MediaplayerHandler::HandleShowPlaylist(const ListValue* args) { MediaPlayer::Get()->ShowPlaylistWindow(); } diff --git a/chrome/browser/dom_ui/most_visited_handler.cc b/chrome/browser/dom_ui/most_visited_handler.cc index 33f3ec6..9a045d8 100644 --- a/chrome/browser/dom_ui/most_visited_handler.cc +++ b/chrome/browser/dom_ui/most_visited_handler.cc @@ -117,7 +117,7 @@ void MostVisitedHandler::RegisterMessages() { NewCallback(this, &MostVisitedHandler::HandleRemovePinnedURL)); } -void MostVisitedHandler::HandleGetMostVisited(const Value* value) { +void MostVisitedHandler::HandleGetMostVisited(const ListValue* args) { if (!got_first_most_visited_request_) { // If our intial data is already here, return it. SendPagesValue(); @@ -175,33 +175,16 @@ void MostVisitedHandler::StartQueryForMostVisited() { } } -void MostVisitedHandler::HandleBlacklistURL(const Value* value) { - if (!value->IsType(Value::TYPE_LIST)) { - NOTREACHED(); - return; - } - std::string url; - const ListValue* list = static_cast<const ListValue*>(value); - if (list->GetSize() == 0 || !list->GetString(0, &url)) { - NOTREACHED(); - return; - } +void MostVisitedHandler::HandleBlacklistURL(const ListValue* args) { + std::string url = WideToUTF8(ExtractStringValue(args)); BlacklistURL(GURL(url)); } -void MostVisitedHandler::HandleRemoveURLsFromBlacklist(const Value* urls) { - if (!urls->IsType(Value::TYPE_LIST)) { - NOTREACHED(); - return; - } - const ListValue* list = static_cast<const ListValue*>(urls); - if (list->GetSize() == 0) { - NOTREACHED(); - return; - } +void MostVisitedHandler::HandleRemoveURLsFromBlacklist(const ListValue* args) { + DCHECK(args->GetSize() != 0); - for (ListValue::const_iterator iter = list->begin(); - iter != list->end(); ++iter) { + for (ListValue::const_iterator iter = args->begin(); + iter != args->end(); ++iter) { std::string url; bool r = (*iter)->GetAsString(&url); if (!r) { @@ -221,7 +204,7 @@ void MostVisitedHandler::HandleRemoveURLsFromBlacklist(const Value* urls) { } } -void MostVisitedHandler::HandleClearBlacklist(const Value* value) { +void MostVisitedHandler::HandleClearBlacklist(const ListValue* args) { UserMetrics::RecordAction(UserMetricsAction("MostVisited_BlacklistCleared"), dom_ui_->GetProfile()); @@ -234,40 +217,34 @@ void MostVisitedHandler::HandleClearBlacklist(const Value* value) { url_blacklist_->Clear(); } -void MostVisitedHandler::HandleAddPinnedURL(const Value* value) { - if (!value->IsType(Value::TYPE_LIST)) { - NOTREACHED(); - return; - } - - const ListValue* list = static_cast<const ListValue*>(value); - DCHECK_EQ(5U, list->GetSize()) << "Wrong number of params to addPinnedURL"; +void MostVisitedHandler::HandleAddPinnedURL(const ListValue* args) { + DCHECK_EQ(5U, args->GetSize()) << "Wrong number of params to addPinnedURL"; MostVisitedPage mvp; std::string tmp_string; string16 tmp_string16; int index; - bool r = list->GetString(0, &tmp_string); + bool r = args->GetString(0, &tmp_string); DCHECK(r) << "Missing URL in addPinnedURL from the NTP Most Visited."; mvp.url = GURL(tmp_string); - r = list->GetString(1, &tmp_string16); + r = args->GetString(1, &tmp_string16); DCHECK(r) << "Missing title in addPinnedURL from the NTP Most Visited."; mvp.title = tmp_string16; - r = list->GetString(2, &tmp_string); + r = args->GetString(2, &tmp_string); DCHECK(r) << "Failed to read the favicon URL in addPinnedURL from the NTP " << "Most Visited."; if (!tmp_string.empty()) mvp.favicon_url = GURL(tmp_string); - r = list->GetString(3, &tmp_string); + r = args->GetString(3, &tmp_string); DCHECK(r) << "Failed to read the thumbnail URL in addPinnedURL from the NTP " << "Most Visited."; if (!tmp_string.empty()) mvp.thumbnail_url = GURL(tmp_string); - r = list->GetString(4, &tmp_string); + r = args->GetString(4, &tmp_string); DCHECK(r) << "Missing index in addPinnedURL from the NTP Most Visited."; base::StringToInt(tmp_string, &index); @@ -298,18 +275,8 @@ void MostVisitedHandler::AddPinnedURL(const MostVisitedPage& page, int index) { // Don't call HandleGetMostVisited. Let the client call this as needed. } -void MostVisitedHandler::HandleRemovePinnedURL(const Value* value) { - if (!value->IsType(Value::TYPE_LIST)) { - NOTREACHED(); - return; - } - - const ListValue* list = static_cast<const ListValue*>(value); - std::string url; - - bool r = list->GetString(0, &url); - DCHECK(r) << "Failed to read the URL to remove from the NTP Most Visited."; - +void MostVisitedHandler::HandleRemovePinnedURL(const ListValue* args) { + std::string url = WideToUTF8(ExtractStringValue(args)); RemovePinnedURL(GURL(url)); } diff --git a/chrome/browser/dom_ui/most_visited_handler.h b/chrome/browser/dom_ui/most_visited_handler.h index fdfd7cd..bdb42e2 100644 --- a/chrome/browser/dom_ui/most_visited_handler.h +++ b/chrome/browser/dom_ui/most_visited_handler.h @@ -35,22 +35,22 @@ class MostVisitedHandler : public DOMMessageHandler, virtual void RegisterMessages(); // Callback for the "getMostVisited" message. - void HandleGetMostVisited(const Value* value); + void HandleGetMostVisited(const ListValue* args); // Callback for the "blacklistURLFromMostVisited" message. - void HandleBlacklistURL(const Value* url); + void HandleBlacklistURL(const ListValue* args); // Callback for the "removeURLsFromMostVisitedBlacklist" message. - void HandleRemoveURLsFromBlacklist(const Value* url); + void HandleRemoveURLsFromBlacklist(const ListValue* args); // Callback for the "clearMostVisitedURLsBlacklist" message. - void HandleClearBlacklist(const Value* url); + void HandleClearBlacklist(const ListValue* args); // Callback for the "addPinnedURL" message. - void HandleAddPinnedURL(const Value* value); + void HandleAddPinnedURL(const ListValue* args); // Callback for the "removePinnedURL" message. - void HandleRemovePinnedURL(const Value* value); + void HandleRemovePinnedURL(const ListValue* args); // NotificationObserver implementation. virtual void Observe(NotificationType type, diff --git a/chrome/browser/dom_ui/net_internals_ui.cc b/chrome/browser/dom_ui/net_internals_ui.cc index aa39cab9..63ad1a2 100644 --- a/chrome/browser/dom_ui/net_internals_ui.cc +++ b/chrome/browser/dom_ui/net_internals_ui.cc @@ -154,7 +154,7 @@ class NetInternalsMessageHandler::IOThreadImpl public ConnectionTester::Delegate { public: // Type for methods that can be used as MessageHandler callbacks. - typedef void (IOThreadImpl::*MessageHandler)(const Value*); + typedef void (IOThreadImpl::*MessageHandler)(const ListValue*); // Creates a proxy for |handler| that will live on the IO thread. // |handler| is a weak pointer, since it is possible for the DOMMessageHandler @@ -184,17 +184,17 @@ class NetInternalsMessageHandler::IOThreadImpl // This message is called after the webpage's onloaded handler has fired. // it indicates that the renderer is ready to start receiving captured data. - void OnRendererReady(const Value* value); - - void OnGetProxySettings(const Value* value); - void OnReloadProxySettings(const Value* value); - void OnGetBadProxies(const Value* value); - void OnClearBadProxies(const Value* value); - void OnGetHostResolverCache(const Value* value); - void OnClearHostResolverCache(const Value* value); - void OnGetPassiveLogEntries(const Value* value); - void OnStartConnectionTests(const Value* value); - void OnGetHttpCacheInfo(const Value* value); + void OnRendererReady(const ListValue* list); + + void OnGetProxySettings(const ListValue* list); + void OnReloadProxySettings(const ListValue* list); + void OnGetBadProxies(const ListValue* list); + void OnClearBadProxies(const ListValue* list); + void OnGetHostResolverCache(const ListValue* list); + void OnClearHostResolverCache(const ListValue* list); + void OnGetPassiveLogEntries(const ListValue* list); + void OnStartConnectionTests(const ListValue* list); + void OnGetHttpCacheInfo(const ListValue* list); // ChromeNetLog::Observer implementation: virtual void OnAddEntry(net::NetLog::EventType type, @@ -216,7 +216,7 @@ class NetInternalsMessageHandler::IOThreadImpl class CallbackHelper; // Helper that runs |method| with |arg|, and deletes |arg| on completion. - void DispatchToMessageHandler(Value* arg, MessageHandler method); + void DispatchToMessageHandler(ListValue* arg, MessageHandler method); // Helper that executes |function_name| in the attached renderer. // The function takes ownership of |arg|. @@ -251,20 +251,21 @@ class NetInternalsMessageHandler::IOThreadImpl::CallbackHelper DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); } - virtual void RunWithParams(const Tuple1<const Value*>& params) { + virtual void RunWithParams(const Tuple1<const ListValue*>& params) { DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); // We need to make a copy of the value in order to pass it over to the IO // thread. We will delete this in IOThreadImpl::DispatchMessageHandler(). - Value* value_copy = params.a ? params.a->DeepCopy() : NULL; + ListValue* list_copy = static_cast<ListValue*>( + params.a ? params.a->DeepCopy() : NULL); if (!ChromeThread::PostTask( ChromeThread::IO, FROM_HERE, NewRunnableMethod(instance_.get(), &IOThreadImpl::DispatchToMessageHandler, - value_copy, method_))) { - // Failed posting the task, avoid leaking |value_copy|. - delete value_copy; + list_copy, method_))) { + // Failed posting the task, avoid leaking |list_copy|. + delete list_copy; } } @@ -426,7 +427,7 @@ void NetInternalsMessageHandler::IOThreadImpl::Detach() { } void NetInternalsMessageHandler::IOThreadImpl::OnRendererReady( - const Value* value) { + const ListValue* list) { DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); DCHECK(!is_observing_log_) << "notifyReady called twice"; @@ -566,7 +567,7 @@ void NetInternalsMessageHandler::IOThreadImpl::OnRendererReady( } void NetInternalsMessageHandler::IOThreadImpl::OnGetProxySettings( - const Value* value) { + const ListValue* list) { URLRequestContext* context = context_getter_->GetURLRequestContext(); net::ProxyService* proxy_service = context->proxy_service(); @@ -582,7 +583,7 @@ void NetInternalsMessageHandler::IOThreadImpl::OnGetProxySettings( } void NetInternalsMessageHandler::IOThreadImpl::OnReloadProxySettings( - const Value* value) { + const ListValue* list) { URLRequestContext* context = context_getter_->GetURLRequestContext(); context->proxy_service()->ForceReloadProxyConfig(); @@ -591,13 +592,13 @@ void NetInternalsMessageHandler::IOThreadImpl::OnReloadProxySettings( } void NetInternalsMessageHandler::IOThreadImpl::OnGetBadProxies( - const Value* value) { + const ListValue* list) { URLRequestContext* context = context_getter_->GetURLRequestContext(); const net::ProxyRetryInfoMap& bad_proxies_map = context->proxy_service()->proxy_retry_info(); - ListValue* list = new ListValue(); + ListValue* dict_list = new ListValue(); for (net::ProxyRetryInfoMap::const_iterator it = bad_proxies_map.begin(); it != bad_proxies_map.end(); ++it) { @@ -608,14 +609,14 @@ void NetInternalsMessageHandler::IOThreadImpl::OnGetBadProxies( dict->SetString("proxy_uri", proxy_uri); dict->SetString("bad_until", TickCountToString(retry_info.bad_until)); - list->Append(dict); + dict_list->Append(dict); } - CallJavascriptFunction(L"g_browser.receivedBadProxies", list); + CallJavascriptFunction(L"g_browser.receivedBadProxies", dict_list); } void NetInternalsMessageHandler::IOThreadImpl::OnClearBadProxies( - const Value* value) { + const ListValue* list) { URLRequestContext* context = context_getter_->GetURLRequestContext(); context->proxy_service()->ClearBadProxiesCache(); @@ -624,7 +625,7 @@ void NetInternalsMessageHandler::IOThreadImpl::OnClearBadProxies( } void NetInternalsMessageHandler::IOThreadImpl::OnGetHostResolverCache( - const Value* value) { + const ListValue* list) { net::HostCache* cache = GetHostResolverCache(context_getter_->GetURLRequestContext()); @@ -683,7 +684,7 @@ void NetInternalsMessageHandler::IOThreadImpl::OnGetHostResolverCache( } void NetInternalsMessageHandler::IOThreadImpl::OnClearHostResolverCache( - const Value* value) { + const ListValue* list) { net::HostCache* cache = GetHostResolverCache(context_getter_->GetURLRequestContext()); @@ -695,34 +696,31 @@ void NetInternalsMessageHandler::IOThreadImpl::OnClearHostResolverCache( } void NetInternalsMessageHandler::IOThreadImpl::OnGetPassiveLogEntries( - const Value* value) { + const ListValue* list) { ChromeNetLog* net_log = io_thread_->globals()->net_log.get(); PassiveLogCollector::EntryList passive_entries; net_log->passive_collector()->GetAllCapturedEvents(&passive_entries); - ListValue* list = new ListValue(); + ListValue* dict_list = new ListValue(); for (size_t i = 0; i < passive_entries.size(); ++i) { const PassiveLogCollector::Entry& e = passive_entries[i]; - list->Append(net::NetLog::EntryToDictionaryValue(e.type, - e.time, - e.source, - e.phase, - e.params, - false)); + dict_list->Append(net::NetLog::EntryToDictionaryValue(e.type, + e.time, + e.source, + e.phase, + e.params, + false)); } - CallJavascriptFunction(L"g_browser.receivedPassiveLogEntries", list); + CallJavascriptFunction(L"g_browser.receivedPassiveLogEntries", dict_list); } void NetInternalsMessageHandler::IOThreadImpl::OnStartConnectionTests( - const Value* value) { + const ListValue* list) { // |value| should be: [<URL to test>]. string16 url_str; - if (value && value->GetType() == Value::TYPE_LIST) { - const ListValue* list = static_cast<const ListValue*>(value); - list->GetString(0, &url_str); - } + CHECK(list->GetString(0, &url_str)); // Try to fix-up the user provided URL into something valid. // For example, turn "www.google.com" into "http://www.google.com". @@ -733,7 +731,7 @@ void NetInternalsMessageHandler::IOThreadImpl::OnStartConnectionTests( } void NetInternalsMessageHandler::IOThreadImpl::OnGetHttpCacheInfo( - const Value* value) { + const ListValue* list) { DictionaryValue* info_dict = new DictionaryValue(); DictionaryValue* stats_dict = new DictionaryValue(); @@ -802,7 +800,7 @@ NetInternalsMessageHandler::IOThreadImpl::OnCompletedConnectionTestSuite() { } void NetInternalsMessageHandler::IOThreadImpl::DispatchToMessageHandler( - Value* arg, MessageHandler method) { + ListValue* arg, MessageHandler method) { DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); (this->*method)(arg); delete arg; diff --git a/chrome/browser/dom_ui/new_tab_page_sync_handler.cc b/chrome/browser/dom_ui/new_tab_page_sync_handler.cc index d52ca0d..bd6712c 100644 --- a/chrome/browser/dom_ui/new_tab_page_sync_handler.cc +++ b/chrome/browser/dom_ui/new_tab_page_sync_handler.cc @@ -110,7 +110,7 @@ void NewTabPageSyncHandler::RegisterMessages() { NewCallback(this, &NewTabPageSyncHandler::HandleSyncLinkClicked)); } -void NewTabPageSyncHandler::HandleGetSyncMessage(const Value* value) { +void NewTabPageSyncHandler::HandleGetSyncMessage(const ListValue* args) { waiting_for_initial_page_load_ = false; BuildAndSendSyncStatus(); } @@ -147,7 +147,7 @@ void NewTabPageSyncHandler::BuildAndSendSyncStatus() { UTF16ToUTF8(status_msg), UTF16ToUTF8(link_text)); } -void NewTabPageSyncHandler::HandleSyncLinkClicked(const Value* value) { +void NewTabPageSyncHandler::HandleSyncLinkClicked(const ListValue* args) { DCHECK(!waiting_for_initial_page_load_); DCHECK(sync_service_); if (!sync_service_->IsSyncEnabled()) diff --git a/chrome/browser/dom_ui/new_tab_page_sync_handler.h b/chrome/browser/dom_ui/new_tab_page_sync_handler.h index 2ac6ac7..9db005b 100644 --- a/chrome/browser/dom_ui/new_tab_page_sync_handler.h +++ b/chrome/browser/dom_ui/new_tab_page_sync_handler.h @@ -12,7 +12,7 @@ #include "chrome/browser/sync/profile_sync_service.h" #include "chrome/browser/sync/sync_ui_util.h" -class Value; +class ListValue; // Sends sync-state changes to the New Tab Page for UI updating and forwards // link clicks on the page to the sync service. @@ -27,9 +27,9 @@ class NewTabPageSyncHandler : public DOMMessageHandler, virtual void RegisterMessages(); // Callback for "GetSyncMessage". - void HandleGetSyncMessage(const Value* value); + void HandleGetSyncMessage(const ListValue* args); // Callback for "SyncLinkClicked". - void HandleSyncLinkClicked(const Value* value); + void HandleSyncLinkClicked(const ListValue* args); // ProfileSyncServiceObserver virtual void OnStateChanged(); diff --git a/chrome/browser/dom_ui/new_tab_ui.cc b/chrome/browser/dom_ui/new_tab_ui.cc index 7fe8ee8..b1aa10a 100644 --- a/chrome/browser/dom_ui/new_tab_ui.cc +++ b/chrome/browser/dom_ui/new_tab_ui.cc @@ -131,10 +131,10 @@ class RecentlyClosedTabsHandler : public DOMMessageHandler, // Callback for the "reopenTab" message. Rewrites the history of the // currently displayed tab to be the one in TabRestoreService with a // history of a session passed in through the content pointer. - void HandleReopenTab(const Value* content); + void HandleReopenTab(const ListValue* args); // Callback for the "getRecentlyClosedTabs" message. - void HandleGetRecentlyClosedTabs(const Value* content); + void HandleGetRecentlyClosedTabs(const ListValue* args); // Observer callback for TabRestoreService::Observer. Sends data on // recently closed tabs to the javascript side of this page to @@ -181,39 +181,21 @@ RecentlyClosedTabsHandler::~RecentlyClosedTabsHandler() { tab_restore_service_->RemoveObserver(this); } -void RecentlyClosedTabsHandler::HandleReopenTab(const Value* content) { +void RecentlyClosedTabsHandler::HandleReopenTab(const ListValue* args) { Browser* browser = Browser::GetBrowserForController( &dom_ui_->tab_contents()->controller(), NULL); if (!browser) return; - // Extract the integer value of the tab session to restore from the - // incoming string array. This will be greatly simplified when - // DOMUIBindings::send() is generalized to all data types instead of - // silently failing when passed anything other then an array of - // strings. - if (content->GetType() == Value::TYPE_LIST) { - const ListValue* list_value = static_cast<const ListValue*>(content); - Value* list_member; - if (list_value->Get(0, &list_member) && - list_member->GetType() == Value::TYPE_STRING) { - const StringValue* string_value = - static_cast<const StringValue*>(list_member); - std::string session_to_restore_str; - if (string_value->GetAsString(&session_to_restore_str)) { - int session_to_restore; - base::StringToInt(session_to_restore_str, &session_to_restore); - tab_restore_service_->RestoreEntryById(browser, session_to_restore, - true); - // The current tab has been nuked at this point; don't touch any member - // variables. - } - } - } + int session_to_restore; + if (ExtractIntegerValue(args, &session_to_restore)) + tab_restore_service_->RestoreEntryById(browser, session_to_restore, true); + // The current tab has been nuked at this point; don't touch any member + // variables. } void RecentlyClosedTabsHandler::HandleGetRecentlyClosedTabs( - const Value* content) { + const ListValue* args) { if (!tab_restore_service_) { tab_restore_service_ = dom_ui_->GetProfile()->GetTabRestoreService(); @@ -351,10 +333,10 @@ class MetricsHandler : public DOMMessageHandler { virtual void RegisterMessages(); // Callback which records a user action. - void HandleMetrics(const Value* content); + void HandleMetrics(const ListValue* args); // Callback for the "logEventTime" message. - void HandleLogEventTime(const Value* content); + void HandleLogEventTime(const ListValue* args); private: @@ -369,35 +351,14 @@ void MetricsHandler::RegisterMessages() { NewCallback(this, &MetricsHandler::HandleLogEventTime)); } -void MetricsHandler::HandleMetrics(const Value* content) { - if (content && content->GetType() == Value::TYPE_LIST) { - const ListValue* list_value = static_cast<const ListValue*>(content); - Value* list_member; - if (list_value->Get(0, &list_member) && - list_member->GetType() == Value::TYPE_STRING) { - const StringValue* string_value = - static_cast<const StringValue*>(list_member); - std::string string_action; - // TODO(viettrungluu): this usage of |RecordComputedAction()| doesn't - // conform with the docs; scripts can't pick this up. - if (string_value->GetAsString(&string_action)) - UserMetrics::RecordComputedAction(string_action, dom_ui_->GetProfile()); - } - } +void MetricsHandler::HandleMetrics(const ListValue* args) { + std::string string_action = WideToUTF8(ExtractStringValue(args)); + UserMetrics::RecordComputedAction(string_action, dom_ui_->GetProfile()); } -void MetricsHandler::HandleLogEventTime(const Value* content) { - if (content && content->GetType() == Value::TYPE_LIST) { - const ListValue* list_value = static_cast<const ListValue*>(content); - Value* list_member; - if (list_value->Get(0, &list_member) && - list_member->GetType() == Value::TYPE_STRING) { - std::string event_name; - if (list_member->GetAsString(&event_name)) { - dom_ui_->tab_contents()->LogNewTabTime(event_name); - } - } - } +void MetricsHandler::HandleLogEventTime(const ListValue* args) { + std::string event_name = WideToUTF8(ExtractStringValue(args)); + dom_ui_->tab_contents()->LogNewTabTime(event_name); } /////////////////////////////////////////////////////////////////////////////// @@ -414,7 +375,7 @@ class NewTabPageSetHomePageHandler : public DOMMessageHandler { virtual void RegisterMessages(); // Callback for "setHomePage". - void HandleSetHomePage(const Value* value); + void HandleSetHomePage(const ListValue* args); private: @@ -427,7 +388,7 @@ void NewTabPageSetHomePageHandler::RegisterMessages() { } void NewTabPageSetHomePageHandler::HandleSetHomePage( - const Value* value) { + const ListValue* args) { dom_ui_->GetProfile()->GetPrefs()->SetBoolean(prefs::kHomePageIsNewTabPage, true); ListValue list_value; diff --git a/chrome/browser/dom_ui/passwords_exceptions_handler.cc b/chrome/browser/dom_ui/passwords_exceptions_handler.cc index c41bf10..44888bf 100644 --- a/chrome/browser/dom_ui/passwords_exceptions_handler.cc +++ b/chrome/browser/dom_ui/passwords_exceptions_handler.cc @@ -75,48 +75,23 @@ PasswordStore* PasswordsExceptionsHandler::GetPasswordStore() { return profile_->GetPasswordStore(Profile::EXPLICIT_ACCESS); } -void PasswordsExceptionsHandler::LoadSavedPasswords(const Value* value) { +void PasswordsExceptionsHandler::LoadSavedPasswords(const ListValue* args) { populater_.Populate(); } -void PasswordsExceptionsHandler::RemoveEntry(const Value* value) { - if (!value || !value->IsType(Value::TYPE_LIST)) { - NOTREACHED(); - return; - } - - const ListValue* param_values = static_cast<const ListValue*>(value); - std::string string_value; - if (param_values->GetSize() != 1 || - !param_values->GetString(0, &string_value)) { - NOTREACHED(); - return; - } - int selected_index; - base::StringToInt(string_value, &selected_index); +void PasswordsExceptionsHandler::RemoveEntry(const ListValue* args) { + int index; + CHECK(ExtractIntegerValue(args, &index)); - GetPasswordStore()->RemoveLogin(*password_list_[selected_index]); - delete password_list_[selected_index]; - password_list_.erase(password_list_.begin() + selected_index); + GetPasswordStore()->RemoveLogin(*password_list_[index]); + delete password_list_[index]; + password_list_.erase(password_list_.begin() + index); SetPasswordList(); } -void PasswordsExceptionsHandler::ShowSelectedPassword(const Value* value) { - if (!value || !value->IsType(Value::TYPE_LIST)) { - NOTREACHED(); - return; - } - - const ListValue* param_values = static_cast<const ListValue*>(value); - std::string string_value; - if (param_values->GetSize() != 1 || - !param_values->GetString(0, &string_value)) { - NOTREACHED(); - return; - } - +void PasswordsExceptionsHandler::ShowSelectedPassword(const ListValue* args) { int index; - base::StringToInt(string_value, &index); + CHECK(ExtractIntegerValue(args, &index)); std::string pass = UTF16ToUTF8(password_list_[index]->password_value); scoped_ptr<Value> password_string(Value::CreateStringValue(pass)); diff --git a/chrome/browser/dom_ui/passwords_exceptions_handler.h b/chrome/browser/dom_ui/passwords_exceptions_handler.h index 1738125..4bc87e8 100644 --- a/chrome/browser/dom_ui/passwords_exceptions_handler.h +++ b/chrome/browser/dom_ui/passwords_exceptions_handler.h @@ -26,15 +26,15 @@ class PasswordsExceptionsHandler : public OptionsPageUIHandler { PasswordStore* GetPasswordStore(); // Fired when user clicks 'show saved passwords' button in personal page. - void LoadSavedPasswords(const Value* value); + void LoadSavedPasswords(const ListValue* args); // Remove an entry. // @param value the entry index to be removed. - void RemoveEntry(const Value* value); + void RemoveEntry(const ListValue* args); // Get password value for the selected entry. // @param value the selected entry index. - void ShowSelectedPassword(const Value* value); + void ShowSelectedPassword(const ListValue* args); // Sets the password list contents to the given data. We take ownership of // the PasswordForms in the vector. diff --git a/chrome/browser/dom_ui/personal_options_handler.cc b/chrome/browser/dom_ui/personal_options_handler.cc index 4e55f4b..2069246 100644 --- a/chrome/browser/dom_ui/personal_options_handler.cc +++ b/chrome/browser/dom_ui/personal_options_handler.cc @@ -119,7 +119,7 @@ void PersonalOptionsHandler::Initialize() { OPTIONS_PAGE_CONTENT)); } -void PersonalOptionsHandler::SetSyncStatusUIString(const Value* value) { +void PersonalOptionsHandler::SetSyncStatusUIString(const ListValue* args) { DCHECK(dom_ui_); ProfileSyncService* service = dom_ui_->GetProfile()->GetProfileSyncService(); @@ -135,7 +135,7 @@ void PersonalOptionsHandler::SetSyncStatusUIString(const Value* value) { } } -void PersonalOptionsHandler::ThemesReset(const Value* value) { +void PersonalOptionsHandler::ThemesReset(const ListValue* args) { DCHECK(dom_ui_); UserMetricsRecordAction(UserMetricsAction("Options_ThemesReset"), @@ -143,7 +143,7 @@ void PersonalOptionsHandler::ThemesReset(const Value* value) { dom_ui_->GetProfile()->ClearTheme(); } -void PersonalOptionsHandler::ThemesGallery(const Value* value) { +void PersonalOptionsHandler::ThemesGallery(const ListValue* args) { DCHECK(dom_ui_); UserMetricsRecordAction(UserMetricsAction("Options_ThemesGallery"), @@ -152,7 +152,7 @@ void PersonalOptionsHandler::ThemesGallery(const Value* value) { } #if defined(TOOLKIT_GTK) -void PersonalOptionsHandler::ThemesSetGTK(const Value* value) { +void PersonalOptionsHandler::ThemesSetGTK(const ListValue* args) { DCHECK(dom_ui_); UserMetricsRecordAction(UserMetricsAction("Options_GtkThemeSet"), diff --git a/chrome/browser/dom_ui/personal_options_handler.h b/chrome/browser/dom_ui/personal_options_handler.h index 7e257be..285c24a 100644 --- a/chrome/browser/dom_ui/personal_options_handler.h +++ b/chrome/browser/dom_ui/personal_options_handler.h @@ -25,11 +25,11 @@ class PersonalOptionsHandler : public OptionsPageUIHandler { virtual void RegisterMessages(); private: - virtual void SetSyncStatusUIString(const Value* value); - virtual void ThemesReset(const Value* value); - virtual void ThemesGallery(const Value* value); + virtual void SetSyncStatusUIString(const ListValue* args); + virtual void ThemesReset(const ListValue* args); + virtual void ThemesGallery(const ListValue* args); #if defined(TOOLKIT_GTK) - virtual void ThemesSetGTK(const Value* value); + virtual void ThemesSetGTK(const ListValue* args); #endif scoped_ptr<OptionsManagedBannerHandler> banner_handler_; diff --git a/chrome/browser/dom_ui/plugins_ui.cc b/chrome/browser/dom_ui/plugins_ui.cc index 922d10e8..d9af1c0 100644 --- a/chrome/browser/dom_ui/plugins_ui.cc +++ b/chrome/browser/dom_ui/plugins_ui.cc @@ -137,15 +137,15 @@ class PluginsDOMHandler : public DOMMessageHandler { virtual void RegisterMessages(); // Callback for the "requestPluginsData" message. - void HandleRequestPluginsData(const Value* value); + void HandleRequestPluginsData(const ListValue* args); // Callback for the "enablePlugin" message. - void HandleEnablePluginMessage(const Value* value); + void HandleEnablePluginMessage(const ListValue* args); // Callback for the "showTermsOfService" message. This really just opens a new // window with about:terms. Flash can't link directly to about:terms due to // the security model. - void HandleShowTermsOfServiceMessage(const Value* value); + void HandleShowTermsOfServiceMessage(const ListValue* args); private: // Creates a dictionary containing all the information about the given plugin; @@ -174,37 +174,33 @@ void PluginsDOMHandler::RegisterMessages() { NewCallback(this, &PluginsDOMHandler::HandleShowTermsOfServiceMessage)); } -void PluginsDOMHandler::HandleRequestPluginsData(const Value* value) { +void PluginsDOMHandler::HandleRequestPluginsData(const ListValue* args) { DictionaryValue* results = new DictionaryValue(); results->Set("plugins", plugin_updater::GetPluginGroupsData()); dom_ui_->CallJavascriptFunction(L"returnPluginsData", *results); } -void PluginsDOMHandler::HandleEnablePluginMessage(const Value* value) { +void PluginsDOMHandler::HandleEnablePluginMessage(const ListValue* args) { // Be robust in accepting badness since plug-ins display HTML (hence // JavaScript). - if (!value->IsType(Value::TYPE_LIST)) - return; - - const ListValue* list = static_cast<const ListValue*>(value); - if (list->GetSize() != 3) + if (args->GetSize() != 3) return; std::string enable_str; std::string is_group_str; - if (!list->GetString(1, &enable_str) || !list->GetString(2, &is_group_str)) + if (!args->GetString(1, &enable_str) || !args->GetString(2, &is_group_str)) return; if (is_group_str == "true") { string16 group_name; - if (!list->GetString(0, &group_name)) + if (!args->GetString(0, &group_name)) return; plugin_updater::EnablePluginGroup(enable_str == "true", group_name); } else { FilePath::StringType file_path; - if (!list->GetString(0, &file_path)) + if (!args->GetString(0, &file_path)) return; plugin_updater::EnablePluginFile(enable_str == "true", file_path); @@ -216,7 +212,7 @@ void PluginsDOMHandler::HandleEnablePluginMessage(const Value* value) { plugin_updater::UpdatePreferences(dom_ui_->GetProfile()); } -void PluginsDOMHandler::HandleShowTermsOfServiceMessage(const Value* value) { +void PluginsDOMHandler::HandleShowTermsOfServiceMessage(const ListValue* args) { // Show it in a new browser window.... Browser* browser = Browser::Create(dom_ui_->GetProfile()); browser->OpenURL(GURL(chrome::kAboutTermsURL), diff --git a/chrome/browser/dom_ui/register_page_ui.cc b/chrome/browser/dom_ui/register_page_ui.cc index 70627bc..3f0b435 100644 --- a/chrome/browser/dom_ui/register_page_ui.cc +++ b/chrome/browser/dom_ui/register_page_ui.cc @@ -67,8 +67,8 @@ class RegisterPageHandler : public DOMMessageHandler, private: // Handlers for JS DOMUI messages. - void HandleGetRegistrationUrl(const Value* value); - void HandleGetUserInfo(const Value* value); + void HandleGetRegistrationUrl(const ListValue* args); + void HandleGetUserInfo(const ListValue* args); #if defined(OS_CHROMEOS) // Callback from chromeos::VersionLoader giving the version. @@ -158,7 +158,7 @@ void RegisterPageHandler::RegisterMessages() { #endif } -void RegisterPageHandler::HandleGetRegistrationUrl(const Value* value) { +void RegisterPageHandler::HandleGetRegistrationUrl(const ListValue* args) { #if defined(OS_CHROMEOS) if (WizardController::default_controller() && WizardController::default_controller()->GetCustomization()) { @@ -174,7 +174,7 @@ void RegisterPageHandler::HandleGetRegistrationUrl(const Value* value) { #endif } -void RegisterPageHandler::HandleGetUserInfo(const Value* value) { +void RegisterPageHandler::HandleGetUserInfo(const ListValue* args) { #if defined(OS_CHROMEOS) if (chromeos::CrosLibrary::Get()->EnsureLoaded()) { version_loader_.GetVersion( diff --git a/chrome/browser/dom_ui/search_engine_manager_handler.cc b/chrome/browser/dom_ui/search_engine_manager_handler.cc index 18b8ab0..fc367bb 100644 --- a/chrome/browser/dom_ui/search_engine_manager_handler.cc +++ b/chrome/browser/dom_ui/search_engine_manager_handler.cc @@ -134,9 +134,9 @@ DictionaryValue* SearchEngineManagerHandler::CreateDictionaryForEngine( return dict; } -void SearchEngineManagerHandler::SetDefaultSearchEngine(const Value* value) { +void SearchEngineManagerHandler::SetDefaultSearchEngine(const ListValue* args) { int index; - if (!ExtractIntegerValue(value, &index)) { + if (!ExtractIntegerValue(args, &index)) { NOTREACHED(); return; } @@ -146,9 +146,9 @@ void SearchEngineManagerHandler::SetDefaultSearchEngine(const Value* value) { controller_->MakeDefaultTemplateURL(index); } -void SearchEngineManagerHandler::RemoveSearchEngine(const Value* value) { +void SearchEngineManagerHandler::RemoveSearchEngine(const ListValue* args) { int index; - if (!ExtractIntegerValue(value, &index)) { + if (!ExtractIntegerValue(args, &index)) { NOTREACHED(); return; } diff --git a/chrome/browser/dom_ui/search_engine_manager_handler.h b/chrome/browser/dom_ui/search_engine_manager_handler.h index 62012e0..2c5ffab 100644 --- a/chrome/browser/dom_ui/search_engine_manager_handler.h +++ b/chrome/browser/dom_ui/search_engine_manager_handler.h @@ -33,10 +33,10 @@ class SearchEngineManagerHandler : public OptionsPageUIHandler, scoped_ptr<KeywordEditorController> controller_; // Removes the search engine at the given index. Called from DOMUI. - void RemoveSearchEngine(const Value* value); + void RemoveSearchEngine(const ListValue* args); // Sets the search engine at the given index to be default. Called from DOMUI. - void SetDefaultSearchEngine(const Value* value); + void SetDefaultSearchEngine(const ListValue* args); // Returns a dictionary to pass to DOMUI representing the given group heading. DictionaryValue* CreateDictionaryForHeading(int group_index); diff --git a/chrome/browser/dom_ui/shown_sections_handler.cc b/chrome/browser/dom_ui/shown_sections_handler.cc index e78f05b..80c6229 100644 --- a/chrome/browser/dom_ui/shown_sections_handler.cc +++ b/chrome/browser/dom_ui/shown_sections_handler.cc @@ -69,31 +69,15 @@ void ShownSectionsHandler::Observe(NotificationType type, dom_ui_->CallJavascriptFunction(L"setShownSections", sections_value); } -void ShownSectionsHandler::HandleGetShownSections(const Value* value) { +void ShownSectionsHandler::HandleGetShownSections(const ListValue* args) { int sections = pref_service_->GetInteger(prefs::kNTPShownSections); FundamentalValue sections_value(sections); dom_ui_->CallJavascriptFunction(L"onShownSections", sections_value); } -void ShownSectionsHandler::HandleSetShownSections(const Value* value) { - if (!value->IsType(Value::TYPE_LIST)) { - NOTREACHED(); - return; - } - - const ListValue* list = static_cast<const ListValue*>(value); - std::string mode_string; - - if (list->GetSize() < 1) { - NOTREACHED() << "setShownSections called with too few arguments"; - return; - } - - bool r = list->GetString(0, &mode_string); - DCHECK(r) << "Missing value in setShownSections from the NTP Most Visited."; - +void ShownSectionsHandler::HandleSetShownSections(const ListValue* args) { int mode; - base::StringToInt(mode_string, &mode); + CHECK(ExtractIntegerValue(args, &mode)); int old_mode = pref_service_->GetInteger(prefs::kNTPShownSections); if (old_mode != mode) { diff --git a/chrome/browser/dom_ui/shown_sections_handler.h b/chrome/browser/dom_ui/shown_sections_handler.h index 25644b3..afe1e26 100644 --- a/chrome/browser/dom_ui/shown_sections_handler.h +++ b/chrome/browser/dom_ui/shown_sections_handler.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -38,10 +38,10 @@ class ShownSectionsHandler : public DOMMessageHandler, const NotificationDetails& details); // Callback for "getShownSections" message. - void HandleGetShownSections(const Value* value); + void HandleGetShownSections(const ListValue* args); // Callback for "setShownSections" message. - void HandleSetShownSections(const Value* value); + void HandleSetShownSections(const ListValue* args); static void RegisterUserPrefs(PrefService* pref_service); diff --git a/chrome/browser/dom_ui/slideshow_ui.cc b/chrome/browser/dom_ui/slideshow_ui.cc index f0140b0..c7475de 100644 --- a/chrome/browser/dom_ui/slideshow_ui.cc +++ b/chrome/browser/dom_ui/slideshow_ui.cc @@ -13,6 +13,7 @@ #include "base/string_util.h" #include "base/thread.h" #include "base/time.h" +#include "base/utf_string_conversions.h" #include "base/values.h" #include "base/weak_ptr.h" #include "chrome/browser/chrome_thread.h" @@ -75,12 +76,12 @@ class SlideshowHandler : public net::DirectoryLister::DirectoryListerDelegate, virtual DOMMessageHandler* Attach(DOMUI* dom_ui); virtual void RegisterMessages(); - void GetChildrenForPath(FilePath& path, bool is_refresh); + void GetChildrenForPath(const FilePath& path, bool is_refresh); // Callback for the "getChildren" message. - void HandleGetChildren(const Value* value); + void HandleGetChildren(const ListValue* args); - void HandleRefreshDirectory(const Value* value); + void HandleRefreshDirectory(const ListValue* args); private: bool PathIsImageFile(const char* filename); @@ -168,28 +169,17 @@ void SlideshowHandler::RegisterMessages() { NewCallback(this, &SlideshowHandler::HandleRefreshDirectory)); } -void SlideshowHandler::HandleRefreshDirectory(const Value* value) { +void SlideshowHandler::HandleRefreshDirectory(const ListValue* args) { #if defined(OS_CHROMEOS) - if (value && value->GetType() == Value::TYPE_LIST) { - const ListValue* list_value = static_cast<const ListValue*>(value); - std::string path; - - // Get path string. - if (list_value->GetString(0, &path)) { - FilePath currentpath; - currentpath = FilePath(path); - GetChildrenForPath(currentpath, true); - } else { - LOG(ERROR) << "Unable to get string"; - return; - } - } + std::string path = WideToUTF8(ExtractStringValue(args)); + GetChildrenForPath(FilePath(path), true); #endif } -void SlideshowHandler::GetChildrenForPath(FilePath& path, bool is_refresh) { +void SlideshowHandler::GetChildrenForPath(const FilePath& path, + bool is_refresh) { filelist_value_.reset(new ListValue()); - currentpath_ = FilePath(path); + currentpath_ = path; if (lister_.get()) { lister_->Cancel(); @@ -211,29 +201,11 @@ void SlideshowHandler::GetChildrenForPath(FilePath& path, bool is_refresh) { lister_->Start(); } -void SlideshowHandler::HandleGetChildren(const Value* value) { +void SlideshowHandler::HandleGetChildren(const ListValue* args) { #if defined(OS_CHROMEOS) - std::string path; - if (value && value->GetType() == Value::TYPE_LIST) { - const ListValue* list_value = static_cast<const ListValue*>(value); - Value* list_member; - - // Get search string. - if (list_value->Get(0, &list_member) && - list_member->GetType() == Value::TYPE_STRING) { - const StringValue* string_value = - static_cast<const StringValue*>(list_member); - string_value->GetAsString(&path); - } - - } else { - LOG(ERROR) << "Wasn't able to get the List if requested files."; - return; - } filelist_value_.reset(new ListValue()); - FilePath currentpath; - currentpath = FilePath(path); - GetChildrenForPath(currentpath, false); + std::string path = WideToUTF8(ExtractStringValue(args)); + GetChildrenForPath(FilePath(path), false); #endif } diff --git a/chrome/browser/dom_ui/stop_syncing_handler.cc b/chrome/browser/dom_ui/stop_syncing_handler.cc index 4ffcaf8..5570a79 100644 --- a/chrome/browser/dom_ui/stop_syncing_handler.cc +++ b/chrome/browser/dom_ui/stop_syncing_handler.cc @@ -38,7 +38,7 @@ void StopSyncingHandler::RegisterMessages() { NewCallback(this, &StopSyncingHandler::StopSyncing)); } -void StopSyncingHandler::StopSyncing(const Value* value){ +void StopSyncingHandler::StopSyncing(const ListValue* args){ DCHECK(dom_ui_); ProfileSyncService* service = dom_ui_->GetProfile()->GetProfileSyncService(); if(service != NULL && ProfileSyncService::IsSyncEnabled()) { diff --git a/chrome/browser/dom_ui/stop_syncing_handler.h b/chrome/browser/dom_ui/stop_syncing_handler.h index f97132b..dd19fe3 100644 --- a/chrome/browser/dom_ui/stop_syncing_handler.h +++ b/chrome/browser/dom_ui/stop_syncing_handler.h @@ -20,7 +20,7 @@ class StopSyncingHandler : public OptionsPageUIHandler { virtual void RegisterMessages(); private: - void StopSyncing(const Value* value); + void StopSyncing(const ListValue* args); DISALLOW_COPY_AND_ASSIGN(StopSyncingHandler); }; diff --git a/chrome/browser/dom_ui/tips_handler.cc b/chrome/browser/dom_ui/tips_handler.cc index bda71ea..be4ab75 100644 --- a/chrome/browser/dom_ui/tips_handler.cc +++ b/chrome/browser/dom_ui/tips_handler.cc @@ -30,7 +30,7 @@ void TipsHandler::RegisterMessages() { NewCallback(this, &TipsHandler::HandleGetTips)); } -void TipsHandler::HandleGetTips(const Value* content) { +void TipsHandler::HandleGetTips(const ListValue* args) { // List containing the tips to be displayed. ListValue list_value; diff --git a/chrome/browser/dom_ui/tips_handler.h b/chrome/browser/dom_ui/tips_handler.h index 326887c..b02f233 100644 --- a/chrome/browser/dom_ui/tips_handler.h +++ b/chrome/browser/dom_ui/tips_handler.h @@ -16,8 +16,8 @@ class DictionaryValue; class DOMUI; +class ListValue; class PrefService; -class Value; class TipsHandler : public DOMMessageHandler { public: @@ -29,7 +29,7 @@ class TipsHandler : public DOMMessageHandler { virtual void RegisterMessages(); // Callback which pulls tips data from the preferences. - void HandleGetTips(const Value* content); + void HandleGetTips(const ListValue* args); // Register tips cache with pref service. static void RegisterUserPrefs(PrefService* prefs); diff --git a/chrome/browser/extensions/extensions_ui.cc b/chrome/browser/extensions/extensions_ui.cc index 3395286..4154644 100644 --- a/chrome/browser/extensions/extensions_ui.cc +++ b/chrome/browser/extensions/extensions_ui.cc @@ -305,7 +305,7 @@ void ExtensionsDOMHandler::RegisterMessages() { NewCallback(this, &ExtensionsDOMHandler::HandleSelectFilePathMessage)); } -void ExtensionsDOMHandler::HandleRequestExtensionsData(const Value* value) { +void ExtensionsDOMHandler::HandleRequestExtensionsData(const ListValue* args) { DictionaryValue* results = new DictionaryValue(); // Add the extensions to the results structure. @@ -415,23 +415,21 @@ ExtensionInstallUI* ExtensionsDOMHandler::GetExtensionInstallUI() { return install_ui_.get(); } -void ExtensionsDOMHandler::HandleToggleDeveloperMode(const Value* value) { +void ExtensionsDOMHandler::HandleToggleDeveloperMode(const ListValue* args) { bool developer_mode = dom_ui_->GetProfile()->GetPrefs() ->GetBoolean(prefs::kExtensionsUIDeveloperMode); dom_ui_->GetProfile()->GetPrefs()->SetBoolean( prefs::kExtensionsUIDeveloperMode, !developer_mode); } -void ExtensionsDOMHandler::HandleInspectMessage(const Value* value) { +void ExtensionsDOMHandler::HandleInspectMessage(const ListValue* args) { std::string render_process_id_str; std::string render_view_id_str; int render_process_id; int render_view_id; - CHECK(value->IsType(Value::TYPE_LIST)); - const ListValue* list = static_cast<const ListValue*>(value); - CHECK(list->GetSize() == 2); - CHECK(list->GetString(0, &render_process_id_str)); - CHECK(list->GetString(1, &render_view_id_str)); + CHECK(args->GetSize() == 2); + CHECK(args->GetString(0, &render_process_id_str)); + CHECK(args->GetString(1, &render_view_id_str)); CHECK(base::StringToInt(render_process_id_str, &render_process_id)); CHECK(base::StringToInt(render_view_id_str, &render_view_id)); RenderViewHost* host = RenderViewHost::FromID(render_process_id, @@ -446,22 +444,17 @@ void ExtensionsDOMHandler::HandleInspectMessage(const Value* value) { DEVTOOLS_TOGGLE_ACTION_SHOW_CONSOLE); } -void ExtensionsDOMHandler::HandleReloadMessage(const Value* value) { - CHECK(value->IsType(Value::TYPE_LIST)); - const ListValue* list = static_cast<const ListValue*>(value); - CHECK(list->GetSize() == 1); - std::string extension_id; - CHECK(list->GetString(0, &extension_id)); +void ExtensionsDOMHandler::HandleReloadMessage(const ListValue* args) { + std::string extension_id = WideToASCII(ExtractStringValue(args)); + CHECK(!extension_id.empty()); extensions_service_->ReloadExtension(extension_id); } -void ExtensionsDOMHandler::HandleEnableMessage(const Value* value) { - CHECK(value->IsType(Value::TYPE_LIST)); - const ListValue* list = static_cast<const ListValue*>(value); - CHECK(list->GetSize() == 2); +void ExtensionsDOMHandler::HandleEnableMessage(const ListValue* args) { + CHECK(args->GetSize() == 2); std::string extension_id, enable_str; - CHECK(list->GetString(0, &extension_id)); - CHECK(list->GetString(1, &enable_str)); + CHECK(args->GetString(0, &extension_id)); + CHECK(args->GetString(1, &enable_str)); if (enable_str == "true") { ExtensionPrefs* prefs = extensions_service_->extension_prefs(); if (prefs->DidExtensionEscalatePermissions(extension_id)) { @@ -477,13 +470,11 @@ void ExtensionsDOMHandler::HandleEnableMessage(const Value* value) { } } -void ExtensionsDOMHandler::HandleEnableIncognitoMessage(const Value* value) { - CHECK(value->IsType(Value::TYPE_LIST)); - const ListValue* list = static_cast<const ListValue*>(value); - CHECK(list->GetSize() == 2); +void ExtensionsDOMHandler::HandleEnableIncognitoMessage(const ListValue* args) { + CHECK(args->GetSize() == 2); std::string extension_id, enable_str; - CHECK(list->GetString(0, &extension_id)); - CHECK(list->GetString(1, &enable_str)); + CHECK(args->GetString(0, &extension_id)); + CHECK(args->GetString(1, &enable_str)); Extension* extension = extensions_service_->GetExtensionById(extension_id, true); DCHECK(extension); @@ -504,13 +495,11 @@ void ExtensionsDOMHandler::HandleEnableIncognitoMessage(const Value* value) { ignore_notifications_ = false; } -void ExtensionsDOMHandler::HandleAllowFileAccessMessage(const Value* value) { - CHECK(value->IsType(Value::TYPE_LIST)); - const ListValue* list = static_cast<const ListValue*>(value); - CHECK(list->GetSize() == 2); +void ExtensionsDOMHandler::HandleAllowFileAccessMessage(const ListValue* args) { + CHECK(args->GetSize() == 2); std::string extension_id, allow_str; - CHECK(list->GetString(0, &extension_id)); - CHECK(list->GetString(1, &allow_str)); + CHECK(args->GetString(0, &extension_id)); + CHECK(args->GetString(1, &allow_str)); Extension* extension = extensions_service_->GetExtensionById(extension_id, true); DCHECK(extension); @@ -518,21 +507,15 @@ void ExtensionsDOMHandler::HandleAllowFileAccessMessage(const Value* value) { extensions_service_->SetAllowFileAccess(extension, allow_str == "true"); } -void ExtensionsDOMHandler::HandleUninstallMessage(const Value* value) { - CHECK(value->IsType(Value::TYPE_LIST)); - const ListValue* list = static_cast<const ListValue*>(value); - CHECK(list->GetSize() == 1); - std::string extension_id; - CHECK(list->GetString(0, &extension_id)); - - Extension *extension = - extensions_service_->GetExtensionById(extension_id, true); +void ExtensionsDOMHandler::HandleUninstallMessage(const ListValue* args) { + Extension* extension = GetExtension(args); if (!extension) return; if (!extension_id_prompting_.empty()) - return; // only one prompt at a time + return; // Only one prompt at a time. + std::string extension_id = WideToASCII(ExtractStringValue(args)); extension_id_prompting_ = extension_id; GetExtensionInstallUI()->ConfirmUninstall(this, extension); @@ -561,27 +544,18 @@ void ExtensionsDOMHandler::InstallUIAbort() { extension_id_prompting_ = ""; } -void ExtensionsDOMHandler::HandleOptionsMessage(const Value* value) { - CHECK(value->IsType(Value::TYPE_LIST)); - const ListValue* list = static_cast<const ListValue*>(value); - CHECK(list->GetSize() == 1); - std::string extension_id; - CHECK(list->GetString(0, &extension_id)); - Extension *extension = - extensions_service_->GetExtensionById(extension_id, false); - if (!extension || extension->options_url().is_empty()) { +void ExtensionsDOMHandler::HandleOptionsMessage(const ListValue* args) { + Extension* extension = GetExtension(args); + if (!extension || extension->options_url().is_empty()) return; - } dom_ui_->GetProfile()->GetExtensionProcessManager()->OpenOptionsPage( extension, NULL); } -void ExtensionsDOMHandler::HandleLoadMessage(const Value* value) { +void ExtensionsDOMHandler::HandleLoadMessage(const ListValue* args) { FilePath::StringType string_path; - CHECK(value->IsType(Value::TYPE_LIST)); - const ListValue* list = static_cast<const ListValue*>(value); - CHECK(list->GetSize() == 1) << list->GetSize(); - CHECK(list->GetString(0, &string_path)); + CHECK(args->GetSize() == 1) << args->GetSize(); + CHECK(args->GetString(0, &string_path)); extensions_service_->LoadExtension(FilePath(string_path)); } @@ -591,14 +565,12 @@ void ExtensionsDOMHandler::ShowAlert(const std::string& message) { dom_ui_->CallJavascriptFunction(L"alert", arguments); } -void ExtensionsDOMHandler::HandlePackMessage(const Value* value) { +void ExtensionsDOMHandler::HandlePackMessage(const ListValue* args) { std::string extension_path; std::string private_key_path; - CHECK(value->IsType(Value::TYPE_LIST)); - const ListValue* list = static_cast<const ListValue*>(value); - CHECK(list->GetSize() == 2); - CHECK(list->GetString(0, &extension_path)); - CHECK(list->GetString(1, &private_key_path)); + CHECK(args->GetSize() == 2); + CHECK(args->GetString(0, &extension_path)); + CHECK(args->GetString(1, &private_key_path)); FilePath root_directory = FilePath::FromWStringHack(UTF8ToWide(extension_path)); @@ -639,21 +611,18 @@ void ExtensionsDOMHandler::OnPackFailure(const std::string& error) { ShowAlert(error); } -void ExtensionsDOMHandler::HandleAutoUpdateMessage(const Value* value) { +void ExtensionsDOMHandler::HandleAutoUpdateMessage(const ListValue* args) { ExtensionUpdater* updater = extensions_service_->updater(); - if (updater) { + if (updater) updater->CheckNow(); - } } -void ExtensionsDOMHandler::HandleSelectFilePathMessage(const Value* value) { +void ExtensionsDOMHandler::HandleSelectFilePathMessage(const ListValue* args) { std::string select_type; std::string operation; - CHECK(value->IsType(Value::TYPE_LIST)); - const ListValue* list = static_cast<const ListValue*>(value); - CHECK(list->GetSize() == 2); - CHECK(list->GetString(0, &select_type)); - CHECK(list->GetString(1, &operation)); + CHECK(args->GetSize() == 2); + CHECK(args->GetString(0, &select_type)); + CHECK(args->GetString(1, &operation)); SelectFileDialog::Type type = SelectFileDialog::SELECT_FOLDER; static SelectFileDialog::FileTypeInfo info; @@ -662,12 +631,12 @@ void ExtensionsDOMHandler::HandleSelectFilePathMessage(const Value* value) { type = SelectFileDialog::SELECT_OPEN_FILE; string16 select_title; - if (operation == "load") + if (operation == "load") { select_title = l10n_util::GetStringUTF16(IDS_EXTENSION_LOAD_FROM_DIRECTORY); - else if (operation == "packRoot") + } else if (operation == "packRoot") { select_title = l10n_util::GetStringUTF16( IDS_EXTENSION_PACK_DIALOG_SELECT_ROOT); - else if (operation == "pem") { + } else if (operation == "pem") { select_title = l10n_util::GetStringUTF16( IDS_EXTENSION_PACK_DIALOG_SELECT_KEY); info.extensions.push_back(std::vector<FilePath::StringType>()); @@ -737,6 +706,12 @@ void ExtensionsDOMHandler::Observe(NotificationType type, } } +Extension* ExtensionsDOMHandler::GetExtension(const ListValue* args) { + std::string extension_id = WideToASCII(ExtractStringValue(args)); + CHECK(!extension_id.empty()); + return extensions_service_->GetExtensionById(extension_id, false); +} + void ExtensionsDOMHandler::MaybeUpdateAfterNotification() { if (!ignore_notifications_ && dom_ui_->tab_contents()) HandleRequestExtensionsData(NULL); diff --git a/chrome/browser/extensions/extensions_ui.h b/chrome/browser/extensions/extensions_ui.h index 6509a6d..fb186fc 100644 --- a/chrome/browser/extensions/extensions_ui.h +++ b/chrome/browser/extensions/extensions_ui.h @@ -24,10 +24,10 @@ class DictionaryValue; class Extension; class ExtensionsService; class FilePath; +class ListValue; class PrefService; class RenderProcessHost; class UserScript; -class Value; // Information about a page running in an extension, for example a toolstrip, // a background page, or a tab contents. @@ -134,46 +134,49 @@ class ExtensionsDOMHandler private: // Callback for "requestExtensionsData" message. - void HandleRequestExtensionsData(const Value* value); + void HandleRequestExtensionsData(const ListValue* args); // Callback for "toggleDeveloperMode" message. - void HandleToggleDeveloperMode(const Value* value); + void HandleToggleDeveloperMode(const ListValue* args); // Callback for "inspect" message. - void HandleInspectMessage(const Value* value); + void HandleInspectMessage(const ListValue* args); // Callback for "reload" message. - void HandleReloadMessage(const Value* value); + void HandleReloadMessage(const ListValue* args); // Callback for "enable" message. - void HandleEnableMessage(const Value* value); + void HandleEnableMessage(const ListValue* args); // Callback for "enableIncognito" message. - void HandleEnableIncognitoMessage(const Value* value); + void HandleEnableIncognitoMessage(const ListValue* args); // Callback for "allowFileAcces" message. - void HandleAllowFileAccessMessage(const Value* value); + void HandleAllowFileAccessMessage(const ListValue* args); // Callback for "uninstall" message. - void HandleUninstallMessage(const Value* value); + void HandleUninstallMessage(const ListValue* args); // Callback for "options" message. - void HandleOptionsMessage(const Value* value); + void HandleOptionsMessage(const ListValue* args); // Callback for "load" message. - void HandleLoadMessage(const Value* value); + void HandleLoadMessage(const ListValue* args); // Callback for "pack" message. - void HandlePackMessage(const Value* value); + void HandlePackMessage(const ListValue* args); // Callback for "autoupdate" message. - void HandleAutoUpdateMessage(const Value* value); + void HandleAutoUpdateMessage(const ListValue* args); // Utility for calling javascript window.alert in the page. void ShowAlert(const std::string& message); // Callback for "selectFilePath" message. - void HandleSelectFilePathMessage(const Value* value); + void HandleSelectFilePathMessage(const ListValue* args); + + // Utility for callbacks that get an extension ID as the sole argument. + Extension* GetExtension(const ListValue* args); // Forces a UI update if appropriate after a notification is received. void MaybeUpdateAfterNotification(); diff --git a/chrome/browser/printing/print_dialog_cloud.cc b/chrome/browser/printing/print_dialog_cloud.cc index 368d25b..b084456 100644 --- a/chrome/browser/printing/print_dialog_cloud.cc +++ b/chrome/browser/printing/print_dialog_cloud.cc @@ -323,7 +323,7 @@ void CloudPrintFlowHandler::Observe(NotificationType type, } } -void CloudPrintFlowHandler::HandleShowDebugger(const Value* value) { +void CloudPrintFlowHandler::HandleShowDebugger(const ListValue* args) { ShowDebugger(); } @@ -342,7 +342,7 @@ CloudPrintFlowHandler::CreateCloudPrintDataSender() { return new CloudPrintDataSender(print_data_helper_.get(), print_job_title_); } -void CloudPrintFlowHandler::HandleSendPrintData(const Value* value) { +void CloudPrintFlowHandler::HandleSendPrintData(const ListValue* args) { DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); // This will cancel any ReadPrintDataFile() or SendPrintDataFile() // requests in flight (this is anticipation of when setting page @@ -359,8 +359,8 @@ void CloudPrintFlowHandler::HandleSendPrintData(const Value* value) { } } -void CloudPrintFlowHandler::HandleSetPageParameters(const Value* value) { - std::string json(dom_ui_util::GetJsonResponseFromFirstArgumentInList(value)); +void CloudPrintFlowHandler::HandleSetPageParameters(const ListValue* args) { + std::string json(dom_ui_util::GetJsonResponseFromFirstArgumentInList(args)); if (json.empty()) return; diff --git a/chrome/browser/printing/print_dialog_cloud_internal.h b/chrome/browser/printing/print_dialog_cloud_internal.h index e14d339..7270b29 100644 --- a/chrome/browser/printing/print_dialog_cloud_internal.h +++ b/chrome/browser/printing/print_dialog_cloud_internal.h @@ -123,9 +123,9 @@ class CloudPrintFlowHandler : public DOMMessageHandler, const NotificationDetails& details); // Callbacks from the page. - void HandleShowDebugger(const Value* value); - void HandleSendPrintData(const Value* value); - void HandleSetPageParameters(const Value* value); + void HandleShowDebugger(const ListValue* args); + void HandleSendPrintData(const ListValue* args); + void HandleSetPageParameters(const ListValue* args); // Call to get the debugger loaded on our hosted dialog page // specifically. Since we're not in an official browser tab, only diff --git a/chrome/browser/remoting/remoting_setup_message_handler.cc b/chrome/browser/remoting/remoting_setup_message_handler.cc index d9d8dea..35806df 100644 --- a/chrome/browser/remoting/remoting_setup_message_handler.cc +++ b/chrome/browser/remoting/remoting_setup_message_handler.cc @@ -20,8 +20,8 @@ void RemotingSetupMessageHandler::RegisterMessages() { NewCallback(this, &RemotingSetupMessageHandler::HandleSubmitAuth)); } -void RemotingSetupMessageHandler::HandleSubmitAuth(const Value* value) { - std::string json(dom_ui_util::GetJsonResponseFromFirstArgumentInList(value)); +void RemotingSetupMessageHandler::HandleSubmitAuth(const ListValue* args) { + std::string json(dom_ui_util::GetJsonResponseFromFirstArgumentInList(args)); std::string username, password, captcha; if (json.empty()) return; diff --git a/chrome/browser/remoting/remoting_setup_message_handler.h b/chrome/browser/remoting/remoting_setup_message_handler.h index b4dcfcb..a01001b 100644 --- a/chrome/browser/remoting/remoting_setup_message_handler.h +++ b/chrome/browser/remoting/remoting_setup_message_handler.h @@ -22,7 +22,7 @@ class RemotingSetupMessageHandler : public DOMMessageHandler { virtual void RegisterMessages(); // Callbacks from the page. - void HandleSubmitAuth(const Value* value); + void HandleSubmitAuth(const ListValue* args); // These functions control which part of the HTML is visible. // TODO(hclam): I really don't feel right about exposing these as public diff --git a/chrome/browser/resources/options/content_settings.css b/chrome/browser/resources/options/content_settings.css index 1101785..a600a47 100644 --- a/chrome/browser/resources/options/content_settings.css +++ b/chrome/browser/resources/options/content_settings.css @@ -12,7 +12,3 @@ found in the LICENSE file. font-weight: bold; cursor: pointer; } - -.fooBar { - background-image: url('../shared/images/minus.png'); -} diff --git a/chrome/browser/sync/sync_setup_flow.cc b/chrome/browser/sync/sync_setup_flow.cc index 27549de..9a59680 100644 --- a/chrome/browser/sync/sync_setup_flow.cc +++ b/chrome/browser/sync/sync_setup_flow.cc @@ -127,8 +127,8 @@ static bool GetDataTypeChoiceData(const std::string& json, return true; } -void FlowHandler::HandleSubmitAuth(const Value* value) { - std::string json(dom_ui_util::GetJsonResponseFromFirstArgumentInList(value)); +void FlowHandler::HandleSubmitAuth(const ListValue* args) { + std::string json(dom_ui_util::GetJsonResponseFromFirstArgumentInList(args)); std::string username, password, captcha; if (json.empty()) return; @@ -144,8 +144,8 @@ void FlowHandler::HandleSubmitAuth(const Value* value) { flow_->OnUserSubmittedAuth(username, password, captcha); } -void FlowHandler::HandleChooseDataTypes(const Value* value) { - std::string json(dom_ui_util::GetJsonResponseFromFirstArgumentInList(value)); +void FlowHandler::HandleChooseDataTypes(const ListValue* args) { + std::string json(dom_ui_util::GetJsonResponseFromFirstArgumentInList(args)); bool sync_everything; syncable::ModelTypeSet chosen_types; if (json.empty()) diff --git a/chrome/browser/sync/sync_setup_flow.h b/chrome/browser/sync/sync_setup_flow.h index e854ce0..6766963 100644 --- a/chrome/browser/sync/sync_setup_flow.h +++ b/chrome/browser/sync/sync_setup_flow.h @@ -179,8 +179,8 @@ class FlowHandler : public DOMMessageHandler { virtual void RegisterMessages(); // Callbacks from the page. - void HandleSubmitAuth(const Value* value); - void HandleChooseDataTypes(const Value* value); + void HandleSubmitAuth(const ListValue* args); + void HandleChooseDataTypes(const ListValue* args); // These functions control which part of the HTML is visible. void ShowGaiaLogin(const DictionaryValue& args); diff --git a/chrome/browser/views/select_file_dialog.cc b/chrome/browser/views/select_file_dialog.cc index 0f2aaaa..523f817 100644 --- a/chrome/browser/views/select_file_dialog.cc +++ b/chrome/browser/views/select_file_dialog.cc @@ -127,7 +127,7 @@ class SelectFileDialogImpl : public SelectFileDialog { virtual void RegisterMessages(); // Callback for the "setDialogTitle" message. - void HandleSetDialogTitle(const Value* value); + void HandleSetDialogTitle(const ListValue* args); private: FileBrowseDelegate* delegate_; @@ -460,8 +460,8 @@ void SelectFileDialogImpl::FileBrowseDelegateHandler::RegisterMessages() { } void SelectFileDialogImpl::FileBrowseDelegateHandler::HandleSetDialogTitle( - const Value* value) { - std::wstring new_title = ExtractStringValue(value); + const ListValue* args) { + std::wstring new_title = ExtractStringValue(args); if (new_title != delegate_->title_) { delegate_->title_ = new_title; |