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

Side by Side Diff: chrome/browser/ui/views/athena/chrome_browser_main_extra_parts_athena.cc

Issue 544953003: Supprot V2 app: step1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 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
« no previous file with comments | « chrome/browser/ui/views/athena/DEPS ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/views/athena/chrome_browser_main_extra_parts_athena. h" 5 #include "chrome/browser/ui/views/athena/chrome_browser_main_extra_parts_athena. h"
6 6
7 #include "athena/env/public/athena_env.h"
7 #include "athena/extensions/public/extensions_delegate.h" 8 #include "athena/extensions/public/extensions_delegate.h"
8 #include "athena/main/public/athena_launcher.h" 9 #include "athena/main/public/athena_launcher.h"
9 #include "base/command_line.h" 10 #include "base/command_line.h"
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/chrome_browser_main_extra_parts.h" 13 #include "chrome/browser/chrome_browser_main_extra_parts.h"
14 #include "chrome/browser/chrome_notification_types.h"
13 #include "chrome/browser/lifetime/application_lifetime.h" 15 #include "chrome/browser/lifetime/application_lifetime.h"
14 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/profiles/profile_manager.h" 17 #include "chrome/browser/profiles/profile_manager.h"
16 #include "chrome/common/chrome_switches.h" 18 #include "chrome/common/chrome_switches.h"
17 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
20 #include "content/public/browser/notification_observer.h"
21 #include "content/public/browser/notification_registrar.h"
22 #include "content/public/browser/notification_service.h"
18 23
19 namespace { 24 namespace {
20 25
21 class ChromeBrowserMainExtraPartsAthena : public ChromeBrowserMainExtraParts { 26 class ChromeBrowserMainExtraPartsAthena : public ChromeBrowserMainExtraParts,
27 public content::NotificationObserver {
22 public: 28 public:
23 ChromeBrowserMainExtraPartsAthena() { 29 ChromeBrowserMainExtraPartsAthena() {
30 registrar_.Add(this,
31 chrome::NOTIFICATION_APP_TERMINATING,
32 content::NotificationService::AllSources());
24 } 33 }
25 34
26 virtual ~ChromeBrowserMainExtraPartsAthena() {} 35 virtual ~ChromeBrowserMainExtraPartsAthena() {}
27 36
28 private: 37 private:
29 // Overridden from ChromeBrowserMainExtraParts: 38 // Overridden from ChromeBrowserMainExtraParts:
30 virtual void PreProfileInit() OVERRIDE { 39 virtual void PreProfileInit() OVERRIDE {
31 athena::StartAthenaEnv(content::BrowserThread::GetMessageLoopProxyForThread( 40 athena::StartAthenaEnv(content::BrowserThread::GetMessageLoopProxyForThread(
32 content::BrowserThread::FILE)); 41 content::BrowserThread::FILE));
33 } 42 }
34 virtual void PostProfileInit() OVERRIDE { 43 virtual void PostProfileInit() OVERRIDE {
35 if (!CommandLine::ForCurrentProcess()->HasSwitch( 44 if (!CommandLine::ForCurrentProcess()->HasSwitch(
36 switches::kDisableZeroBrowsersOpenForTests)) { 45 switches::kDisableZeroBrowsersOpenForTests)) {
37 chrome::IncrementKeepAliveCount(); 46 chrome::IncrementKeepAliveCount();
38 } 47 }
39 Profile* profile = 48 Profile* profile =
40 g_browser_process->profile_manager()->GetActiveUserProfile(); 49 g_browser_process->profile_manager()->GetActiveUserProfile();
41 // TODO(oshima|polukhin): Start OOBE/Login process. 50 // TODO(oshima|polukhin): Start OOBE/Login process.
42 athena::ExtensionsDelegate::CreateExtensionsDelegateForChrome(profile); 51 athena::ExtensionsDelegate::CreateExtensionsDelegateForChrome(profile);
43 athena::StartAthenaSessionWithContext(profile); 52 athena::StartAthenaSessionWithContext(profile);
44 } 53 }
45 virtual void PostMainMessageLoopRun() OVERRIDE { athena::ShutdownAthena(); } 54 virtual void PostMainMessageLoopRun() OVERRIDE { athena::ShutdownAthena(); }
46 55
56 // content::NotificationObserver:
57 virtual void Observe(int type,
58 const content::NotificationSource& source,
59 const content::NotificationDetails& details) OVERRIDE {
60 switch (type) {
61 case chrome::NOTIFICATION_APP_TERMINATING:
62 athena::AthenaEnv::Get()->OnTerminating();
63 break;
64 }
65 }
66
67 content::NotificationRegistrar registrar_;
68
47 DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainExtraPartsAthena); 69 DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainExtraPartsAthena);
48 }; 70 };
49 71
50 } // namespace 72 } // namespace
51 73
52 ChromeBrowserMainExtraParts* CreateChromeBrowserMainExtraPartsAthena() { 74 ChromeBrowserMainExtraParts* CreateChromeBrowserMainExtraPartsAthena() {
53 return new ChromeBrowserMainExtraPartsAthena(); 75 return new ChromeBrowserMainExtraPartsAthena();
54 } 76 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/athena/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698