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

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

Issue 7782015: content: Move web intent constrained window to TabContentsWrapper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 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) 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 "chrome/browser/favicon/favicon_service.h" 9 #include "chrome/browser/favicon/favicon_service.h"
10 #include "chrome/browser/intents/web_intent_data.h" 10 #include "chrome/browser/intents/web_intent_data.h"
11 #include "chrome/browser/intents/web_intents_registry.h" 11 #include "chrome/browser/intents/web_intents_registry.h"
12 #include "chrome/browser/intents/web_intents_registry_factory.h" 12 #include "chrome/browser/intents/web_intents_registry_factory.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/intents/web_intent_picker.h" 14 #include "chrome/browser/ui/intents/web_intent_picker.h"
15 #include "chrome/browser/ui/intents/web_intent_picker_factory.h" 15 #include "chrome/browser/ui/intents/web_intent_picker_factory.h"
16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
16 #include "chrome/browser/webdata/web_data_service.h" 17 #include "chrome/browser/webdata/web_data_service.h"
17 #include "content/browser/tab_contents/tab_contents.h" 18 #include "content/browser/tab_contents/tab_contents.h"
18 #include "content/common/notification_source.h" 19 #include "content/common/notification_source.h"
19 #include "ui/gfx/codec/png_codec.h" 20 #include "ui/gfx/codec/png_codec.h"
20 21
21 namespace { 22 namespace {
22 23
23 // Gets the favicon service for the profile in |tab_contents|. 24 // Gets the favicon service for the profile in |tab_contents|.
24 FaviconService* GetFaviconService(TabContents* tab_contents) { 25 FaviconService* GetFaviconService(TabContentsWrapper* wrapper) {
25 Profile* profile = Profile::FromBrowserContext( 26 return wrapper->profile()->GetFaviconService(Profile::EXPLICIT_ACCESS);
26 tab_contents->browser_context());
27 return profile->GetFaviconService(Profile::EXPLICIT_ACCESS);
28 } 27 }
29 28
30 // Gets the web intents registry for the profile in |tab_contents|. 29 // Gets the web intents registry for the profile in |tab_contents|.
31 WebIntentsRegistry* GetWebIntentsRegistry(TabContents* tab_contents) { 30 WebIntentsRegistry* GetWebIntentsRegistry(TabContentsWrapper* wrapper) {
32 Profile* profile = Profile::FromBrowserContext( 31 return WebIntentsRegistryFactory::GetForProfile(wrapper->profile());
33 tab_contents->browser_context());
34 return WebIntentsRegistryFactory::GetForProfile(profile);
35 } 32 }
36 33
37 } // namespace 34 } // namespace
38 35
39 // A class that asynchronously fetches web intent data from the web intents 36 // A class that asynchronously fetches web intent data from the web intents
40 // registry. 37 // registry.
41 class WebIntentPickerController::WebIntentDataFetcher 38 class WebIntentPickerController::WebIntentDataFetcher
42 : public WebIntentsRegistry::Consumer { 39 : public WebIntentsRegistry::Consumer {
43 public: 40 public:
44 WebIntentDataFetcher(WebIntentPickerController* controller, 41 WebIntentDataFetcher(WebIntentPickerController* controller,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 // A weak pointer to the favicon service. 89 // A weak pointer to the favicon service.
93 FaviconService* favicon_service_; 90 FaviconService* favicon_service_;
94 91
95 // The Consumer to handle asynchronous favicon requests. 92 // The Consumer to handle asynchronous favicon requests.
96 CancelableRequestConsumerTSimple<size_t> load_consumer_; 93 CancelableRequestConsumerTSimple<size_t> load_consumer_;
97 94
98 DISALLOW_COPY_AND_ASSIGN(FaviconFetcher); 95 DISALLOW_COPY_AND_ASSIGN(FaviconFetcher);
99 }; 96 };
100 97
101 WebIntentPickerController::WebIntentPickerController( 98 WebIntentPickerController::WebIntentPickerController(
102 TabContents* tab_contents, 99 TabContentsWrapper* wrapper,
103 WebIntentPickerFactory* factory) 100 WebIntentPickerFactory* factory)
104 : tab_contents_(tab_contents), 101 : wrapper_(wrapper),
105 picker_factory_(factory), 102 picker_factory_(factory),
106 web_intent_data_fetcher_( 103 web_intent_data_fetcher_(
107 new WebIntentDataFetcher(this, 104 new WebIntentDataFetcher(this,
108 GetWebIntentsRegistry(tab_contents))), 105 GetWebIntentsRegistry(wrapper))),
109 favicon_fetcher_( 106 favicon_fetcher_(
110 new FaviconFetcher(this, GetFaviconService(tab_contents))), 107 new FaviconFetcher(this, GetFaviconService(wrapper))),
111 picker_(NULL), 108 picker_(NULL),
112 pending_async_count_(0) { 109 pending_async_count_(0) {
113 NavigationController* controller = &tab_contents->controller(); 110 NavigationController* controller = &wrapper->controller();
114 registrar_.Add(this, content::NOTIFICATION_LOAD_START, 111 registrar_.Add(this, content::NOTIFICATION_LOAD_START,
115 Source<NavigationController>(controller)); 112 Source<NavigationController>(controller));
116 registrar_.Add(this, content::NOTIFICATION_TAB_CLOSING, 113 registrar_.Add(this, content::NOTIFICATION_TAB_CLOSING,
117 Source<NavigationController>(controller)); 114 Source<NavigationController>(controller));
118 } 115 }
119 116
120 WebIntentPickerController::~WebIntentPickerController() { 117 WebIntentPickerController::~WebIntentPickerController() {
121 } 118 }
122 119
123 void WebIntentPickerController::ShowDialog(const string16& action, 120 void WebIntentPickerController::ShowDialog(const string16& action,
124 const string16& type) { 121 const string16& type) {
125 if (picker_ != NULL) 122 if (picker_ != NULL)
126 return; 123 return;
127 124
128 picker_ = picker_factory_->Create(tab_contents_, this); 125 picker_ = picker_factory_->Create(wrapper_, this);
129 126
130 // TODO(binji) Remove this check when there are implementations of the picker 127 // TODO(binji) Remove this check when there are implementations of the picker
131 // for windows and mac. 128 // for windows and mac.
132 if (picker_ == NULL) 129 if (picker_ == NULL)
133 return; 130 return;
134 131
135 web_intent_data_fetcher_->Fetch(action, type); 132 web_intent_data_fetcher_->Fetch(action, type);
136 } 133 }
137 134
138 void WebIntentPickerController::Observe(int type, 135 void WebIntentPickerController::Observe(int type,
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 if (gfx::PNGCodec::Decode(favicon_data.image_data->front(), 252 if (gfx::PNGCodec::Decode(favicon_data.image_data->front(),
256 favicon_data.image_data->size(), 253 favicon_data.image_data->size(),
257 &icon_bitmap)) { 254 &icon_bitmap)) {
258 controller_->OnFaviconDataAvailable(index, icon_bitmap); 255 controller_->OnFaviconDataAvailable(index, icon_bitmap);
259 return; 256 return;
260 } 257 }
261 } 258 }
262 259
263 controller_->OnFaviconDataUnavailable(index); 260 controller_->OnFaviconDataUnavailable(index);
264 } 261 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698