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

Side by Side Diff: chrome/browser/ui/webui/options/browser_options_handler.cc

Issue 8135001: Fixed behavior of the bookmark bar visibility. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reviewed, rebased Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/options/browser_options_handler.h" 5 #include "chrome/browser/ui/webui/options/browser_options_handler.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
12 #include "base/string_number_conversions.h" 11 #include "base/string_number_conversions.h"
13 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
14 #include "base/values.h" 13 #include "base/values.h"
15 #include "chrome/browser/autocomplete/autocomplete.h" 14 #include "chrome/browser/autocomplete/autocomplete.h"
16 #include "chrome/browser/autocomplete/autocomplete_match.h" 15 #include "chrome/browser/autocomplete/autocomplete_match.h"
17 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/custom_home_pages_table_model.h" 17 #include "chrome/browser/custom_home_pages_table_model.h"
19 #include "chrome/browser/instant/instant_confirm_dialog.h" 18 #include "chrome/browser/instant/instant_confirm_dialog.h"
20 #include "chrome/browser/instant/instant_controller.h" 19 #include "chrome/browser/instant/instant_controller.h"
21 #include "chrome/browser/instant/instant_field_trial.h" 20 #include "chrome/browser/instant/instant_field_trial.h"
22 #include "chrome/browser/net/url_fixer_upper.h" 21 #include "chrome/browser/net/url_fixer_upper.h"
23 #include "chrome/browser/prefs/pref_service.h" 22 #include "chrome/browser/prefs/pref_service.h"
24 #include "chrome/browser/prefs/session_startup_pref.h" 23 #include "chrome/browser/prefs/session_startup_pref.h"
25 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
26 #include "chrome/browser/search_engines/template_url.h" 25 #include "chrome/browser/search_engines/template_url.h"
27 #include "chrome/browser/search_engines/template_url_service.h" 26 #include "chrome/browser/search_engines/template_url_service.h"
28 #include "chrome/browser/search_engines/template_url_service_factory.h" 27 #include "chrome/browser/search_engines/template_url_service_factory.h"
29 #include "chrome/browser/ui/webui/favicon_source.h" 28 #include "chrome/browser/ui/webui/favicon_source.h"
30 #include "chrome/common/chrome_notification_types.h" 29 #include "chrome/common/chrome_notification_types.h"
31 #include "chrome/common/pref_names.h" 30 #include "chrome/common/pref_names.h"
32 #include "chrome/common/url_constants.h" 31 #include "chrome/common/url_constants.h"
33 #include "content/browser/browser_thread.h" 32 #include "content/browser/browser_thread.h"
34 #include "content/browser/user_metrics.h" 33 #include "content/browser/user_metrics.h"
35 #include "content/common/notification_details.h" 34 #include "content/common/notification_details.h"
36 #include "content/common/notification_service.h"
37 #include "content/common/notification_source.h" 35 #include "content/common/notification_source.h"
38 #include "grit/chromium_strings.h" 36 #include "grit/chromium_strings.h"
39 #include "grit/generated_resources.h" 37 #include "grit/generated_resources.h"
40 #include "ui/base/l10n/l10n_util.h" 38 #include "ui/base/l10n/l10n_util.h"
41 39
42 BrowserOptionsHandler::BrowserOptionsHandler() 40 BrowserOptionsHandler::BrowserOptionsHandler()
43 : template_url_service_(NULL), startup_custom_pages_table_model_(NULL) { 41 : template_url_service_(NULL), startup_custom_pages_table_model_(NULL) {
44 #if !defined(OS_MACOSX) 42 #if !defined(OS_MACOSX)
45 default_browser_worker_ = new ShellIntegration::DefaultBrowserWorker(this); 43 default_browser_worker_ = new ShellIntegration::DefaultBrowserWorker(this);
46 #endif 44 #endif
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 base::Unretained(this))); 113 base::Unretained(this)));
116 web_ui_->RegisterMessageCallback("setStartupPagesToCurrentPages", 114 web_ui_->RegisterMessageCallback("setStartupPagesToCurrentPages",
117 base::Bind(&BrowserOptionsHandler::SetStartupPagesToCurrentPages, 115 base::Bind(&BrowserOptionsHandler::SetStartupPagesToCurrentPages,
118 base::Unretained(this))); 116 base::Unretained(this)));
119 web_ui_->RegisterMessageCallback("dragDropStartupPage", 117 web_ui_->RegisterMessageCallback("dragDropStartupPage",
120 base::Bind(&BrowserOptionsHandler::DragDropStartupPage, 118 base::Bind(&BrowserOptionsHandler::DragDropStartupPage,
121 base::Unretained(this))); 119 base::Unretained(this)));
122 web_ui_->RegisterMessageCallback("requestAutocompleteSuggestions", 120 web_ui_->RegisterMessageCallback("requestAutocompleteSuggestions",
123 base::Bind(&BrowserOptionsHandler::RequestAutocompleteSuggestions, 121 base::Bind(&BrowserOptionsHandler::RequestAutocompleteSuggestions,
124 base::Unretained(this))); 122 base::Unretained(this)));
125 web_ui_->RegisterMessageCallback("toggleShowBookmarksBar",
126 base::Bind(&BrowserOptionsHandler::ToggleShowBookmarksBar,
127 base::Unretained(this)));
128 web_ui_->RegisterMessageCallback("enableInstant", 123 web_ui_->RegisterMessageCallback("enableInstant",
129 base::Bind(&BrowserOptionsHandler::EnableInstant, 124 base::Bind(&BrowserOptionsHandler::EnableInstant,
130 base::Unretained(this))); 125 base::Unretained(this)));
131 web_ui_->RegisterMessageCallback("disableInstant", 126 web_ui_->RegisterMessageCallback("disableInstant",
132 base::Bind(&BrowserOptionsHandler::DisableInstant, 127 base::Bind(&BrowserOptionsHandler::DisableInstant,
133 base::Unretained(this))); 128 base::Unretained(this)));
134 web_ui_->RegisterMessageCallback("getInstantFieldTrialStatus", 129 web_ui_->RegisterMessageCallback("getInstantFieldTrialStatus",
135 base::Bind(&BrowserOptionsHandler::GetInstantFieldTrialStatus, 130 base::Bind(&BrowserOptionsHandler::GetInstantFieldTrialStatus,
136 base::Unretained(this))); 131 base::Unretained(this)));
137 } 132 }
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 void BrowserOptionsHandler::RequestAutocompleteSuggestions( 461 void BrowserOptionsHandler::RequestAutocompleteSuggestions(
467 const ListValue* args) { 462 const ListValue* args) {
468 string16 input; 463 string16 input;
469 CHECK_EQ(args->GetSize(), 1U); 464 CHECK_EQ(args->GetSize(), 1U);
470 CHECK(args->GetString(0, &input)); 465 CHECK(args->GetString(0, &input));
471 466
472 autocomplete_controller_->Start(input, string16(), true, false, false, 467 autocomplete_controller_->Start(input, string16(), true, false, false,
473 AutocompleteInput::ALL_MATCHES); 468 AutocompleteInput::ALL_MATCHES);
474 } 469 }
475 470
476 void BrowserOptionsHandler::ToggleShowBookmarksBar(const ListValue* args) {
477 Source<Profile> source(Profile::FromWebUI(web_ui_));
478 NotificationService::current()->Notify(
479 chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED,
480 source,
481 NotificationService::NoDetails());
482 }
483
484 void BrowserOptionsHandler::EnableInstant(const ListValue* args) { 471 void BrowserOptionsHandler::EnableInstant(const ListValue* args) {
485 InstantController::Enable(Profile::FromWebUI(web_ui_)); 472 InstantController::Enable(Profile::FromWebUI(web_ui_));
486 } 473 }
487 474
488 void BrowserOptionsHandler::DisableInstant(const ListValue* args) { 475 void BrowserOptionsHandler::DisableInstant(const ListValue* args) {
489 InstantController::Disable(Profile::FromWebUI(web_ui_)); 476 InstantController::Disable(Profile::FromWebUI(web_ui_));
490 } 477 }
491 478
492 void BrowserOptionsHandler::GetInstantFieldTrialStatus(const ListValue* args) { 479 void BrowserOptionsHandler::GetInstantFieldTrialStatus(const ListValue* args) {
493 base::FundamentalValue enabled( 480 base::FundamentalValue enabled(
(...skipping 17 matching lines...) Expand all
511 DictionaryValue* entry = new DictionaryValue(); 498 DictionaryValue* entry = new DictionaryValue();
512 entry->SetString("title", match.description); 499 entry->SetString("title", match.description);
513 entry->SetString("displayURL", match.contents); 500 entry->SetString("displayURL", match.contents);
514 entry->SetString("url", match.destination_url.spec()); 501 entry->SetString("url", match.destination_url.spec());
515 suggestions.Append(entry); 502 suggestions.Append(entry);
516 } 503 }
517 504
518 web_ui_->CallJavascriptFunction( 505 web_ui_->CallJavascriptFunction(
519 "BrowserOptions.updateAutocompleteSuggestions", suggestions); 506 "BrowserOptions.updateAutocompleteSuggestions", suggestions);
520 } 507 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698