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

Side by Side Diff: chrome/browser/ui/intents/web_intent_picker_controller.cc

Issue 8934011: Rename IntentsHost -> WebIntentsDispatcher and IntentsDispatcher -> WebIntentsHost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head Created 9 years 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) 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/intents/web_intent_picker_controller.h" 5 #include "chrome/browser/ui/intents/web_intent_picker_controller.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/favicon/favicon_service.h" 12 #include "chrome/browser/favicon/favicon_service.h"
13 #include "chrome/browser/intents/web_intents_registry.h" 13 #include "chrome/browser/intents/web_intents_registry.h"
14 #include "chrome/browser/intents/web_intents_registry_factory.h" 14 #include "chrome/browser/intents/web_intents_registry_factory.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/tabs/tab_strip_model.h" 16 #include "chrome/browser/tabs/tab_strip_model.h"
17 #include "chrome/browser/ui/browser_navigator.h" 17 #include "chrome/browser/ui/browser_navigator.h"
18 #include "chrome/browser/ui/intents/web_intent_picker.h" 18 #include "chrome/browser/ui/intents/web_intent_picker.h"
19 #include "chrome/browser/ui/intents/web_intent_picker_factory.h" 19 #include "chrome/browser/ui/intents/web_intent_picker_factory.h"
20 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 20 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
21 #include "chrome/browser/webdata/web_data_service.h" 21 #include "chrome/browser/webdata/web_data_service.h"
22 #include "content/browser/intents/intent_injector.h" 22 #include "content/browser/intents/intent_injector.h"
23 #include "content/browser/tab_contents/tab_contents.h" 23 #include "content/browser/tab_contents/tab_contents.h"
24 #include "content/public/browser/intents_host.h" 24 #include "content/public/browser/web_intents_dispatcher.h"
25 #include "content/public/browser/notification_source.h" 25 #include "content/public/browser/notification_source.h"
26 #include "ui/gfx/codec/png_codec.h" 26 #include "ui/gfx/codec/png_codec.h"
27 #include "webkit/glue/web_intent_service_data.h" 27 #include "webkit/glue/web_intent_service_data.h"
28 28
29 namespace { 29 namespace {
30 30
31 // Gets the favicon service for the profile in |tab_contents|. 31 // Gets the favicon service for the profile in |tab_contents|.
32 FaviconService* GetFaviconService(TabContentsWrapper* wrapper) { 32 FaviconService* GetFaviconService(TabContentsWrapper* wrapper) {
33 return wrapper->profile()->GetFaviconService(Profile::EXPLICIT_ACCESS); 33 return wrapper->profile()->GetFaviconService(Profile::EXPLICIT_ACCESS);
34 } 34 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 NavigationController* controller = &wrapper->tab_contents()->GetController(); 119 NavigationController* controller = &wrapper->tab_contents()->GetController();
120 registrar_.Add(this, content::NOTIFICATION_LOAD_START, 120 registrar_.Add(this, content::NOTIFICATION_LOAD_START,
121 content::Source<NavigationController>(controller)); 121 content::Source<NavigationController>(controller));
122 registrar_.Add(this, content::NOTIFICATION_TAB_CLOSING, 122 registrar_.Add(this, content::NOTIFICATION_TAB_CLOSING,
123 content::Source<NavigationController>(controller)); 123 content::Source<NavigationController>(controller));
124 } 124 }
125 125
126 WebIntentPickerController::~WebIntentPickerController() { 126 WebIntentPickerController::~WebIntentPickerController() {
127 } 127 }
128 128
129 void WebIntentPickerController::SetIntentsHost( 129 void WebIntentPickerController::SetIntentsDispatcher(
130 content::IntentsHost* intents_host) { 130 content::WebIntentsDispatcher* intents_dispatcher) {
131 intents_host_.reset(intents_host); 131 intents_dispatcher_.reset(intents_dispatcher);
132 intents_host_->RegisterReplyNotification( 132 intents_dispatcher_->RegisterReplyNotification(
133 base::Bind(&WebIntentPickerController::OnSendReturnMessage, 133 base::Bind(&WebIntentPickerController::OnSendReturnMessage,
134 base::Unretained(this))); 134 base::Unretained(this)));
135 } 135 }
136 136
137 void WebIntentPickerController::ShowDialog(Browser* browser, 137 void WebIntentPickerController::ShowDialog(Browser* browser,
138 const string16& action, 138 const string16& action,
139 const string16& type) { 139 const string16& type) {
140 if (picker_ != NULL) 140 if (picker_ != NULL)
141 return; 141 return;
142 142
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 content::PAGE_TRANSITION_AUTO_BOOKMARK); 179 content::PAGE_TRANSITION_AUTO_BOOKMARK);
180 params.disposition = NEW_FOREGROUND_TAB; 180 params.disposition = NEW_FOREGROUND_TAB;
181 params.profile = wrapper_->profile(); 181 params.profile = wrapper_->profile();
182 browser::Navigate(&params); 182 browser::Navigate(&params);
183 new_tab_contents = params.target_contents->tab_contents(); 183 new_tab_contents = params.target_contents->tab_contents();
184 service_tab_ = new_tab_contents; 184 service_tab_ = new_tab_contents;
185 185
186 ClosePicker(); 186 ClosePicker();
187 } 187 }
188 188
189 intents_host_->DispatchIntent(new_tab_contents); 189 intents_dispatcher_->DispatchIntent(new_tab_contents);
190 } 190 }
191 191
192 void WebIntentPickerController::OnCancelled() { 192 void WebIntentPickerController::OnCancelled() {
193 if (!intents_host_.get()) 193 if (!intents_dispatcher_.get())
194 return; 194 return;
195 195
196 if (service_tab_) { 196 if (service_tab_) {
197 intents_host_->SendReplyMessage(webkit_glue::WEB_INTENT_SERVICE_TAB_CLOSED, 197 intents_dispatcher_->SendReplyMessage(
198 string16()); 198 webkit_glue::WEB_INTENT_SERVICE_TAB_CLOSED, string16());
199 } else { 199 } else {
200 intents_host_->SendReplyMessage(webkit_glue::WEB_INTENT_PICKER_CANCELLED, 200 intents_dispatcher_->SendReplyMessage(
201 string16()); 201 webkit_glue::WEB_INTENT_PICKER_CANCELLED, string16());
202 } 202 }
203 203
204 ClosePicker(); 204 ClosePicker();
205 } 205 }
206 206
207 void WebIntentPickerController::OnClosing() { 207 void WebIntentPickerController::OnClosing() {
208 } 208 }
209 209
210 void WebIntentPickerController::OnSendReturnMessage() { 210 void WebIntentPickerController::OnSendReturnMessage() {
211 ClosePicker(); 211 ClosePicker();
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 if (gfx::PNGCodec::Decode(favicon_data.image_data->front(), 323 if (gfx::PNGCodec::Decode(favicon_data.image_data->front(),
324 favicon_data.image_data->size(), 324 favicon_data.image_data->size(),
325 &icon_bitmap)) { 325 &icon_bitmap)) {
326 controller_->OnFaviconDataAvailable(index, icon_bitmap); 326 controller_->OnFaviconDataAvailable(index, icon_bitmap);
327 return; 327 return;
328 } 328 }
329 } 329 }
330 330
331 controller_->OnFaviconDataUnavailable(index); 331 controller_->OnFaviconDataUnavailable(index);
332 } 332 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698