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

Side by Side Diff: chrome_frame/ready_mode/ready_mode.cc

Issue 6288009: More installer refactoring in the interest of fixing some bugs and cleaning t... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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
« no previous file with comments | « chrome/installer/util/util_constants.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_frame/ready_mode/ready_mode.h" 5 #include "chrome_frame/ready_mode/ready_mode.h"
6 6
7 #include <atlbase.h> 7 #include <atlbase.h>
8 #include <shlguid.h> 8 #include <shlguid.h>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/linked_ptr.h" 12 #include "base/linked_ptr.h"
13 #include "base/scoped_ptr.h" 13 #include "base/scoped_ptr.h"
14 #include "base/weak_ptr.h" 14 #include "base/weak_ptr.h"
15 #include "base/win/scoped_bstr.h" 15 #include "base/win/scoped_bstr.h"
16 #include "base/win/scoped_comptr.h" 16 #include "base/win/scoped_comptr.h"
17 #include "base/win/win_util.h" 17 #include "base/win/win_util.h"
18 #include "chrome/installer/util/browser_distribution.h"
18 #include "net/base/registry_controlled_domain.h" 19 #include "net/base/registry_controlled_domain.h"
19 #include "chrome/installer/util/package_properties.h"
20 #include "chrome_frame/infobars/infobar_manager.h" 20 #include "chrome_frame/infobars/infobar_manager.h"
21 #include "chrome_frame/ready_mode/internal/ready_mode_web_browser_adapter.h" 21 #include "chrome_frame/ready_mode/internal/ready_mode_web_browser_adapter.h"
22 #include "chrome_frame/ready_mode/internal/ready_prompt_content.h" 22 #include "chrome_frame/ready_mode/internal/ready_prompt_content.h"
23 #include "chrome_frame/ready_mode/internal/registry_ready_mode_state.h" 23 #include "chrome_frame/ready_mode/internal/registry_ready_mode_state.h"
24 #include "chrome_frame/ready_mode/internal/url_launcher.h" 24 #include "chrome_frame/ready_mode/internal/url_launcher.h"
25 #include "chrome_frame/utils.h" 25 #include "chrome_frame/utils.h"
26 26
27 namespace { 27 namespace {
28 28
29 // Temporarily disable Ready Mode for 36 hours when the user so indicates. 29 // Temporarily disable Ready Mode for 36 hours when the user so indicates.
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 void BrowserObserver::ShowPrompt() { 213 void BrowserObserver::ShowPrompt() {
214 // This pointer is self-managed and not guaranteed to survive handling of 214 // This pointer is self-managed and not guaranteed to survive handling of
215 // Windows events. 215 // Windows events.
216 InfobarManager* infobar_manager = GetInfobarManager(); 216 InfobarManager* infobar_manager = GetInfobarManager();
217 217
218 if (infobar_manager) { 218 if (infobar_manager) {
219 // Owned by ready_mode_state 219 // Owned by ready_mode_state
220 scoped_ptr<RegistryReadyModeState::Observer> ready_mode_state_observer( 220 scoped_ptr<RegistryReadyModeState::Observer> ready_mode_state_observer(
221 new StateObserver(weak_ptr_factory_.GetWeakPtr())); 221 new StateObserver(weak_ptr_factory_.GetWeakPtr()));
222 222
223 installer::ActivePackageProperties package_properties; 223 BrowserDistribution* dist =
224 BrowserDistribution::GetSpecificDistribution(
225 BrowserDistribution::CHROME_BINARIES);
224 226
225 // Owned by infobar_content 227 // Owned by infobar_content
226 scoped_ptr<ReadyModeState> ready_mode_state(new RegistryReadyModeState( 228 scoped_ptr<ReadyModeState> ready_mode_state(new RegistryReadyModeState(
227 package_properties.GetStateKey(), 229 dist->GetStateKey(),
228 base::TimeDelta::FromMinutes(kTemporaryDeclineDurationMinutes), 230 base::TimeDelta::FromMinutes(kTemporaryDeclineDurationMinutes),
229 ready_mode_state_observer.release())); 231 ready_mode_state_observer.release()));
230 232
231 // Owned by infobar_content 233 // Owned by infobar_content
232 scoped_ptr<UrlLauncher> url_launcher(new UrlLauncherImpl(web_browser_)); 234 scoped_ptr<UrlLauncher> url_launcher(new UrlLauncherImpl(web_browser_));
233 235
234 // Owned by infobar_manager 236 // Owned by infobar_manager
235 scoped_ptr<InfobarContent> infobar_content(new ReadyPromptContent( 237 scoped_ptr<InfobarContent> infobar_content(new ReadyPromptContent(
236 ready_mode_state.release(), url_launcher.release())); 238 ready_mode_state.release(), url_launcher.release()));
237 239
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 namespace ready_mode { 355 namespace ready_mode {
354 356
355 // Determines the current Ready Mode state. If it is active, attempts to set up 357 // Determines the current Ready Mode state. If it is active, attempts to set up
356 // prompting. If we cannot set up prompting, attempts to temporarily disable 358 // prompting. If we cannot set up prompting, attempts to temporarily disable
357 // Ready Mode. In the end, if Ready Mode is disabled, pass that information on 359 // Ready Mode. In the end, if Ready Mode is disabled, pass that information on
358 // to the Delegate, so that it may disabled Chrome Frame functionality. 360 // to the Delegate, so that it may disabled Chrome Frame functionality.
359 void Configure(Delegate* chrome_frame, IWebBrowser2* web_browser) { 361 void Configure(Delegate* chrome_frame, IWebBrowser2* web_browser) {
360 // Take ownership of the delegate 362 // Take ownership of the delegate
361 linked_ptr<Delegate> delegate(chrome_frame); 363 linked_ptr<Delegate> delegate(chrome_frame);
362 chrome_frame = NULL; 364 chrome_frame = NULL;
365 BrowserDistribution* dist =
366 BrowserDistribution::GetSpecificDistribution(
367 BrowserDistribution::CHROME_BINARIES);
363 368
364 RegistryReadyModeState ready_mode_state( 369 RegistryReadyModeState ready_mode_state(
365 installer::ActivePackageProperties().GetStateKey(), 370 dist->GetStateKey(),
366 base::TimeDelta::FromMinutes(kTemporaryDeclineDurationMinutes), 371 base::TimeDelta::FromMinutes(kTemporaryDeclineDurationMinutes),
367 NULL); // NULL => no observer required 372 NULL); // NULL => no observer required
368 373
369 ReadyModeStatus status = ready_mode_state.GetStatus(); 374 ReadyModeStatus status = ready_mode_state.GetStatus();
370 375
371 // If the user temporarily declined Chrome Frame, but the timeout has elapsed, 376 // If the user temporarily declined Chrome Frame, but the timeout has elapsed,
372 // attempt to revert to active Ready Mode state. 377 // attempt to revert to active Ready Mode state.
373 if (status == READY_MODE_TEMPORARY_DECLINE_EXPIRED) { 378 if (status == READY_MODE_TEMPORARY_DECLINE_EXPIRED) {
374 ready_mode_state.ExpireTemporaryDecline(); 379 ready_mode_state.ExpireTemporaryDecline();
375 status = ready_mode_state.GetStatus(); 380 status = ready_mode_state.GetStatus();
376 } 381 }
377 382
378 // If Ready Mode is active, attempt to set up prompting. 383 // If Ready Mode is active, attempt to set up prompting.
379 if (status == READY_MODE_ACTIVE) { 384 if (status == READY_MODE_ACTIVE) {
380 if (!InstallPrompts(delegate, web_browser)) { 385 if (!InstallPrompts(delegate, web_browser)) {
381 // Failed to set up prompting. Turn off Ready Mode for now. 386 // Failed to set up prompting. Turn off Ready Mode for now.
382 ready_mode_state.TemporarilyDeclineChromeFrame(); 387 ready_mode_state.TemporarilyDeclineChromeFrame();
383 status = ready_mode_state.GetStatus(); 388 status = ready_mode_state.GetStatus();
384 } 389 }
385 } 390 }
386 391
387 // Depending on the state we finally end up in, tell our Delegate to disable 392 // Depending on the state we finally end up in, tell our Delegate to disable
388 // Chrome Frame functionality. 393 // Chrome Frame functionality.
389 if (ShouldDisableChromeFrame(status)) 394 if (ShouldDisableChromeFrame(status))
390 delegate->DisableChromeFrame(); 395 delegate->DisableChromeFrame();
391 } 396 }
392 397
393 } // namespace ready_mode 398 } // namespace ready_mode
OLDNEW
« no previous file with comments | « chrome/installer/util/util_constants.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698