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

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

Issue 7044136: Support drag&drop for startup pages (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fixed review issues Created 9 years, 6 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') | no next file » | 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"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 web_ui_->RegisterMessageCallback( 107 web_ui_->RegisterMessageCallback(
108 "addStartupPage", 108 "addStartupPage",
109 NewCallback(this, &BrowserOptionsHandler::AddStartupPage)); 109 NewCallback(this, &BrowserOptionsHandler::AddStartupPage));
110 web_ui_->RegisterMessageCallback( 110 web_ui_->RegisterMessageCallback(
111 "editStartupPage", 111 "editStartupPage",
112 NewCallback(this, &BrowserOptionsHandler::EditStartupPage)); 112 NewCallback(this, &BrowserOptionsHandler::EditStartupPage));
113 web_ui_->RegisterMessageCallback( 113 web_ui_->RegisterMessageCallback(
114 "setStartupPagesToCurrentPages", 114 "setStartupPagesToCurrentPages",
115 NewCallback(this, &BrowserOptionsHandler::SetStartupPagesToCurrentPages)); 115 NewCallback(this, &BrowserOptionsHandler::SetStartupPagesToCurrentPages));
116 web_ui_->RegisterMessageCallback( 116 web_ui_->RegisterMessageCallback(
117 "dragDropStartupPage",
118 NewCallback(this, &BrowserOptionsHandler::DragDropStartupPage));
119 web_ui_->RegisterMessageCallback(
117 "requestAutocompleteSuggestions", 120 "requestAutocompleteSuggestions",
118 NewCallback(this, 121 NewCallback(this,
119 &BrowserOptionsHandler::RequestAutocompleteSuggestions)); 122 &BrowserOptionsHandler::RequestAutocompleteSuggestions));
120 web_ui_->RegisterMessageCallback( 123 web_ui_->RegisterMessageCallback(
121 "toggleShowBookmarksBar", 124 "toggleShowBookmarksBar",
122 NewCallback(this, &BrowserOptionsHandler::ToggleShowBookmarksBar)); 125 NewCallback(this, &BrowserOptionsHandler::ToggleShowBookmarksBar));
123 } 126 }
124 127
125 void BrowserOptionsHandler::Initialize() { 128 void BrowserOptionsHandler::Initialize() {
126 Profile* profile = web_ui_->GetProfile(); 129 Profile* profile = web_ui_->GetProfile();
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 if (index < 0 || index > startup_custom_pages_table_model_->RowCount()) { 401 if (index < 0 || index > startup_custom_pages_table_model_->RowCount()) {
399 NOTREACHED(); 402 NOTREACHED();
400 return; 403 return;
401 } 404 }
402 405
403 std::vector<GURL> urls = startup_custom_pages_table_model_->GetURLs(); 406 std::vector<GURL> urls = startup_custom_pages_table_model_->GetURLs();
404 urls[index] = URLFixerUpper::FixupURL(url_string, std::string()); 407 urls[index] = URLFixerUpper::FixupURL(url_string, std::string());
405 startup_custom_pages_table_model_->SetURLs(urls); 408 startup_custom_pages_table_model_->SetURLs(urls);
406 } 409 }
407 410
411 void BrowserOptionsHandler::DragDropStartupPage(const ListValue* args) {
412 CHECK_EQ(args->GetSize(), 2U);
413
414 std::string value;
415 int to_index;
416
417 CHECK(args->GetString(0, &value));
418 base::StringToInt(value, &to_index);
419
420 ListValue* selected;
421 CHECK(args->GetList(1, &selected));
422
423 std::vector<int> index_list;
424 for (size_t i = 0; i < selected->GetSize(); ++i) {
425 int index;
426 CHECK(selected->GetString(i, &value));
427 base::StringToInt(value, &index);
428 index_list.push_back(index);
429 }
430
431 startup_custom_pages_table_model_->MoveURLs(to_index, index_list);
432 SaveStartupPagesPref();
433 }
434
408 void BrowserOptionsHandler::SaveStartupPagesPref() { 435 void BrowserOptionsHandler::SaveStartupPagesPref() {
409 PrefService* prefs = web_ui_->GetProfile()->GetPrefs(); 436 PrefService* prefs = web_ui_->GetProfile()->GetPrefs();
410 437
411 SessionStartupPref pref = SessionStartupPref::GetStartupPref(prefs); 438 SessionStartupPref pref = SessionStartupPref::GetStartupPref(prefs);
412 pref.urls = startup_custom_pages_table_model_->GetURLs(); 439 pref.urls = startup_custom_pages_table_model_->GetURLs();
413 440
414 SessionStartupPref::SetStartupPref(prefs, pref); 441 SessionStartupPref::SetStartupPref(prefs, pref);
415 } 442 }
416 443
417 void BrowserOptionsHandler::RequestAutocompleteSuggestions( 444 void BrowserOptionsHandler::RequestAutocompleteSuggestions(
(...skipping 29 matching lines...) Expand all
447 DictionaryValue* entry = new DictionaryValue(); 474 DictionaryValue* entry = new DictionaryValue();
448 entry->SetString("title", match.description); 475 entry->SetString("title", match.description);
449 entry->SetString("displayURL", match.contents); 476 entry->SetString("displayURL", match.contents);
450 entry->SetString("url", match.destination_url.spec()); 477 entry->SetString("url", match.destination_url.spec());
451 suggestions.Append(entry); 478 suggestions.Append(entry);
452 } 479 }
453 480
454 web_ui_->CallJavascriptFunction( 481 web_ui_->CallJavascriptFunction(
455 "BrowserOptions.updateAutocompleteSuggestions", suggestions); 482 "BrowserOptions.updateAutocompleteSuggestions", suggestions);
456 } 483 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/browser_options_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698