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

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

Issue 7461075: Revert 94073 (broke a ton of tests) - Introduce a field trial for Instant. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 5 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
« no previous file with comments | « chrome/browser/ui/webui/options/browser_options_handler.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/singleton.h" 9 #include "base/memory/singleton.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/browser/autocomplete/autocomplete.h" 13 #include "chrome/browser/autocomplete/autocomplete.h"
14 #include "chrome/browser/autocomplete/autocomplete_match.h" 14 #include "chrome/browser/autocomplete/autocomplete_match.h"
15 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/custom_home_pages_table_model.h" 16 #include "chrome/browser/custom_home_pages_table_model.h"
17 #include "chrome/browser/instant/instant_confirm_dialog.h" 17 #include "chrome/browser/instant/instant_confirm_dialog.h"
18 #include "chrome/browser/instant/instant_controller.h" 18 #include "chrome/browser/instant/instant_controller.h"
19 #include "chrome/browser/instant/instant_field_trial.h"
20 #include "chrome/browser/net/url_fixer_upper.h" 19 #include "chrome/browser/net/url_fixer_upper.h"
21 #include "chrome/browser/prefs/pref_service.h" 20 #include "chrome/browser/prefs/pref_service.h"
22 #include "chrome/browser/prefs/session_startup_pref.h" 21 #include "chrome/browser/prefs/session_startup_pref.h"
23 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/search_engines/template_url.h" 23 #include "chrome/browser/search_engines/template_url.h"
25 #include "chrome/browser/search_engines/template_url_service.h" 24 #include "chrome/browser/search_engines/template_url_service.h"
26 #include "chrome/browser/search_engines/template_url_service_factory.h" 25 #include "chrome/browser/search_engines/template_url_service_factory.h"
27 #include "chrome/browser/ui/webui/favicon_source.h" 26 #include "chrome/browser/ui/webui/favicon_source.h"
28 #include "chrome/common/chrome_notification_types.h" 27 #include "chrome/common/chrome_notification_types.h"
29 #include "chrome/common/pref_names.h" 28 #include "chrome/common/pref_names.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 &BrowserOptionsHandler::RequestAutocompleteSuggestions)); 122 &BrowserOptionsHandler::RequestAutocompleteSuggestions));
124 web_ui_->RegisterMessageCallback( 123 web_ui_->RegisterMessageCallback(
125 "toggleShowBookmarksBar", 124 "toggleShowBookmarksBar",
126 NewCallback(this, &BrowserOptionsHandler::ToggleShowBookmarksBar)); 125 NewCallback(this, &BrowserOptionsHandler::ToggleShowBookmarksBar));
127 web_ui_->RegisterMessageCallback( 126 web_ui_->RegisterMessageCallback(
128 "enableInstant", 127 "enableInstant",
129 NewCallback(this, &BrowserOptionsHandler::EnableInstant)); 128 NewCallback(this, &BrowserOptionsHandler::EnableInstant));
130 web_ui_->RegisterMessageCallback( 129 web_ui_->RegisterMessageCallback(
131 "disableInstant", 130 "disableInstant",
132 NewCallback(this, &BrowserOptionsHandler::DisableInstant)); 131 NewCallback(this, &BrowserOptionsHandler::DisableInstant));
133 web_ui_->RegisterMessageCallback(
134 "getInstantFieldTrialStatus",
135 NewCallback(this, &BrowserOptionsHandler::GetInstantFieldTrialStatus));
136 } 132 }
137 133
138 void BrowserOptionsHandler::Initialize() { 134 void BrowserOptionsHandler::Initialize() {
139 Profile* profile = web_ui_->GetProfile(); 135 Profile* profile = web_ui_->GetProfile();
140 136
141 // Create our favicon data source. 137 // Create our favicon data source.
142 profile->GetChromeURLDataManager()->AddDataSource( 138 profile->GetChromeURLDataManager()->AddDataSource(
143 new FaviconSource(profile, FaviconSource::FAVICON)); 139 new FaviconSource(profile, FaviconSource::FAVICON));
144 140
145 homepage_.Init(prefs::kHomePage, profile->GetPrefs(), NULL); 141 homepage_.Init(prefs::kHomePage, profile->GetPrefs(), NULL);
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 } 477 }
482 478
483 void BrowserOptionsHandler::EnableInstant(const ListValue* args) { 479 void BrowserOptionsHandler::EnableInstant(const ListValue* args) {
484 InstantController::Enable(web_ui_->GetProfile()); 480 InstantController::Enable(web_ui_->GetProfile());
485 } 481 }
486 482
487 void BrowserOptionsHandler::DisableInstant(const ListValue* args) { 483 void BrowserOptionsHandler::DisableInstant(const ListValue* args) {
488 InstantController::Disable(web_ui_->GetProfile()); 484 InstantController::Disable(web_ui_->GetProfile());
489 } 485 }
490 486
491 void BrowserOptionsHandler::GetInstantFieldTrialStatus(const ListValue* args) {
492 FundamentalValue enabled(
493 InstantFieldTrial::IsExperimentGroup(web_ui_->GetProfile()));
494 web_ui_->CallJavascriptFunction("BrowserOptions.setInstantFieldTrialStatus",
495 enabled);
496 }
497
498 void BrowserOptionsHandler::OnResultChanged(bool default_match_changed) { 487 void BrowserOptionsHandler::OnResultChanged(bool default_match_changed) {
499 const AutocompleteResult& result = autocomplete_controller_->result(); 488 const AutocompleteResult& result = autocomplete_controller_->result();
500 ListValue suggestions; 489 ListValue suggestions;
501 for (size_t i = 0; i < result.size(); ++i) { 490 for (size_t i = 0; i < result.size(); ++i) {
502 const AutocompleteMatch& match = result.match_at(i); 491 const AutocompleteMatch& match = result.match_at(i);
503 AutocompleteMatch::Type type = match.type; 492 AutocompleteMatch::Type type = match.type;
504 if (type != AutocompleteMatch::HISTORY_URL && 493 if (type != AutocompleteMatch::HISTORY_URL &&
505 type != AutocompleteMatch::HISTORY_TITLE && 494 type != AutocompleteMatch::HISTORY_TITLE &&
506 type != AutocompleteMatch::HISTORY_BODY && 495 type != AutocompleteMatch::HISTORY_BODY &&
507 type != AutocompleteMatch::HISTORY_KEYWORD && 496 type != AutocompleteMatch::HISTORY_KEYWORD &&
508 type != AutocompleteMatch::NAVSUGGEST) 497 type != AutocompleteMatch::NAVSUGGEST)
509 continue; 498 continue;
510 DictionaryValue* entry = new DictionaryValue(); 499 DictionaryValue* entry = new DictionaryValue();
511 entry->SetString("title", match.description); 500 entry->SetString("title", match.description);
512 entry->SetString("displayURL", match.contents); 501 entry->SetString("displayURL", match.contents);
513 entry->SetString("url", match.destination_url.spec()); 502 entry->SetString("url", match.destination_url.spec());
514 suggestions.Append(entry); 503 suggestions.Append(entry);
515 } 504 }
516 505
517 web_ui_->CallJavascriptFunction( 506 web_ui_->CallJavascriptFunction(
518 "BrowserOptions.updateAutocompleteSuggestions", suggestions); 507 "BrowserOptions.updateAutocompleteSuggestions", suggestions);
519 } 508 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/browser_options_handler.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698