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

Side by Side Diff: chrome/browser/ui/cocoa/web_intent_picker_cocoa.mm

Issue 10534093: TabContentsWrapper -> TabContents, part 37. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/cocoa/web_intent_picker_cocoa.h" 5 #include "chrome/browser/ui/cocoa/web_intent_picker_cocoa.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/sys_string_conversions.h" 11 #include "base/sys_string_conversions.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/tab_contents/tab_util.h" 13 #include "chrome/browser/tab_contents/tab_util.h"
14 #include "chrome/browser/ui/browser_window.h" 14 #include "chrome/browser/ui/browser_window.h"
15 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 15 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
16 #include "chrome/browser/ui/cocoa/constrained_window_mac.h" 16 #include "chrome/browser/ui/cocoa/constrained_window_mac.h"
17 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" 17 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
18 #import "chrome/browser/ui/cocoa/web_intent_sheet_controller.h" 18 #import "chrome/browser/ui/cocoa/web_intent_sheet_controller.h"
19 #include "chrome/browser/ui/intents/web_intent_inline_disposition_delegate.h" 19 #include "chrome/browser/ui/intents/web_intent_inline_disposition_delegate.h"
20 #include "chrome/browser/ui/intents/web_intent_picker.h" 20 #include "chrome/browser/ui/intents/web_intent_picker.h"
21 #include "chrome/browser/ui/intents/web_intent_picker_delegate.h" 21 #include "chrome/browser/ui/intents/web_intent_picker_delegate.h"
22 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 22 #include "chrome/browser/ui/tab_contents/tab_contents.h"
23 #include "content/public/browser/web_contents.h" 23 #include "content/public/browser/web_contents.h"
24 #include "skia/ext/skia_utils_mac.h" 24 #include "skia/ext/skia_utils_mac.h"
25 #include "ui/gfx/image/image.h" 25 #include "ui/gfx/image/image.h"
26 26
27 using content::WebContents; 27 using content::WebContents;
28 28
29 namespace { 29 namespace {
30 30
31 // Since any delegates for constrained windows are tasked with deleting 31 // Since any delegates for constrained windows are tasked with deleting
32 // themselves, and the WebIntentPicker needs to live longer than the 32 // themselves, and the WebIntentPicker needs to live longer than the
(...skipping 26 matching lines...) Expand all
59 void ConstrainedPickerSheetDelegate::DeleteDelegate() { 59 void ConstrainedPickerSheetDelegate::DeleteDelegate() {
60 if (is_sheet_open()) 60 if (is_sheet_open())
61 [NSApp endSheet:sheet()]; 61 [NSApp endSheet:sheet()];
62 62
63 delete this; 63 delete this;
64 } 64 }
65 65
66 } // namespace 66 } // namespace
67 67
68 // static 68 // static
69 WebIntentPicker* WebIntentPicker::Create(TabContentsWrapper* wrapper, 69 WebIntentPicker* WebIntentPicker::Create(TabContents* tab_contents,
70 WebIntentPickerDelegate* delegate, 70 WebIntentPickerDelegate* delegate,
71 WebIntentPickerModel* model) { 71 WebIntentPickerModel* model) {
72 return new WebIntentPickerCocoa(wrapper, delegate, model); 72 return new WebIntentPickerCocoa(tab_contents, delegate, model);
73 } 73 }
74 74
75 WebIntentPickerCocoa::WebIntentPickerCocoa() 75 WebIntentPickerCocoa::WebIntentPickerCocoa()
76 : delegate_(NULL), 76 : delegate_(NULL),
77 model_(NULL), 77 model_(NULL),
78 wrapper_(NULL), 78 tab_contents_(NULL),
79 sheet_controller_(nil), 79 sheet_controller_(nil),
80 service_invoked(false) { 80 service_invoked(false) {
81 } 81 }
82 82
83 WebIntentPickerCocoa::WebIntentPickerCocoa(TabContentsWrapper* wrapper, 83 WebIntentPickerCocoa::WebIntentPickerCocoa(TabContents* tab_contents,
84 WebIntentPickerDelegate* delegate, 84 WebIntentPickerDelegate* delegate,
85 WebIntentPickerModel* model) 85 WebIntentPickerModel* model)
86 : delegate_(delegate), 86 : delegate_(delegate),
87 model_(model), 87 model_(model),
88 wrapper_(wrapper), 88 tab_contents_(tab_contents),
89 sheet_controller_(nil), 89 sheet_controller_(nil),
90 service_invoked(false) { 90 service_invoked(false) {
91 model_->set_observer(this); 91 model_->set_observer(this);
92 92
93 DCHECK(delegate); 93 DCHECK(delegate);
94 DCHECK(wrapper); 94 DCHECK(tab_contents);
95 95
96 sheet_controller_ = [ 96 sheet_controller_ = [
97 [WebIntentPickerSheetController alloc] initWithPicker:this]; 97 [WebIntentPickerSheetController alloc] initWithPicker:this];
98 98
99 // Deleted when ConstrainedPickerSheetDelegate::DeleteDelegate() runs. 99 // Deleted when ConstrainedPickerSheetDelegate::DeleteDelegate() runs.
100 ConstrainedPickerSheetDelegate* constrained_delegate = 100 ConstrainedPickerSheetDelegate* constrained_delegate =
101 new ConstrainedPickerSheetDelegate(this, sheet_controller_); 101 new ConstrainedPickerSheetDelegate(this, sheet_controller_);
102 102
103 window_ = new ConstrainedWindowMac(wrapper, constrained_delegate); 103 window_ = new ConstrainedWindowMac(tab_contents, constrained_delegate);
104 } 104 }
105 105
106 WebIntentPickerCocoa::~WebIntentPickerCocoa() { 106 WebIntentPickerCocoa::~WebIntentPickerCocoa() {
107 if (model_ != NULL) 107 if (model_ != NULL)
108 model_->set_observer(NULL); 108 model_->set_observer(NULL);
109 } 109 }
110 110
111 void WebIntentPickerCocoa::OnSheetDidEnd(NSWindow* sheet) { 111 void WebIntentPickerCocoa::OnSheetDidEnd(NSWindow* sheet) {
112 [sheet orderOut:sheet_controller_]; 112 [sheet orderOut:sheet_controller_];
113 if (window_) 113 if (window_)
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 void WebIntentPickerCocoa::OnExtensionIconChanged( 150 void WebIntentPickerCocoa::OnExtensionIconChanged(
151 WebIntentPickerModel* model, 151 WebIntentPickerModel* model,
152 const string16& extension_id) { 152 const string16& extension_id) {
153 // We don't handle individual icon changes - just redo the whole model. 153 // We don't handle individual icon changes - just redo the whole model.
154 PerformLayout(); 154 PerformLayout();
155 } 155 }
156 156
157 void WebIntentPickerCocoa::OnInlineDisposition(WebIntentPickerModel* model, 157 void WebIntentPickerCocoa::OnInlineDisposition(WebIntentPickerModel* model,
158 const GURL& url) { 158 const GURL& url) {
159 content::WebContents* web_contents = content::WebContents::Create( 159 content::WebContents* web_contents = content::WebContents::Create(
160 wrapper_->profile(), 160 tab_contents_->profile(),
161 tab_util::GetSiteInstanceForNewTab(wrapper_->profile(), url), 161 tab_util::GetSiteInstanceForNewTab(tab_contents_->profile(), url),
162 MSG_ROUTING_NONE, NULL, NULL); 162 MSG_ROUTING_NONE, NULL, NULL);
163 inline_disposition_tab_contents_.reset(new TabContentsWrapper(web_contents)); 163 inline_disposition_tab_contents_.reset(new TabContents(web_contents));
164 inline_disposition_delegate_.reset( 164 inline_disposition_delegate_.reset(
165 new WebIntentInlineDispositionDelegate(this, web_contents, 165 new WebIntentInlineDispositionDelegate(this, web_contents,
166 wrapper_->profile())); 166 tab_contents_->profile()));
167 167
168 // Must call this immediately after WebContents creation to avoid race 168 // Must call this immediately after WebContents creation to avoid race
169 // with load. 169 // with load.
170 delegate_->OnInlineDispositionWebContentsCreated(web_contents); 170 delegate_->OnInlineDispositionWebContentsCreated(web_contents);
171 171
172 inline_disposition_tab_contents_->web_contents()->GetController().LoadURL( 172 inline_disposition_tab_contents_->web_contents()->GetController().LoadURL(
173 url, 173 url,
174 content::Referrer(), 174 content::Referrer(),
175 content::PAGE_TRANSITION_START_PAGE, 175 content::PAGE_TRANSITION_START_PAGE,
176 std::string()); 176 std::string());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 222
223 void WebIntentPickerCocoa::OnExtensionLinkClicked(const std::string& id) { 223 void WebIntentPickerCocoa::OnExtensionLinkClicked(const std::string& id) {
224 DCHECK(delegate_); 224 DCHECK(delegate_);
225 delegate_->OnExtensionLinkClicked(id); 225 delegate_->OnExtensionLinkClicked(id);
226 } 226 }
227 227
228 void WebIntentPickerCocoa::OnSuggestionsLinkClicked() { 228 void WebIntentPickerCocoa::OnSuggestionsLinkClicked() {
229 DCHECK(delegate_); 229 DCHECK(delegate_);
230 delegate_->OnSuggestionsLinkClicked(); 230 delegate_->OnSuggestionsLinkClicked();
231 } 231 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/web_intent_picker_cocoa.h ('k') | chrome/browser/ui/cocoa/web_intent_sheet_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698