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

Side by Side Diff: chrome/browser/cocoa/search_engine_dialog_controller.mm

Issue 4206002: Firefox import broken for first run on Mac (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #import "chrome/browser/cocoa/search_engine_dialog_controller.h" 5 #import "chrome/browser/cocoa/search_engine_dialog_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "app/l10n_util_mac.h" 9 #include "app/l10n_util_mac.h"
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
(...skipping 22 matching lines...) Expand all
33 const int kLogoLabelHeight = 25; 33 const int kLogoLabelHeight = 25;
34 34
35 @interface SearchEngineDialogController (Private) 35 @interface SearchEngineDialogController (Private)
36 - (void)onTemplateURLModelChanged; 36 - (void)onTemplateURLModelChanged;
37 - (void)buildSearchEngineView; 37 - (void)buildSearchEngineView;
38 - (NSView*)viewForSearchEngine:(const TemplateURL*)engine 38 - (NSView*)viewForSearchEngine:(const TemplateURL*)engine
39 atIndex:(size_t)index; 39 atIndex:(size_t)index;
40 - (IBAction)searchEngineSelected:(id)sender; 40 - (IBAction)searchEngineSelected:(id)sender;
41 @end 41 @end
42 42
43 class SearchEngineDialogControllerBridge : public TemplateURLModelObserver { 43 class SearchEngineDialogControllerBridge :
44 public base::RefCounted<SearchEngineDialogControllerBridge>,
45 public TemplateURLModelObserver {
44 public: 46 public:
45 SearchEngineDialogControllerBridge(SearchEngineDialogController* controller); 47 SearchEngineDialogControllerBridge(SearchEngineDialogController* controller);
46 48
47 // TemplateURLModelObserver 49 // TemplateURLModelObserver
48 virtual void OnTemplateURLModelChanged(); 50 virtual void OnTemplateURLModelChanged();
49 51
50 private: 52 private:
51 SearchEngineDialogController* controller_; 53 SearchEngineDialogController* controller_;
52 }; 54 };
53 55
(...skipping 10 matching lines...) Expand all
64 66
65 @synthesize profile = profile_; 67 @synthesize profile = profile_;
66 @synthesize randomize = randomize_; 68 @synthesize randomize = randomize_;
67 69
68 - (id)init { 70 - (id)init {
69 NSString* nibpath = 71 NSString* nibpath =
70 [mac_util::MainAppBundle() pathForResource:@"SearchEngineDialog" 72 [mac_util::MainAppBundle() pathForResource:@"SearchEngineDialog"
71 ofType:@"nib"]; 73 ofType:@"nib"];
72 self = [super initWithWindowNibPath:nibpath owner:self]; 74 self = [super initWithWindowNibPath:nibpath owner:self];
73 if (self != nil) { 75 if (self != nil) {
74 bridge_.reset(new SearchEngineDialogControllerBridge(self)); 76 bridge_ = new SearchEngineDialogControllerBridge(self);
75 } 77 }
76 return self; 78 return self;
77 } 79 }
78 80
79 - (void)dealloc { 81 - (void)dealloc {
80 [super dealloc]; 82 [super dealloc];
81 } 83 }
82 84
83 - (IBAction)showWindow:(id)sender { 85 - (IBAction)showWindow:(id)sender {
84 searchEnginesModel_ = profile_->GetTemplateURLModel(); 86 searchEnginesModel_ = profile_->GetTemplateURLModel();
85 searchEnginesModel_->AddObserver(bridge_.get()); 87 searchEnginesModel_->AddObserver(bridge_.get());
86 88
87 if (searchEnginesModel_->loaded()) { 89 if (searchEnginesModel_->loaded()) {
88 [self onTemplateURLModelChanged]; 90 MessageLoop::current()->PostTask(
91 FROM_HERE,
92 NewRunnableMethod(
93 bridge_.get(),
94 &SearchEngineDialogControllerBridge::OnTemplateURLModelChanged));
89 } else { 95 } else {
90 searchEnginesModel_->Load(); 96 searchEnginesModel_->Load();
91 MessageLoop::current()->Run();
92 } 97 }
98 MessageLoop::current()->Run();
93 } 99 }
94 100
95 - (void)onTemplateURLModelChanged { 101 - (void)onTemplateURLModelChanged {
96 searchEnginesModel_->RemoveObserver(bridge_.get()); 102 searchEnginesModel_->RemoveObserver(bridge_.get());
97 103
98 // Add the search engines in the search_engines_model_ to the buttons list. 104 // Add the search engines in the search_engines_model_ to the buttons list.
99 // The first three will always be from prepopulated data. 105 // The first three will always be from prepopulated data.
100 std::vector<const TemplateURL*> templateUrls = 106 std::vector<const TemplateURL*> templateUrls =
101 searchEnginesModel_->GetTemplateURLs(); 107 searchEnginesModel_->GetTemplateURLs();
102 108
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 - (NSFont*)mainLabelFont { 276 - (NSFont*)mainLabelFont {
271 return [NSFont boldSystemFontOfSize:13]; 277 return [NSFont boldSystemFontOfSize:13];
272 } 278 }
273 279
274 - (IBAction)searchEngineSelected:(id)sender { 280 - (IBAction)searchEngineSelected:(id)sender {
275 [[self window] close]; 281 [[self window] close];
276 [NSApp stopModalWithCode:[sender tag]]; 282 [NSApp stopModalWithCode:[sender tag]];
277 } 283 }
278 284
279 @end 285 @end
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/search_engine_dialog_controller.h ('k') | chrome/browser/importer/importer_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698