OLD | NEW |
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/extensions/bundle_installer.h" | 5 #include "chrome/browser/extensions/bundle_installer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 const SkBitmap& icon, | 105 const SkBitmap& icon, |
106 const std::string& authuser, | 106 const std::string& authuser, |
107 const std::string& delegated_username, | 107 const std::string& delegated_username, |
108 const BundleInstaller::ItemList& items) | 108 const BundleInstaller::ItemList& items) |
109 : approved_(false), | 109 : approved_(false), |
110 browser_(browser), | 110 browser_(browser), |
111 name_(name), | 111 name_(name), |
112 icon_(icon), | 112 icon_(icon), |
113 authuser_(authuser), | 113 authuser_(authuser), |
114 delegated_username_(delegated_username), | 114 delegated_username_(delegated_username), |
115 host_desktop_type_(browser->host_desktop_type()), | |
116 profile_(browser->profile()), | 115 profile_(browser->profile()), |
117 weak_factory_(this) { | 116 weak_factory_(this) { |
118 BrowserList::AddObserver(this); | 117 BrowserList::AddObserver(this); |
119 for (size_t i = 0; i < items.size(); ++i) { | 118 for (size_t i = 0; i < items.size(); ++i) { |
120 items_[items[i].id] = items[i]; | 119 items_[items[i].id] = items[i]; |
121 items_[items[i].id].state = Item::STATE_PENDING; | 120 items_[items[i].id].state = Item::STATE_PENDING; |
122 } | 121 } |
123 } | 122 } |
124 | 123 |
125 BundleInstaller::~BundleInstaller() { | 124 BundleInstaller::~BundleInstaller() { |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 | 271 |
273 if (g_auto_approve_for_test == PROCEED) { | 272 if (g_auto_approve_for_test == PROCEED) { |
274 OnInstallPromptDone(ExtensionInstallPrompt::Result::ACCEPTED); | 273 OnInstallPromptDone(ExtensionInstallPrompt::Result::ACCEPTED); |
275 } else if (g_auto_approve_for_test == ABORT) { | 274 } else if (g_auto_approve_for_test == ABORT) { |
276 OnInstallPromptDone(ExtensionInstallPrompt::Result::USER_CANCELED); | 275 OnInstallPromptDone(ExtensionInstallPrompt::Result::USER_CANCELED); |
277 } else { | 276 } else { |
278 Browser* browser = browser_; | 277 Browser* browser = browser_; |
279 if (!browser) { | 278 if (!browser) { |
280 // The browser that we got initially could have gone away during our | 279 // The browser that we got initially could have gone away during our |
281 // thread hopping. | 280 // thread hopping. |
282 browser = chrome::FindLastActiveWithProfile(profile_, host_desktop_type_); | 281 browser = chrome::FindLastActiveWithProfile(profile_); |
283 } | 282 } |
284 content::WebContents* web_contents = NULL; | 283 content::WebContents* web_contents = NULL; |
285 if (browser) | 284 if (browser) |
286 web_contents = browser->tab_strip_model()->GetActiveWebContents(); | 285 web_contents = browser->tab_strip_model()->GetActiveWebContents(); |
287 install_ui_.reset(new ExtensionInstallPrompt(web_contents)); | 286 install_ui_.reset(new ExtensionInstallPrompt(web_contents)); |
288 scoped_ptr<ExtensionInstallPrompt::Prompt> prompt; | 287 scoped_ptr<ExtensionInstallPrompt::Prompt> prompt; |
289 if (delegated_username_.empty()) { | 288 if (delegated_username_.empty()) { |
290 prompt.reset(new ExtensionInstallPrompt::Prompt( | 289 prompt.reset(new ExtensionInstallPrompt::Prompt( |
291 ExtensionInstallPrompt::BUNDLE_INSTALL_PROMPT)); | 290 ExtensionInstallPrompt::BUNDLE_INSTALL_PROMPT)); |
292 } else { | 291 } else { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 | 373 |
375 ShowInstalledBubbleIfDone(); | 374 ShowInstalledBubbleIfDone(); |
376 } | 375 } |
377 | 376 |
378 void BundleInstaller::OnBrowserRemoved(Browser* browser) { | 377 void BundleInstaller::OnBrowserRemoved(Browser* browser) { |
379 if (browser_ == browser) | 378 if (browser_ == browser) |
380 browser_ = nullptr; | 379 browser_ = nullptr; |
381 } | 380 } |
382 | 381 |
383 } // namespace extensions | 382 } // namespace extensions |
OLD | NEW |