| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/views/options/general_page_view.h" | 5 #include "chrome/browser/views/options/general_page_view.h" |
| 6 | 6 |
| 7 #include "base/gfx/png_decoder.h" | 7 #include "base/gfx/png_decoder.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/thread.h" | 10 #include "base/thread.h" |
| 11 #include "chrome/browser/browser.h" | 11 #include "chrome/browser/browser.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 89 |
| 90 // Updates the UI in our associated view with the current default browser | 90 // Updates the UI in our associated view with the current default browser |
| 91 // state. | 91 // state. |
| 92 void UpdateUI(bool is_default); | 92 void UpdateUI(bool is_default); |
| 93 | 93 |
| 94 GeneralPageView* general_page_view_; | 94 GeneralPageView* general_page_view_; |
| 95 | 95 |
| 96 MessageLoop* ui_loop_; | 96 MessageLoop* ui_loop_; |
| 97 MessageLoop* file_loop_; | 97 MessageLoop* file_loop_; |
| 98 | 98 |
| 99 DISALLOW_EVIL_CONSTRUCTORS(GeneralPageView::DefaultBrowserWorker); | 99 DISALLOW_COPY_AND_ASSIGN(GeneralPageView::DefaultBrowserWorker); |
| 100 }; | 100 }; |
| 101 | 101 |
| 102 GeneralPageView::DefaultBrowserWorker::DefaultBrowserWorker( | 102 GeneralPageView::DefaultBrowserWorker::DefaultBrowserWorker( |
| 103 GeneralPageView* general_page_view) | 103 GeneralPageView* general_page_view) |
| 104 : general_page_view_(general_page_view), | 104 : general_page_view_(general_page_view), |
| 105 ui_loop_(MessageLoop::current()), | 105 ui_loop_(MessageLoop::current()), |
| 106 file_loop_(g_browser_process->file_thread()->message_loop()) { | 106 file_loop_(g_browser_process->file_thread()->message_loop()) { |
| 107 } | 107 } |
| 108 | 108 |
| 109 void GeneralPageView::DefaultBrowserWorker::StartCheckDefaultBrowser() { | 109 void GeneralPageView::DefaultBrowserWorker::StartCheckDefaultBrowser() { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 static SkBitmap default_favicon_; | 232 static SkBitmap default_favicon_; |
| 233 | 233 |
| 234 // Profile used to load icons. | 234 // Profile used to load icons. |
| 235 Profile* profile_; | 235 Profile* profile_; |
| 236 | 236 |
| 237 views::TableModelObserver* observer_; | 237 views::TableModelObserver* observer_; |
| 238 | 238 |
| 239 // Used in loading favicons. | 239 // Used in loading favicons. |
| 240 CancelableRequestConsumer fav_icon_consumer_; | 240 CancelableRequestConsumer fav_icon_consumer_; |
| 241 | 241 |
| 242 DISALLOW_EVIL_CONSTRUCTORS(CustomHomePagesTableModel); | 242 DISALLOW_COPY_AND_ASSIGN(CustomHomePagesTableModel); |
| 243 }; | 243 }; |
| 244 | 244 |
| 245 // static | 245 // static |
| 246 SkBitmap CustomHomePagesTableModel::default_favicon_; | 246 SkBitmap CustomHomePagesTableModel::default_favicon_; |
| 247 | 247 |
| 248 CustomHomePagesTableModel::CustomHomePagesTableModel(Profile* profile) | 248 CustomHomePagesTableModel::CustomHomePagesTableModel(Profile* profile) |
| 249 : profile_(profile), | 249 : profile_(profile), |
| 250 observer_(NULL) { | 250 observer_(NULL) { |
| 251 InitClass(); | 251 InitClass(); |
| 252 } | 252 } |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 | 411 |
| 412 TemplateURLModel* template_url_model_; | 412 TemplateURLModel* template_url_model_; |
| 413 | 413 |
| 414 // The combobox hosting us. | 414 // The combobox hosting us. |
| 415 views::ComboBox* combo_box_; | 415 views::ComboBox* combo_box_; |
| 416 | 416 |
| 417 // The TemplateURLs we're showing. | 417 // The TemplateURLs we're showing. |
| 418 typedef std::vector<const TemplateURL*> TemplateURLs; | 418 typedef std::vector<const TemplateURL*> TemplateURLs; |
| 419 TemplateURLs template_urls_; | 419 TemplateURLs template_urls_; |
| 420 | 420 |
| 421 DISALLOW_EVIL_CONSTRUCTORS(SearchEngineListModel); | 421 DISALLOW_COPY_AND_ASSIGN(SearchEngineListModel); |
| 422 }; | 422 }; |
| 423 | 423 |
| 424 SearchEngineListModel::SearchEngineListModel(Profile* profile) | 424 SearchEngineListModel::SearchEngineListModel(Profile* profile) |
| 425 : template_url_model_(profile->GetTemplateURLModel()), | 425 : template_url_model_(profile->GetTemplateURLModel()), |
| 426 combo_box_(NULL) { | 426 combo_box_(NULL) { |
| 427 if (template_url_model_) { | 427 if (template_url_model_) { |
| 428 template_url_model_->Load(); | 428 template_url_model_->Load(); |
| 429 template_url_model_->AddObserver(this); | 429 template_url_model_->AddObserver(this); |
| 430 } | 430 } |
| 431 ResetContents(); | 431 ResetContents(); |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 // If the text field contains a valid URL, sync it to prefs. We run it | 607 // If the text field contains a valid URL, sync it to prefs. We run it |
| 608 // through the fixer upper to allow input like "google.com" to be converted | 608 // through the fixer upper to allow input like "google.com" to be converted |
| 609 // to something valid ("http://google.com"). | 609 // to something valid ("http://google.com"). |
| 610 std::wstring url_string = URLFixerUpper::FixupURL( | 610 std::wstring url_string = URLFixerUpper::FixupURL( |
| 611 homepage_use_url_textfield_->GetText(), std::wstring()); | 611 homepage_use_url_textfield_->GetText(), std::wstring()); |
| 612 if (GURL(url_string).is_valid()) | 612 if (GURL(url_string).is_valid()) |
| 613 SetHomepage(url_string); | 613 SetHomepage(url_string); |
| 614 } | 614 } |
| 615 } | 615 } |
| 616 | 616 |
| 617 void GeneralPageView::HandleKeystroke(views::TextField* sender, | 617 bool GeneralPageView::HandleKeystroke(views::TextField* sender, |
| 618 UINT message, TCHAR key, | 618 UINT message, TCHAR key, |
| 619 UINT repeat_count, UINT flags) { | 619 UINT repeat_count, UINT flags) { |
| 620 // Not necessary. | 620 return false; |
| 621 } | 621 } |
| 622 | 622 |
| 623 /////////////////////////////////////////////////////////////////////////////// | 623 /////////////////////////////////////////////////////////////////////////////// |
| 624 // GeneralPageView, OptionsPageView implementation: | 624 // GeneralPageView, OptionsPageView implementation: |
| 625 | 625 |
| 626 void GeneralPageView::InitControlLayout() { | 626 void GeneralPageView::InitControlLayout() { |
| 627 using views::GridLayout; | 627 using views::GridLayout; |
| 628 using views::ColumnSet; | 628 using views::ColumnSet; |
| 629 | 629 |
| 630 GridLayout* layout = new GridLayout(this); | 630 GridLayout* layout = new GridLayout(this); |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1078 homepage_use_url_textfield_->SetEnabled(false); | 1078 homepage_use_url_textfield_->SetEnabled(false); |
| 1079 homepage_use_url_textfield_->SetReadOnly(true); | 1079 homepage_use_url_textfield_->SetReadOnly(true); |
| 1080 } | 1080 } |
| 1081 } | 1081 } |
| 1082 | 1082 |
| 1083 void GeneralPageView::SetDefaultSearchProvider() { | 1083 void GeneralPageView::SetDefaultSearchProvider() { |
| 1084 const int index = default_search_engine_combobox_->GetSelectedItem(); | 1084 const int index = default_search_engine_combobox_->GetSelectedItem(); |
| 1085 default_search_engines_model_->model()->SetDefaultSearchProvider( | 1085 default_search_engines_model_->model()->SetDefaultSearchProvider( |
| 1086 default_search_engines_model_->GetTemplateURLAt(index)); | 1086 default_search_engines_model_->GetTemplateURLAt(index)); |
| 1087 } | 1087 } |
| OLD | NEW |